diff --git a/README.md b/README.md index 1d99888a09..23fa09d6f3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Downloads Downloads - + Downloads

**严肃声明:现在、未来都不会有商业版本,所有代码全部开源!!** @@ -98,7 +98,7 @@ ![开源项目对比](/.image/common/project-vs.png) -③ 代码整洁、架构整洁,遵循《阿里巴巴 Java 开发手册》规范,代码注释详细,57000 行 Java 代码,22000 行代码注释。 +③ 代码整洁、架构整洁,遵循《阿里巴巴 Java 开发手册》规范,代码注释详细,113770 行 Java 代码,42462 行代码注释。 ## 🤝 项目外包 diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 00ac143564..8458fc73a4 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -360,14 +360,6 @@ ${spring-boot-admin.version} - - - cn.iocoder.boot - yudao-spring-boot-starter-test - ${revision} - test - - org.mockito mockito-inline diff --git a/yudao-example/pom.xml b/yudao-example/pom.xml deleted file mode 100644 index 82b85a5f96..0000000000 --- a/yudao-example/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - 4.0.0 - - - - cn.iocoder.boot - yudao-example - 1.0.0-snapshot - pom - - yudao-sso-demo-by-code - yudao-sso-demo-by-password - - - ${project.artifactId} - 提供各种示例,例如说:SSO 单点登录 - https://github.com/YunaiV/ruoyi-vue-pro - - diff --git a/yudao-example/yudao-sso-demo-by-code/pom.xml b/yudao-example/yudao-sso-demo-by-code/pom.xml deleted file mode 100644 index 84f482b077..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - 4.0.0 - - - - cn.iocoder.boot - yudao-sso-demo-by-code - 1.0.0-snapshot - jar - - ${project.artifactId} - 基于授权码模式,如何实现 SSO 单点登录? - https://github.com/YunaiV/ruoyi-vue-pro - - - - 21 - 21 - UTF-8 - - 3.2.0 - - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - - - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-security - - - - cn.hutool - hutool-all - 5.8.22 - - - - org.projectlombok - lombok - true - - - - diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/SSODemoApplication.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/SSODemoApplication.java deleted file mode 100644 index f6b160745d..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/SSODemoApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.ssodemo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SSODemoApplication { - - public static void main(String[] args) { - SpringApplication.run(SSODemoApplication.class, args); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/OAuth2Client.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/OAuth2Client.java deleted file mode 100644 index d2e160f6f0..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/OAuth2Client.java +++ /dev/null @@ -1,157 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client; - -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.client.dto.oauth2.OAuth2AccessTokenRespDTO; -import cn.iocoder.yudao.ssodemo.client.dto.oauth2.OAuth2CheckTokenRespDTO; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.*; -import org.springframework.stereotype.Component; -import org.springframework.util.Assert; -import org.springframework.util.Base64Utils; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import java.nio.charset.StandardCharsets; - -/** - * OAuth 2.0 客户端 - * - * 对应调用 OAuth2OpenController 接口 - */ -@Component -public class OAuth2Client { - - private static final String BASE_URL = "http://127.0.0.1:48080/admin-api/system/oauth2"; - - /** - * 租户编号 - * - * 默认使用 1;如果使用别的租户,可以调整 - */ - public static final Long TENANT_ID = 1L; - - private static final String CLIENT_ID = "yudao-sso-demo-by-code"; - private static final String CLIENT_SECRET = "test"; - - -// @Resource // 可优化,注册一个 RestTemplate Bean,然后注入 - private final RestTemplate restTemplate = new RestTemplate(); - - /** - * 使用 code 授权码,获得访问令牌 - * - * @param code 授权码 - * @param redirectUri 重定向 URI - * @return 访问令牌 - */ - public CommonResult postAccessToken(String code, String redirectUri) { - // 1.1 构建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - headers.set("tenant-id", TENANT_ID.toString()); - addClientHeader(headers); - // 1.2 构建请求参数 - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("grant_type", "authorization_code"); - body.add("code", code); - body.add("redirect_uri", redirectUri); -// body.add("state", ""); // 选填;填了会校验 - - // 2. 执行请求 - ResponseEntity> exchange = restTemplate.exchange( - BASE_URL + "/token", - HttpMethod.POST, - new HttpEntity<>(body, headers), - new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 - Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); - return exchange.getBody(); - } - - /** - * 校验访问令牌,并返回它的基本信息 - * - * @param token 访问令牌 - * @return 访问令牌的基本信息 - */ - public CommonResult checkToken(String token) { - // 1.1 构建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - headers.set("tenant-id", TENANT_ID.toString()); - addClientHeader(headers); - // 1.2 构建请求参数 - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("token", token); - - // 2. 执行请求 - ResponseEntity> exchange = restTemplate.exchange( - BASE_URL + "/check-token", - HttpMethod.POST, - new HttpEntity<>(body, headers), - new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 - Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); - return exchange.getBody(); - } - - /** - * 使用刷新令牌,获得(刷新)访问令牌 - * - * @param refreshToken 刷新令牌 - * @return 访问令牌 - */ - public CommonResult refreshToken(String refreshToken) { - // 1.1 构建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - headers.set("tenant-id", TENANT_ID.toString()); - addClientHeader(headers); - // 1.2 构建请求参数 - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("grant_type", "refresh_token"); - body.add("refresh_token", refreshToken); - - // 2. 执行请求 - ResponseEntity> exchange = restTemplate.exchange( - BASE_URL + "/token", - HttpMethod.POST, - new HttpEntity<>(body, headers), - new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 - Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); - return exchange.getBody(); - } - - /** - * 删除访问令牌 - * - * @param token 访问令牌 - * @return 成功 - */ - public CommonResult revokeToken(String token) { - // 1.1 构建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - headers.set("tenant-id", TENANT_ID.toString()); - addClientHeader(headers); - // 1.2 构建请求参数 - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("token", token); - - // 2. 执行请求 - ResponseEntity> exchange = restTemplate.exchange( - BASE_URL + "/token", - HttpMethod.DELETE, - new HttpEntity<>(body, headers), - new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 - Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); - return exchange.getBody(); - } - - private static void addClientHeader(HttpHeaders headers) { - // client 拼接,需要 BASE64 编码 - String client = CLIENT_ID + ":" + CLIENT_SECRET; - client = Base64Utils.encodeToString(client.getBytes(StandardCharsets.UTF_8)); - headers.add("Authorization", "Basic " + client); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/UserClient.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/UserClient.java deleted file mode 100644 index 666bd3ee4b..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/UserClient.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client; - -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.client.dto.user.UserInfoRespDTO; -import cn.iocoder.yudao.ssodemo.client.dto.user.UserUpdateReqDTO; -import cn.iocoder.yudao.ssodemo.framework.core.LoginUser; -import cn.iocoder.yudao.ssodemo.framework.core.util.SecurityUtils; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.*; -import org.springframework.stereotype.Component; -import org.springframework.util.Assert; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -/** - * 用户 User 信息的客户端 - * - * 对应调用 OAuth2UserController 接口 - */ -@Component -public class UserClient { - - private static final String BASE_URL = "http://127.0.0.1:48080/admin-api//system/oauth2/user"; - - // @Resource // 可优化,注册一个 RestTemplate Bean,然后注入 - private final RestTemplate restTemplate = new RestTemplate(); - - public CommonResult getUser() { - // 1.1 构建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - headers.set("tenant-id", OAuth2Client.TENANT_ID.toString()); - addTokenHeader(headers); - // 1.2 构建请求参数 - MultiValueMap body = new LinkedMultiValueMap<>(); - - // 2. 执行请求 - ResponseEntity> exchange = restTemplate.exchange( - BASE_URL + "/get", - HttpMethod.GET, - new HttpEntity<>(body, headers), - new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 - Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); - return exchange.getBody(); - } - - public CommonResult updateUser(UserUpdateReqDTO updateReqDTO) { - // 1.1 构建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - headers.set("tenant-id", OAuth2Client.TENANT_ID.toString()); - addTokenHeader(headers); - // 1.2 构建请求参数 - // 使用 updateReqDTO 即可 - - // 2. 执行请求 - ResponseEntity> exchange = restTemplate.exchange( - BASE_URL + "/update", - HttpMethod.PUT, - new HttpEntity<>(updateReqDTO, headers), - new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 - Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); - return exchange.getBody(); - } - - - private static void addTokenHeader(HttpHeaders headers) { - LoginUser loginUser = SecurityUtils.getLoginUser(); - Assert.notNull(loginUser, "登录用户不能为空"); - headers.add("Authorization", "Bearer " + loginUser.getAccessToken()); - } -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/CommonResult.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/CommonResult.java deleted file mode 100644 index 548fe51e4c..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/CommonResult.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client.dto; - -import lombok.Data; - -import java.io.Serializable; - -/** - * 通用返回 - * - * @param 数据泛型 - */ -@Data -public class CommonResult implements Serializable { - - /** - * 错误码 - */ - private Integer code; - /** - * 返回数据 - */ - private T data; - /** - * 错误提示,用户可阅读 - */ - private String msg; - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/oauth2/OAuth2AccessTokenRespDTO.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/oauth2/OAuth2AccessTokenRespDTO.java deleted file mode 100644 index 6a5369a207..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/oauth2/OAuth2AccessTokenRespDTO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client.dto.oauth2; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 访问令牌 Response DTO - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class OAuth2AccessTokenRespDTO { - - /** - * 访问令牌 - */ - @JsonProperty("access_token") - private String accessToken; - - /** - * 刷新令牌 - */ - @JsonProperty("refresh_token") - private String refreshToken; - - /** - * 令牌类型 - */ - @JsonProperty("token_type") - private String tokenType; - - /** - * 过期时间;单位:秒 - */ - @JsonProperty("expires_in") - private Long expiresIn; - - /** - * 授权范围;如果多个授权范围,使用空格分隔 - */ - private String scope; - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/oauth2/OAuth2CheckTokenRespDTO.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/oauth2/OAuth2CheckTokenRespDTO.java deleted file mode 100644 index 862bcf04bc..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/oauth2/OAuth2CheckTokenRespDTO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client.dto.oauth2; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -/** - * 校验令牌 Response DTO - * - * @author 芋道源码 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class OAuth2CheckTokenRespDTO { - - /** - * 用户编号 - */ - @JsonProperty("user_id") - private Long userId; - /** - * 用户类型 - */ - @JsonProperty("user_type") - private Integer userType; - /** - * 租户编号 - */ - @JsonProperty("tenant_id") - private Long tenantId; - - /** - * 客户端编号 - */ - @JsonProperty("client_id") - private String clientId; - /** - * 授权范围 - */ - private List scopes; - - /** - * 访问令牌 - */ - @JsonProperty("access_token") - private String accessToken; - - /** - * 过期时间 - * - * 时间戳 / 1000,即单位:秒 - */ - private Long exp; - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/user/UserInfoRespDTO.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/user/UserInfoRespDTO.java deleted file mode 100644 index e81bea9eb8..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/user/UserInfoRespDTO.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client.dto.user; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -/** - * 获得用户基本信息 Response dto - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class UserInfoRespDTO { - - /** - * 用户编号 - */ - private Long id; - - /** - * 用户账号 - */ - private String username; - - /** - * 用户昵称 - */ - private String nickname; - - /** - * 用户邮箱 - */ - private String email; - /** - * 手机号码 - */ - private String mobile; - - /** - * 用户性别 - */ - private Integer sex; - - /** - * 用户头像 - */ - private String avatar; - - /** - * 所在部门 - */ - private Dept dept; - - /** - * 所属岗位数组 - */ - private List posts; - - /** - * 部门 - */ - @Data - public static class Dept { - - /** - * 部门编号 - */ - private Long id; - - /** - * 部门名称 - */ - private String name; - - } - - /** - * 岗位 - */ - @Data - public static class Post { - - /** - * 岗位编号 - */ - private Long id; - - /** - * 岗位名称 - */ - private String name; - - } - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/user/UserUpdateReqDTO.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/user/UserUpdateReqDTO.java deleted file mode 100644 index e711d73111..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/user/UserUpdateReqDTO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client.dto.user; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 更新用户基本信息 Request DTO - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class UserUpdateReqDTO { - - /** - * 用户昵称 - */ - private String nickname; - - /** - * 用户邮箱 - */ - private String email; - - /** - * 手机号码 - */ - private String mobile; - - /** - * 用户性别 - */ - private Integer sex; - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/controller/AuthController.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/controller/AuthController.java deleted file mode 100644 index 63257fcfd9..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/controller/AuthController.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.ssodemo.controller; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.ssodemo.client.OAuth2Client; -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.client.dto.oauth2.OAuth2AccessTokenRespDTO; -import cn.iocoder.yudao.ssodemo.framework.core.util.SecurityUtils; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletRequest; - -@RestController -@RequestMapping("/auth") -public class AuthController { - - @Resource - private OAuth2Client oauth2Client; - - /** - * 使用 code 访问令牌,获得访问令牌 - * - * @param code 授权码 - * @param redirectUri 重定向 URI - * @return 访问令牌;注意,实际项目中,最好创建对应的 ResponseVO 类,只返回必要的字段 - */ - @PostMapping("/login-by-code") - public CommonResult loginByCode(@RequestParam("code") String code, - @RequestParam("redirectUri") String redirectUri) { - return oauth2Client.postAccessToken(code, redirectUri); - } - - /** - * 使用刷新令牌,获得(刷新)访问令牌 - * - * @param refreshToken 刷新令牌 - * @return 访问令牌;注意,实际项目中,最好创建对应的 ResponseVO 类,只返回必要的字段 - */ - @PostMapping("/refresh-token") - public CommonResult refreshToken(@RequestParam("refreshToken") String refreshToken) { - return oauth2Client.refreshToken(refreshToken); - } - - /** - * 退出登录 - * - * @param request 请求 - * @return 成功 - */ - @PostMapping("/logout") - public CommonResult logout(HttpServletRequest request) { - String token = SecurityUtils.obtainAuthorization(request, "Authorization"); - if (StrUtil.isNotBlank(token)) { - return oauth2Client.revokeToken(token); - } - // 返回成功 - return new CommonResult<>(); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/controller/UserController.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/controller/UserController.java deleted file mode 100644 index 6f6a2357ac..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/controller/UserController.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.ssodemo.controller; - -import cn.iocoder.yudao.ssodemo.client.UserClient; -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.client.dto.user.UserInfoRespDTO; -import cn.iocoder.yudao.ssodemo.client.dto.user.UserUpdateReqDTO; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; - -@RestController -@RequestMapping("/user") -public class UserController { - - @Resource - private UserClient userClient; - - /** - * 获得当前登录用户的基本信息 - * - * @return 用户信息;注意,实际项目中,最好创建对应的 ResponseVO 类,只返回必要的字段 - */ - @GetMapping("/get") - public CommonResult getUser() { - return userClient.getUser(); - } - - /** - * 更新当前登录用户的昵称 - * - * @param nickname 昵称 - * @return 成功 - */ - @PutMapping("/update") - public CommonResult updateUser(@RequestParam("nickname") String nickname) { - UserUpdateReqDTO updateReqDTO = new UserUpdateReqDTO(nickname, null, null, null); - return userClient.updateUser(updateReqDTO); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/config/SecurityConfiguration.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/config/SecurityConfiguration.java deleted file mode 100644 index 6c90098f29..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/config/SecurityConfiguration.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.config; - -import cn.iocoder.yudao.ssodemo.framework.core.filter.TokenAuthenticationFilter; -import cn.iocoder.yudao.ssodemo.framework.core.handler.AccessDeniedHandlerImpl; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpMethod; -import org.springframework.security.config.Customizer; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; -import org.springframework.security.web.AuthenticationEntryPoint; -import org.springframework.security.web.SecurityFilterChain; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; - -import jakarta.annotation.Resource; - -@Configuration(proxyBeanMethods = false) -@EnableWebSecurity -public class SecurityConfiguration{ - - @Resource - private TokenAuthenticationFilter tokenAuthenticationFilter; - - @Resource - private AccessDeniedHandlerImpl accessDeniedHandler; - @Resource - private AuthenticationEntryPoint authenticationEntryPoint; - - @Bean - protected SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { - // 设置 URL 安全权限 - httpSecurity - // 开启跨域 - .cors(Customizer.withDefaults()) - // CSRF 禁用,因为不使用 Session - .csrf(AbstractHttpConfigurer::disable) - // 一堆自定义的 Spring Security 处理器 - .exceptionHandling(c -> c.authenticationEntryPoint(authenticationEntryPoint) - .accessDeniedHandler(accessDeniedHandler)); - - // 设置每个请求的权限 - httpSecurity.authorizeHttpRequests(c -> c - // 1. 静态资源,可匿名访问 - .requestMatchers(HttpMethod.GET, "/*.html", "/*.html", "/*.css", "/*.js").permitAll() - // 2. 登录相关的接口,可匿名访问 - .requestMatchers("/auth/login-by-code").permitAll() - .requestMatchers("/auth/refresh-token").permitAll() - .requestMatchers("/auth/logout").permitAll()) - // 3. 兜底规则,必须认证 - .authorizeHttpRequests(c -> c.anyRequest().authenticated()); - - // 添加 Token Filter - httpSecurity.addFilterBefore(tokenAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); - return httpSecurity.build(); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/LoginUser.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/LoginUser.java deleted file mode 100644 index 44f3edf547..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/LoginUser.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.core; - -import lombok.Data; - -import java.util.List; - -/** - * 登录用户信息 - * - * @author 芋道源码 - */ -@Data -public class LoginUser { - - /** - * 用户编号 - */ - private Long id; - /** - * 用户类型 - */ - private Integer userType; - /** - * 租户编号 - */ - private Long tenantId; - /** - * 授权范围 - */ - private List scopes; - - /** - * 访问令牌 - */ - private String accessToken; - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/filter/TokenAuthenticationFilter.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/filter/TokenAuthenticationFilter.java deleted file mode 100644 index 511371ce24..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/filter/TokenAuthenticationFilter.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.core.filter; - -import cn.iocoder.yudao.ssodemo.client.OAuth2Client; -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.client.dto.oauth2.OAuth2CheckTokenRespDTO; -import cn.iocoder.yudao.ssodemo.framework.core.LoginUser; -import cn.iocoder.yudao.ssodemo.framework.core.util.SecurityUtils; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import org.springframework.web.filter.OncePerRequestFilter; - -import jakarta.annotation.Resource; -import jakarta.servlet.FilterChain; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Token 过滤器,验证 token 的有效性 - * 验证通过后,获得 {@link LoginUser} 信息,并加入到 Spring Security 上下文 - * - * @author 芋道源码 - */ -@Component -public class TokenAuthenticationFilter extends OncePerRequestFilter { - - @Resource - private OAuth2Client oauth2Client; - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, - FilterChain filterChain) throws ServletException, IOException { - // 1. 获得访问令牌 - String token = SecurityUtils.obtainAuthorization(request, "Authorization"); - if (StringUtils.hasText(token)) { - // 2. 基于 token 构建登录用户 - LoginUser loginUser = buildLoginUserByToken(token); - // 3. 设置当前用户 - if (loginUser != null) { - SecurityUtils.setLoginUser(loginUser, request); - } - } - - // 继续过滤链 - filterChain.doFilter(request, response); - } - - private LoginUser buildLoginUserByToken(String token) { - try { - CommonResult accessTokenResult = oauth2Client.checkToken(token); - OAuth2CheckTokenRespDTO accessToken = accessTokenResult.getData(); - if (accessToken == null) { - return null; - } - // 构建登录用户 - return new LoginUser().setId(accessToken.getUserId()).setUserType(accessToken.getUserType()) - .setTenantId(accessToken.getTenantId()).setScopes(accessToken.getScopes()) - .setAccessToken(accessToken.getAccessToken()); - } catch (Exception exception) { - // 校验 Token 不通过时,考虑到一些接口是无需登录的,所以直接返回 null 即可 - return null; - } - } - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/handler/AccessDeniedHandlerImpl.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/handler/AccessDeniedHandlerImpl.java deleted file mode 100644 index e0c1a141d4..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/handler/AccessDeniedHandlerImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.core.handler; - -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.framework.core.util.SecurityUtils; -import cn.iocoder.yudao.ssodemo.framework.core.util.ServletUtils; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; -import org.springframework.security.access.AccessDeniedException; -import org.springframework.security.web.access.AccessDeniedHandler; -import org.springframework.security.web.access.ExceptionTranslationFilter; -import org.springframework.stereotype.Component; - -import jakarta.servlet.FilterChain; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * 访问一个需要认证的 URL 资源,已经认证(登录)但是没有权限的情况下,返回 {@link GlobalErrorCodeConstants#FORBIDDEN} 错误码。 - * - * 补充:Spring Security 通过 {@link ExceptionTranslationFilter#handleAccessDeniedException(HttpServletRequest, HttpServletResponse, FilterChain, AccessDeniedException)} 方法,调用当前类 - * - * @author 芋道源码 - */ -@Component -@SuppressWarnings("JavadocReference") -@Slf4j -public class AccessDeniedHandlerImpl implements AccessDeniedHandler { - - @Override - public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) - throws IOException, ServletException { - // 打印 warn 的原因是,不定期合并 warn,看看有没恶意破坏 - log.warn("[commence][访问 URL({}) 时,用户({}) 权限不够]", request.getRequestURI(), - SecurityUtils.getLoginUserId(), e); - // 返回 403 - CommonResult result = new CommonResult<>(); - result.setCode(HttpStatus.FORBIDDEN.value()); - result.setMsg("没有该操作权限"); - ServletUtils.writeJSON(response, result); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/handler/AuthenticationEntryPointImpl.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/handler/AuthenticationEntryPointImpl.java deleted file mode 100644 index 950a3317aa..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/handler/AuthenticationEntryPointImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.core.handler; - -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.framework.core.util.ServletUtils; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.AuthenticationEntryPoint; -import org.springframework.security.web.access.ExceptionTranslationFilter; -import org.springframework.stereotype.Component; - -import jakarta.servlet.FilterChain; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -/** - * 访问一个需要认证的 URL 资源,但是此时自己尚未认证(登录)的情况下,返回 {@link GlobalErrorCodeConstants#UNAUTHORIZED} 错误码,从而使前端重定向到登录页 - * - * 补充:Spring Security 通过 {@link ExceptionTranslationFilter#sendStartAuthentication(HttpServletRequest, HttpServletResponse, FilterChain, AuthenticationException)} 方法,调用当前类 - */ -@Component -@Slf4j -@SuppressWarnings("JavadocReference") // 忽略文档引用报错 -public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint { - - @Override - public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) { - log.debug("[commence][访问 URL({}) 时,没有登录]", request.getRequestURI(), e); - // 返回 401 - CommonResult result = new CommonResult<>(); - result.setCode(HttpStatus.UNAUTHORIZED.value()); - result.setMsg("账号未登录"); - ServletUtils.writeJSON(response, result); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/util/SecurityUtils.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/util/SecurityUtils.java deleted file mode 100644 index ad70aae25f..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/util/SecurityUtils.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.core.util; - -import cn.iocoder.yudao.ssodemo.framework.core.LoginUser; -import org.springframework.lang.Nullable; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContext; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; -import org.springframework.util.StringUtils; - -import jakarta.servlet.http.HttpServletRequest; -import java.util.Collections; - -/** - * 安全服务工具类 - * - * @author 芋道源码 - */ -public class SecurityUtils { - - public static final String AUTHORIZATION_BEARER = "Bearer"; - - private SecurityUtils() {} - - /** - * 从请求中,获得认证 Token - * - * @param request 请求 - * @param header 认证 Token 对应的 Header 名字 - * @return 认证 Token - */ - public static String obtainAuthorization(HttpServletRequest request, String header) { - String authorization = request.getHeader(header); - if (!StringUtils.hasText(authorization)) { - return null; - } - int index = authorization.indexOf(AUTHORIZATION_BEARER + " "); - if (index == -1) { // 未找到 - return null; - } - return authorization.substring(index + 7).trim(); - } - - /** - * 获得当前认证信息 - * - * @return 认证信息 - */ - public static Authentication getAuthentication() { - SecurityContext context = SecurityContextHolder.getContext(); - if (context == null) { - return null; - } - return context.getAuthentication(); - } - - /** - * 获取当前用户 - * - * @return 当前用户 - */ - @Nullable - public static LoginUser getLoginUser() { - Authentication authentication = getAuthentication(); - if (authentication == null) { - return null; - } - return authentication.getPrincipal() instanceof LoginUser ? (LoginUser) authentication.getPrincipal() : null; - } - - /** - * 获得当前用户的编号,从上下文中 - * - * @return 用户编号 - */ - @Nullable - public static Long getLoginUserId() { - LoginUser loginUser = getLoginUser(); - return loginUser != null ? loginUser.getId() : null; - } - - /** - * 设置当前用户 - * - * @param loginUser 登录用户 - * @param request 请求 - */ - public static void setLoginUser(LoginUser loginUser, HttpServletRequest request) { - // 创建 Authentication,并设置到上下文 - Authentication authentication = buildAuthentication(loginUser, request); - SecurityContextHolder.getContext().setAuthentication(authentication); - } - - private static Authentication buildAuthentication(LoginUser loginUser, HttpServletRequest request) { - // 创建 UsernamePasswordAuthenticationToken 对象 - UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken( - loginUser, null, Collections.emptyList()); - authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); - return authenticationToken; - } - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/util/ServletUtils.java b/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/util/ServletUtils.java deleted file mode 100644 index 644f836b22..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/util/ServletUtils.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.core.util; - -import cn.hutool.extra.servlet.JakartaServletUtil; -import cn.hutool.extra.servlet.ServletUtil; -import cn.hutool.json.JSONUtil; -import org.springframework.http.MediaType; - -import jakarta.servlet.http.HttpServletResponse; - -/** - * 客户端工具类 - * - * @author 芋道源码 - */ -public class ServletUtils { - - /** - * 返回 JSON 字符串 - * - * @param response 响应 - * @param object 对象,会序列化成 JSON 字符串 - */ - @SuppressWarnings("deprecation") // 必须使用 APPLICATION_JSON_UTF8_VALUE,否则会乱码 - public static void writeJSON(HttpServletResponse response, Object object) { - String content = JSONUtil.toJsonStr(object); - JakartaServletUtil.write(response, content, MediaType.APPLICATION_JSON_UTF8_VALUE); - } - - public static void write(HttpServletResponse response, String text, String contentType) { - JakartaServletUtil.write(response, text, contentType); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/resources/application.yaml b/yudao-example/yudao-sso-demo-by-code/src/main/resources/application.yaml deleted file mode 100644 index a62cf97dc1..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/resources/application.yaml +++ /dev/null @@ -1,2 +0,0 @@ -server: - port: 18080 diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/resources/static/callback.html b/yudao-example/yudao-sso-demo-by-code/src/main/resources/static/callback.html deleted file mode 100644 index 123a1af9bc..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/resources/static/callback.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - SSO 授权后的回调页 - - - - - - - - -正在使用 code 授权码,进行 accessToken 访问令牌的获取 - - diff --git a/yudao-example/yudao-sso-demo-by-code/src/main/resources/static/index.html b/yudao-example/yudao-sso-demo-by-code/src/main/resources/static/index.html deleted file mode 100644 index a4f858363e..0000000000 --- a/yudao-example/yudao-sso-demo-by-code/src/main/resources/static/index.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - - 首页 - - - - - - - - - - - - - - diff --git a/yudao-example/yudao-sso-demo-by-password/pom.xml b/yudao-example/yudao-sso-demo-by-password/pom.xml deleted file mode 100644 index 8c2b6b81ae..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - 4.0.0 - - - - cn.iocoder.boot - yudao-sso-demo-by-password - 1.0.0-snapshot - jar - - ${project.artifactId} - 基于密码模式,如何实现 SSO 单点登录? - https://github.com/YunaiV/ruoyi-vue-pro - - - - 21 - 21 - UTF-8 - - 3.2.0 - - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - - - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-security - - - - cn.hutool - hutool-all - 5.8.22 - - - - org.projectlombok - lombok - true - - - - diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/SSODemoApplication.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/SSODemoApplication.java deleted file mode 100644 index f6b160745d..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/SSODemoApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.ssodemo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SSODemoApplication { - - public static void main(String[] args) { - SpringApplication.run(SSODemoApplication.class, args); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/OAuth2Client.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/OAuth2Client.java deleted file mode 100644 index 4f6b634818..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/OAuth2Client.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client; - -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.client.dto.oauth2.OAuth2AccessTokenRespDTO; -import cn.iocoder.yudao.ssodemo.client.dto.oauth2.OAuth2CheckTokenRespDTO; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.*; -import org.springframework.stereotype.Component; -import org.springframework.util.Assert; -import org.springframework.util.Base64Utils; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import java.nio.charset.StandardCharsets; - -/** - * OAuth 2.0 客户端 - * - * 对应调用 OAuth2OpenController 接口 - */ -@Component -public class OAuth2Client { - - private static final String BASE_URL = "http://127.0.0.1:48080/admin-api/system/oauth2"; - - /** - * 租户编号 - * - * 默认使用 1;如果使用别的租户,可以调整 - */ - public static final Long TENANT_ID = 1L; - - private static final String CLIENT_ID = "yudao-sso-demo-by-password"; - private static final String CLIENT_SECRET = "test"; - - -// @Resource // 可优化,注册一个 RestTemplate Bean,然后注入 - private final RestTemplate restTemplate = new RestTemplate(); - - /** - * 校验访问令牌,并返回它的基本信息 - * - * @param token 访问令牌 - * @return 访问令牌的基本信息 - */ - public CommonResult checkToken(String token) { - // 1.1 构建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - headers.set("tenant-id", TENANT_ID.toString()); - addClientHeader(headers); - // 1.2 构建请求参数 - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("token", token); - - // 2. 执行请求 - ResponseEntity> exchange = restTemplate.exchange( - BASE_URL + "/check-token", - HttpMethod.POST, - new HttpEntity<>(body, headers), - new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 - Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); - return exchange.getBody(); - } - - /** - * 使用刷新令牌,获得(刷新)访问令牌 - * - * @param refreshToken 刷新令牌 - * @return 访问令牌 - */ - public CommonResult refreshToken(String refreshToken) { - // 1.1 构建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - headers.set("tenant-id", TENANT_ID.toString()); - addClientHeader(headers); - // 1.2 构建请求参数 - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("grant_type", "refresh_token"); - body.add("refresh_token", refreshToken); - - // 2. 执行请求 - ResponseEntity> exchange = restTemplate.exchange( - BASE_URL + "/token", - HttpMethod.POST, - new HttpEntity<>(body, headers), - new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 - Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); - return exchange.getBody(); - } - - /** - * 删除访问令牌 - * - * @param token 访问令牌 - * @return 成功 - */ - public CommonResult revokeToken(String token) { - // 1.1 构建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - headers.set("tenant-id", TENANT_ID.toString()); - addClientHeader(headers); - // 1.2 构建请求参数 - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("token", token); - - // 2. 执行请求 - ResponseEntity> exchange = restTemplate.exchange( - BASE_URL + "/token", - HttpMethod.DELETE, - new HttpEntity<>(body, headers), - new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 - Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); - return exchange.getBody(); - } - - private static void addClientHeader(HttpHeaders headers) { - // client 拼接,需要 BASE64 编码 - String client = CLIENT_ID + ":" + CLIENT_SECRET; - client = Base64Utils.encodeToString(client.getBytes(StandardCharsets.UTF_8)); - headers.add("Authorization", "Basic " + client); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/UserClient.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/UserClient.java deleted file mode 100644 index 666bd3ee4b..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/UserClient.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client; - -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.client.dto.user.UserInfoRespDTO; -import cn.iocoder.yudao.ssodemo.client.dto.user.UserUpdateReqDTO; -import cn.iocoder.yudao.ssodemo.framework.core.LoginUser; -import cn.iocoder.yudao.ssodemo.framework.core.util.SecurityUtils; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.*; -import org.springframework.stereotype.Component; -import org.springframework.util.Assert; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -/** - * 用户 User 信息的客户端 - * - * 对应调用 OAuth2UserController 接口 - */ -@Component -public class UserClient { - - private static final String BASE_URL = "http://127.0.0.1:48080/admin-api//system/oauth2/user"; - - // @Resource // 可优化,注册一个 RestTemplate Bean,然后注入 - private final RestTemplate restTemplate = new RestTemplate(); - - public CommonResult getUser() { - // 1.1 构建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - headers.set("tenant-id", OAuth2Client.TENANT_ID.toString()); - addTokenHeader(headers); - // 1.2 构建请求参数 - MultiValueMap body = new LinkedMultiValueMap<>(); - - // 2. 执行请求 - ResponseEntity> exchange = restTemplate.exchange( - BASE_URL + "/get", - HttpMethod.GET, - new HttpEntity<>(body, headers), - new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 - Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); - return exchange.getBody(); - } - - public CommonResult updateUser(UserUpdateReqDTO updateReqDTO) { - // 1.1 构建请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - headers.set("tenant-id", OAuth2Client.TENANT_ID.toString()); - addTokenHeader(headers); - // 1.2 构建请求参数 - // 使用 updateReqDTO 即可 - - // 2. 执行请求 - ResponseEntity> exchange = restTemplate.exchange( - BASE_URL + "/update", - HttpMethod.PUT, - new HttpEntity<>(updateReqDTO, headers), - new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 - Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); - return exchange.getBody(); - } - - - private static void addTokenHeader(HttpHeaders headers) { - LoginUser loginUser = SecurityUtils.getLoginUser(); - Assert.notNull(loginUser, "登录用户不能为空"); - headers.add("Authorization", "Bearer " + loginUser.getAccessToken()); - } -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/CommonResult.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/CommonResult.java deleted file mode 100644 index 548fe51e4c..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/CommonResult.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client.dto; - -import lombok.Data; - -import java.io.Serializable; - -/** - * 通用返回 - * - * @param 数据泛型 - */ -@Data -public class CommonResult implements Serializable { - - /** - * 错误码 - */ - private Integer code; - /** - * 返回数据 - */ - private T data; - /** - * 错误提示,用户可阅读 - */ - private String msg; - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/oauth2/OAuth2AccessTokenRespDTO.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/oauth2/OAuth2AccessTokenRespDTO.java deleted file mode 100644 index 6a5369a207..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/oauth2/OAuth2AccessTokenRespDTO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client.dto.oauth2; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 访问令牌 Response DTO - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class OAuth2AccessTokenRespDTO { - - /** - * 访问令牌 - */ - @JsonProperty("access_token") - private String accessToken; - - /** - * 刷新令牌 - */ - @JsonProperty("refresh_token") - private String refreshToken; - - /** - * 令牌类型 - */ - @JsonProperty("token_type") - private String tokenType; - - /** - * 过期时间;单位:秒 - */ - @JsonProperty("expires_in") - private Long expiresIn; - - /** - * 授权范围;如果多个授权范围,使用空格分隔 - */ - private String scope; - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/oauth2/OAuth2CheckTokenRespDTO.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/oauth2/OAuth2CheckTokenRespDTO.java deleted file mode 100644 index 862bcf04bc..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/oauth2/OAuth2CheckTokenRespDTO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client.dto.oauth2; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -/** - * 校验令牌 Response DTO - * - * @author 芋道源码 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class OAuth2CheckTokenRespDTO { - - /** - * 用户编号 - */ - @JsonProperty("user_id") - private Long userId; - /** - * 用户类型 - */ - @JsonProperty("user_type") - private Integer userType; - /** - * 租户编号 - */ - @JsonProperty("tenant_id") - private Long tenantId; - - /** - * 客户端编号 - */ - @JsonProperty("client_id") - private String clientId; - /** - * 授权范围 - */ - private List scopes; - - /** - * 访问令牌 - */ - @JsonProperty("access_token") - private String accessToken; - - /** - * 过期时间 - * - * 时间戳 / 1000,即单位:秒 - */ - private Long exp; - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/user/UserInfoRespDTO.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/user/UserInfoRespDTO.java deleted file mode 100644 index e81bea9eb8..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/user/UserInfoRespDTO.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client.dto.user; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -/** - * 获得用户基本信息 Response dto - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class UserInfoRespDTO { - - /** - * 用户编号 - */ - private Long id; - - /** - * 用户账号 - */ - private String username; - - /** - * 用户昵称 - */ - private String nickname; - - /** - * 用户邮箱 - */ - private String email; - /** - * 手机号码 - */ - private String mobile; - - /** - * 用户性别 - */ - private Integer sex; - - /** - * 用户头像 - */ - private String avatar; - - /** - * 所在部门 - */ - private Dept dept; - - /** - * 所属岗位数组 - */ - private List posts; - - /** - * 部门 - */ - @Data - public static class Dept { - - /** - * 部门编号 - */ - private Long id; - - /** - * 部门名称 - */ - private String name; - - } - - /** - * 岗位 - */ - @Data - public static class Post { - - /** - * 岗位编号 - */ - private Long id; - - /** - * 岗位名称 - */ - private String name; - - } - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/user/UserUpdateReqDTO.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/user/UserUpdateReqDTO.java deleted file mode 100644 index e711d73111..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/client/dto/user/UserUpdateReqDTO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.ssodemo.client.dto.user; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 更新用户基本信息 Request DTO - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class UserUpdateReqDTO { - - /** - * 用户昵称 - */ - private String nickname; - - /** - * 用户邮箱 - */ - private String email; - - /** - * 手机号码 - */ - private String mobile; - - /** - * 用户性别 - */ - private Integer sex; - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/controller/AuthController.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/controller/AuthController.java deleted file mode 100644 index 3011ad81fa..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/controller/AuthController.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.ssodemo.controller; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.ssodemo.client.OAuth2Client; -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.client.dto.oauth2.OAuth2AccessTokenRespDTO; -import cn.iocoder.yudao.ssodemo.framework.core.util.SecurityUtils; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletRequest; - -@RestController -@RequestMapping("/auth") -public class AuthController { - - @Resource - private OAuth2Client oauth2Client; - - /** - * 使用刷新令牌,获得(刷新)访问令牌 - * - * @param refreshToken 刷新令牌 - * @return 访问令牌;注意,实际项目中,最好创建对应的 ResponseVO 类,只返回必要的字段 - */ - @PostMapping("/refresh-token") - public CommonResult refreshToken(@RequestParam("refreshToken") String refreshToken) { - return oauth2Client.refreshToken(refreshToken); - } - - /** - * 退出登录 - * - * @param request 请求 - * @return 成功 - */ - @PostMapping("/logout") - public CommonResult logout(HttpServletRequest request) { - String token = SecurityUtils.obtainAuthorization(request, "Authorization"); - if (StrUtil.isNotBlank(token)) { - return oauth2Client.revokeToken(token); - } - // 返回成功 - return new CommonResult<>(); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/controller/UserController.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/controller/UserController.java deleted file mode 100644 index 6f6a2357ac..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/controller/UserController.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.ssodemo.controller; - -import cn.iocoder.yudao.ssodemo.client.UserClient; -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.client.dto.user.UserInfoRespDTO; -import cn.iocoder.yudao.ssodemo.client.dto.user.UserUpdateReqDTO; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; - -@RestController -@RequestMapping("/user") -public class UserController { - - @Resource - private UserClient userClient; - - /** - * 获得当前登录用户的基本信息 - * - * @return 用户信息;注意,实际项目中,最好创建对应的 ResponseVO 类,只返回必要的字段 - */ - @GetMapping("/get") - public CommonResult getUser() { - return userClient.getUser(); - } - - /** - * 更新当前登录用户的昵称 - * - * @param nickname 昵称 - * @return 成功 - */ - @PutMapping("/update") - public CommonResult updateUser(@RequestParam("nickname") String nickname) { - UserUpdateReqDTO updateReqDTO = new UserUpdateReqDTO(nickname, null, null, null); - return userClient.updateUser(updateReqDTO); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/config/SecurityConfiguration.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/config/SecurityConfiguration.java deleted file mode 100644 index b90f650e2e..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/config/SecurityConfiguration.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.config; - -import cn.iocoder.yudao.ssodemo.framework.core.filter.TokenAuthenticationFilter; -import cn.iocoder.yudao.ssodemo.framework.core.handler.AccessDeniedHandlerImpl; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpMethod; -import org.springframework.security.config.Customizer; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; -import org.springframework.security.web.AuthenticationEntryPoint; -import org.springframework.security.web.SecurityFilterChain; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; - -import jakarta.annotation.Resource; - -@Configuration(proxyBeanMethods = false) -@EnableWebSecurity -public class SecurityConfiguration { - - @Resource - private TokenAuthenticationFilter tokenAuthenticationFilter; - - @Resource - private AccessDeniedHandlerImpl accessDeniedHandler; - @Resource - private AuthenticationEntryPoint authenticationEntryPoint; - - @Bean - protected SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { - // 设置 URL 安全权限 - httpSecurity - // 开启跨域 - .cors(Customizer.withDefaults()) - // CSRF 禁用,因为不使用 Session - .csrf(AbstractHttpConfigurer::disable) - // 一堆自定义的 Spring Security 处理器 - .exceptionHandling(c -> c.authenticationEntryPoint(authenticationEntryPoint) - .accessDeniedHandler(accessDeniedHandler)); - - // 设置每个请求的权限 - httpSecurity.authorizeHttpRequests(c -> c - // 1. 静态资源,可匿名访问 - .requestMatchers(HttpMethod.GET, "/*.html", "/*.html", "/*.css", "/*.js").permitAll() - // 2. 登录相关的接口,可匿名访问 - .requestMatchers("/auth/login-by-code").permitAll() - .requestMatchers("/auth/refresh-token").permitAll() - .requestMatchers("/auth/logout").permitAll()) - // 3. 兜底规则,必须认证 - .authorizeHttpRequests(c -> c.anyRequest().authenticated()); - - // 添加 Token Filter - httpSecurity.addFilterBefore(tokenAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); - return httpSecurity.build(); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/LoginUser.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/LoginUser.java deleted file mode 100644 index 44f3edf547..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/LoginUser.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.core; - -import lombok.Data; - -import java.util.List; - -/** - * 登录用户信息 - * - * @author 芋道源码 - */ -@Data -public class LoginUser { - - /** - * 用户编号 - */ - private Long id; - /** - * 用户类型 - */ - private Integer userType; - /** - * 租户编号 - */ - private Long tenantId; - /** - * 授权范围 - */ - private List scopes; - - /** - * 访问令牌 - */ - private String accessToken; - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/filter/TokenAuthenticationFilter.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/filter/TokenAuthenticationFilter.java deleted file mode 100644 index 511371ce24..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/filter/TokenAuthenticationFilter.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.core.filter; - -import cn.iocoder.yudao.ssodemo.client.OAuth2Client; -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.client.dto.oauth2.OAuth2CheckTokenRespDTO; -import cn.iocoder.yudao.ssodemo.framework.core.LoginUser; -import cn.iocoder.yudao.ssodemo.framework.core.util.SecurityUtils; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import org.springframework.web.filter.OncePerRequestFilter; - -import jakarta.annotation.Resource; -import jakarta.servlet.FilterChain; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Token 过滤器,验证 token 的有效性 - * 验证通过后,获得 {@link LoginUser} 信息,并加入到 Spring Security 上下文 - * - * @author 芋道源码 - */ -@Component -public class TokenAuthenticationFilter extends OncePerRequestFilter { - - @Resource - private OAuth2Client oauth2Client; - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, - FilterChain filterChain) throws ServletException, IOException { - // 1. 获得访问令牌 - String token = SecurityUtils.obtainAuthorization(request, "Authorization"); - if (StringUtils.hasText(token)) { - // 2. 基于 token 构建登录用户 - LoginUser loginUser = buildLoginUserByToken(token); - // 3. 设置当前用户 - if (loginUser != null) { - SecurityUtils.setLoginUser(loginUser, request); - } - } - - // 继续过滤链 - filterChain.doFilter(request, response); - } - - private LoginUser buildLoginUserByToken(String token) { - try { - CommonResult accessTokenResult = oauth2Client.checkToken(token); - OAuth2CheckTokenRespDTO accessToken = accessTokenResult.getData(); - if (accessToken == null) { - return null; - } - // 构建登录用户 - return new LoginUser().setId(accessToken.getUserId()).setUserType(accessToken.getUserType()) - .setTenantId(accessToken.getTenantId()).setScopes(accessToken.getScopes()) - .setAccessToken(accessToken.getAccessToken()); - } catch (Exception exception) { - // 校验 Token 不通过时,考虑到一些接口是无需登录的,所以直接返回 null 即可 - return null; - } - } - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/handler/AccessDeniedHandlerImpl.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/handler/AccessDeniedHandlerImpl.java deleted file mode 100644 index e0c1a141d4..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/handler/AccessDeniedHandlerImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.core.handler; - -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.framework.core.util.SecurityUtils; -import cn.iocoder.yudao.ssodemo.framework.core.util.ServletUtils; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; -import org.springframework.security.access.AccessDeniedException; -import org.springframework.security.web.access.AccessDeniedHandler; -import org.springframework.security.web.access.ExceptionTranslationFilter; -import org.springframework.stereotype.Component; - -import jakarta.servlet.FilterChain; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * 访问一个需要认证的 URL 资源,已经认证(登录)但是没有权限的情况下,返回 {@link GlobalErrorCodeConstants#FORBIDDEN} 错误码。 - * - * 补充:Spring Security 通过 {@link ExceptionTranslationFilter#handleAccessDeniedException(HttpServletRequest, HttpServletResponse, FilterChain, AccessDeniedException)} 方法,调用当前类 - * - * @author 芋道源码 - */ -@Component -@SuppressWarnings("JavadocReference") -@Slf4j -public class AccessDeniedHandlerImpl implements AccessDeniedHandler { - - @Override - public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) - throws IOException, ServletException { - // 打印 warn 的原因是,不定期合并 warn,看看有没恶意破坏 - log.warn("[commence][访问 URL({}) 时,用户({}) 权限不够]", request.getRequestURI(), - SecurityUtils.getLoginUserId(), e); - // 返回 403 - CommonResult result = new CommonResult<>(); - result.setCode(HttpStatus.FORBIDDEN.value()); - result.setMsg("没有该操作权限"); - ServletUtils.writeJSON(response, result); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/handler/AuthenticationEntryPointImpl.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/handler/AuthenticationEntryPointImpl.java deleted file mode 100644 index 950a3317aa..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/handler/AuthenticationEntryPointImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.core.handler; - -import cn.iocoder.yudao.ssodemo.client.dto.CommonResult; -import cn.iocoder.yudao.ssodemo.framework.core.util.ServletUtils; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.AuthenticationEntryPoint; -import org.springframework.security.web.access.ExceptionTranslationFilter; -import org.springframework.stereotype.Component; - -import jakarta.servlet.FilterChain; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -/** - * 访问一个需要认证的 URL 资源,但是此时自己尚未认证(登录)的情况下,返回 {@link GlobalErrorCodeConstants#UNAUTHORIZED} 错误码,从而使前端重定向到登录页 - * - * 补充:Spring Security 通过 {@link ExceptionTranslationFilter#sendStartAuthentication(HttpServletRequest, HttpServletResponse, FilterChain, AuthenticationException)} 方法,调用当前类 - */ -@Component -@Slf4j -@SuppressWarnings("JavadocReference") // 忽略文档引用报错 -public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint { - - @Override - public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) { - log.debug("[commence][访问 URL({}) 时,没有登录]", request.getRequestURI(), e); - // 返回 401 - CommonResult result = new CommonResult<>(); - result.setCode(HttpStatus.UNAUTHORIZED.value()); - result.setMsg("账号未登录"); - ServletUtils.writeJSON(response, result); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/util/SecurityUtils.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/util/SecurityUtils.java deleted file mode 100644 index ad70aae25f..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/util/SecurityUtils.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.core.util; - -import cn.iocoder.yudao.ssodemo.framework.core.LoginUser; -import org.springframework.lang.Nullable; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContext; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; -import org.springframework.util.StringUtils; - -import jakarta.servlet.http.HttpServletRequest; -import java.util.Collections; - -/** - * 安全服务工具类 - * - * @author 芋道源码 - */ -public class SecurityUtils { - - public static final String AUTHORIZATION_BEARER = "Bearer"; - - private SecurityUtils() {} - - /** - * 从请求中,获得认证 Token - * - * @param request 请求 - * @param header 认证 Token 对应的 Header 名字 - * @return 认证 Token - */ - public static String obtainAuthorization(HttpServletRequest request, String header) { - String authorization = request.getHeader(header); - if (!StringUtils.hasText(authorization)) { - return null; - } - int index = authorization.indexOf(AUTHORIZATION_BEARER + " "); - if (index == -1) { // 未找到 - return null; - } - return authorization.substring(index + 7).trim(); - } - - /** - * 获得当前认证信息 - * - * @return 认证信息 - */ - public static Authentication getAuthentication() { - SecurityContext context = SecurityContextHolder.getContext(); - if (context == null) { - return null; - } - return context.getAuthentication(); - } - - /** - * 获取当前用户 - * - * @return 当前用户 - */ - @Nullable - public static LoginUser getLoginUser() { - Authentication authentication = getAuthentication(); - if (authentication == null) { - return null; - } - return authentication.getPrincipal() instanceof LoginUser ? (LoginUser) authentication.getPrincipal() : null; - } - - /** - * 获得当前用户的编号,从上下文中 - * - * @return 用户编号 - */ - @Nullable - public static Long getLoginUserId() { - LoginUser loginUser = getLoginUser(); - return loginUser != null ? loginUser.getId() : null; - } - - /** - * 设置当前用户 - * - * @param loginUser 登录用户 - * @param request 请求 - */ - public static void setLoginUser(LoginUser loginUser, HttpServletRequest request) { - // 创建 Authentication,并设置到上下文 - Authentication authentication = buildAuthentication(loginUser, request); - SecurityContextHolder.getContext().setAuthentication(authentication); - } - - private static Authentication buildAuthentication(LoginUser loginUser, HttpServletRequest request) { - // 创建 UsernamePasswordAuthenticationToken 对象 - UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken( - loginUser, null, Collections.emptyList()); - authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); - return authenticationToken; - } - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/util/ServletUtils.java b/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/util/ServletUtils.java deleted file mode 100644 index 644f836b22..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/java/cn/iocoder/yudao/ssodemo/framework/core/util/ServletUtils.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.ssodemo.framework.core.util; - -import cn.hutool.extra.servlet.JakartaServletUtil; -import cn.hutool.extra.servlet.ServletUtil; -import cn.hutool.json.JSONUtil; -import org.springframework.http.MediaType; - -import jakarta.servlet.http.HttpServletResponse; - -/** - * 客户端工具类 - * - * @author 芋道源码 - */ -public class ServletUtils { - - /** - * 返回 JSON 字符串 - * - * @param response 响应 - * @param object 对象,会序列化成 JSON 字符串 - */ - @SuppressWarnings("deprecation") // 必须使用 APPLICATION_JSON_UTF8_VALUE,否则会乱码 - public static void writeJSON(HttpServletResponse response, Object object) { - String content = JSONUtil.toJsonStr(object); - JakartaServletUtil.write(response, content, MediaType.APPLICATION_JSON_UTF8_VALUE); - } - - public static void write(HttpServletResponse response, String text, String contentType) { - JakartaServletUtil.write(response, text, contentType); - } - -} diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/resources/application.yaml b/yudao-example/yudao-sso-demo-by-password/src/main/resources/application.yaml deleted file mode 100644 index a62cf97dc1..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/resources/application.yaml +++ /dev/null @@ -1,2 +0,0 @@ -server: - port: 18080 diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/resources/static/index.html b/yudao-example/yudao-sso-demo-by-password/src/main/resources/static/index.html deleted file mode 100644 index 8a5372901d..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/resources/static/index.html +++ /dev/null @@ -1,154 +0,0 @@ - - - - - 首页 - - - - - - - - - - - - - - diff --git a/yudao-example/yudao-sso-demo-by-password/src/main/resources/static/login.html b/yudao-example/yudao-sso-demo-by-password/src/main/resources/static/login.html deleted file mode 100644 index 79b866bf2c..0000000000 --- a/yudao-example/yudao-sso-demo-by-password/src/main/resources/static/login.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - 登录 - - - - - - -账号:
-密码:
- - - - diff --git a/yudao-framework/pom.xml b/yudao-framework/pom.xml index 6a8212314f..ed1240c5d1 100644 --- a/yudao-framework/pom.xml +++ b/yudao-framework/pom.xml @@ -24,19 +24,16 @@ yudao-spring-boot-starter-mq yudao-spring-boot-starter-excel - yudao-spring-boot-starter-test yudao-spring-boot-starter-biz-operatelog yudao-spring-boot-starter-biz-dict yudao-spring-boot-starter-biz-sms - yudao-spring-boot-starter-biz-pay yudao-spring-boot-starter-biz-tenant yudao-spring-boot-starter-biz-data-permission yudao-spring-boot-starter-biz-error-code yudao-spring-boot-starter-biz-ip - yudao-spring-boot-starter-flowable yudao-spring-boot-starter-captcha yudao-spring-boot-starter-websocket yudao-spring-boot-starter-desensitize diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/pom.xml index 09e878688b..1dc0b085a8 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/pom.xml @@ -41,12 +41,6 @@ ${revision} - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/aop/DataPermissionAnnotationInterceptorTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/aop/DataPermissionAnnotationInterceptorTest.java deleted file mode 100644 index ba97ede2fc..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/aop/DataPermissionAnnotationInterceptorTest.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.aop; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import org.aopalliance.intercept.MethodInvocation; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.lang.reflect.Method; - -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.when; - -/** - * {@link DataPermissionAnnotationInterceptor} 的单元测试 - * - * @author 芋道源码 - */ -public class DataPermissionAnnotationInterceptorTest extends BaseMockitoUnitTest { - - @InjectMocks - private DataPermissionAnnotationInterceptor interceptor; - - @Mock - private MethodInvocation methodInvocation; - - @BeforeEach - public void setUp() { - interceptor.getDataPermissionCache().clear(); - } - - @Test // 无 @DataPermission 注解 - public void testInvoke_none() throws Throwable { - // 参数 - mockMethodInvocation(TestNone.class); - - // 调用 - Object result = interceptor.invoke(methodInvocation); - // 断言 - assertEquals("none", result); - assertEquals(1, interceptor.getDataPermissionCache().size()); - assertTrue(CollUtil.getFirst(interceptor.getDataPermissionCache().values()).enable()); - } - - @Test // 在 Method 上有 @DataPermission 注解 - public void testInvoke_method() throws Throwable { - // 参数 - mockMethodInvocation(TestMethod.class); - - // 调用 - Object result = interceptor.invoke(methodInvocation); - // 断言 - assertEquals("method", result); - assertEquals(1, interceptor.getDataPermissionCache().size()); - assertFalse(CollUtil.getFirst(interceptor.getDataPermissionCache().values()).enable()); - } - - @Test // 在 Class 上有 @DataPermission 注解 - public void testInvoke_class() throws Throwable { - // 参数 - mockMethodInvocation(TestClass.class); - - // 调用 - Object result = interceptor.invoke(methodInvocation); - // 断言 - assertEquals("class", result); - assertEquals(1, interceptor.getDataPermissionCache().size()); - assertFalse(CollUtil.getFirst(interceptor.getDataPermissionCache().values()).enable()); - } - - private void mockMethodInvocation(Class clazz) throws Throwable { - Object targetObject = clazz.newInstance(); - Method method = targetObject.getClass().getMethod("echo"); - when(methodInvocation.getThis()).thenReturn(targetObject); - when(methodInvocation.getMethod()).thenReturn(method); - when(methodInvocation.proceed()).then(invocationOnMock -> method.invoke(targetObject)); - } - - static class TestMethod { - - @DataPermission(enable = false) - public String echo() { - return "method"; - } - - } - - @DataPermission(enable = false) - static class TestClass { - - public String echo() { - return "class"; - } - - } - - static class TestNone { - - public String echo() { - return "none"; - } - - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/aop/DataPermissionContextHolderTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/aop/DataPermissionContextHolderTest.java deleted file mode 100644 index 688b92d9f2..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/aop/DataPermissionContextHolderTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.aop; - -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.mockito.Mockito.mock; - -/** - * {@link DataPermissionContextHolder} 的单元测试 - * - * @author 芋道源码 - */ -class DataPermissionContextHolderTest { - - @BeforeEach - public void setUp() { - DataPermissionContextHolder.clear(); - } - - @Test - public void testGet() { - // mock 方法 - DataPermission dataPermission01 = mock(DataPermission.class); - DataPermissionContextHolder.add(dataPermission01); - DataPermission dataPermission02 = mock(DataPermission.class); - DataPermissionContextHolder.add(dataPermission02); - - // 调用 - DataPermission result = DataPermissionContextHolder.get(); - // 断言 - assertSame(result, dataPermission02); - } - - @Test - public void testPush() { - // 调用 - DataPermission dataPermission01 = mock(DataPermission.class); - DataPermissionContextHolder.add(dataPermission01); - DataPermission dataPermission02 = mock(DataPermission.class); - DataPermissionContextHolder.add(dataPermission02); - // 断言 - DataPermission first = DataPermissionContextHolder.getAll().get(0); - DataPermission second = DataPermissionContextHolder.getAll().get(1); - assertSame(dataPermission01, first); - assertSame(dataPermission02, second); - } - - @Test - public void testRemove() { - // mock 方法 - DataPermission dataPermission01 = mock(DataPermission.class); - DataPermissionContextHolder.add(dataPermission01); - DataPermission dataPermission02 = mock(DataPermission.class); - DataPermissionContextHolder.add(dataPermission02); - - // 调用 - DataPermission result = DataPermissionContextHolder.remove(); - // 断言 - assertSame(result, dataPermission02); - assertEquals(1, DataPermissionContextHolder.getAll().size()); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest.java deleted file mode 100644 index 145360789c..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest.java +++ /dev/null @@ -1,190 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.db; - -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRule; -import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRuleFactory; -import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import com.baomidou.mybatisplus.core.toolkit.PluginUtils; -import net.sf.jsqlparser.expression.Alias; -import net.sf.jsqlparser.expression.Expression; -import net.sf.jsqlparser.expression.LongValue; -import net.sf.jsqlparser.expression.operators.relational.EqualsTo; -import net.sf.jsqlparser.schema.Column; -import org.apache.ibatis.executor.Executor; -import org.apache.ibatis.executor.statement.StatementHandler; -import org.apache.ibatis.mapping.BoundSql; -import org.apache.ibatis.mapping.MappedStatement; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockedStatic; - -import java.sql.Connection; -import java.util.*; - -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link DataPermissionDatabaseInterceptor} 的单元测试 - * 主要测试 {@link DataPermissionDatabaseInterceptor#beforePrepare(StatementHandler, Connection, Integer)} - * 和 {@link DataPermissionDatabaseInterceptor#beforeUpdate(Executor, MappedStatement, Object)} - * 以及在这个过程中,ContextHolder 和 MappedStatementCache - * - * @author 芋道源码 - */ -public class DataPermissionDatabaseInterceptorTest extends BaseMockitoUnitTest { - - @InjectMocks - private DataPermissionDatabaseInterceptor interceptor; - - @Mock - private DataPermissionRuleFactory ruleFactory; - - @BeforeEach - public void setUp() { - // 清理上下文 - DataPermissionDatabaseInterceptor.ContextHolder.clear(); - // 清空缓存 - interceptor.getMappedStatementCache().clear(); - } - - @Test // 不存在规则,且不匹配 - public void testBeforeQuery_withoutRule() { - try (MockedStatic pluginUtilsMock = mockStatic(PluginUtils.class)) { - // 准备参数 - MappedStatement mappedStatement = mock(MappedStatement.class); - BoundSql boundSql = mock(BoundSql.class); - - // 调用 - interceptor.beforeQuery(null, mappedStatement, null, null, null, boundSql); - // 断言 - pluginUtilsMock.verify(() -> PluginUtils.mpBoundSql(boundSql), never()); - } - } - - @Test // 存在规则,且不匹配 - public void testBeforeQuery_withMatchRule() { - try (MockedStatic pluginUtilsMock = mockStatic(PluginUtils.class)) { - // 准备参数 - MappedStatement mappedStatement = mock(MappedStatement.class); - BoundSql boundSql = mock(BoundSql.class); - // mock 方法(数据权限) - when(ruleFactory.getDataPermissionRule(same(mappedStatement.getId()))) - .thenReturn(singletonList(new DeptDataPermissionRule())); - // mock 方法(MPBoundSql) - PluginUtils.MPBoundSql mpBs = mock(PluginUtils.MPBoundSql.class); - pluginUtilsMock.when(() -> PluginUtils.mpBoundSql(same(boundSql))).thenReturn(mpBs); - // mock 方法(SQL) - String sql = "select * from t_user where id = 1"; - when(mpBs.sql()).thenReturn(sql); - // 针对 ContextHolder 和 MappedStatementCache 暂时不 mock,主要想校验过程中,数据是否正确 - - // 调用 - interceptor.beforeQuery(null, mappedStatement, null, null, null, boundSql); - // 断言 - verify(mpBs, times(1)).sql( - eq("SELECT * FROM t_user WHERE id = 1 AND t_user.dept_id = 100")); - // 断言缓存 - assertTrue(interceptor.getMappedStatementCache().getNoRewritableMappedStatements().isEmpty()); - } - } - - @Test // 存在规则,但不匹配 - public void testBeforeQuery_withoutMatchRule() { - try (MockedStatic pluginUtilsMock = mockStatic(PluginUtils.class)) { - // 准备参数 - MappedStatement mappedStatement = mock(MappedStatement.class); - BoundSql boundSql = mock(BoundSql.class); - // mock 方法(数据权限) - when(ruleFactory.getDataPermissionRule(same(mappedStatement.getId()))) - .thenReturn(singletonList(new DeptDataPermissionRule())); - // mock 方法(MPBoundSql) - PluginUtils.MPBoundSql mpBs = mock(PluginUtils.MPBoundSql.class); - pluginUtilsMock.when(() -> PluginUtils.mpBoundSql(same(boundSql))).thenReturn(mpBs); - // mock 方法(SQL) - String sql = "select * from t_role where id = 1"; - when(mpBs.sql()).thenReturn(sql); - // 针对 ContextHolder 和 MappedStatementCache 暂时不 mock,主要想校验过程中,数据是否正确 - - // 调用 - interceptor.beforeQuery(null, mappedStatement, null, null, null, boundSql); - // 断言 - verify(mpBs, times(1)).sql( - eq("SELECT * FROM t_role WHERE id = 1")); - // 断言缓存 - assertFalse(interceptor.getMappedStatementCache().getNoRewritableMappedStatements().isEmpty()); - } - } - - @Test - public void testAddNoRewritable() { - // 准备参数 - MappedStatement ms = mock(MappedStatement.class); - List rules = singletonList(new DeptDataPermissionRule()); - // mock 方法 - when(ms.getId()).thenReturn("selectById"); - - // 调用 - interceptor.getMappedStatementCache().addNoRewritable(ms, rules); - // 断言 - Map, Set> noRewritableMappedStatements = - interceptor.getMappedStatementCache().getNoRewritableMappedStatements(); - assertEquals(1, noRewritableMappedStatements.size()); - assertEquals(SetUtils.asSet("selectById"), noRewritableMappedStatements.get(DeptDataPermissionRule.class)); - } - - @Test - public void testNoRewritable() { - // 准备参数 - MappedStatement ms = mock(MappedStatement.class); - // mock 方法 - when(ms.getId()).thenReturn("selectById"); - // mock 数据 - List rules = singletonList(new DeptDataPermissionRule()); - interceptor.getMappedStatementCache().addNoRewritable(ms, rules); - - // 场景一,rules 为空 - assertTrue(interceptor.getMappedStatementCache().noRewritable(ms, null)); - // 场景二,rules 非空,可重写 - assertFalse(interceptor.getMappedStatementCache().noRewritable(ms, singletonList(new EmptyDataPermissionRule()))); - // 场景三,rule 非空,不可重写 - assertTrue(interceptor.getMappedStatementCache().noRewritable(ms, rules)); - } - - private static class DeptDataPermissionRule implements DataPermissionRule { - - private static final String COLUMN = "dept_id"; - - @Override - public Set getTableNames() { - return SetUtils.asSet("t_user"); - } - - @Override - public Expression getExpression(String tableName, Alias tableAlias) { - Column column = MyBatisUtils.buildColumn(tableName, tableAlias, COLUMN); - LongValue value = new LongValue(100L); - return new EqualsTo(column, value); - } - - } - - private static class EmptyDataPermissionRule implements DataPermissionRule { - - @Override - public Set getTableNames() { - return Collections.emptySet(); - } - - @Override - public Expression getExpression(String tableName, Alias tableAlias) { - return null; - } - - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest2.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest2.java deleted file mode 100644 index b8cad13cf2..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest2.java +++ /dev/null @@ -1,533 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.db; - -import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRule; -import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRuleFactory; -import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import net.sf.jsqlparser.expression.Alias; -import net.sf.jsqlparser.expression.Expression; -import net.sf.jsqlparser.expression.LongValue; -import net.sf.jsqlparser.expression.operators.relational.EqualsTo; -import net.sf.jsqlparser.expression.operators.relational.ExpressionList; -import net.sf.jsqlparser.expression.operators.relational.InExpression; -import net.sf.jsqlparser.schema.Column; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Arrays; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * {@link DataPermissionDatabaseInterceptor} 的单元测试 - * 主要复用了 MyBatis Plus 的 TenantLineInnerInterceptorTest 的单元测试 - * 不过它的单元测试不是很规范,考虑到是复用的,所以暂时不进行修改~ - * - * @author 芋道源码 - */ -public class DataPermissionDatabaseInterceptorTest2 extends BaseMockitoUnitTest { - - @InjectMocks - private DataPermissionDatabaseInterceptor interceptor; - - @Mock - private DataPermissionRuleFactory ruleFactory; - - @BeforeEach - public void setUp() { - // 租户的数据权限规则 - DataPermissionRule tenantRule = new DataPermissionRule() { - - private static final String COLUMN = "tenant_id"; - - @Override - public Set getTableNames() { - return asSet("entity", "entity1", "entity2", "entity3", "t1", "t2", "sys_dict_item", // 支持 MyBatis Plus 的单元测试 - "t_user", "t_role"); // 满足自己的单元测试 - } - - @Override - public Expression getExpression(String tableName, Alias tableAlias) { - Column column = MyBatisUtils.buildColumn(tableName, tableAlias, COLUMN); - LongValue value = new LongValue(1L); - return new EqualsTo(column, value); - } - - }; - // 部门的数据权限规则 - DataPermissionRule deptRule = new DataPermissionRule() { - - private static final String COLUMN = "dept_id"; - - @Override - public Set getTableNames() { - return asSet("t_user"); // 满足自己的单元测试 - } - - @Override - public Expression getExpression(String tableName, Alias tableAlias) { - Column column = MyBatisUtils.buildColumn(tableName, tableAlias, COLUMN); - ExpressionList values = new ExpressionList(new LongValue(10L), - new LongValue(20L)); - return new InExpression(column, values); - } - - }; - // 设置到上下文,保证 - DataPermissionDatabaseInterceptor.ContextHolder.init(Arrays.asList(tenantRule, deptRule)); - } - - @Test - void delete() { - assertSql("delete from entity where id = ?", - "DELETE FROM entity WHERE id = ? AND entity.tenant_id = 1"); - } - - @Test - void update() { - assertSql("update entity set name = ? where id = ?", - "UPDATE entity SET name = ? WHERE id = ? AND entity.tenant_id = 1"); - } - - @Test - void selectSingle() { - // 单表 - assertSql("select * from entity where id = ?", - "SELECT * FROM entity WHERE id = ? AND entity.tenant_id = 1"); - - assertSql("select * from entity where id = ? or name = ?", - "SELECT * FROM entity WHERE (id = ? OR name = ?) AND entity.tenant_id = 1"); - - assertSql("SELECT * FROM entity WHERE (id = ? OR name = ?)", - "SELECT * FROM entity WHERE (id = ? OR name = ?) AND entity.tenant_id = 1"); - - /* not */ - assertSql("SELECT * FROM entity WHERE not (id = ? OR name = ?)", - "SELECT * FROM entity WHERE NOT (id = ? OR name = ?) AND entity.tenant_id = 1"); - } - - @Test - void selectSubSelectIn() { - /* in */ - assertSql("SELECT * FROM entity e WHERE e.id IN (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE e.id IN (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - // 在最前 - assertSql("SELECT * FROM entity e WHERE e.id IN " + - "(select e1.id from entity1 e1 where e1.id = ?) and e.id = ?", - "SELECT * FROM entity e WHERE e.id IN " + - "(SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.id = ? AND e.tenant_id = 1"); - // 在最后 - assertSql("SELECT * FROM entity e WHERE e.id = ? and e.id IN " + - "(select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE e.id = ? AND e.id IN " + - "(SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - // 在中间 - assertSql("SELECT * FROM entity e WHERE e.id = ? and e.id IN " + - "(select e1.id from entity1 e1 where e1.id = ?) and e.id = ?", - "SELECT * FROM entity e WHERE e.id = ? AND e.id IN " + - "(SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.id = ? AND e.tenant_id = 1"); - } - - @Test - void selectSubSelectEq() { - /* = */ - assertSql("SELECT * FROM entity e WHERE e.id = (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - } - - @Test - void selectSubSelectInnerNotEq() { - /* inner not = */ - assertSql("SELECT * FROM entity e WHERE not (e.id = (select e1.id from entity1 e1 where e1.id = ?))", - "SELECT * FROM entity e WHERE NOT (e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1)) AND e.tenant_id = 1"); - - assertSql("SELECT * FROM entity e WHERE not (e.id = (select e1.id from entity1 e1 where e1.id = ?) and e.id = ?)", - "SELECT * FROM entity e WHERE NOT (e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.id = ?) AND e.tenant_id = 1"); - } - - @Test - void selectSubSelectExists() { - /* EXISTS */ - assertSql("SELECT * FROM entity e WHERE EXISTS (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE EXISTS (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - - - /* NOT EXISTS */ - assertSql("SELECT * FROM entity e WHERE NOT EXISTS (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE NOT EXISTS (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - } - - @Test - void selectSubSelect() { - /* >= */ - assertSql("SELECT * FROM entity e WHERE e.id >= (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE e.id >= (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - - - /* <= */ - assertSql("SELECT * FROM entity e WHERE e.id <= (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE e.id <= (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - - - /* <> */ - assertSql("SELECT * FROM entity e WHERE e.id <> (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE e.id <> (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - } - - @Test - void selectFromSelect() { - assertSql("SELECT * FROM (select e.id from entity e WHERE e.id = (select e1.id from entity1 e1 where e1.id = ?))", - "SELECT * FROM (SELECT e.id FROM entity e WHERE e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1)"); - } - - @Test - void selectBodySubSelect() { - assertSql("select t1.col1,(select t2.col2 from t2 t2 where t1.col1=t2.col1) from t1 t1", - "SELECT t1.col1, (SELECT t2.col2 FROM t2 t2 WHERE t1.col1 = t2.col1 AND t2.tenant_id = 1) FROM t1 t1 WHERE t1.tenant_id = 1"); - } - - @Test - void selectLeftJoin() { - // left join - assertSql("SELECT * FROM entity e " + - "left join entity1 e1 on e1.id = e.id " + - "WHERE e.id = ? OR e.name = ?", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "left join entity1 e1 on e1.id = e.id " + - "WHERE (e.id = ? OR e.name = ?)", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "left join entity1 e1 on e1.id = e.id " + - "left join entity2 e2 on e1.id = e2.id", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1 " + - "WHERE e.tenant_id = 1"); - } - - @Test - void selectRightJoin() { - // right join - assertSql("SELECT * FROM entity e " + - "right join entity1 e1 on e1.id = e.id", - "SELECT * FROM entity e " + - "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + - "WHERE e1.tenant_id = 1"); - - assertSql("SELECT * FROM with_as_1 e " + - "right join entity1 e1 on e1.id = e.id", - "SELECT * FROM with_as_1 e " + - "RIGHT JOIN entity1 e1 ON e1.id = e.id " + - "WHERE e1.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "right join entity1 e1 on e1.id = e.id " + - "WHERE e.id = ? OR e.name = ?", - "SELECT * FROM entity e " + - "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "right join entity1 e1 on e1.id = e.id " + - "right join entity2 e2 on e1.id = e2.id ", - "SELECT * FROM entity e " + - "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + - "RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1 " + - "WHERE e2.tenant_id = 1"); - } - - @Test - void selectMixJoin() { - assertSql("SELECT * FROM entity e " + - "right join entity1 e1 on e1.id = e.id " + - "left join entity2 e2 on e1.id = e2.id", - "SELECT * FROM entity e " + - "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + - "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1 " + - "WHERE e1.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "left join entity1 e1 on e1.id = e.id " + - "right join entity2 e2 on e1.id = e2.id", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1 " + - "WHERE e2.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "left join entity1 e1 on e1.id = e.id " + - "inner join entity2 e2 on e1.id = e2.id", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "INNER JOIN entity2 e2 ON e1.id = e2.id AND e.tenant_id = 1 AND e2.tenant_id = 1"); - } - - - @Test - void selectJoinSubSelect() { - assertSql("select * from (select * from entity) e1 " + - "left join entity2 e2 on e1.id = e2.id", - "SELECT * FROM (SELECT * FROM entity WHERE entity.tenant_id = 1) e1 " + - "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1"); - - assertSql("select * from entity1 e1 " + - "left join (select * from entity2) e2 " + - "on e1.id = e2.id", - "SELECT * FROM entity1 e1 " + - "LEFT JOIN (SELECT * FROM entity2 WHERE entity2.tenant_id = 1) e2 " + - "ON e1.id = e2.id " + - "WHERE e1.tenant_id = 1"); - } - - @Test - void selectSubJoin() { - - assertSql("select * FROM " + - "(entity1 e1 right JOIN entity2 e2 ON e1.id = e2.id)", - "SELECT * FROM " + - "(entity1 e1 RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1) " + - "WHERE e2.tenant_id = 1"); - - assertSql("select * FROM " + - "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id)", - "SELECT * FROM " + - "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + - "WHERE e1.tenant_id = 1"); - - - assertSql("select * FROM " + - "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id) " + - "right join entity3 e3 on e1.id = e3.id", - "SELECT * FROM " + - "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + - "RIGHT JOIN entity3 e3 ON e1.id = e3.id AND e1.tenant_id = 1 " + - "WHERE e3.tenant_id = 1"); - - - assertSql("select * FROM entity e " + - "LEFT JOIN (entity1 e1 right join entity2 e2 ON e1.id = e2.id) " + - "on e.id = e2.id", - "SELECT * FROM entity e " + - "LEFT JOIN (entity1 e1 RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1) " + - "ON e.id = e2.id AND e2.tenant_id = 1 " + - "WHERE e.tenant_id = 1"); - - assertSql("select * FROM entity e " + - "LEFT JOIN (entity1 e1 left join entity2 e2 ON e1.id = e2.id) " + - "on e.id = e2.id", - "SELECT * FROM entity e " + - "LEFT JOIN (entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + - "ON e.id = e2.id AND e1.tenant_id = 1 " + - "WHERE e.tenant_id = 1"); - - assertSql("select * FROM entity e " + - "RIGHT JOIN (entity1 e1 left join entity2 e2 ON e1.id = e2.id) " + - "on e.id = e2.id", - "SELECT * FROM entity e " + - "RIGHT JOIN (entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + - "ON e.id = e2.id AND e.tenant_id = 1 " + - "WHERE e1.tenant_id = 1"); - } - - - @Test - void selectLeftJoinMultipleTrailingOn() { - // 多个 on 尾缀的 - assertSql("SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 " + - "LEFT JOIN entity2 e2 ON e2.id = e1.id " + - "ON e1.id = e.id " + - "WHERE (e.id = ? OR e.NAME = ?)", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 " + - "LEFT JOIN entity2 e2 ON e2.id = e1.id AND e2.tenant_id = 1 " + - "ON e1.id = e.id AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.NAME = ?) AND e.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 " + - "LEFT JOIN with_as_A e2 ON e2.id = e1.id " + - "ON e1.id = e.id " + - "WHERE (e.id = ? OR e.NAME = ?)", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 " + - "LEFT JOIN with_as_A e2 ON e2.id = e1.id " + - "ON e1.id = e.id AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.NAME = ?) AND e.tenant_id = 1"); - } - - @Test - void selectInnerJoin() { - // inner join - assertSql("SELECT * FROM entity e " + - "inner join entity1 e1 on e1.id = e.id " + - "WHERE e.id = ? OR e.name = ?", - "SELECT * FROM entity e " + - "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e1.tenant_id = 1 " + - "WHERE e.id = ? OR e.name = ?"); - - assertSql("SELECT * FROM entity e " + - "inner join entity1 e1 on e1.id = e.id " + - "WHERE (e.id = ? OR e.name = ?)", - "SELECT * FROM entity e " + - "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?)"); - - // 隐式内连接 - assertSql("SELECT * FROM entity,entity1 " + - "WHERE entity.id = entity1.id", - "SELECT * FROM entity, entity1 " + - "WHERE entity.id = entity1.id AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); - - // 隐式内连接 - assertSql("SELECT * FROM entity a, with_as_entity1 b " + - "WHERE a.id = b.id", - "SELECT * FROM entity a, with_as_entity1 b " + - "WHERE a.id = b.id AND a.tenant_id = 1"); - - assertSql("SELECT * FROM with_as_entity a, with_as_entity1 b " + - "WHERE a.id = b.id", - "SELECT * FROM with_as_entity a, with_as_entity1 b " + - "WHERE a.id = b.id"); - - // SubJoin with 隐式内连接 - assertSql("SELECT * FROM (entity,entity1) " + - "WHERE entity.id = entity1.id", - "SELECT * FROM (entity, entity1) " + - "WHERE entity.id = entity1.id " + - "AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); - - assertSql("SELECT * FROM ((entity,entity1),entity2) " + - "WHERE entity.id = entity1.id and entity.id = entity2.id", - "SELECT * FROM ((entity, entity1), entity2) " + - "WHERE entity.id = entity1.id AND entity.id = entity2.id " + - "AND entity.tenant_id = 1 AND entity1.tenant_id = 1 AND entity2.tenant_id = 1"); - - assertSql("SELECT * FROM (entity,(entity1,entity2)) " + - "WHERE entity.id = entity1.id and entity.id = entity2.id", - "SELECT * FROM (entity, (entity1, entity2)) " + - "WHERE entity.id = entity1.id AND entity.id = entity2.id " + - "AND entity.tenant_id = 1 AND entity1.tenant_id = 1 AND entity2.tenant_id = 1"); - - // 沙雕的括号写法 - assertSql("SELECT * FROM (((entity,entity1))) " + - "WHERE entity.id = entity1.id", - "SELECT * FROM (((entity, entity1))) " + - "WHERE entity.id = entity1.id " + - "AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); - - } - - - @Test - void selectWithAs() { - assertSql("with with_as_A as (select * from entity) select * from with_as_A", - "WITH with_as_A AS (SELECT * FROM entity WHERE entity.tenant_id = 1) SELECT * FROM with_as_A"); - } - - - @Test - void selectIgnoreTable() { - assertSql(" SELECT dict.dict_code, item.item_text AS \"text\", item.item_value AS \"value\" FROM sys_dict_item item INNER JOIN sys_dict dict ON dict.id = item.dict_id WHERE dict.dict_code IN (1, 2, 3) AND item.item_value IN (1, 2, 3)", - "SELECT dict.dict_code, item.item_text AS \"text\", item.item_value AS \"value\" FROM sys_dict_item item INNER JOIN sys_dict dict ON dict.id = item.dict_id AND item.tenant_id = 1 WHERE dict.dict_code IN (1, 2, 3) AND item.item_value IN (1, 2, 3)"); - } - - private void assertSql(String sql, String targetSql) { - assertEquals(targetSql, interceptor.parserSingle(sql, null)); - } - - - // ========== 额外的测试 ========== - - @Test - public void testSelectSingle() { - // 单表 - assertSql("select * from t_user where id = ?", - "SELECT * FROM t_user WHERE id = ? AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); - - assertSql("select * from t_user where id = ? or name = ?", - "SELECT * FROM t_user WHERE (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); - - assertSql("SELECT * FROM t_user WHERE (id = ? OR name = ?)", - "SELECT * FROM t_user WHERE (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); - - /* not */ - assertSql("SELECT * FROM t_user WHERE not (id = ? OR name = ?)", - "SELECT * FROM t_user WHERE NOT (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); - } - - @Test - public void testSelectLeftJoin() { - // left join - assertSql("SELECT * FROM t_user e " + - "left join t_role e1 on e1.id = e.id " + - "WHERE e.id = ? OR e.name = ?", - "SELECT * FROM t_user e " + - "LEFT JOIN t_role e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1 AND e.dept_id IN (10, 20)"); - - // 条件 e.id = ? OR e.name = ? 带括号 - assertSql("SELECT * FROM t_user e " + - "left join t_role e1 on e1.id = e.id " + - "WHERE (e.id = ? OR e.name = ?)", - "SELECT * FROM t_user e " + - "LEFT JOIN t_role e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1 AND e.dept_id IN (10, 20)"); - } - - @Test - public void testSelectRightJoin() { - // right join - assertSql("SELECT * FROM t_user e " + - "right join t_role e1 on e1.id = e.id " + - "WHERE e.id = ? OR e.name = ?", - "SELECT * FROM t_user e " + - "RIGHT JOIN t_role e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) " + - "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1"); - - // 条件 e.id = ? OR e.name = ? 带括号 - assertSql("SELECT * FROM t_user e " + - "right join t_role e1 on e1.id = e.id " + - "WHERE (e.id = ? OR e.name = ?)", - "SELECT * FROM t_user e " + - "RIGHT JOIN t_role e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) " + - "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1"); - } - - @Test - public void testSelectInnerJoin() { - // inner join - assertSql("SELECT * FROM t_user e " + - "inner join entity1 e1 on e1.id = e.id " + - "WHERE e.id = ? OR e.name = ?", - "SELECT * FROM t_user e " + - "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) AND e1.tenant_id = 1 " + - "WHERE e.id = ? OR e.name = ?"); - - // 条件 e.id = ? OR e.name = ? 带括号 - assertSql("SELECT * FROM t_user e " + - "inner join entity1 e1 on e1.id = e.id " + - "WHERE (e.id = ? OR e.name = ?)", - "SELECT * FROM t_user e " + - "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?)"); - - // 没有 On 的 inner join - assertSql("SELECT * FROM entity,entity1 " + - "WHERE entity.id = entity1.id", - "SELECT * FROM entity, entity1 " + - "WHERE entity.id = entity1.id AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/rule/DataPermissionRuleFactoryImplTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/rule/DataPermissionRuleFactoryImplTest.java deleted file mode 100644 index 17dddc929e..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/rule/DataPermissionRuleFactoryImplTest.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.rule; - -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import cn.iocoder.yudao.framework.datapermission.core.aop.DataPermissionContextHolder; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import net.sf.jsqlparser.expression.Alias; -import net.sf.jsqlparser.expression.Expression; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Spy; -import org.springframework.core.annotation.AnnotationUtils; - -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link DataPermissionRuleFactoryImpl} 单元测试 - * - * @author 芋道源码 - */ -class DataPermissionRuleFactoryImplTest extends BaseMockitoUnitTest { - - @InjectMocks - private DataPermissionRuleFactoryImpl dataPermissionRuleFactory; - - @Spy - private List rules = Arrays.asList(new DataPermissionRule01(), - new DataPermissionRule02()); - - @BeforeEach - public void setUp() { - DataPermissionContextHolder.clear(); - } - - @Test - public void testGetDataPermissionRule_02() { - // 准备参数 - String mappedStatementId = randomString(); - - // 调用 - List result = dataPermissionRuleFactory.getDataPermissionRule(mappedStatementId); - // 断言 - assertSame(rules, result); - } - - @Test - public void testGetDataPermissionRule_03() { - // 准备参数 - String mappedStatementId = randomString(); - // mock 方法 - DataPermissionContextHolder.add(AnnotationUtils.findAnnotation(TestClass03.class, DataPermission.class)); - - // 调用 - List result = dataPermissionRuleFactory.getDataPermissionRule(mappedStatementId); - // 断言 - assertTrue(result.isEmpty()); - } - - @Test - public void testGetDataPermissionRule_04() { - // 准备参数 - String mappedStatementId = randomString(); - // mock 方法 - DataPermissionContextHolder.add(AnnotationUtils.findAnnotation(TestClass04.class, DataPermission.class)); - - // 调用 - List result = dataPermissionRuleFactory.getDataPermissionRule(mappedStatementId); - // 断言 - assertEquals(1, result.size()); - assertEquals(DataPermissionRule01.class, result.get(0).getClass()); - } - - @Test - public void testGetDataPermissionRule_05() { - // 准备参数 - String mappedStatementId = randomString(); - // mock 方法 - DataPermissionContextHolder.add(AnnotationUtils.findAnnotation(TestClass05.class, DataPermission.class)); - - // 调用 - List result = dataPermissionRuleFactory.getDataPermissionRule(mappedStatementId); - // 断言 - assertEquals(1, result.size()); - assertEquals(DataPermissionRule02.class, result.get(0).getClass()); - } - - @Test - public void testGetDataPermissionRule_06() { - // 准备参数 - String mappedStatementId = randomString(); - // mock 方法 - DataPermissionContextHolder.add(AnnotationUtils.findAnnotation(TestClass06.class, DataPermission.class)); - - // 调用 - List result = dataPermissionRuleFactory.getDataPermissionRule(mappedStatementId); - // 断言 - assertSame(rules, result); - } - - @DataPermission(enable = false) - static class TestClass03 {} - - @DataPermission(includeRules = DataPermissionRule01.class) - static class TestClass04 {} - - @DataPermission(excludeRules = DataPermissionRule01.class) - static class TestClass05 {} - - @DataPermission - static class TestClass06 {} - - static class DataPermissionRule01 implements DataPermissionRule { - - @Override - public Set getTableNames() { - return null; - } - - @Override - public Expression getExpression(String tableName, Alias tableAlias) { - return null; - } - - } - - static class DataPermissionRule02 implements DataPermissionRule { - - @Override - public Set getTableNames() { - return null; - } - - @Override - public Expression getExpression(String tableName, Alias tableAlias) { - return null; - } - - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRuleTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRuleTest.java deleted file mode 100644 index d0fe496eda..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRuleTest.java +++ /dev/null @@ -1,238 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.rule.dept; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.security.core.LoginUser; -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespDTO; -import net.sf.jsqlparser.expression.Alias; -import net.sf.jsqlparser.expression.Expression; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockedStatic; - -import java.util.Map; - -import static cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRule.EXPRESSION_NULL; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.same; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.when; - -/** - * {@link DeptDataPermissionRule} 的单元测试 - * - * @author 芋道源码 - */ -class DeptDataPermissionRuleTest extends BaseMockitoUnitTest { - - @InjectMocks - private DeptDataPermissionRule rule; - - @Mock - private PermissionApi permissionApi; - - @BeforeEach - @SuppressWarnings("unchecked") - public void setUp() { - // 清空 rule - rule.getTableNames().clear(); - ((Map) ReflectUtil.getFieldValue(rule, "deptColumns")).clear(); - ((Map) ReflectUtil.getFieldValue(rule, "deptColumns")).clear(); - } - - @Test // 无 LoginUser - public void testGetExpression_noLoginUser() { - // 准备参数 - String tableName = randomString(); - Alias tableAlias = new Alias(randomString()); - // mock 方法 - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertNull(expression); - } - - @Test // 无数据权限时 - public void testGetExpression_noDeptDataPermission() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法 - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(permissionApi 返回 null) - when(permissionApi.getDeptDataPermission(eq(loginUser.getId()))).thenReturn(null); - - // 调用 - NullPointerException exception = assertThrows(NullPointerException.class, - () -> rule.getExpression(tableName, tableAlias)); - // 断言 - assertEquals("LoginUser(1) Table(t_user/u) 未返回数据权限", exception.getMessage()); - } - } - - @Test // 全部数据权限 - public void testGetExpression_allDeptDataPermission() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法(LoginUser) - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(DeptDataPermissionRespDTO) - DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO().setAll(true); - when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(deptDataPermission); - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertNull(expression); - assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class)); - } - } - - @Test // 即不能查看部门,又不能查看自己,则说明 100% 无权限 - public void testGetExpression_noDept_noSelf() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法(LoginUser) - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(DeptDataPermissionRespDTO) - DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO(); - when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(deptDataPermission); - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertEquals("null = null", expression.toString()); - assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class)); - } - } - - @Test // 拼接 Dept 和 User 的条件(字段都不符合) - public void testGetExpression_noDeptColumn_noSelfColumn() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法(LoginUser) - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(DeptDataPermissionRespDTO) - DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO() - .setDeptIds(SetUtils.asSet(10L, 20L)).setSelf(true); - when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(deptDataPermission); - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertSame(EXPRESSION_NULL, expression); - assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class)); - } - } - - @Test // 拼接 Dept 和 User 的条件(self 符合) - public void testGetExpression_noDeptColumn_yesSelfColumn() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法(LoginUser) - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(DeptDataPermissionRespDTO) - DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO() - .setSelf(true); - when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(deptDataPermission); - // 添加 user 字段配置 - rule.addUserColumn("t_user", "id"); - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertEquals("u.id = 1", expression.toString()); - assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class)); - } - } - - @Test // 拼接 Dept 和 User 的条件(dept 符合) - public void testGetExpression_yesDeptColumn_noSelfColumn() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法(LoginUser) - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(DeptDataPermissionRespDTO) - DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO() - .setDeptIds(CollUtil.newLinkedHashSet(10L, 20L)); - when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(deptDataPermission); - // 添加 dept 字段配置 - rule.addDeptColumn("t_user", "dept_id"); - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertEquals("u.dept_id IN (10, 20)", expression.toString()); - assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class)); - } - } - - @Test // 拼接 Dept 和 User 的条件(dept + self 符合) - public void testGetExpression_yesDeptColumn_yesSelfColumn() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法(LoginUser) - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(DeptDataPermissionRespDTO) - DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO() - .setDeptIds(CollUtil.newLinkedHashSet(10L, 20L)).setSelf(true); - when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(deptDataPermission); - // 添加 user 字段配置 - rule.addUserColumn("t_user", "id"); - // 添加 dept 字段配置 - rule.addDeptColumn("t_user", "dept_id"); - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertEquals("(u.dept_id IN (10, 20) OR u.id = 1)", expression.toString()); - assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class)); - } - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/util/DataPermissionUtilsTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/util/DataPermissionUtilsTest.java deleted file mode 100644 index 1cc57c2586..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/util/DataPermissionUtilsTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.util; - -import cn.iocoder.yudao.framework.datapermission.core.aop.DataPermissionContextHolder; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -public class DataPermissionUtilsTest { - - @Test - public void testExecuteIgnore() { - DataPermissionUtils.executeIgnore(() -> assertFalse(DataPermissionContextHolder.get().enable())); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-dict/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-dict/pom.xml index e74551ff01..01d6cd614f 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-dict/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-dict/pom.xml @@ -40,11 +40,5 @@ guava - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - diff --git a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/test/java/cn/iocoder/yudao/framework/dict/core/util/DictFrameworkUtilsTest.java b/yudao-framework/yudao-spring-boot-starter-biz-dict/src/test/java/cn/iocoder/yudao/framework/dict/core/util/DictFrameworkUtilsTest.java deleted file mode 100644 index 787cf2376a..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/test/java/cn/iocoder/yudao/framework/dict/core/util/DictFrameworkUtilsTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.framework.dict.core.util; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.api.dict.DictDataApi; -import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; - -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.when; - -/** - * {@link DictFrameworkUtils} 的单元测试 - */ -public class DictFrameworkUtilsTest extends BaseMockitoUnitTest { - - @Mock - private DictDataApi dictDataApi; - - @BeforeEach - public void setUp() { - DictFrameworkUtils.init(dictDataApi); - } - - @Test - public void testGetDictDataLabel() { - // mock 数据 - DictDataRespDTO dataRespDTO = randomPojo(DictDataRespDTO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - // mock 方法 - when(dictDataApi.getDictData(dataRespDTO.getDictType(), dataRespDTO.getValue())).thenReturn(dataRespDTO); - // 断言返回值 - assertEquals(dataRespDTO.getLabel(), DictFrameworkUtils.getDictDataLabel(dataRespDTO.getDictType(), dataRespDTO.getValue())); - } - - @Test - public void testParseDictDataValue() { - // mock 数据 - DictDataRespDTO resp = randomPojo(DictDataRespDTO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - // mock 方法 - when(dictDataApi.parseDictData(resp.getDictType(), resp.getLabel())).thenReturn(resp); - // 断言返回值 - assertEquals(resp.getValue(), DictFrameworkUtils.parseDictDataValue(resp.getDictType(), resp.getLabel())); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-ip/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-ip/pom.xml index bc800c85d0..46026d4bc5 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-ip/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-ip/pom.xml @@ -43,12 +43,6 @@ provided - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - diff --git a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaUtilsTest.java b/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaUtilsTest.java deleted file mode 100644 index 8f5646b337..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaUtilsTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.framework.ip.core.utils; - - -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * {@link AreaUtils} 的单元测试 - * - * @author 芋道源码 - */ -public class AreaUtilsTest { - - @Test - public void testGetArea() { - // 调用:北京 - Area area = AreaUtils.getArea(110100); - // 断言 - assertEquals(area.getId(), 110100); - assertEquals(area.getName(), "北京市"); - assertEquals(area.getType(), AreaTypeEnum.CITY.getType()); - assertEquals(area.getParent().getId(), 110000); - assertEquals(area.getChildren().size(), 16); - } - - @Test - public void testFormat() { - assertEquals(AreaUtils.format(110105), "北京 北京市 朝阳区"); - assertEquals(AreaUtils.format(1), "中国"); - assertEquals(AreaUtils.format(2), "蒙古"); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/IPUtilsTest.java b/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/IPUtilsTest.java deleted file mode 100644 index 761a1aa63f..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/IPUtilsTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.framework.ip.core.utils; - -import cn.iocoder.yudao.framework.ip.core.Area; -import org.junit.jupiter.api.Test; -import org.lionsoul.ip2region.xdb.Searcher; - - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * {@link IPUtils} 的单元测试 - * - * @author wanglhup - */ -public class IPUtilsTest { - - @Test - public void testGetAreaId_string() { - // 120.202.4.0|120.202.4.255|420600 - Integer areaId = IPUtils.getAreaId("120.202.4.50"); - assertEquals(420600, areaId); - } - - @Test - public void testGetAreaId_long() throws Exception { - // 120.203.123.0|120.203.133.255|360900 - long ip = Searcher.checkIP("120.203.123.250"); - Integer areaId = IPUtils.getAreaId(ip); - assertEquals(360900, areaId); - } - - @Test - public void testGetArea_string() { - // 120.202.4.0|120.202.4.255|420600 - Area area = IPUtils.getArea("120.202.4.50"); - assertEquals("襄阳市", area.getName()); - } - - @Test - public void testGetArea_long() throws Exception { - // 120.203.123.0|120.203.133.255|360900 - long ip = Searcher.checkIP("120.203.123.252"); - Area area = IPUtils.getArea(ip); - assertEquals("宜春市", area.getName()); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml deleted file mode 100644 index a13b7dd3a4..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - yudao-framework - cn.iocoder.boot - ${revision} - - 4.0.0 - - yudao-spring-boot-starter-biz-pay - ${project.artifactId} - 支付拓展,接入国内多个支付渠道 - 1. 支付宝,基于官方 SDK 接入 - 2. 微信支付,基于 weixin-java-pay 接入 - - - - - cn.iocoder.boot - yudao-common - - - - - org.springframework.boot - spring-boot-starter - - - - - org.springframework.boot - spring-boot-starter-validation - - - - org.slf4j - slf4j-api - - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-core - - - - - com.alipay.sdk - alipay-sdk-java - 4.35.79.ALL - - - org.bouncycastle - bcprov-jdk15on - - - - - com.github.binarywang - weixin-java-pay - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - - - - diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java deleted file mode 100644 index e57f4ac702..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.framework.pay.config; - -import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.client.impl.PayClientFactoryImpl; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; - -/** - * 支付配置类 - * - * @author 芋道源码 - */ -@AutoConfiguration -public class YudaoPayAutoConfiguration { - - @Bean - public PayClientFactory payClientFactory() { - return new PayClientFactoryImpl(); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java deleted file mode 100644 index 86e3566b2b..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; - -import java.util.Map; - -/** - * 支付客户端,用于对接各支付渠道的 SDK,实现发起支付、退款等功能 - * - * @author 芋道源码 - */ -public interface PayClient { - - /** - * 获得渠道编号 - * - * @return 渠道编号 - */ - Long getId(); - - // ============ 支付相关 ========== - - /** - * 调用支付渠道,统一下单 - * - * @param reqDTO 下单信息 - * @return 支付订单信息 - */ - PayOrderRespDTO unifiedOrder(PayOrderUnifiedReqDTO reqDTO); - - /** - * 解析 order 回调数据 - * - * @param params HTTP 回调接口 content type 为 application/x-www-form-urlencoded 的所有参数 - * @param body HTTP 回调接口的 request body - * @return 支付订单信息 - */ - PayOrderRespDTO parseOrderNotify(Map params, String body); - - /** - * 获得支付订单信息 - * - * @param outTradeNo 外部订单号 - * @return 支付订单信息 - */ - PayOrderRespDTO getOrder(String outTradeNo); - - // ============ 退款相关 ========== - - /** - * 调用支付渠道,进行退款 - * - * @param reqDTO 统一退款请求信息 - * @return 退款信息 - */ - PayRefundRespDTO unifiedRefund(PayRefundUnifiedReqDTO reqDTO); - - /** - * 解析 refund 回调数据 - * - * @param params HTTP 回调接口 content type 为 application/x-www-form-urlencoded 的所有参数 - * @param body HTTP 回调接口的 request body - * @return 支付订单信息 - */ - PayRefundRespDTO parseRefundNotify(Map params, String body); - - /** - * 获得退款订单信息 - * - * @param outTradeNo 外部订单号 - * @param outRefundNo 外部退款号 - * @return 退款订单信息 - */ - PayRefundRespDTO getRefund(String outTradeNo, String outRefundNo); - - /** - * 调用渠道,进行转账 - * - * @param reqDTO 统一转账请求信息 - * @return 转账信息 - */ - PayTransferRespDTO unifiedTransfer(PayTransferUnifiedReqDTO reqDTO); - - /** - * 获得转账订单信息 - * - * @param outTradeNo 外部订单号 - * @param type 转账类型 - * @return 转账信息 - */ - PayTransferRespDTO getTransfer(String outTradeNo, PayTransferTypeEnum type); -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java deleted file mode 100644 index beb3b41655..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client; - -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -import jakarta.validation.Validator; - -/** - * 支付客户端的配置,本质是支付渠道的配置 - * 每个不同的渠道,需要不同的配置,通过子类来定义 - * - * @author 芋道源码 - */ -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS) -// @JsonTypeInfo 注解的作用,Jackson 多态 -// 1. 序列化到时数据库时,增加 @class 属性。 -// 2. 反序列化到内存对象时,通过 @class 属性,可以创建出正确的类型 -public interface PayClientConfig { - - /** - * 参数校验 - * - * @param validator 校验对象 - */ - void validate(Validator validator); - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java deleted file mode 100644 index 53f1a8c069..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client; - -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; - -/** - * 支付客户端的工厂接口 - * - * @author 芋道源码 - */ -public interface PayClientFactory { - - /** - * 获得支付客户端 - * - * @param channelId 渠道编号 - * @return 支付客户端 - */ - PayClient getPayClient(Long channelId); - - /** - * 创建支付客户端 - * - * @param channelId 渠道编号 - * @param channelCode 渠道编码 - * @param config 支付配置 - */ - void createOrUpdatePayClient(Long channelId, String channelCode, - Config config); - - /** - * 注册支付客户端 Class,用于模块中实现的 PayClient - * - * @param channel 支付渠道的编码的枚举 - * @param payClientClass 支付客户端 class - */ - void registerPayClientClass(PayChannelEnum channel, Class payClientClass); - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderRespDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderRespDTO.java deleted file mode 100644 index 82050a6fcb..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderRespDTO.java +++ /dev/null @@ -1,141 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.order; - -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 渠道支付订单 Response DTO - * - * @author 芋道源码 - */ -@Data -public class PayOrderRespDTO { - - /** - * 支付状态 - * - * 枚举:{@link PayOrderStatusRespEnum} - */ - private Integer status; - - /** - * 外部订单号 - * - * 对应 PayOrderExtensionDO 的 no 字段 - */ - private String outTradeNo; - - /** - * 支付渠道编号 - */ - private String channelOrderNo; - /** - * 支付渠道用户编号 - */ - private String channelUserId; - - /** - * 支付成功时间 - */ - private LocalDateTime successTime; - - /** - * 原始的同步/异步通知结果 - */ - private Object rawData; - - // ========== 主动发起支付时,会返回的字段 ========== - - /** - * 展示模式 - * - * 枚举 {@link PayOrderDisplayModeEnum} 类 - */ - private String displayMode; - /** - * 展示内容 - */ - private String displayContent; - - /** - * 调用渠道的错误码 - * - * 注意:这里返回的是业务异常,而是不系统异常。 - * 如果是系统异常,则会抛出 {@link PayException} - */ - private String channelErrorCode; - /** - * 调用渠道报错时,错误信息 - */ - private String channelErrorMsg; - - public PayOrderRespDTO() { - } - - /** - * 创建【WAITING】状态的订单返回 - */ - public static PayOrderRespDTO waitingOf(String displayMode, String displayContent, - String outTradeNo, Object rawData) { - PayOrderRespDTO respDTO = new PayOrderRespDTO(); - respDTO.status = PayOrderStatusRespEnum.WAITING.getStatus(); - respDTO.displayMode = displayMode; - respDTO.displayContent = displayContent; - // 相对通用的字段 - respDTO.outTradeNo = outTradeNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【SUCCESS】状态的订单返回 - */ - public static PayOrderRespDTO successOf(String channelOrderNo, String channelUserId, LocalDateTime successTime, - String outTradeNo, Object rawData) { - PayOrderRespDTO respDTO = new PayOrderRespDTO(); - respDTO.status = PayOrderStatusRespEnum.SUCCESS.getStatus(); - respDTO.channelOrderNo = channelOrderNo; - respDTO.channelUserId = channelUserId; - respDTO.successTime = successTime; - // 相对通用的字段 - respDTO.outTradeNo = outTradeNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建指定状态的订单返回,适合支付渠道回调时 - */ - public static PayOrderRespDTO of(Integer status, String channelOrderNo, String channelUserId, LocalDateTime successTime, - String outTradeNo, Object rawData) { - PayOrderRespDTO respDTO = new PayOrderRespDTO(); - respDTO.status = status; - respDTO.channelOrderNo = channelOrderNo; - respDTO.channelUserId = channelUserId; - respDTO.successTime = successTime; - // 相对通用的字段 - respDTO.outTradeNo = outTradeNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【CLOSED】状态的订单返回,适合调用支付渠道失败时 - */ - public static PayOrderRespDTO closedOf(String channelErrorCode, String channelErrorMsg, - String outTradeNo, Object rawData) { - PayOrderRespDTO respDTO = new PayOrderRespDTO(); - respDTO.status = PayOrderStatusRespEnum.CLOSED.getStatus(); - respDTO.channelErrorCode = channelErrorCode; - respDTO.channelErrorMsg = channelErrorMsg; - // 相对通用的字段 - respDTO.outTradeNo = outTradeNo; - respDTO.rawData = rawData; - return respDTO; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java deleted file mode 100644 index 15be7a7576..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.order; - -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import lombok.Data; -import org.hibernate.validator.constraints.Length; -import org.hibernate.validator.constraints.URL; - -import jakarta.validation.constraints.DecimalMin; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.Map; - -/** - * 统一下单 Request DTO - * - * @author 芋道源码 - */ -@Data -public class PayOrderUnifiedReqDTO { - - /** - * 用户 IP - */ - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - // ========== 商户相关字段 ========== - - /** - * 外部订单号 - * - * 对应 PayOrderExtensionDO 的 no 字段 - */ - @NotEmpty(message = "外部订单编号不能为空") - private String outTradeNo; - /** - * 商品标题 - */ - @NotEmpty(message = "商品标题不能为空") - @Length(max = 32, message = "商品标题不能超过 32") - private String subject; - /** - * 商品描述信息 - */ - @Length(max = 128, message = "商品描述信息长度不能超过128") - private String body; - /** - * 支付结果的 notify 回调地址 - */ - @NotEmpty(message = "支付结果的回调地址不能为空") - @URL(message = "支付结果的 notify 回调地址必须是 URL 格式") - private String notifyUrl; - /** - * 支付结果的 return 回调地址 - */ - @URL(message = "支付结果的 return 回调地址必须是 URL 格式") - private String returnUrl; - - // ========== 订单相关字段 ========== - - /** - * 支付金额,单位:分 - */ - @NotNull(message = "支付金额不能为空") - @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") - private Integer price; - - /** - * 支付过期时间 - */ - @NotNull(message = "支付过期时间不能为空") - private LocalDateTime expireTime; - - // ========== 拓展参数 ========== - /** - * 支付渠道的额外参数 - * - * 例如说,微信公众号需要传递 openid 参数 - */ - private Map channelExtras; - - /** - * 展示模式 - * - * 如果不传递,则每个支付渠道使用默认的方式 - * - * 枚举 {@link PayOrderDisplayModeEnum} - */ - private String displayMode; - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundRespDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundRespDTO.java deleted file mode 100644 index 3184f278de..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundRespDTO.java +++ /dev/null @@ -1,115 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.refund; - -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 渠道退款订单 Response DTO - * - * @author jason - */ -@Data -public class PayRefundRespDTO { - - /** - * 退款状态 - * - * 枚举 {@link PayRefundStatusRespEnum} - */ - private Integer status; - - /** - * 外部退款号 - * - * 对应 PayRefundDO 的 no 字段 - */ - private String outRefundNo; - - /** - * 渠道退款单号 - * - * 对应 PayRefundDO.channelRefundNo 字段 - */ - private String channelRefundNo; - - /** - * 退款成功时间 - */ - private LocalDateTime successTime; - - /** - * 原始的异步通知结果 - */ - private Object rawData; - - /** - * 调用渠道的错误码 - * - * 注意:这里返回的是业务异常,而是不系统异常。 - * 如果是系统异常,则会抛出 {@link PayException} - */ - private String channelErrorCode; - /** - * 调用渠道报错时,错误信息 - */ - private String channelErrorMsg; - - private PayRefundRespDTO() { - } - - /** - * 创建【WAITING】状态的退款返回 - */ - public static PayRefundRespDTO waitingOf(String channelRefundNo, - String outRefundNo, Object rawData) { - PayRefundRespDTO respDTO = new PayRefundRespDTO(); - respDTO.status = PayRefundStatusRespEnum.WAITING.getStatus(); - respDTO.channelRefundNo = channelRefundNo; - // 相对通用的字段 - respDTO.outRefundNo = outRefundNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【SUCCESS】状态的退款返回 - */ - public static PayRefundRespDTO successOf(String channelRefundNo, LocalDateTime successTime, - String outRefundNo, Object rawData) { - PayRefundRespDTO respDTO = new PayRefundRespDTO(); - respDTO.status = PayRefundStatusRespEnum.SUCCESS.getStatus(); - respDTO.channelRefundNo = channelRefundNo; - respDTO.successTime = successTime; - // 相对通用的字段 - respDTO.outRefundNo = outRefundNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【FAILURE】状态的退款返回 - */ - public static PayRefundRespDTO failureOf(String outRefundNo, Object rawData) { - return failureOf(null, null, - outRefundNo, rawData); - } - - /** - * 创建【FAILURE】状态的退款返回 - */ - public static PayRefundRespDTO failureOf(String channelErrorCode, String channelErrorMsg, - String outRefundNo, Object rawData) { - PayRefundRespDTO respDTO = new PayRefundRespDTO(); - respDTO.status = PayRefundStatusRespEnum.FAILURE.getStatus(); - respDTO.channelErrorCode = channelErrorCode; - respDTO.channelErrorMsg = channelErrorMsg; - // 相对通用的字段 - respDTO.outRefundNo = outRefundNo; - respDTO.rawData = rawData; - return respDTO; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java deleted file mode 100644 index 3101633b86..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.refund; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; -import org.hibernate.validator.constraints.URL; - -import jakarta.validation.constraints.DecimalMin; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * 统一 退款 Request DTO - * - * @author jason - */ -@Accessors(chain = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -@Data -public class PayRefundUnifiedReqDTO { - - /** - * 外部订单号 - * - * 对应 PayOrderExtensionDO 的 no 字段 - */ - @NotEmpty(message = "外部订单编号不能为空") - private String outTradeNo; - - /** - * 外部退款号 - * - * 对应 PayRefundDO 的 no 字段 - */ - @NotEmpty(message = "退款请求单号不能为空") - private String outRefundNo; - - /** - * 退款原因 - */ - @NotEmpty(message = "退款原因不能为空") - private String reason; - - /** - * 支付金额,单位:分 - * - * 目前微信支付在退款的时候,必须传递该字段 - */ - @NotNull(message = "支付金额不能为空") - @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") - private Integer payPrice; - /** - * 退款金额,单位:分 - */ - @NotNull(message = "退款金额不能为空") - @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") - private Integer refundPrice; - - /** - * 退款结果的 notify 回调地址 - */ - @NotEmpty(message = "支付结果的回调地址不能为空") - @URL(message = "支付结果的 notify 回调地址必须是 URL 格式") - private String notifyUrl; - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferRespDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferRespDTO.java deleted file mode 100644 index 0f9b48240c..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferRespDTO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.transfer; - -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 统一转账 Response DTO - * - * @author jason - */ -@Data -public class PayTransferRespDTO { - - /** - * 转账状态 - * - * 关联 {@link PayTransferStatusRespEnum#getStatus()} - */ - private Integer status; - - /** - * 外部转账单号 - * - */ - private String outTransferNo; - - /** - * 支付渠道编号 - */ - private String channelTransferNo; - - /** - * 支付成功时间 - */ - private LocalDateTime successTime; - - /** - * 原始的返回结果 - */ - private Object rawData; - - /** - * 调用渠道的错误码 - */ - private String channelErrorCode; - /** - * 调用渠道报错时,错误信息 - */ - private String channelErrorMsg; - - /** - * 创建【WAITING】状态的转账返回 - */ - public static PayTransferRespDTO waitingOf(String channelTransferNo, - String outTransferNo, Object rawData) { - PayTransferRespDTO respDTO = new PayTransferRespDTO(); - respDTO.status = PayTransferStatusRespEnum.WAITING.getStatus(); - respDTO.channelTransferNo = channelTransferNo; - respDTO.outTransferNo = outTransferNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【IN_PROGRESS】状态的转账返回 - */ - public static PayTransferRespDTO dealingOf(String channelTransferNo, - String outTransferNo, Object rawData) { - PayTransferRespDTO respDTO = new PayTransferRespDTO(); - respDTO.status = PayTransferStatusRespEnum.IN_PROGRESS.getStatus(); - respDTO.channelTransferNo = channelTransferNo; - respDTO.outTransferNo = outTransferNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【CLOSED】状态的转账返回 - */ - public static PayTransferRespDTO closedOf(String channelErrorCode, String channelErrorMsg, - String outTransferNo, Object rawData) { - PayTransferRespDTO respDTO = new PayTransferRespDTO(); - respDTO.status = PayTransferStatusRespEnum.CLOSED.getStatus(); - respDTO.channelErrorCode = channelErrorCode; - respDTO.channelErrorMsg = channelErrorMsg; - // 相对通用的字段 - respDTO.outTransferNo = outTransferNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【SUCCESS】状态的转账返回 - */ - public static PayTransferRespDTO successOf(String channelTransferNo, LocalDateTime successTime, - String outTransferNo, Object rawData) { - PayTransferRespDTO respDTO = new PayTransferRespDTO(); - respDTO.status = PayTransferStatusRespEnum.SUCCESS.getStatus(); - respDTO.channelTransferNo = channelTransferNo; - respDTO.successTime = successTime; - // 相对通用的字段 - respDTO.outTransferNo = outTransferNo; - respDTO.rawData = rawData; - return respDTO; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java deleted file mode 100644 index 43afa86a30..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.transfer; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import lombok.Data; -import org.hibernate.validator.constraints.Length; - -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.Map; - -import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum.*; - -/** - * 统一转账 Request DTO - * - * @author jason - */ -@Data -public class PayTransferUnifiedReqDTO { - - /** - * 转账类型 - * - * 关联 {@link PayTransferTypeEnum#getType()} - */ - @NotNull(message = "转账类型不能为空") - @InEnum(PayTransferTypeEnum.class) - private Integer type; - - /** - * 用户 IP - */ - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - @NotEmpty(message = "外部转账单编号不能为空") - private String outTransferNo; - - /** - * 转账金额,单位:分 - */ - @NotNull(message = "转账金额不能为空") - @Min(value = 1, message = "转账金额必须大于零") - private Integer price; - - /** - * 转账标题 - */ - @NotEmpty(message = "转账标题不能为空") - @Length(max = 128, message = "转账标题不能超过 128") - private String subject; - - /** - * 收款人姓名 - */ - @NotBlank(message = "收款人姓名不能为空", groups = {Alipay.class}) - private String userName; - - /** - * 支付宝登录号 - */ - @NotBlank(message = "支付宝登录号不能为空", groups = {Alipay.class}) - private String alipayLogonId; - - /** - * 微信 openId - */ - @NotBlank(message = "微信 openId 不能为空", groups = {WxPay.class}) - private String openid; - - /** - * 支付渠道的额外参数 - */ - private Map channelExtras; -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/exception/PayException.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/exception/PayException.java deleted file mode 100644 index 75f4c39750..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/exception/PayException.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.exception; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 支付系统异常 Exception - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class PayException extends RuntimeException { - - public PayException(Throwable cause) { - super(cause); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java deleted file mode 100644 index 82d68b58f6..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java +++ /dev/null @@ -1,250 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import lombok.extern.slf4j.Slf4j; - -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.NOT_IMPLEMENTED; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; - -/** - * 支付客户端的抽象类,提供模板方法,减少子类的冗余代码 - * - * @author 芋道源码 - */ -@Slf4j -public abstract class AbstractPayClient implements PayClient { - - /** - * 渠道编号 - */ - private final Long channelId; - /** - * 渠道编码 - */ - @SuppressWarnings("FieldCanBeLocal") - private final String channelCode; - /** - * 支付配置 - */ - protected Config config; - - public AbstractPayClient(Long channelId, String channelCode, Config config) { - this.channelId = channelId; - this.channelCode = channelCode; - this.config = config; - } - - /** - * 初始化 - */ - public final void init() { - doInit(); - log.debug("[init][客户端({}) 初始化完成]", getId()); - } - - /** - * 自定义初始化 - */ - protected abstract void doInit(); - - public final void refresh(Config config) { - // 判断是否更新 - if (config.equals(this.config)) { - return; - } - log.info("[refresh][客户端({})发生变化,重新初始化]", getId()); - this.config = config; - // 初始化 - this.init(); - } - - @Override - public Long getId() { - return channelId; - } - - // ============ 支付相关 ========== - - @Override - public final PayOrderRespDTO unifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - ValidationUtils.validate(reqDTO); - // 执行统一下单 - PayOrderRespDTO resp; - try { - resp = doUnifiedOrder(reqDTO); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - // 系统异常,则包装成 PayException 异常抛出 - log.error("[unifiedOrder][客户端({}) request({}) 发起支付异常]", - getId(), toJsonString(reqDTO), ex); - throw buildPayException(ex); - } - return resp; - } - - protected abstract PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) - throws Throwable; - - @Override - public final PayOrderRespDTO parseOrderNotify(Map params, String body) { - try { - return doParseOrderNotify(params, body); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[parseOrderNotify][客户端({}) params({}) body({}) 解析失败]", - getId(), params, body, ex); - throw buildPayException(ex); - } - } - - protected abstract PayOrderRespDTO doParseOrderNotify(Map params, String body) - throws Throwable; - - @Override - public final PayOrderRespDTO getOrder(String outTradeNo) { - try { - return doGetOrder(outTradeNo); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[getOrder][客户端({}) outTradeNo({}) 查询支付单异常]", - getId(), outTradeNo, ex); - throw buildPayException(ex); - } - } - - protected abstract PayOrderRespDTO doGetOrder(String outTradeNo) - throws Throwable; - - // ============ 退款相关 ========== - - @Override - public final PayRefundRespDTO unifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - ValidationUtils.validate(reqDTO); - // 执行统一退款 - PayRefundRespDTO resp; - try { - resp = doUnifiedRefund(reqDTO); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - // 系统异常,则包装成 PayException 异常抛出 - log.error("[unifiedRefund][客户端({}) request({}) 发起退款异常]", - getId(), toJsonString(reqDTO), ex); - throw buildPayException(ex); - } - return resp; - } - - protected abstract PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable; - - @Override - public final PayRefundRespDTO parseRefundNotify(Map params, String body) { - try { - return doParseRefundNotify(params, body); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[parseRefundNotify][客户端({}) params({}) body({}) 解析失败]", - getId(), params, body, ex); - throw buildPayException(ex); - } - } - - protected abstract PayRefundRespDTO doParseRefundNotify(Map params, String body) - throws Throwable; - - @Override - public final PayRefundRespDTO getRefund(String outTradeNo, String outRefundNo) { - try { - return doGetRefund(outTradeNo, outRefundNo); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[getRefund][客户端({}) outTradeNo({}) outRefundNo({}) 查询退款单异常]", - getId(), outTradeNo, outRefundNo, ex); - throw buildPayException(ex); - } - } - - protected abstract PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) - throws Throwable; - - @Override - public final PayTransferRespDTO unifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { - validatePayTransferReqDTO(reqDTO); - PayTransferRespDTO resp; - try { - resp = doUnifiedTransfer(reqDTO); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - // 系统异常,则包装成 PayException 异常抛出 - log.error("[unifiedTransfer][客户端({}) request({}) 发起转账异常]", - getId(), toJsonString(reqDTO), ex); - throw buildPayException(ex); - } - return resp; - } - private void validatePayTransferReqDTO(PayTransferUnifiedReqDTO reqDTO) { - PayTransferTypeEnum transferType = PayTransferTypeEnum.typeOf(reqDTO.getType()); - switch (transferType) { - case ALIPAY_BALANCE: { - ValidationUtils.validate(reqDTO, PayTransferTypeEnum.Alipay.class); - break; - } - case WX_BALANCE: { - ValidationUtils.validate(reqDTO, PayTransferTypeEnum.WxPay.class); - break; - } - default: { - throw exception(NOT_IMPLEMENTED); - } - } - } - - @Override - public final PayTransferRespDTO getTransfer(String outTradeNo, PayTransferTypeEnum type) { - try { - return doGetTransfer(outTradeNo, type); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[getTransfer][客户端({}) outTradeNo({}) type({}) 查询转账单异常]", - getId(), outTradeNo, type, ex); - throw buildPayException(ex); - } - } - - protected abstract PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) - throws Throwable; - - protected abstract PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) - throws Throwable; - - // ========== 各种工具方法 ========== - - private PayException buildPayException(Throwable ex) { - if (ex instanceof PayException) { - return (PayException) ex; - } - throw new PayException(ex); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java deleted file mode 100644 index 80581f3049..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl; - -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import lombok.Data; - -import jakarta.validation.Validator; - -/** - * 无需任何配置 PayClientConfig 实现类 - * - * @author jason - */ -@Data -public class NonePayClientConfig implements PayClientConfig { - - /** - * 配置名称 - *

- * 如果不加任何属性,JsonUtils.parseObject2 解析会报错,所以暂时加个名称 - */ - private String name; - - public NonePayClientConfig(){ - this.name = "none-config"; - } - - @Override - public void validate(Validator validator) { - // 无任何配置不需要校验 - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java deleted file mode 100644 index 0b39587abb..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.*; -import cn.iocoder.yudao.framework.pay.core.client.impl.mock.MockPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.*; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import lombok.extern.slf4j.Slf4j; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import static cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum.*; - -/** - * 支付客户端的工厂实现类 - * - * @author 芋道源码 - */ -@Slf4j -public class PayClientFactoryImpl implements PayClientFactory { - - /** - * 支付客户端 Map - * - * key:渠道编号 - */ - private final ConcurrentMap> clients = new ConcurrentHashMap<>(); - - /** - * 支付客户端 Class Map - */ - private final Map> clientClass = new ConcurrentHashMap<>(); - - public PayClientFactoryImpl() { - // 微信支付客户端 - clientClass.put(WX_PUB, WxPubPayClient.class); - clientClass.put(WX_LITE, WxLitePayClient.class); - clientClass.put(WX_APP, WxAppPayClient.class); - clientClass.put(WX_BAR, WxBarPayClient.class); - clientClass.put(WX_NATIVE, WxNativePayClient.class); - // 支付包支付客户端 - clientClass.put(ALIPAY_WAP, AlipayWapPayClient.class); - clientClass.put(ALIPAY_QR, AlipayQrPayClient.class); - clientClass.put(ALIPAY_APP, AlipayAppPayClient.class); - clientClass.put(ALIPAY_PC, AlipayPcPayClient.class); - clientClass.put(ALIPAY_BAR, AlipayBarPayClient.class); - // Mock 支付客户端 - clientClass.put(MOCK, MockPayClient.class); - } - - @Override - public void registerPayClientClass(PayChannelEnum channel, Class payClientClass) { - clientClass.put(channel, payClientClass); - } - - @Override - public PayClient getPayClient(Long channelId) { - AbstractPayClient client = clients.get(channelId); - if (client == null) { - log.error("[getPayClient][渠道编号({}) 找不到客户端]", channelId); - } - return client; - } - - @Override - @SuppressWarnings("unchecked") - public void createOrUpdatePayClient(Long channelId, String channelCode, - Config config) { - AbstractPayClient client = (AbstractPayClient) clients.get(channelId); - if (client == null) { - client = this.createPayClient(channelId, channelCode, config); - client.init(); - clients.put(client.getId(), client); - } else { - client.refresh(config); - } - } - - @SuppressWarnings("unchecked") - private AbstractPayClient createPayClient(Long channelId, String channelCode, - Config config) { - PayChannelEnum channelEnum = PayChannelEnum.getByCode(channelCode); - Assert.notNull(channelEnum, String.format("支付渠道(%s) 为空", channelCode)); - Class payClientClass = clientClass.get(channelEnum); - Assert.notNull(payClientClass, String.format("支付渠道(%s) Class 为空", channelCode)); - return (AbstractPayClient) ReflectUtil.newInstance(payClientClass, channelId, config); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java deleted file mode 100644 index 4dcf236755..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java +++ /dev/null @@ -1,342 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.AlipayConfig; -import com.alipay.api.AlipayResponse; -import com.alipay.api.DefaultAlipayClient; -import com.alipay.api.domain.*; -import com.alipay.api.internal.util.AlipaySignature; -import com.alipay.api.request.*; -import com.alipay.api.response.*; -import lombok.Getter; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; - -import java.nio.charset.StandardCharsets; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.Map; -import java.util.Objects; -import java.util.function.Supplier; - -import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER; -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE; - -/** - * 支付宝抽象类,实现支付宝统一的接口、以及部分实现(退款) - * - * @author jason - */ -@Slf4j -public abstract class AbstractAlipayPayClient extends AbstractPayClient { - - @Getter // 仅用于单测场景 - protected DefaultAlipayClient client; - - public AbstractAlipayPayClient(Long channelId, String channelCode, AlipayPayClientConfig config) { - super(channelId, channelCode, config); - } - - @Override - @SneakyThrows - protected void doInit() { - AlipayConfig alipayConfig = new AlipayConfig(); - BeanUtil.copyProperties(config, alipayConfig, false); - this.client = new DefaultAlipayClient(alipayConfig); - } - - // ============ 支付相关 ========== - - /** - * 构造支付关闭的 {@link PayOrderRespDTO} 对象 - * - * @return 支付关闭的 {@link PayOrderRespDTO} 对象 - */ - protected PayOrderRespDTO buildClosedPayOrderRespDTO(PayOrderUnifiedReqDTO reqDTO, AlipayResponse response) { - Assert.isFalse(response.isSuccess()); - return PayOrderRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), - reqDTO.getOutTradeNo(), response); - } - - @Override - public PayOrderRespDTO doParseOrderNotify(Map params, String body) throws Throwable { - // 1. 校验回调数据 - Map bodyObj = HttpUtil.decodeParamMap(body, StandardCharsets.UTF_8); - AlipaySignature.rsaCheckV1(bodyObj, config.getAlipayPublicKey(), - StandardCharsets.UTF_8.name(), config.getSignType()); - - // 2. 解析订单的状态 - // 额外说明:支付宝不仅仅支付成功会回调,再各种触发支付单数据变化时,都会进行回调,所以这里 status 的解析会写的比较复杂 - Integer status = parseStatus(bodyObj.get("trade_status")); - // 特殊逻辑: 支付宝没有退款成功的状态,所以,如果有退款金额,我们认为是退款成功 - if (MapUtil.getDouble(bodyObj, "refund_fee", 0D) > 0) { - status = PayOrderStatusRespEnum.REFUND.getStatus(); - } - Assert.notNull(status, (Supplier) () -> { - throw new IllegalArgumentException(StrUtil.format("body({}) 的 trade_status 不正确", body)); - }); - return PayOrderRespDTO.of(status, bodyObj.get("trade_no"), bodyObj.get("seller_id"), parseTime(params.get("gmt_payment")), - bodyObj.get("out_trade_no"), body); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) throws Throwable { - // 1.1 构建 AlipayTradeRefundModel 请求 - AlipayTradeQueryModel model = new AlipayTradeQueryModel(); - model.setOutTradeNo(outTradeNo); - // 1.2 构建 AlipayTradeQueryRequest 请求 - AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); - request.setBizModel(model); - AlipayTradeQueryResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { - // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - if (!response.isSuccess()) { // 不成功,例如说订单不存在 - return PayOrderRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), - outTradeNo, response); - } - // 2.2 解析订单的状态 - Integer status = parseStatus(response.getTradeStatus()); - Assert.notNull(status, () -> { - throw new IllegalArgumentException(StrUtil.format("body({}) 的 trade_status 不正确", response.getBody())); - }); - return PayOrderRespDTO.of(status, response.getTradeNo(), response.getBuyerUserId(), LocalDateTimeUtil.of(response.getSendPayDate()), - outTradeNo, response); - } - - private static Integer parseStatus(String tradeStatus) { - return Objects.equals("WAIT_BUYER_PAY", tradeStatus) ? PayOrderStatusRespEnum.WAITING.getStatus() - : ObjectUtils.equalsAny(tradeStatus, "TRADE_FINISHED", "TRADE_SUCCESS") ? PayOrderStatusRespEnum.SUCCESS.getStatus() - : Objects.equals("TRADE_CLOSED", tradeStatus) ? PayOrderStatusRespEnum.CLOSED.getStatus() : null; - } - - // ============ 退款相关 ========== - - /** - * 支付宝统一的退款接口 alipay.trade.refund - * - * @param reqDTO 退款请求 request DTO - * @return 退款请求 Response - */ - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradeRefundModel 请求 - AlipayTradeRefundModel model = new AlipayTradeRefundModel(); - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setOutRequestNo(reqDTO.getOutRefundNo()); - model.setRefundAmount(formatAmount(reqDTO.getRefundPrice())); - model.setRefundReason(reqDTO.getReason()); - // 1.2 构建 AlipayTradePayRequest 请求 - AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); - request.setBizModel(model); - - // 2.1 执行请求 - AlipayTradeRefundResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - if (!response.isSuccess()) { - // 当出现 ACQ.SYSTEM_ERROR, 退款可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询 - if (ObjectUtils.equalsAny(response.getSubCode(), "ACQ.SYSTEM_ERROR", "SYSTEM_ERROR")) { - return PayRefundRespDTO.waitingOf(null, reqDTO.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(response.getSubCode(), response.getSubMsg(), reqDTO.getOutRefundNo(), response); - } - // 2.2 创建返回结果 - // 支付宝只要退款调用返回 success,就认为退款成功,不需要回调。具体可见 parseNotify 方法的说明。 - // 另外,支付宝没有退款单号,所以不用设置 - return PayRefundRespDTO.successOf(null, LocalDateTimeUtil.of(response.getGmtRefundPay()), - reqDTO.getOutRefundNo(), response); - } - - @Override - public PayRefundRespDTO doParseRefundNotify(Map params, String body) { - // 补充说明:支付宝退款时,没有回调,这点和微信支付是不同的。并且,退款分成部分退款、和全部退款。 - // ① 部分退款:是会有回调,但是它回调的是订单状态的同步回调,不是退款订单的回调 - // ② 全部退款:Wap 支付有订单状态的同步回调,但是 PC/扫码又没有 - // 所以,这里在解析时,即使是退款导致的订单状态同步,我们也忽略不做为“退款同步”,而是订单的回调。 - // 实际上,支付宝退款只要发起成功,就可以认为退款成功,不需要等待回调。 - throw new UnsupportedOperationException("支付宝无退款回调"); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws AlipayApiException { - // 1.1 构建 AlipayTradeFastpayRefundQueryModel 请求 - AlipayTradeFastpayRefundQueryModel model = new AlipayTradeFastpayRefundQueryModel(); - model.setOutTradeNo(outTradeNo); - model.setOutRequestNo(outRefundNo); - model.setQueryOptions(Collections.singletonList("gmt_refund_pay")); - // 1.2 构建 AlipayTradeFastpayRefundQueryRequest 请求 - AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest(); - request.setBizModel(model); - - // 2.1 执行请求 - AlipayTradeFastpayRefundQueryResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - if (!response.isSuccess()) { - // 明确不存在的情况,应该就是失败,可进行关闭 - if (ObjectUtils.equalsAny(response.getSubCode(), "TRADE_NOT_EXIST", "ACQ.TRADE_NOT_EXIST")) { - return PayRefundRespDTO.failureOf(outRefundNo, response); - } - // 可能存在“ACQ.SYSTEM_ERROR”系统错误等情况,所以返回 WAIT 继续等待 - return PayRefundRespDTO.waitingOf(null, outRefundNo, response); - } - // 2.2 创建返回结果 - if (Objects.equals(response.getRefundStatus(), "REFUND_SUCCESS")) { - return PayRefundRespDTO.successOf(null, LocalDateTimeUtil.of(response.getGmtRefundPay()), - outRefundNo, response); - } - return PayRefundRespDTO.waitingOf(null, outRefundNo, response); - } - - @Override - protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 校验公钥类型 必须使用公钥证书模式 - if (!Objects.equals(config.getMode(), MODE_CERTIFICATE)) { - throw exception0(ERROR_CONFIGURATION.getCode(), "支付宝单笔转账必须使用公钥证书模式"); - } - // 1.2 构建 AlipayFundTransUniTransferModel - AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel(); - // ① 通用的参数 - model.setTransAmount(formatAmount(reqDTO.getPrice())); // 转账金额 - model.setOrderTitle(reqDTO.getSubject()); // 转账业务的标题,用于在支付宝用户的账单里显示。 - model.setOutBizNo(reqDTO.getOutTransferNo()); - model.setProductCode("TRANS_ACCOUNT_NO_PWD"); // 销售产品码。单笔无密转账固定为 TRANS_ACCOUNT_NO_PWD - model.setBizScene("DIRECT_TRANSFER"); // 业务场景 单笔无密转账固定为 DIRECT_TRANSFER - if (reqDTO.getChannelExtras() != null) { - model.setBusinessParams(JsonUtils.toJsonString(reqDTO.getChannelExtras())); - } - // ② 个性化的参数 - Participant payeeInfo = new Participant(); - PayTransferTypeEnum transferType = PayTransferTypeEnum.typeOf(reqDTO.getType()); - switch (transferType) { - // TODO @jason:是不是不用传递 transferType 参数哈?因为应该已经明确是支付宝啦? - // @芋艿。 是不是还要考虑转账到银行卡。所以传 transferType 但是转账到银行卡不知道要如何测试?? - case ALIPAY_BALANCE: { - payeeInfo.setIdentityType("ALIPAY_LOGON_ID"); - payeeInfo.setIdentity(reqDTO.getAlipayLogonId()); // 支付宝登录号 - payeeInfo.setName(reqDTO.getUserName()); // 支付宝账号姓名 - model.setPayeeInfo(payeeInfo); - break; - } - case BANK_CARD: { - payeeInfo.setIdentityType("BANKCARD_ACCOUNT"); - // TODO 待实现 - throw exception(NOT_IMPLEMENTED); - } - default: { - throw exception0(BAD_REQUEST.getCode(), "不正确的转账类型: {}", transferType); - } - } - // 1.3 构建 AlipayFundTransUniTransferRequest - AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest(); - request.setBizModel(model); - // 执行请求 - AlipayFundTransUniTransferResponse response = client.certificateExecute(request); - // 处理结果 - if (!response.isSuccess()) { - // 当出现 SYSTEM_ERROR, 转账可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询,或相同 outBizNo 重新发起转账 - // 发现 outBizNo 相同 两次请求参数相同. 会返回 "PAYMENT_INFO_INCONSISTENCY", 不知道哪里的问题. 暂时返回 WAIT. 后续job 会轮询 - if (ObjectUtils.equalsAny(response.getSubCode(),"PAYMENT_INFO_INCONSISTENCY", "SYSTEM_ERROR", "ACQ.SYSTEM_ERROR")) { - return PayTransferRespDTO.waitingOf(null, reqDTO.getOutTransferNo(), response); - } - return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), - reqDTO.getOutTransferNo(), response); - } else { - if (ObjectUtils.equalsAny(response.getStatus(), "REFUND", "FAIL")) { // 转账到银行卡会出现 "REFUND" "FAIL" - return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), - reqDTO.getOutTransferNo(), response); - } - if (Objects.equals(response.getStatus(), "DEALING")) { // 转账到银行卡会出现 "DEALING" 处理中 - return PayTransferRespDTO.dealingOf(response.getOrderId(), reqDTO.getOutTransferNo(), response); - } - return PayTransferRespDTO.successOf(response.getOrderId(), parseTime(response.getTransDate()), - response.getOutBizNo(), response); - } - - } - - @Override - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) throws Throwable { - // 1.1 构建 AlipayFundTransCommonQueryModel - AlipayFundTransCommonQueryModel model = new AlipayFundTransCommonQueryModel(); - model.setProductCode(type == PayTransferTypeEnum.BANK_CARD ? "TRANS_BANKCARD_NO_PWD" : "TRANS_ACCOUNT_NO_PWD"); - model.setBizScene("DIRECT_TRANSFER"); //业务场景 - model.setOutBizNo(outTradeNo); - // 1.2 构建 AlipayFundTransCommonQueryRequest - AlipayFundTransCommonQueryRequest request = new AlipayFundTransCommonQueryRequest(); - request.setBizModel(model); - - // 2.1 执行请求 - AlipayFundTransCommonQueryResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - // 2.2 处理返回结果 - if (response.isSuccess()) { - if (ObjectUtils.equalsAny(response.getStatus(), "REFUND", "FAIL")) { // 转账到银行卡会出现 "REFUND" "FAIL" - return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), - outTradeNo, response); - } - if (Objects.equals(response.getStatus(), "DEALING")) { // 转账到银行卡会出现 "DEALING" 处理中 - return PayTransferRespDTO.dealingOf(response.getOrderId(), outTradeNo, response); - } - return PayTransferRespDTO.successOf(response.getOrderId(), parseTime(response.getPayDate()), - response.getOutBizNo(), response); - } else { - // 当出现 SYSTEM_ERROR, 转账可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询, 或相同 outBizNo 重新发起转账 - // 当出现 ORDER_NOT_EXIST 可能是转账还在处理中,也可能是转账处理失败. 返回 WAIT 状态. 后续 job 会轮询, 或相同 outBizNo 重新发起转账 - if (ObjectUtils.equalsAny(response.getSubCode(), "ORDER_NOT_EXIST", "SYSTEM_ERROR", "ACQ.SYSTEM_ERROR")) { - return PayTransferRespDTO.waitingOf(null, outTradeNo, response); - } - return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), - outTradeNo, response); - } - } - - // ========== 各种工具方法 ========== - - protected String formatAmount(Integer amount) { - return String.valueOf(amount / 100.0); - } - - protected String formatTime(LocalDateTime time) { - return LocalDateTimeUtil.format(time, NORM_DATETIME_FORMATTER); - } - - protected LocalDateTime parseTime(String str) { - return LocalDateTimeUtil.parse(str, NORM_DATETIME_FORMATTER); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java deleted file mode 100644 index 4e5a37e9de..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradeAppPayModel; -import com.alipay.api.request.AlipayTradeAppPayRequest; -import com.alipay.api.response.AlipayTradeAppPayResponse; -import lombok.extern.slf4j.Slf4j; - -/** - * 支付宝【App 支付】的 PayClient 实现类 - * - * 文档:App 支付 - * - * // TODO 芋艿:未详细测试,因为手头没 App - * - * @author 芋道源码 - */ -@Slf4j -public class AlipayAppPayClient extends AbstractAlipayPayClient { - - public AlipayAppPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_APP.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradeAppPayModel 请求 - AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody() + "test"); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setTimeExpire(formatTime(reqDTO.getExpireTime())); - model.setProductCode("QUICK_MSECURITY_PAY"); // 销售产品码:无线快捷支付产品 - // ② 个性化的参数【无】 - // ③ 支付宝扫码支付只有一种展示 - String displayMode = PayOrderDisplayModeEnum.APP.getMode(); - - // 1.2 构建 AlipayTradePrecreateRequest 请求 - AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradeAppPayResponse response = client.sdkExecute(request); - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - return PayOrderRespDTO.waitingOf(displayMode, response.getBody(), - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java deleted file mode 100644 index 1f90d6b58e..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradePayModel; -import com.alipay.api.request.AlipayTradePayRequest; -import com.alipay.api.response.AlipayTradePayResponse; -import lombok.extern.slf4j.Slf4j; - -import java.time.LocalDateTime; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE; - -/** - * 支付宝【条码支付】的 PayClient 实现类 - * - * 文档:当面付 - * - * @author 芋道源码 - */ -@Slf4j -public class AlipayBarPayClient extends AbstractAlipayPayClient { - - public AlipayBarPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_BAR.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - String authCode = MapUtil.getStr(reqDTO.getChannelExtras(), "auth_code"); - if (StrUtil.isEmpty(authCode)) { - throw exception0(BAD_REQUEST.getCode(), "条形码不能为空"); - } - - // 1.1 构建 AlipayTradePayModel 请求 - AlipayTradePayModel model = new AlipayTradePayModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody()); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setScene("bar_code"); // 当面付条码支付场景 - // ② 个性化的参数 - model.setAuthCode(authCode); - // ③ 支付宝条码支付只有一种展示 - String displayMode = PayOrderDisplayModeEnum.BAR_CODE.getMode(); - - // 1.2 构建 AlipayTradePayRequest 请求 - AlipayTradePayRequest request = new AlipayTradePayRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradePayResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { - // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - if ("10000".equals(response.getCode())) { // 免密支付 - LocalDateTime successTime = LocalDateTimeUtil.of(response.getGmtPayment()); - return PayOrderRespDTO.successOf(response.getTradeNo(), response.getBuyerUserId(), successTime, - response.getOutTradeNo(), response) - .setDisplayMode(displayMode).setDisplayContent(""); - } - // 大额支付,需要用户输入密码,所以返回 waiting。此时,前端一般会进行轮询 - return PayOrderRespDTO.waitingOf(displayMode, "", - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClientConfig.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClientConfig.java deleted file mode 100644 index 13f2885d40..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClientConfig.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import lombok.Data; - -import jakarta.validation.Validator; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; - -/** - * 支付宝的 PayClientConfig 实现类 - * 属性主要来自 {@link com.alipay.api.AlipayConfig} 的必要属性 - * - * @author 芋道源码 - */ -@Data -public class AlipayPayClientConfig implements PayClientConfig { - - /** - * 公钥类型 - 公钥模式 - */ - public static final Integer MODE_PUBLIC_KEY = 1; - /** - * 公钥类型 - 证书模式 - */ - public static final Integer MODE_CERTIFICATE = 2; - - /** - * 签名算法类型 - RSA - */ - public static final String SIGN_TYPE_DEFAULT = "RSA2"; - - /** - * 网关地址 - * - * 1. 生产环境 - * 2. 沙箱环境 - */ - @NotBlank(message = "网关地址不能为空", groups = {ModePublicKey.class, ModeCertificate.class}) - private String serverUrl; - - /** - * 开放平台上创建的应用的 ID - */ - @NotBlank(message = "开放平台上创建的应用的 ID不能为空", groups = {ModePublicKey.class, ModeCertificate.class}) - private String appId; - - /** - * 签名算法类型,推荐:RSA2 - *

- * {@link #SIGN_TYPE_DEFAULT} - */ - @NotBlank(message = "签名算法类型不能为空", groups = {ModePublicKey.class, ModeCertificate.class}) - private String signType; - - /** - * 公钥类型 - * 1. {@link #MODE_PUBLIC_KEY} 情况,privateKey + alipayPublicKey - * 2. {@link #MODE_CERTIFICATE} 情况,appCertContent + alipayPublicCertContent + rootCertContent - */ - @NotNull(message = "公钥类型不能为空", groups = {ModePublicKey.class, ModeCertificate.class}) - private Integer mode; - - // ========== 公钥模式 ========== - /** - * 商户私钥 - */ - @NotBlank(message = "商户私钥不能为空", groups = {ModePublicKey.class}) - private String privateKey; - - /** - * 支付宝公钥字符串 - */ - @NotBlank(message = "支付宝公钥字符串不能为空", groups = {ModePublicKey.class}) - private String alipayPublicKey; - - // ========== 证书模式 ========== - /** - * 指定商户公钥应用证书内容字符串 - */ - @NotBlank(message = "指定商户公钥应用证书内容不能为空", groups = {ModeCertificate.class}) - private String appCertContent; - /** - * 指定支付宝公钥证书内容字符串 - */ - @NotBlank(message = "指定支付宝公钥证书内容不能为空", groups = {ModeCertificate.class}) - private String alipayPublicCertContent; - /** - * 指定根证书内容字符串 - */ - @NotBlank(message = "指定根证书内容字符串不能为空", groups = {ModeCertificate.class}) - private String rootCertContent; - - public interface ModePublicKey { - } - - public interface ModeCertificate { - } - - @Override - public void validate(Validator validator) { - ValidationUtils.validate(validator, this, - MODE_PUBLIC_KEY.equals(this.getMode()) ? ModePublicKey.class : ModeCertificate.class); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java deleted file mode 100644 index 6dbd19bef3..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.http.Method; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradePagePayModel; -import com.alipay.api.request.AlipayTradePagePayRequest; -import com.alipay.api.response.AlipayTradePagePayResponse; -import lombok.extern.slf4j.Slf4j; - -import java.util.Objects; - -/** - * 支付宝【PC 网站】的 PayClient 实现类 - * - * 文档:电脑网站支付 - * - * @author XGD - */ -@Slf4j -public class AlipayPcPayClient extends AbstractAlipayPayClient { - - public AlipayPcPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_PC.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradePagePayModel 请求 - AlipayTradePagePayModel model = new AlipayTradePagePayModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody()); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setTimeExpire(formatTime(reqDTO.getExpireTime())); - model.setProductCode("FAST_INSTANT_TRADE_PAY"); // 销售产品码. 目前 PC 支付场景下仅支持 FAST_INSTANT_TRADE_PAY - // ② 个性化的参数 - // 如果想弄更多个性化的参数,可参考 https://www.pingxx.com/api/支付渠道 extra 参数说明.html 的 alipay_pc_direct 部分进行拓展 - model.setQrPayMode("2"); // 跳转模式 - 订单码,效果参见:https://help.pingxx.com/article/1137360/ - // ③ 支付宝 PC 支付有两种展示模式:FORM、URL - String displayMode = ObjectUtil.defaultIfNull(reqDTO.getDisplayMode(), - PayOrderDisplayModeEnum.URL.getMode()); - - // 1.2 构建 AlipayTradePagePayRequest 请求 - AlipayTradePagePayRequest request = new AlipayTradePagePayRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradePagePayResponse response; - if (Objects.equals(displayMode, PayOrderDisplayModeEnum.FORM.getMode())) { - response = client.pageExecute(request, Method.POST.name()); // 需要特殊使用 POST 请求 - } else { - response = client.pageExecute(request, Method.GET.name()); - } - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - return PayOrderRespDTO.waitingOf(displayMode, response.getBody(), - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java deleted file mode 100644 index bb3ad17713..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradePrecreateModel; -import com.alipay.api.request.AlipayTradePrecreateRequest; -import com.alipay.api.response.AlipayTradePrecreateResponse; -import lombok.extern.slf4j.Slf4j; - -import java.util.Objects; - -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE; - -/** - * 支付宝【扫码支付】的 PayClient 实现类 - * - * 文档:扫码支付 - * - * @author 芋道源码 - */ -@Slf4j -public class AlipayQrPayClient extends AbstractAlipayPayClient { - - public AlipayQrPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_QR.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradePrecreateModel 请求 - AlipayTradePrecreateModel model = new AlipayTradePrecreateModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody()); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setProductCode("FACE_TO_FACE_PAYMENT"); // 销售产品码. 目前扫码支付场景下仅支持 FACE_TO_FACE_PAYMENT - // ② 个性化的参数【无】 - // ③ 支付宝扫码支付只有一种展示,考虑到前端可能希望二维码扫描后,手机打开 - String displayMode = PayOrderDisplayModeEnum.QR_CODE.getMode(); - - // 1.2 构建 AlipayTradePrecreateRequest 请求 - AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradePrecreateResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { - // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - return PayOrderRespDTO.waitingOf(displayMode, response.getQrCode(), - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java deleted file mode 100644 index f9dccf5a7e..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.http.Method; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradeWapPayModel; -import com.alipay.api.request.AlipayTradeWapPayRequest; -import com.alipay.api.response.AlipayTradeWapPayResponse; -import lombok.extern.slf4j.Slf4j; - -/** - * 支付宝【Wap 网站】的 PayClient 实现类 - * - * 文档:手机网站支付接口 - * - * @author 芋道源码 - */ -@Slf4j -public class AlipayWapPayClient extends AbstractAlipayPayClient { - - public AlipayWapPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradeWapPayModel 请求 - AlipayTradeWapPayModel model = new AlipayTradeWapPayModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody()); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setProductCode("QUICK_WAP_PAY"); // 销售产品码. 目前 Wap 支付场景下仅支持 QUICK_WAP_PAY - // ② 个性化的参数【无】 - // ③ 支付宝 Wap 支付只有一种展示:URL - String displayMode = PayOrderDisplayModeEnum.URL.getMode(); - - // 1.2 构建 AlipayTradeWapPayRequest 请求 - AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - model.setQuitUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradeWapPayResponse response = client.pageExecute(request, Method.GET.name()); - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - return PayOrderRespDTO.waitingOf(displayMode, response.getBody(), - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java deleted file mode 100644 index 1ad1ad7134..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.mock; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; - -import java.time.LocalDateTime; -import java.util.Map; - -/** - * 模拟支付的 PayClient 实现类 - * - * 模拟支付返回结果都是成功,方便大家日常流畅 - * - * @author jason - */ -public class MockPayClient extends AbstractPayClient { - - private static final String MOCK_RESP_SUCCESS_DATA = "MOCK_SUCCESS"; - - public MockPayClient(Long channelId, NonePayClientConfig config) { - super(channelId, PayChannelEnum.MOCK.getCode(), config); - } - - @Override - protected void doInit() { - } - - @Override - protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - return PayOrderRespDTO.successOf("MOCK-P-" + reqDTO.getOutTradeNo(), "", LocalDateTime.now(), - reqDTO.getOutTradeNo(), MOCK_RESP_SUCCESS_DATA); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) { - return PayOrderRespDTO.successOf("MOCK-P-" + outTradeNo, "", LocalDateTime.now(), - outTradeNo, MOCK_RESP_SUCCESS_DATA); - } - - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - return PayRefundRespDTO.successOf("MOCK-R-" + reqDTO.getOutRefundNo(), LocalDateTime.now(), - reqDTO.getOutRefundNo(), MOCK_RESP_SUCCESS_DATA); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) { - return PayRefundRespDTO.successOf("MOCK-R-" + outRefundNo, LocalDateTime.now(), - outRefundNo, MOCK_RESP_SUCCESS_DATA); - } - - @Override - protected PayRefundRespDTO doParseRefundNotify(Map params, String body) { - throw new UnsupportedOperationException("模拟支付无退款回调"); - } - - @Override - protected PayOrderRespDTO doParseOrderNotify(Map params, String body) { - throw new UnsupportedOperationException("模拟支付无支付回调"); - } - - @Override - protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { - throw new UnsupportedOperationException("待实现"); - } - - @Override - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) { - throw new UnsupportedOperationException("待实现"); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java deleted file mode 100644 index ada1f42e6e..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java +++ /dev/null @@ -1,483 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.codec.Base64; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.date.TemporalAccessorUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.io.FileUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import com.github.binarywang.wxpay.bean.notify.WxPayNotifyV3Result; -import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; -import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; -import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyV3Result; -import com.github.binarywang.wxpay.bean.request.*; -import com.github.binarywang.wxpay.bean.result.*; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; -import lombok.extern.slf4j.Slf4j; - -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.Map; -import java.util.Objects; - -import static cn.hutool.core.date.DatePattern.*; -import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig.API_VERSION_V2; - -/** - * 微信支付抽象类,实现微信统一的接口、以及部分实现(退款) - * - * @author 遇到源码 - */ -@Slf4j -public abstract class AbstractWxPayClient extends AbstractPayClient { - - protected WxPayService client; - - public AbstractWxPayClient(Long channelId, String channelCode, WxPayClientConfig config) { - super(channelId, channelCode, config); - } - - /** - * 初始化 client 客户端 - * - * @param tradeType 交易类型 - */ - protected void doInit(String tradeType) { - // 创建 config 配置 - WxPayConfig payConfig = new WxPayConfig(); - BeanUtil.copyProperties(config, payConfig, "keyContent", "privateKeyContent", "privateCertContent"); - payConfig.setTradeType(tradeType); - // weixin-pay-java 无法设置内容,只允许读取文件,所以这里要创建临时文件来解决 - if (Base64.isBase64(config.getKeyContent())) { - payConfig.setKeyPath(FileUtils.createTempFile(Base64.decode(config.getKeyContent())).getPath()); - } - if (StrUtil.isNotEmpty(config.getPrivateKeyContent())) { - payConfig.setPrivateKeyPath(FileUtils.createTempFile(config.getPrivateKeyContent()).getPath()); - } - if (StrUtil.isNotEmpty(config.getPrivateCertContent())) { - payConfig.setPrivateCertPath(FileUtils.createTempFile(config.getPrivateCertContent()).getPath()); - } - - // 创建 client 客户端 - client = new WxPayServiceImpl(); - client.setConfig(payConfig); - } - - // ============ 支付相关 ========== - - @Override - protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws Exception { - try { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doUnifiedOrderV2(reqDTO); - case WxPayClientConfig.API_VERSION_V3: - return doUnifiedOrderV3(reqDTO); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } catch (WxPayException e) { - String errorCode = getErrorCode(e); - String errorMessage = getErrorMessage(e); - return PayOrderRespDTO.closedOf(errorCode, errorMessage, - reqDTO.getOutTradeNo(), e.getXmlString()); - } - } - - /** - * 【V2】调用支付渠道,统一下单 - * - * @param reqDTO 下单信息 - * @return 各支付渠道的返回结果 - */ - protected abstract PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) - throws Exception; - - /** - * 【V3】调用支付渠道,统一下单 - * - * @param reqDTO 下单信息 - * @return 各支付渠道的返回结果 - */ - protected abstract PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) - throws WxPayException; - - /** - * 【V2】创建微信下单请求 - * - * @param reqDTO 下信息 - * @return 下单请求 - */ - protected WxPayUnifiedOrderRequest buildPayUnifiedOrderRequestV2(PayOrderUnifiedReqDTO reqDTO) { - return WxPayUnifiedOrderRequest.newBuilder() - .outTradeNo(reqDTO.getOutTradeNo()) - .body(reqDTO.getSubject()) - .detail(reqDTO.getBody()) - .totalFee(reqDTO.getPrice()) // 单位分 - .timeExpire(formatDateV2(reqDTO.getExpireTime())) - .spbillCreateIp(reqDTO.getUserIp()) - .notifyUrl(reqDTO.getNotifyUrl()) - .build(); - } - - /** - * 【V3】创建微信下单请求 - * - * @param reqDTO 下信息 - * @return 下单请求 - */ - protected WxPayUnifiedOrderV3Request buildPayUnifiedOrderRequestV3(PayOrderUnifiedReqDTO reqDTO) { - WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request(); - request.setOutTradeNo(reqDTO.getOutTradeNo()); - request.setDescription(reqDTO.getSubject()); - request.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(reqDTO.getPrice())); // 单位分 - request.setTimeExpire(formatDateV3(reqDTO.getExpireTime())); - request.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(reqDTO.getUserIp())); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - return request; - } - - @Override - public PayOrderRespDTO doParseOrderNotify(Map params, String body) throws WxPayException { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doParseOrderNotifyV2(body); - case WxPayClientConfig.API_VERSION_V3: - return doParseOrderNotifyV3(body); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } - - private PayOrderRespDTO doParseOrderNotifyV2(String body) throws WxPayException { - // 1. 解析回调 - WxPayOrderNotifyResult response = client.parseOrderNotifyResult(body); - // 2. 构建结果 - // V2 微信支付的回调,只有 SUCCESS 支付成功、CLOSED 支付失败两种情况,无需像支付宝一样解析的比较复杂 - Integer status = Objects.equals(response.getResultCode(), "SUCCESS") ? - PayOrderStatusRespEnum.SUCCESS.getStatus() : PayOrderStatusRespEnum.CLOSED.getStatus(); - return PayOrderRespDTO.of(status, response.getTransactionId(), response.getOpenid(), parseDateV2(response.getTimeEnd()), - response.getOutTradeNo(), body); - } - - private PayOrderRespDTO doParseOrderNotifyV3(String body) throws WxPayException { - // 1. 解析回调 - WxPayNotifyV3Result response = client.parseOrderNotifyV3Result(body, null); - WxPayNotifyV3Result.DecryptNotifyResult result = response.getResult(); - // 2. 构建结果 - Integer status = parseStatus(result.getTradeState()); - String openid = result.getPayer() != null ? result.getPayer().getOpenid() : null; - return PayOrderRespDTO.of(status, result.getTransactionId(), openid, parseDateV3(result.getSuccessTime()), - result.getOutTradeNo(), body); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) throws Throwable { - try { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doGetOrderV2(outTradeNo); - case WxPayClientConfig.API_VERSION_V3: - return doGetOrderV3(outTradeNo); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } catch (WxPayException e) { - if (ObjectUtils.equalsAny(e.getErrCode(), "ORDERNOTEXIST", "ORDER_NOT_EXIST")) { - String errorCode = getErrorCode(e); - String errorMessage = getErrorMessage(e); - return PayOrderRespDTO.closedOf(errorCode, errorMessage, - outTradeNo, e.getXmlString()); - } - throw e; - } - } - - private PayOrderRespDTO doGetOrderV2(String outTradeNo) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayOrderQueryRequest request = WxPayOrderQueryRequest.newBuilder() - .outTradeNo(outTradeNo).build(); - // 执行请求 - WxPayOrderQueryResult response = client.queryOrder(request); - - // 转换结果 - Integer status = parseStatus(response.getTradeState()); - return PayOrderRespDTO.of(status, response.getTransactionId(), response.getOpenid(), parseDateV2(response.getTimeEnd()), - outTradeNo, response); - } - - private PayOrderRespDTO doGetOrderV3(String outTradeNo) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayOrderQueryV3Request request = new WxPayOrderQueryV3Request() - .setOutTradeNo(outTradeNo); - // 执行请求 - WxPayOrderQueryV3Result response = client.queryOrderV3(request); - - // 转换结果 - Integer status = parseStatus(response.getTradeState()); - String openid = response.getPayer() != null ? response.getPayer().getOpenid() : null; - return PayOrderRespDTO.of(status, response.getTransactionId(), openid, parseDateV3(response.getSuccessTime()), - outTradeNo, response); - } - - private static Integer parseStatus(String tradeState) { - switch (tradeState) { - case "NOTPAY": - case "USERPAYING": // 支付中,等待用户输入密码(条码支付独有) - return PayOrderStatusRespEnum.WAITING.getStatus(); - case "SUCCESS": - return PayOrderStatusRespEnum.SUCCESS.getStatus(); - case "REFUND": - return PayOrderStatusRespEnum.REFUND.getStatus(); - case "CLOSED": - case "REVOKED": // 已撤销(刷卡支付独有) - case "PAYERROR": // 支付失败(其它原因,如银行返回失败) - return PayOrderStatusRespEnum.CLOSED.getStatus(); - default: - throw new IllegalArgumentException(StrUtil.format("未知的支付状态({})", tradeState)); - } - } - - // ============ 退款相关 ========== - - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable { - try { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doUnifiedRefundV2(reqDTO); - case WxPayClientConfig.API_VERSION_V3: - return doUnifiedRefundV3(reqDTO); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } catch (WxPayException e) { - String errorCode = getErrorCode(e); - String errorMessage = getErrorMessage(e); - return PayRefundRespDTO.failureOf(errorCode, errorMessage, - reqDTO.getOutTradeNo(), e.getXmlString()); - } - } - - private PayRefundRespDTO doUnifiedRefundV2(PayRefundUnifiedReqDTO reqDTO) throws Throwable { - // 1. 构建 WxPayRefundRequest 请求 - WxPayRefundRequest request = new WxPayRefundRequest() - .setOutTradeNo(reqDTO.getOutTradeNo()) - .setOutRefundNo(reqDTO.getOutRefundNo()) - .setRefundFee(reqDTO.getRefundPrice()) - .setRefundDesc(reqDTO.getReason()) - .setTotalFee(reqDTO.getPayPrice()) - .setNotifyUrl(reqDTO.getNotifyUrl()); - // 2.1 执行请求 - WxPayRefundResult response = client.refundV2(request); - // 2.2 创建返回结果 - if (Objects.equals("SUCCESS", response.getResultCode())) { // V2 情况下,不直接返回退款成功,而是等待异步通知 - return PayRefundRespDTO.waitingOf(response.getRefundId(), - reqDTO.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(reqDTO.getOutRefundNo(), response); - } - - private PayRefundRespDTO doUnifiedRefundV3(PayRefundUnifiedReqDTO reqDTO) throws Throwable { - // 1. 构建 WxPayRefundRequest 请求 - WxPayRefundV3Request request = new WxPayRefundV3Request() - .setOutTradeNo(reqDTO.getOutTradeNo()) - .setOutRefundNo(reqDTO.getOutRefundNo()) - .setAmount(new WxPayRefundV3Request.Amount().setRefund(reqDTO.getRefundPrice()) - .setTotal(reqDTO.getPayPrice()).setCurrency("CNY")) - .setReason(reqDTO.getReason()) - .setNotifyUrl(reqDTO.getNotifyUrl()); - // 2.1 执行请求 - WxPayRefundV3Result response = client.refundV3(request); - // 2.2 创建返回结果 - if (Objects.equals("SUCCESS", response.getStatus())) { - return PayRefundRespDTO.successOf(response.getRefundId(), parseDateV3(response.getSuccessTime()), - reqDTO.getOutRefundNo(), response); - } - if (Objects.equals("PROCESSING", response.getStatus())) { - return PayRefundRespDTO.waitingOf(response.getRefundId(), - reqDTO.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(reqDTO.getOutRefundNo(), response); - } - - @Override - public PayRefundRespDTO doParseRefundNotify(Map params, String body) throws WxPayException { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doParseRefundNotifyV2(body); - case WxPayClientConfig.API_VERSION_V3: - return parseRefundNotifyV3(body); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } - - private PayRefundRespDTO doParseRefundNotifyV2(String body) throws WxPayException { - // 1. 解析回调 - WxPayRefundNotifyResult response = client.parseRefundNotifyResult(body); - WxPayRefundNotifyResult.ReqInfo result = response.getReqInfo(); - // 2. 构建结果 - if (Objects.equals("SUCCESS", result.getRefundStatus())) { - return PayRefundRespDTO.successOf(result.getRefundId(), parseDateV2B(result.getSuccessTime()), - result.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(result.getOutRefundNo(), response); - } - - private PayRefundRespDTO parseRefundNotifyV3(String body) throws WxPayException { - // 1. 解析回调 - WxPayRefundNotifyV3Result response = client.parseRefundNotifyV3Result(body, null); - WxPayRefundNotifyV3Result.DecryptNotifyResult result = response.getResult(); - // 2. 构建结果 - if (Objects.equals("SUCCESS", result.getRefundStatus())) { - return PayRefundRespDTO.successOf(result.getRefundId(), parseDateV3(result.getSuccessTime()), - result.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(result.getOutRefundNo(), response); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws WxPayException { - try { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doGetRefundV2(outTradeNo, outRefundNo); - case WxPayClientConfig.API_VERSION_V3: - return doGetRefundV3(outTradeNo, outRefundNo); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } catch (WxPayException e) { - if (ObjectUtils.equalsAny(e.getErrCode(), "REFUNDNOTEXIST", "RESOURCE_NOT_EXISTS")) { - String errorCode = getErrorCode(e); - String errorMessage = getErrorMessage(e); - return PayRefundRespDTO.failureOf(errorCode, errorMessage, - outRefundNo, e.getXmlString()); - } - throw e; - } - } - - private PayRefundRespDTO doGetRefundV2(String outTradeNo, String outRefundNo) throws WxPayException { - // 1. 构建 WxPayRefundRequest 请求 - WxPayRefundQueryRequest request = WxPayRefundQueryRequest.newBuilder() - .outTradeNo(outTradeNo) - .outRefundNo(outRefundNo) - .build(); - // 2.1 执行请求 - WxPayRefundQueryResult response = client.refundQuery(request); - // 2.2 创建返回结果 - if (!Objects.equals("SUCCESS", response.getResultCode())) { - return PayRefundRespDTO.waitingOf(null, - outRefundNo, response); - } - WxPayRefundQueryResult.RefundRecord refund = CollUtil.findOne(response.getRefundRecords(), - record -> record.getOutRefundNo().equals(outRefundNo)); - if (refund == null) { - return PayRefundRespDTO.failureOf(outRefundNo, response); - } - switch (refund.getRefundStatus()) { - case "SUCCESS": - return PayRefundRespDTO.successOf(refund.getRefundId(), parseDateV2B(refund.getRefundSuccessTime()), - outRefundNo, response); - case "PROCESSING": - return PayRefundRespDTO.waitingOf(refund.getRefundId(), - outRefundNo, response); - case "CHANGE": // 退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,资金回流到商户的现金帐号,需要商户人工干预,通过线下或者财付通转账的方式进行退款 - case "FAIL": - return PayRefundRespDTO.failureOf(outRefundNo, response); - default: - throw new IllegalArgumentException(String.format("未知的退款状态(%s)", refund.getRefundStatus())); - } - } - - private PayRefundRespDTO doGetRefundV3(String outTradeNo, String outRefundNo) throws WxPayException { - // 1. 构建 WxPayRefundRequest 请求 - WxPayRefundQueryV3Request request = new WxPayRefundQueryV3Request(); - request.setOutRefundNo(outRefundNo); - // 2.1 执行请求 - WxPayRefundQueryV3Result response = client.refundQueryV3(request); - // 2.2 创建返回结果 - switch (response.getStatus()) { - case "SUCCESS": - return PayRefundRespDTO.successOf(response.getRefundId(), parseDateV3(response.getSuccessTime()), - outRefundNo, response); - case "PROCESSING": - return PayRefundRespDTO.waitingOf(response.getRefundId(), - outRefundNo, response); - case "ABNORMAL": // 退款异常 - case "CLOSED": - return PayRefundRespDTO.failureOf(outRefundNo, response); - default: - throw new IllegalArgumentException(String.format("未知的退款状态(%s)", response.getStatus())); - } - } - - @Override - protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { - throw new UnsupportedOperationException("待实现"); - } - - @Override - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) { - throw new UnsupportedOperationException("待实现"); - } - - // ========== 各种工具方法 ========== - - static String formatDateV2(LocalDateTime time) { - return TemporalAccessorUtil.format(time.atZone(ZoneId.systemDefault()), PURE_DATETIME_PATTERN); - } - - static LocalDateTime parseDateV2(String time) { - return LocalDateTimeUtil.parse(time, PURE_DATETIME_PATTERN); - } - - static LocalDateTime parseDateV2B(String time) { - return LocalDateTimeUtil.parse(time, NORM_DATETIME_PATTERN); - } - - static String formatDateV3(LocalDateTime time) { - return TemporalAccessorUtil.format(time.atZone(ZoneId.systemDefault()), UTC_WITH_XXX_OFFSET_PATTERN); - } - - static LocalDateTime parseDateV3(String time) { - return LocalDateTimeUtil.parse(time, UTC_WITH_XXX_OFFSET_PATTERN); - } - - static String getErrorCode(WxPayException e) { - if (StrUtil.isNotEmpty(e.getErrCode())) { - return e.getErrCode(); - } - if (StrUtil.isNotEmpty(e.getCustomErrorMsg())) { - return "CUSTOM_ERROR"; - } - return e.getReturnCode(); - } - - static String getErrorMessage(WxPayException e) { - if (StrUtil.isNotEmpty(e.getErrCode())) { - return e.getErrCodeDes(); - } - if (StrUtil.isNotEmpty(e.getCustomErrorMsg())) { - return e.getCustomErrorMsg(); - } - return e.getReturnMsg(); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxAppPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxAppPayClient.java deleted file mode 100644 index 396694a75b..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxAppPayClient.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import lombok.extern.slf4j.Slf4j; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; - -/** - * 微信支付【App 支付】的 PayClient 实现类 - * - * 文档:App 支付 - * - * // TODO 芋艿:未详细测试,因为手头没 App - * - * @author 芋道源码 - */ -@Slf4j -public class WxAppPayClient extends AbstractWxPayClient { - - public WxAppPayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_APP.getCode(), config); - } - - @Override - protected void doInit() { - super.doInit(WxPayConstants.TradeType.APP); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO); - // 执行请求 - WxPayMpOrderResult response = client.createOrder(request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), - reqDTO.getOutTradeNo(), response); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderV3Request 对象 - WxPayUnifiedOrderV3Request request = buildPayUnifiedOrderRequestV3(reqDTO); - // 执行请求 - WxPayUnifiedOrderV3Result.AppResult response = client.createOrderV3(TradeTypeEnum.APP, request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), - reqDTO.getOutTradeNo(), response); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClient.java deleted file mode 100644 index d01b504050..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClient.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest; -import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import lombok.extern.slf4j.Slf4j; - -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.concurrent.TimeUnit; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; - -/** - * 微信支付【付款码支付】的 PayClient 实现类 - * - * 文档:付款码支付 - * - * @author 芋道源码 - */ -@Slf4j -public class WxBarPayClient extends AbstractWxPayClient { - - /** - * 微信付款码的过期时间 - */ - private static final Duration AUTH_CODE_EXPIRE = Duration.ofMinutes(3); - - public WxBarPayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_BAR.getCode(), config); - } - - @Override - protected void doInit() { - super.doInit(WxPayConstants.TradeType.MICROPAY); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 由于付款码需要不断轮询,所以需要在较短的时间完成支付 - LocalDateTime expireTime = LocalDateTimeUtils.addTime(AUTH_CODE_EXPIRE); - if (expireTime.isAfter(reqDTO.getExpireTime())) { - expireTime = reqDTO.getExpireTime(); - } - // 构建 WxPayMicropayRequest 对象 - WxPayMicropayRequest request = WxPayMicropayRequest.newBuilder() - .outTradeNo(reqDTO.getOutTradeNo()) - .body(reqDTO.getSubject()) - .detail(reqDTO.getBody()) - .totalFee(reqDTO.getPrice()) // 单位分 - .timeExpire(formatDateV2(expireTime)) - .spbillCreateIp(reqDTO.getUserIp()) - .authCode(getAuthCode(reqDTO)) - .build(); - // 执行请求,重试直到失败(过期),或者成功 - WxPayException lastWxPayException = null; - for (int i = 1; i < Byte.MAX_VALUE; i++) { - try { - WxPayMicropayResult response = client.micropay(request); - // 支付成功,例如说:1)用户输入了密码;2)用户免密支付 - return PayOrderRespDTO.successOf(response.getTransactionId(), response.getOpenid(), parseDateV2(response.getTimeEnd()), - response.getOutTradeNo(), response) - .setDisplayMode(PayOrderDisplayModeEnum.BAR_CODE.getMode()); - } catch (WxPayException ex) { - lastWxPayException = ex; - // 如果不满足这 3 种任一的,则直接抛出 WxPayException 异常,不仅需处理 - // 1. SYSTEMERROR:接口返回错误:请立即调用被扫订单结果查询API,查询当前订单状态,并根据订单的状态决定下一步的操作。 - // 2. USERPAYING:用户支付中,需要输入密码:等待 5 秒,然后调用被扫订单结果查询 API,查询当前订单的不同状态,决定下一步的操作。 - // 3. BANKERROR:银行系统异常:请立即调用被扫订单结果查询 API,查询当前订单的不同状态,决定下一步的操作。 - if (!StrUtil.equalsAny(ex.getErrCode(), "SYSTEMERROR", "USERPAYING", "BANKERROR")) { - throw ex; - } - // 等待 5 秒,继续下一轮重新发起支付 - log.info("[doUnifiedOrderV2][发起微信 Bar 支付第({})失败,等待下一轮重试,请求({}),响应({})]", i, - toJsonString(request), ex.getMessage()); - ThreadUtil.sleep(5, TimeUnit.SECONDS); - } - } - throw lastWxPayException; - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - return doUnifiedOrderV2(reqDTO); - } - - // ========== 各种工具方法 ========== - - static String getAuthCode(PayOrderUnifiedReqDTO reqDTO) { - String authCode = MapUtil.getStr(reqDTO.getChannelExtras(), "authCode"); - if (StrUtil.isEmpty(authCode)) { - throw invalidParamException("支付请求的 authCode 不能为空!"); - } - return authCode; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxLitePayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxLitePayClient.java deleted file mode 100644 index 9929955ae2..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxLitePayClient.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import lombok.extern.slf4j.Slf4j; - -/** - * 微信支付【小程序】的 PayClient 实现类 - * - * 由于公众号和小程序的微信支付逻辑一致,所以直接进行继承 - * - * 文档:JSAPI 下单 - * - * @author zwy - */ -@Slf4j -public class WxLitePayClient extends WxPubPayClient { - - public WxLitePayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_LITE.getCode(), config); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java deleted file mode 100644 index 5a073501d4..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import lombok.extern.slf4j.Slf4j; - -/** - * 微信支付【Native 二维码】的 PayClient 实现类 - * - * 文档:Native 下单 - * - * @author zwy - */ -@Slf4j -public class WxNativePayClient extends AbstractWxPayClient { - - public WxNativePayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_NATIVE.getCode(), config); - } - - @Override - protected void doInit() { - super.doInit(WxPayConstants.TradeType.NATIVE); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO); - // 执行请求 - WxPayNativeOrderResult response = client.createOrder(request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.QR_CODE.getMode(), response.getCodeUrl(), - reqDTO.getOutTradeNo(), response); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderV3Request 对象 - WxPayUnifiedOrderV3Request request = buildPayUnifiedOrderRequestV3(reqDTO); - // 执行请求 - String response = client.createOrderV3(TradeTypeEnum.NATIVE, request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.QR_CODE.getMode(), response, - reqDTO.getOutTradeNo(), response); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPayClientConfig.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPayClientConfig.java deleted file mode 100644 index de5b0234a4..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPayClientConfig.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.hutool.core.io.IoUtil; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import lombok.Data; - -import jakarta.validation.Validator; -import jakarta.validation.constraints.NotBlank; -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -/** - * 微信支付的 PayClientConfig 实现类 - * 属性主要来自 {@link com.github.binarywang.wxpay.config.WxPayConfig} 的必要属性 - * - * @author 芋道源码 - */ -@Data -public class WxPayClientConfig implements PayClientConfig { - - /** - * API 版本 - V2 - * - * V2 协议说明 - */ - public static final String API_VERSION_V2 = "v2"; - /** - * API 版本 - V3 - * - * V3 协议说明 - */ - public static final String API_VERSION_V3 = "v3"; - - /** - * 公众号或者小程序的 appid - * - * 只有公众号或小程序需要该字段 - */ - @NotBlank(message = "APPID 不能为空", groups = {V2.class, V3.class}) - private String appId; - /** - * 商户号 - */ - @NotBlank(message = "商户号不能为空", groups = {V2.class, V3.class}) - private String mchId; - /** - * API 版本 - */ - @NotBlank(message = "API 版本不能为空", groups = {V2.class, V3.class}) - private String apiVersion; - - // ========== V2 版本的参数 ========== - - /** - * 商户密钥 - */ - @NotBlank(message = "商户密钥不能为空", groups = V2.class) - private String mchKey; - /** - * apiclient_cert.p12 证书文件的对应字符串【base64 格式】 - * - * 为什么采用 base64 格式?因为 p12 读取后是二进制,需要转换成 base64 格式才好传输和存储 - */ - @NotBlank(message = "apiclient_cert.p12 不能为空", groups = V2.class) - private String keyContent; - - // ========== V3 版本的参数 ========== - /** - * apiclient_key.pem 证书文件的对应字符串 - */ - @NotBlank(message = "apiclient_key 不能为空", groups = V3.class) - private String privateKeyContent; - /** - * apiclient_cert.pem 证书文件的对应的字符串 - */ - @NotBlank(message = "apiclient_cert 不能为空", groups = V3.class) - private String privateCertContent; - /** - * apiV3 密钥值 - */ - @NotBlank(message = "apiV3 密钥值不能为空", groups = V3.class) - private String apiV3Key; - - /** - * 分组校验 v2版本 - */ - public interface V2 { - } - - /** - * 分组校验 v3版本 - */ - public interface V3 { - } - - @Override - public void validate(Validator validator) { - ValidationUtils.validate(validator, this, - API_VERSION_V2.equals(this.getApiVersion()) ? V2.class : V3.class); - } - - public static void main(String[] args) throws FileNotFoundException { - String path = "/Users/yunai/Downloads/wx_pay/apiclient_cert.p12"; - /// String path = "/Users/yunai/Downloads/wx_pay/apiclient_key.pem"; - /// String path = "/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"; - System.out.println(IoUtil.readUtf8(new FileInputStream(path))); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java deleted file mode 100644 index 390c513630..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import lombok.extern.slf4j.Slf4j; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; - -/** - * 微信支付(公众号)的 PayClient 实现类 - * - * 文档:JSAPI 下单 - * - * @author 芋道源码 - */ -@Slf4j -public class WxPubPayClient extends AbstractWxPayClient { - - public WxPubPayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_PUB.getCode(), config); - } - - protected WxPubPayClient(Long channelId, String channelCode, WxPayClientConfig config) { - super(channelId, channelCode, config); - } - - @Override - protected void doInit() { - super.doInit(WxPayConstants.TradeType.JSAPI); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO) - .setOpenid(getOpenid(reqDTO)); - // 执行请求 - WxPayMpOrderResult response = client.createOrder(request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), - reqDTO.getOutTradeNo(), response); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderV3Request request = buildPayUnifiedOrderRequestV3(reqDTO) - .setPayer(new WxPayUnifiedOrderV3Request.Payer().setOpenid(getOpenid(reqDTO))); - // 执行请求 - WxPayUnifiedOrderV3Result.JsapiResult response = client.createOrderV3(TradeTypeEnum.JSAPI, request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), - reqDTO.getOutTradeNo(), response); - } - - // ========== 各种工具方法 ========== - - static String getOpenid(PayOrderUnifiedReqDTO reqDTO) { - String openid = MapUtil.getStr(reqDTO.getChannelExtras(), "openid"); - if (StrUtil.isEmpty(openid)) { - throw invalidParamException("支付请求的 openid 不能为空!"); - } - return openid; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java deleted file mode 100644 index 83d2d13add..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.channel; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 支付渠道的编码的枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayChannelEnum { - - WX_PUB("wx_pub", "微信 JSAPI 支付", WxPayClientConfig.class), // 公众号网页 - WX_LITE("wx_lite", "微信小程序支付", WxPayClientConfig.class), - WX_APP("wx_app", "微信 App 支付", WxPayClientConfig.class), - WX_NATIVE("wx_native", "微信 Native 支付", WxPayClientConfig.class), - WX_BAR("wx_bar", "微信付款码支付", WxPayClientConfig.class), - - ALIPAY_PC("alipay_pc", "支付宝 PC 网站支付", AlipayPayClientConfig.class), - ALIPAY_WAP("alipay_wap", "支付宝 Wap 网站支付", AlipayPayClientConfig.class), - ALIPAY_APP("alipay_app", "支付宝App 支付", AlipayPayClientConfig.class), - ALIPAY_QR("alipay_qr", "支付宝扫码支付", AlipayPayClientConfig.class), - ALIPAY_BAR("alipay_bar", "支付宝条码支付", AlipayPayClientConfig.class), - MOCK("mock", "模拟支付", NonePayClientConfig.class), - - WALLET("wallet", "钱包支付", NonePayClientConfig.class); - - /** - * 编码 - * - * 参考 支付渠道属性值 - */ - private final String code; - /** - * 名字 - */ - private final String name; - - /** - * 配置类 - */ - private final Class configClass; - - /** - * 微信支付 - */ - public static final String WECHAT = "WECHAT"; - - /** - * 支付宝支付 - */ - public static final String ALIPAY = "ALIPAY"; - - public static PayChannelEnum getByCode(String code) { - return ArrayUtil.firstMatch(o -> o.getCode().equals(code), values()); - } - - public static boolean isAlipay(String channelCode) { - return channelCode != null && channelCode.startsWith("alipay"); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderDisplayModeEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderDisplayModeEnum.java deleted file mode 100644 index 129c406029..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderDisplayModeEnum.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.order; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 支付 UI 展示模式 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayOrderDisplayModeEnum { - - URL("url"), // Redirect 跳转链接的方式 - IFRAME("iframe"), // IFrame 内嵌链接的方式【目前暂时用不到】 - FORM("form"), // HTML 表单提交 - QR_CODE("qr_code"), // 二维码的文字内容 - QR_CODE_URL("qr_code_url"), // 二维码的图片链接 - BAR_CODE("bar_code"), // 条形码 - APP("app"), // 应用:Android、iOS、微信小程序、微信公众号等,需要做自定义处理的 - ; - - /** - * 展示模式 - */ - private final String mode; - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderStatusRespEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderStatusRespEnum.java deleted file mode 100644 index eac381c472..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderStatusRespEnum.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.order; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 渠道的支付状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayOrderStatusRespEnum { - - WAITING(0, "未支付"), - SUCCESS(10, "支付成功"), - REFUND(20, "已退款"), - CLOSED(30, "支付关闭"), - ; - - private final Integer status; - private final String name; - - /** - * 判断是否支付成功 - * - * @param status 状态 - * @return 是否支付成功 - */ - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - /** - * 判断是否已退款 - * - * @param status 状态 - * @return 是否支付成功 - */ - public static boolean isRefund(Integer status) { - return Objects.equals(status, REFUND.getStatus()); - } - - /** - * 判断是否支付关闭 - * - * @param status 状态 - * @return 是否支付关闭 - */ - public static boolean isClosed(Integer status) { - return Objects.equals(status, CLOSED.getStatus()); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayRefundStatusRespEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayRefundStatusRespEnum.java deleted file mode 100644 index 8ad61a6cff..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayRefundStatusRespEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.refund; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 渠道的退款状态枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum PayRefundStatusRespEnum { - - WAITING(0, "等待退款"), - SUCCESS(10, "退款成功"), - FAILURE(20, "退款失败"); - - private final Integer status; - private final String name; - - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - public static boolean isFailure(Integer status) { - return Objects.equals(status, FAILURE.getStatus()); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferStatusRespEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferStatusRespEnum.java deleted file mode 100644 index 35ea344da2..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferStatusRespEnum.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.transfer; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 渠道的转账状态枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum PayTransferStatusRespEnum { - - WAITING(0, "等待转账"), - - /** - * TODO 转账到银行卡. 会有T+0 T+1 到账的请情况。 还未实现 - * TODO @jason:可以看看其它开源项目,针对这个场景,处理策略是怎么样的?例如说,每天主动轮询?这个状态的单子? - */ - IN_PROGRESS(10, "转账进行中"), - - SUCCESS(20, "转账成功"), - /** - * 转账关闭 (失败,或者其它情况) - */ - CLOSED(30, "转账关闭"); - - private final Integer status; - private final String name; - - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - public static boolean isClosed(Integer status) { - return Objects.equals(status, CLOSED.getStatus()); - } - - public static boolean isInProgress(Integer status) { - return Objects.equals(status, IN_PROGRESS.getStatus()); - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferTypeEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferTypeEnum.java deleted file mode 100644 index a7580f0132..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferTypeEnum.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.transfer; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 转账类型枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum PayTransferTypeEnum implements IntArrayValuable { - - ALIPAY_BALANCE(1, "支付宝余额"), - WX_BALANCE(2, "微信余额"), - BANK_CARD(3, "银行卡"), - WALLET_BALANCE(4, "钱包余额"); - - public interface WxPay { - } - - public interface Alipay { - } - - private final Integer type; - private final String name; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PayTransferTypeEnum::getType).toArray(); - - @Override - public int[] array() { - return ARRAYS; - } - - public static PayTransferTypeEnum typeOf(Integer type) { - return ArrayUtil.firstMatch(item -> item.getType().equals(type), values()); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index f2a8bf1463..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1 +0,0 @@ -cn.iocoder.yudao.framework.pay.config.YudaoPayAutoConfiguration \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java deleted file mode 100644 index 9842560636..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl; - -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayQrPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPubPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -/** - * {@link PayClientFactoryImpl} 的集成测试 - * - * @author 芋道源码 - */ -@Disabled -public class PayClientFactoryImplIntegrationTest { - - private static final String SERVER_URL_SANDBOX = "https://openapi.alipaydev.com/gateway.do"; - - private final PayClientFactoryImpl payClientFactory = new PayClientFactoryImpl(); - - /** - * {@link WxPubPayClient} 的 V2 版本 - */ - @Test - public void testCreatePayClient_WX_PUB_V2() { - // 创建配置 - WxPayClientConfig config = new WxPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WxPayClientConfig.API_VERSION_V2); - config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); -// CommonResult result = client.unifiedOrder(reqDTO); -// System.out.println(result); - } - - /** - * {@link WxPubPayClient} 的 V3 版本 - */ - @Test - public void testCreatePayClient_WX_PUB_V3() throws FileNotFoundException { - // 创建配置 - WxPayClientConfig config = new WxPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WxPayClientConfig.API_VERSION_V3); - config.setPrivateKeyContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_key.pem"))); - config.setPrivateCertContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"))); - config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); -// CommonResult result = client.unifiedOrder(reqDTO); -// System.out.println(result); - } - - /** - * {@link AlipayQrPayClient} - */ - @Test - @SuppressWarnings("unchecked") - public void testCreatePayClient_ALIPAY_QR() { - // 创建配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_QR.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); - reqDTO.setNotifyUrl("http://yunai.natapp1.cc/admin-api/pay/notify/callback/18"); // TODO @tina: 这里改成你的 natapp 回调地址 -// CommonResult result = (CommonResult) client.unifiedOrder(reqDTO); -// System.out.println(JsonUtils.toJsonString(result)); -// System.out.println(result.getData().getQrCode()); - } - - /** - * {@link AlipayWapPayClient} - */ - @Test - public void testCreatePayClient_ALIPAY_WAP() { - // 创建配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); -// CommonResult result = client.unifiedOrder(reqDTO); -// System.out.println(JsonUtils.toJsonString(result)); - } - - private static PayOrderUnifiedReqDTO buildPayOrderUnifiedReqDTO() { - PayOrderUnifiedReqDTO reqDTO = new PayOrderUnifiedReqDTO(); - reqDTO.setPrice(123); - reqDTO.setSubject("IPhone 13"); - reqDTO.setBody("biubiubiu"); - reqDTO.setOutTradeNo(String.valueOf(System.currentTimeMillis())); - reqDTO.setUserIp("127.0.0.1"); - reqDTO.setNotifyUrl("http://127.0.0.1:8080"); - return reqDTO; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClientTest.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClientTest.java deleted file mode 100644 index 7c45b6a90f..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClientTest.java +++ /dev/null @@ -1,221 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import com.alipay.api.AlipayApiException; -import com.alipay.api.DefaultAlipayClient; -import com.alipay.api.DefaultSigner; -import com.alipay.api.domain.AlipayTradeRefundModel; -import com.alipay.api.request.AlipayTradeRefundRequest; -import com.alipay.api.response.AlipayTradeRefundResponse; -import lombok.Setter; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.Mock; - -import jakarta.validation.ConstraintViolationException; -import java.util.Date; - -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_PUBLIC_KEY; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * 支付宝 Client 的测试基类 - * - * @author jason - */ -public abstract class AbstractAlipayClientTest extends BaseMockitoUnitTest { - - protected AlipayPayClientConfig config = randomPojo(AlipayPayClientConfig.class, o -> { - o.setServerUrl(randomURL()); - o.setPrivateKey(randomString()); - o.setMode(MODE_PUBLIC_KEY); - o.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - o.setAppCertContent(""); - o.setAlipayPublicCertContent(""); - o.setRootCertContent(""); - }); - - @Mock - protected DefaultAlipayClient defaultAlipayClient; - - @Setter - private AbstractAlipayPayClient client; - - /** - * 子类需要实现该方法. 设置 client 的具体实现 - */ - @BeforeEach - public abstract void setUp(); - - @Test - @DisplayName("支付宝 Client 初始化") - public void testDoInit() { - // 调用 - client.doInit(); - // 断言 - DefaultAlipayClient realClient = client.getClient(); - assertNotSame(defaultAlipayClient, realClient); - assertInstanceOf(DefaultSigner.class, realClient.getSigner()); - assertEquals(config.getPrivateKey(), ((DefaultSigner) realClient.getSigner()).getPrivateKey()); - } - - @Test - @DisplayName("支付宝 Client 统一退款:成功") - public void testUnifiedRefund_success() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - Date refundTime = randomDate(); - String outRefundNo = randomString(); - String outTradeNo = randomString(); - Integer refundAmount = randomInteger(); - AlipayTradeRefundResponse response = randomPojo(AlipayTradeRefundResponse.class, o -> { - o.setSubCode(""); - o.setGmtRefundPay(refundTime); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertInstanceOf(AlipayTradeRefundModel.class, request.getBizModel()); - AlipayTradeRefundModel bizModel = (AlipayTradeRefundModel) request.getBizModel(); - assertEquals(outRefundNo, bizModel.getOutRequestNo()); - assertEquals(outTradeNo, bizModel.getOutTradeNo()); - assertEquals(String.valueOf(refundAmount / 100.0), bizModel.getRefundAmount()); - return true; - }))).thenReturn(response); - // 准备请求参数 - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { - o.setOutRefundNo(outRefundNo); - o.setOutTradeNo(outTradeNo); - o.setNotifyUrl(notifyUrl); - o.setRefundPrice(refundAmount); - }); - - // 调用 - PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO); - // 断言 - assertEquals(PayRefundStatusRespEnum.SUCCESS.getStatus(), resp.getStatus()); - assertEquals(outRefundNo, resp.getOutRefundNo()); - assertNull(resp.getChannelRefundNo()); - assertEquals(LocalDateTimeUtil.of(refundTime), resp.getSuccessTime()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 Client 统一退款:渠道返回失败") - public void test_unified_refund_channel_failed() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - String subCode = randomString(); - String subMsg = randomString(); - AlipayTradeRefundResponse response = randomPojo(AlipayTradeRefundResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertInstanceOf(AlipayTradeRefundModel.class, request.getBizModel()); - return true; - }))).thenReturn(response); - // 准备请求参数 - String outRefundNo = randomString(); - String outTradeNo = randomString(); - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { - o.setOutRefundNo(outRefundNo); - o.setOutTradeNo(outTradeNo); - o.setNotifyUrl(notifyUrl); - }); - - // 调用 - PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO); - // 断言 - assertEquals(PayRefundStatusRespEnum.FAILURE.getStatus(), resp.getStatus()); - assertEquals(outRefundNo, resp.getOutRefundNo()); - assertNull(resp.getChannelRefundNo()); - assertNull(resp.getSuccessTime()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 Client 统一退款:参数校验不通过") - public void testUnifiedRefund_paramInvalidate() { - // 准备请求参数 - String notifyUrl = randomURL(); - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { - o.setOutTradeNo(""); - o.setNotifyUrl(notifyUrl); - }); - - // 调用,并断言 - assertThrows(ConstraintViolationException.class, () -> client.unifiedRefund(refundReqDTO)); - } - - @Test - @DisplayName("支付宝 Client 统一退款:抛出业务异常") - public void testUnifiedRefund_throwServiceException() throws AlipayApiException { - // mock 方法 - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> true))) - .thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); - // 准备请求参数 - String notifyUrl = randomURL(); - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> o.setNotifyUrl(notifyUrl)); - - // 调用,并断言 - assertThrows(ServiceException.class, () -> client.unifiedRefund(refundReqDTO)); - } - - @Test - @DisplayName("支付宝 Client 统一退款:抛出系统异常") - public void testUnifiedRefund_throwPayException() throws AlipayApiException { - // mock 方法 - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> true))) - .thenThrow(new RuntimeException("系统异常")); - // 准备请求参数 - String notifyUrl = randomURL(); - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> o.setNotifyUrl(notifyUrl)); - - // 调用,并断言 - assertThrows(PayException.class, () -> client.unifiedRefund(refundReqDTO)); - } - - @Test - @DisplayName("支付宝 Client 统一下单:参数校验不通过") - public void testUnifiedOrder_paramInvalidate() { - // 准备请求参数 - String outTradeNo = randomString(); - String notifyUrl = randomURL(); - PayOrderUnifiedReqDTO reqDTO = randomPojo(PayOrderUnifiedReqDTO.class, o -> { - o.setOutTradeNo(outTradeNo); - o.setNotifyUrl(notifyUrl); - }); - - // 调用,并断言 - assertThrows(ConstraintViolationException.class, () -> client.unifiedOrder(reqDTO)); - } - - protected PayOrderUnifiedReqDTO buildOrderUnifiedReqDTO(String notifyUrl, String outTradeNo, Integer price) { - return randomPojo(PayOrderUnifiedReqDTO.class, o -> { - o.setOutTradeNo(outTradeNo); - o.setNotifyUrl(notifyUrl); - o.setPrice(price); - o.setSubject(RandomUtil.randomString(32)); - o.setBody(RandomUtil.randomString(32)); - }); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClientTest.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClientTest.java deleted file mode 100644 index 47f10081ca..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClientTest.java +++ /dev/null @@ -1,170 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradePayModel; -import com.alipay.api.request.AlipayTradePayRequest; -import com.alipay.api.response.AlipayTradePayResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * {@link AlipayBarPayClient} 单元测试 - * - * @author jason - */ -public class AlipayBarPayClientTest extends AbstractAlipayClientTest { - - @InjectMocks - private AlipayBarPayClient client = new AlipayBarPayClient(randomLongId(), config); - - @Override - @BeforeEach - public void setUp() { - setClient(client); - } - - @Test - @DisplayName("支付宝条码支付:非免密码支付下单成功") - public void testUnifiedOrder_success() throws AlipayApiException { - // mock 方法 - String outTradeNo = randomString(); - String notifyUrl = randomURL(); - Integer price = randomInteger(); - String authCode = randomString(); - AlipayTradePayResponse response = randomPojo(AlipayTradePayResponse.class, o -> o.setSubCode("")); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertInstanceOf(AlipayTradePayModel.class, request.getBizModel()); - assertEquals(notifyUrl, request.getNotifyUrl()); - AlipayTradePayModel model = (AlipayTradePayModel) request.getBizModel(); - assertEquals(outTradeNo, model.getOutTradeNo()); - assertEquals(String.valueOf(price / 100.0), model.getTotalAmount()); - assertEquals(authCode, model.getAuthCode()); - return true; - }))).thenReturn(response); - // 准备请求参数 - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - Map extraParam = new HashMap<>(); - extraParam.put("auth_code", authCode); - reqDTO.setChannelExtras(extraParam); - - // 调用方法 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.BAR_CODE.getMode(), resp.getDisplayMode()); - assertEquals("", resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝条码支付:免密码支付下单成功") - public void testUnifiedOrder_code10000Success() throws AlipayApiException { - // mock 方法 - String outTradeNo = randomString(); - String channelNo = randomString(); - String channelUserId = randomString(); - Date payTime = randomDate(); - AlipayTradePayResponse response = randomPojo(AlipayTradePayResponse.class, o -> { - o.setSubCode(""); - o.setCode("10000"); - o.setOutTradeNo(outTradeNo); - o.setTradeNo(channelNo); - o.setBuyerUserId(channelUserId); - o.setGmtPayment(payTime); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> true))) - .thenReturn(response); - // 准备请求参数 - String authCode = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); - Map extraParam = new HashMap<>(); - extraParam.put("auth_code", authCode); - reqDTO.setChannelExtras(extraParam); - - // 下单请求 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(PayOrderStatusRespEnum.SUCCESS.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertEquals(channelNo, resp.getChannelOrderNo()); - assertEquals(channelUserId, resp.getChannelUserId()); - assertEquals(LocalDateTimeUtil.of(payTime), resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.BAR_CODE.getMode(), resp.getDisplayMode()); - assertEquals("", resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝条码支付:没有传条码") - public void testUnifiedOrder_emptyAuthCode() { - // 准备参数 - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); - - // 调用,并断言 - assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); - } - - @Test - @DisplayName("支付宝条码支付:渠道返回失败") - public void test_unified_order_channel_failed() throws AlipayApiException { - // mock 方法 - String subCode = randomString(); - String subMsg = randomString(); - AlipayTradePayResponse response = randomPojo(AlipayTradePayResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> true))) - .thenReturn(response); - // 准备请求参数 - String authCode = randomString(); - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); - Map extraParam = new HashMap<>(); - extraParam.put("auth_code", authCode); - reqDTO.setChannelExtras(extraParam); - - // 调用方法 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(CLOSED.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertNull(resp.getDisplayMode()); - assertNull(resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClientTest.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClientTest.java deleted file mode 100644 index d78caf28c5..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClientTest.java +++ /dev/null @@ -1,131 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.http.Method; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.request.AlipayTradePagePayRequest; -import com.alipay.api.response.AlipayTradePagePayResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; - -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link AlipayPcPayClient} 单元测试 - * - * @author jason - */ -public class AlipayPcPayClientTest extends AbstractAlipayClientTest { - - @InjectMocks - private AlipayPcPayClient client = new AlipayPcPayClient(randomLongId(), config); - - @Override - @BeforeEach - public void setUp() { - setClient(client); - } - - @Test - @DisplayName("支付宝 PC 网站支付:URL Display Mode 下单成功") - public void testUnifiedOrder_urlSuccess() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - AlipayTradePagePayResponse response = randomPojo(AlipayTradePagePayResponse.class, o -> o.setSubCode("")); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> true), - eq(Method.GET.name()))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - Integer price = randomInteger(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - reqDTO.setDisplayMode(null); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.URL.getMode(), resp.getDisplayMode()); - assertEquals(response.getBody(), resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 PC 网站支付:Form Display Mode 下单成功") - public void testUnifiedOrder_formSuccess() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - AlipayTradePagePayResponse response = randomPojo(AlipayTradePagePayResponse.class, o -> o.setSubCode("")); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> true), - eq(Method.POST.name()))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - Integer price = randomInteger(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - reqDTO.setDisplayMode(PayOrderDisplayModeEnum.FORM.getMode()); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.FORM.getMode(), resp.getDisplayMode()); - assertEquals(response.getBody(), resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 PC 网站支付:渠道返回失败") - public void testUnifiedOrder_channelFailed() throws AlipayApiException { - // mock 方法 - String subCode = randomString(); - String subMsg = randomString(); - AlipayTradePagePayResponse response = randomPojo(AlipayTradePagePayResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> true), - eq(Method.GET.name()))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); - reqDTO.setDisplayMode(PayOrderDisplayModeEnum.URL.getMode()); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(CLOSED.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertNull(resp.getDisplayMode()); - assertNull(resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClientTest.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClientTest.java deleted file mode 100644 index c7e1eb33f7..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClientTest.java +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.request.AlipayTradePrecreateRequest; -import com.alipay.api.response.AlipayTradePrecreateResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; - -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * {@link AlipayQrPayClient} 单元测试 - * - * @author jason - */ -public class AlipayQrPayClientTest extends AbstractAlipayClientTest { - - @InjectMocks - private AlipayQrPayClient client = new AlipayQrPayClient(randomLongId(), config); - - @BeforeEach - public void setUp() { - setClient(client); - } - - @Test - @DisplayName("支付宝扫描支付:下单成功") - public void testUnifiedOrder_success() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - String qrCode = randomString(); - Integer price = randomInteger(); - AlipayTradePrecreateResponse response = randomPojo(AlipayTradePrecreateResponse.class, o -> { - o.setQrCode(qrCode); - o.setSubCode(""); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.QR_CODE.getMode(), resp.getDisplayMode()); - assertEquals(response.getQrCode(), resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝扫描支付:渠道返回失败") - public void testUnifiedOrder_channelFailed() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - String subCode = randomString(); - String subMsg = randomString(); - Integer price = randomInteger(); - AlipayTradePrecreateResponse response = randomPojo(AlipayTradePrecreateResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - // mock - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(CLOSED.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertNull(resp.getDisplayMode()); - assertNull(resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝扫描支付, 抛出系统异常") - public void testUnifiedOrder_throwPayException() throws AlipayApiException { - // mock 方法 - String outTradeNo = randomString(); - String notifyUrl = randomURL(); - Integer price = randomInteger(); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }))).thenThrow(new RuntimeException("系统异常")); - // 准备请求参数 - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo,price); - - // 调用,并断言 - assertThrows(PayException.class, () -> client.unifiedOrder(reqDTO)); - } - - @Test - @DisplayName("支付宝 Client 统一下单:抛出业务异常") - public void testUnifiedOrder_throwServiceException() throws AlipayApiException { - // mock 方法 - String outTradeNo = randomString(); - String notifyUrl = randomURL(); - Integer price = randomInteger(); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }))).thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); - // 准备请求参数 - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - - // 调用,并断言 - assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClientTest.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClientTest.java deleted file mode 100644 index af0c7170bf..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClientTest.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.http.Method; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradeWapPayModel; -import com.alipay.api.request.AlipayTradeWapPayRequest; -import com.alipay.api.response.AlipayTradeWapPayResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; - -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link AlipayWapPayClient} 单元测试 - * - * @author jason - */ -public class AlipayWapPayClientTest extends AbstractAlipayClientTest { - - /** - * 支付宝 H5 支付 Client - */ - @InjectMocks - private AlipayWapPayClient client = new AlipayWapPayClient(randomLongId(), config); - - @BeforeEach - public void setUp() { - setClient(client); - } - - @Test - @DisplayName("支付宝 H5 支付:下单成功") - public void testUnifiedOrder_success() throws AlipayApiException { - // mock 方法 - String h5Body = randomString(); - Integer price = randomInteger(); - AlipayTradeWapPayResponse response = randomPojo(AlipayTradeWapPayResponse.class, o -> { - o.setSubCode(""); - o.setBody(h5Body); - }); - String notifyUrl = randomURL(); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> { - assertInstanceOf(AlipayTradeWapPayModel.class, request.getBizModel()); - AlipayTradeWapPayModel bizModel = (AlipayTradeWapPayModel) request.getBizModel(); - assertEquals(String.valueOf(price / 100.0), bizModel.getTotalAmount()); - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }), eq(Method.GET.name()))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.URL.getMode(), resp.getDisplayMode()); - assertEquals(response.getBody(), resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 H5 支付:渠道返回失败") - public void test_unified_order_channel_failed() throws AlipayApiException { - // mock 方法 - String subCode = randomString(); - String subMsg = randomString(); - AlipayTradeWapPayResponse response = randomPojo(AlipayTradeWapPayResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> true), - eq(Method.GET.name()))).thenReturn(response); - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(CLOSED.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertNull(resp.getDisplayMode()); - assertNull(resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClientIntegrationTest.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClientIntegrationTest.java deleted file mode 100644 index 9af11ac3fc..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClientIntegrationTest.java +++ /dev/null @@ -1,123 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; -import com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest; -import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest; -import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult; -import com.github.binarywang.wxpay.bean.result.WxPayRefundResult; -import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.time.Duration; - -import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.AbstractWxPayClient.formatDateV2; - -/** - * {@link WxBarPayClient} 的集成测试,用于快速调试微信条码支付 - * - * @author 芋道源码 - */ -@Disabled -public class WxBarPayClientIntegrationTest { - - @Test - public void testPayV2() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV2(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起支付 - WxPayMicropayRequest request = WxPayMicropayRequest.newBuilder() - .outTradeNo(String.valueOf(System.currentTimeMillis())) - .body("测试支付-body") - .detail("测试支付-detail") - .totalFee(1) // 单位分 - .timeExpire(formatDateV2(LocalDateTimeUtils.addTime(Duration.ofMinutes(2)))) - .spbillCreateIp("127.0.0.1") - .authCode("134298744426278497") - .build(); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - WxPayMicropayResult response = client.micropay(request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - @Test - public void testParseRefundNotifyV2() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV2(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行解析 - String xml = "SUCCESS"; - WxPayRefundNotifyResult response = client.parseRefundNotifyResult(xml); - System.out.println(response.getReqInfo()); - } - - @Test - public void testRefundV2() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV2(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起退款 - WxPayRefundRequest request = new WxPayRefundRequest() - .setOutTradeNo("1689545667276") - .setOutRefundNo(String.valueOf(System.currentTimeMillis())) - .setRefundFee(1) - .setRefundDesc("就是想退了") - .setTotalFee(1); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - WxPayRefundResult response = client.refund(request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - @Test - public void testRefundV3() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV2(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起退款 - WxPayRefundV3Request request = new WxPayRefundV3Request() - .setOutTradeNo("1689506325635") - .setOutRefundNo(String.valueOf(System.currentTimeMillis())) - .setAmount(new WxPayRefundV3Request.Amount().setTotal(1).setRefund(1).setCurrency("CNY")) - .setReason("就是想退了"); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - WxPayRefundV3Result response = client.refundV3(request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - private WxPayConfig buildWxPayConfigV2() { - WxPayConfig config = new WxPayConfig(); - config.setAppId("wx62056c0d5e8db250"); - config.setMchId("1545083881"); - config.setMchKey("dS1ngeN63JLr3NRbvPH9AJy3MyUxZdim"); -// config.setSignType(WxPayConstants.SignType.MD5); - config.setKeyPath("/Users/yunai/Downloads/wx_pay/apiclient_cert.p12"); - return config; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClientIntegrationTest.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClientIntegrationTest.java deleted file mode 100644 index 5e73601c2b..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClientIntegrationTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.time.Duration; - -import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.AbstractWxPayClient.formatDateV3; - -/** - * {@link WxNativePayClient} 的集成测试,用于快速调试微信扫码支付 - * - * @author 芋道源码 - */ -@Disabled -public class WxNativePayClientIntegrationTest { - - @Test - public void testPayV3() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV3(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起支付 - WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request() - .setOutTradeNo(String.valueOf(System.currentTimeMillis())) - .setDescription("测试支付-body") - .setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(1)) // 单位分 - .setTimeExpire(formatDateV3(LocalDateTimeUtils.addTime(Duration.ofMinutes(2)))) - .setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp("127.0.0.1")) - .setNotifyUrl("http://127.0.0.1:48080"); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - String response = client.createOrderV3(TradeTypeEnum.NATIVE, request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - @Test - public void testRefundV3() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV3(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起退款 - WxPayRefundV3Request request = new WxPayRefundV3Request() - .setOutTradeNo("1689545729695") - .setOutRefundNo(String.valueOf(System.currentTimeMillis())) - .setAmount(new WxPayRefundV3Request.Amount().setTotal(1).setRefund(1).setCurrency("CNY")) - .setReason("就是想退了"); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - WxPayRefundV3Result response = client.refundV3(request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - private WxPayConfig buildWxPayConfigV3() { - WxPayConfig config = new WxPayConfig(); - config.setAppId("wx62056c0d5e8db250"); - config.setMchId("1545083881"); - config.setApiV3Key("459arNsYHl1mgkiO6H9ZH5KkhFXSxaA4"); -// config.setCertSerialNo(serialNo); - config.setPrivateCertPath("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"); - config.setPrivateKeyPath("/Users/yunai/Downloads/wx_pay/apiclient_key.pem"); - return config; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-sms/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-sms/pom.xml index faa6a8d34d..c0d056c18d 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-sms/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-sms/pom.xml @@ -33,13 +33,6 @@ opentracing-util - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - - com.google.guava diff --git a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test/java/cn/iocoder/yudao/framework/sms/core/client/impl/aliyun/AliyunSmsClientTest.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test/java/cn/iocoder/yudao/framework/sms/core/client/impl/aliyun/AliyunSmsClientTest.java deleted file mode 100644 index c60cd26a1b..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test/java/cn/iocoder/yudao/framework/sms/core/client/impl/aliyun/AliyunSmsClientTest.java +++ /dev/null @@ -1,187 +0,0 @@ -package cn.iocoder.yudao.framework.sms.core.client.impl.aliyun; - -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO; -import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO; -import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO; -import cn.iocoder.yudao.framework.sms.core.enums.SmsTemplateAuditStatusEnum; -import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import com.aliyuncs.IAcsClient; -import com.aliyuncs.dysmsapi.model.v20170525.QuerySmsTemplateRequest; -import com.aliyuncs.dysmsapi.model.v20170525.QuerySmsTemplateResponse; -import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; -import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; -import com.google.common.collect.Lists; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * {@link AliyunSmsClient} 的单元测试 - * - * @author 芋道源码 - */ -public class AliyunSmsClientTest extends BaseMockitoUnitTest { - - private final SmsChannelProperties properties = new SmsChannelProperties() - .setApiKey(randomString()) // 随机一个 apiKey,避免构建报错 - .setApiSecret(randomString()) // 随机一个 apiSecret,避免构建报错 - .setSignature("芋道源码"); - - @InjectMocks - private final AliyunSmsClient smsClient = new AliyunSmsClient(properties); - - @Mock - private IAcsClient client; - - @Test - public void testDoInit() { - // 准备参数 - // mock 方法 - - // 调用 - smsClient.doInit(); - // 断言 - assertNotSame(client, ReflectUtil.getFieldValue(smsClient, "acsClient")); - } - - @Test - public void tesSendSms_success() throws Throwable { - // 准备参数 - Long sendLogId = randomLongId(); - String mobile = randomString(); - String apiTemplateId = randomString(); - List> templateParams = Lists.newArrayList( - new KeyValue<>("code", 1234), new KeyValue<>("op", "login")); - // mock 方法 - SendSmsResponse response = randomPojo(SendSmsResponse.class, o -> o.setCode("OK")); - when(client.getAcsResponse(argThat((ArgumentMatcher) acsRequest -> { - assertEquals(mobile, acsRequest.getPhoneNumbers()); - assertEquals(properties.getSignature(), acsRequest.getSignName()); - assertEquals(apiTemplateId, acsRequest.getTemplateCode()); - assertEquals(toJsonString(MapUtils.convertMap(templateParams)), acsRequest.getTemplateParam()); - assertEquals(sendLogId.toString(), acsRequest.getOutId()); - return true; - }))).thenReturn(response); - - // 调用 - SmsSendRespDTO result = smsClient.sendSms(sendLogId, mobile, - apiTemplateId, templateParams); - // 断言 - assertTrue(result.getSuccess()); - assertEquals(response.getRequestId(), result.getApiRequestId()); - assertEquals(response.getCode(), result.getApiCode()); - assertEquals(response.getMessage(), result.getApiMsg()); - assertEquals(response.getBizId(), result.getSerialNo()); - } - - @Test - public void tesSendSms_fail() throws Throwable { - // 准备参数 - Long sendLogId = randomLongId(); - String mobile = randomString(); - String apiTemplateId = randomString(); - List> templateParams = Lists.newArrayList( - new KeyValue<>("code", 1234), new KeyValue<>("op", "login")); - // mock 方法 - SendSmsResponse response = randomPojo(SendSmsResponse.class, o -> o.setCode("ERROR")); - when(client.getAcsResponse(argThat((ArgumentMatcher) acsRequest -> { - assertEquals(mobile, acsRequest.getPhoneNumbers()); - assertEquals(properties.getSignature(), acsRequest.getSignName()); - assertEquals(apiTemplateId, acsRequest.getTemplateCode()); - assertEquals(toJsonString(MapUtils.convertMap(templateParams)), acsRequest.getTemplateParam()); - assertEquals(sendLogId.toString(), acsRequest.getOutId()); - return true; - }))).thenReturn(response); - - // 调用 - SmsSendRespDTO result = smsClient.sendSms(sendLogId, mobile, apiTemplateId, templateParams); - // 断言 - assertFalse(result.getSuccess()); - assertEquals(response.getRequestId(), result.getApiRequestId()); - assertEquals(response.getCode(), result.getApiCode()); - assertEquals(response.getMessage(), result.getApiMsg()); - assertEquals(response.getBizId(), result.getSerialNo()); - } - - @Test - public void testParseSmsReceiveStatus() { - // 准备参数 - String text = "[\n" + - " {\n" + - " \"phone_number\" : \"13900000001\",\n" + - " \"send_time\" : \"2017-01-01 11:12:13\",\n" + - " \"report_time\" : \"2017-02-02 22:23:24\",\n" + - " \"success\" : true,\n" + - " \"err_code\" : \"DELIVERED\",\n" + - " \"err_msg\" : \"用户接收成功\",\n" + - " \"sms_size\" : \"1\",\n" + - " \"biz_id\" : \"12345\",\n" + - " \"out_id\" : \"67890\"\n" + - " }\n" + - "]"; - // mock 方法 - - // 调用 - List statuses = smsClient.parseSmsReceiveStatus(text); - // 断言 - assertEquals(1, statuses.size()); - assertTrue(statuses.get(0).getSuccess()); - assertEquals("DELIVERED", statuses.get(0).getErrorCode()); - assertEquals("用户接收成功", statuses.get(0).getErrorMsg()); - assertEquals("13900000001", statuses.get(0).getMobile()); - assertEquals(LocalDateTime.of(2017, 2, 2, 22, 23, 24), - statuses.get(0).getReceiveTime()); - assertEquals("12345", statuses.get(0).getSerialNo()); - assertEquals(67890L, statuses.get(0).getLogId()); - } - - @Test - public void testGetSmsTemplate() throws Throwable { - // 准备参数 - String apiTemplateId = randomString(); - // mock 方法 - QuerySmsTemplateResponse response = randomPojo(QuerySmsTemplateResponse.class, o -> { - o.setCode("OK"); - o.setTemplateStatus(1); // 设置模板通过 - }); - when(client.getAcsResponse(argThat((ArgumentMatcher) acsRequest -> { - assertEquals(apiTemplateId, acsRequest.getTemplateCode()); - return true; - }))).thenReturn(response); - - // 调用 - SmsTemplateRespDTO result = smsClient.getSmsTemplate(apiTemplateId); - // 断言 - assertEquals(response.getTemplateCode(), result.getId()); - assertEquals(response.getTemplateContent(), result.getContent()); - assertEquals(SmsTemplateAuditStatusEnum.SUCCESS.getStatus(), result.getAuditStatus()); - assertEquals(response.getReason(), result.getAuditReason()); - } - - @Test - public void testConvertSmsTemplateAuditStatus() { - assertEquals(SmsTemplateAuditStatusEnum.CHECKING.getStatus(), - smsClient.convertSmsTemplateAuditStatus(0)); - assertEquals(SmsTemplateAuditStatusEnum.SUCCESS.getStatus(), - smsClient.convertSmsTemplateAuditStatus(1)); - assertEquals(SmsTemplateAuditStatusEnum.FAIL.getStatus(), - smsClient.convertSmsTemplateAuditStatus(2)); - assertThrows(IllegalArgumentException.class, () -> smsClient.convertSmsTemplateAuditStatus(3), - "未知审核状态(3)"); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test/java/cn/iocoder/yudao/framework/sms/core/client/impl/tencent/TencentSmsClientTest.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test/java/cn/iocoder/yudao/framework/sms/core/client/impl/tencent/TencentSmsClientTest.java deleted file mode 100644 index d62eed1e1f..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test/java/cn/iocoder/yudao/framework/sms/core/client/impl/tencent/TencentSmsClientTest.java +++ /dev/null @@ -1,230 +0,0 @@ -package cn.iocoder.yudao.framework.sms.core.client.impl.tencent; - -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO; -import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO; -import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO; -import cn.iocoder.yudao.framework.sms.core.enums.SmsTemplateAuditStatusEnum; -import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import com.google.common.collect.Lists; -import com.tencentcloudapi.sms.v20210111.SmsClient; -import com.tencentcloudapi.sms.v20210111.models.DescribeSmsTemplateListResponse; -import com.tencentcloudapi.sms.v20210111.models.DescribeTemplateListStatus; -import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse; -import com.tencentcloudapi.sms.v20210111.models.SendStatus; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * {@link TencentSmsClient} 的单元测试 - * - * @author shiwp - */ -public class TencentSmsClientTest extends BaseMockitoUnitTest { - - private final SmsChannelProperties properties = new SmsChannelProperties() - .setApiKey(randomString() + " " + randomString()) // 随机一个 apiKey,避免构建报错 - .setApiSecret(randomString()) // 随机一个 apiSecret,避免构建报错 - .setSignature("芋道源码"); - - @InjectMocks - private TencentSmsClient smsClient = new TencentSmsClient(properties); - - @Mock - private SmsClient client; - - @Test - public void testDoInit() { - // 准备参数 - // mock 方法 - - // 调用 - smsClient.doInit(); - // 断言 - assertNotSame(client, ReflectUtil.getFieldValue(smsClient, "client")); - } - - @Test - public void testRefresh() { - // 准备参数 - SmsChannelProperties p = new SmsChannelProperties() - .setApiKey(randomString() + " " + randomString()) // 随机一个 apiKey,避免构建报错 - .setApiSecret(randomString()) // 随机一个 apiSecret,避免构建报错 - .setSignature("芋道源码"); - // 调用 - smsClient.refresh(p); - // 断言 - assertNotSame(client, ReflectUtil.getFieldValue(smsClient, "client")); - } - - @Test - public void testDoSendSms_success() throws Throwable { - // 准备参数 - Long sendLogId = randomLongId(); - String mobile = randomString(); - String apiTemplateId = randomString(); - List> templateParams = Lists.newArrayList( - new KeyValue<>("1", 1234), new KeyValue<>("2", "login")); - String requestId = randomString(); - String serialNo = randomString(); - // mock 方法 - SendSmsResponse response = randomPojo(SendSmsResponse.class, o -> { - o.setRequestId(requestId); - SendStatus[] sendStatuses = new SendStatus[1]; - o.setSendStatusSet(sendStatuses); - SendStatus sendStatus = new SendStatus(); - sendStatuses[0] = sendStatus; - sendStatus.setCode(TencentSmsClient.API_CODE_SUCCESS); - sendStatus.setMessage("send success"); - sendStatus.setSerialNo(serialNo); - }); - when(client.SendSms(argThat(request -> { - assertEquals(mobile, request.getPhoneNumberSet()[0]); - assertEquals(properties.getSignature(), request.getSignName()); - assertEquals(apiTemplateId, request.getTemplateId()); - assertEquals(toJsonString(ArrayUtils.toArray(new ArrayList<>(MapUtils.convertMap(templateParams).values()), String::valueOf)), - toJsonString(request.getTemplateParamSet())); - assertEquals(sendLogId, ReflectUtil.getFieldValue(JsonUtils.parseObject(request.getSessionContext(), TencentSmsClient.SessionContext.class), "logId")); - return true; - }))).thenReturn(response); - - // 调用 - SmsSendRespDTO result = smsClient.sendSms(sendLogId, mobile, apiTemplateId, templateParams); - // 断言 - assertTrue(result.getSuccess()); - assertEquals(response.getRequestId(), result.getApiRequestId()); - assertEquals(response.getSendStatusSet()[0].getCode(), result.getApiCode()); - assertEquals(response.getSendStatusSet()[0].getMessage(), result.getApiMsg()); - assertEquals(response.getSendStatusSet()[0].getSerialNo(), result.getSerialNo()); - } - - @Test - public void testDoSendSms_fail() throws Throwable { - // 准备参数 - Long sendLogId = randomLongId(); - String mobile = randomString(); - String apiTemplateId = randomString(); - List> templateParams = Lists.newArrayList( - new KeyValue<>("1", 1234), new KeyValue<>("2", "login")); - String requestId = randomString(); - String serialNo = randomString(); - // mock 方法 - SendSmsResponse response = randomPojo(SendSmsResponse.class, o -> { - o.setRequestId(requestId); - SendStatus[] sendStatuses = new SendStatus[1]; - o.setSendStatusSet(sendStatuses); - SendStatus sendStatus = new SendStatus(); - sendStatuses[0] = sendStatus; - sendStatus.setCode("ERROR"); - sendStatus.setMessage("send success"); - sendStatus.setSerialNo(serialNo); - }); - when(client.SendSms(argThat(request -> { - assertEquals(mobile, request.getPhoneNumberSet()[0]); - assertEquals(properties.getSignature(), request.getSignName()); - assertEquals(apiTemplateId, request.getTemplateId()); - assertEquals(toJsonString(ArrayUtils.toArray(new ArrayList<>(MapUtils.convertMap(templateParams).values()), String::valueOf)), - toJsonString(request.getTemplateParamSet())); - assertEquals(sendLogId, ReflectUtil.getFieldValue(JsonUtils.parseObject(request.getSessionContext(), TencentSmsClient.SessionContext.class), "logId")); - return true; - }))).thenReturn(response); - - // 调用 - SmsSendRespDTO result = smsClient.sendSms(sendLogId, mobile, apiTemplateId, templateParams); - // 断言 - assertFalse(result.getSuccess()); - assertEquals(response.getRequestId(), result.getApiRequestId()); - assertEquals(response.getSendStatusSet()[0].getCode(), result.getApiCode()); - assertEquals(response.getSendStatusSet()[0].getMessage(), result.getApiMsg()); - assertEquals(response.getSendStatusSet()[0].getSerialNo(), result.getSerialNo()); - } - - @Test - public void testParseSmsReceiveStatus() { - // 准备参数 - String text = "[\n" + - " {\n" + - " \"user_receive_time\": \"2015-10-17 08:03:04\",\n" + - " \"nationcode\": \"86\",\n" + - " \"mobile\": \"13900000001\",\n" + - " \"report_status\": \"SUCCESS\",\n" + - " \"errmsg\": \"DELIVRD\",\n" + - " \"description\": \"用户短信送达成功\",\n" + - " \"sid\": \"12345\",\n" + - " \"ext\": {\"logId\":\"67890\"}\n" + - " }\n" + - "]"; - // mock 方法 - - // 调用 - List statuses = smsClient.parseSmsReceiveStatus(text); - // 断言 - assertEquals(1, statuses.size()); - assertTrue(statuses.get(0).getSuccess()); - assertEquals("DELIVRD", statuses.get(0).getErrorCode()); - assertEquals("用户短信送达成功", statuses.get(0).getErrorMsg()); - assertEquals("13900000001", statuses.get(0).getMobile()); - assertEquals(LocalDateTime.of(2015, 10, 17, 8, 3, 4), statuses.get(0).getReceiveTime()); - assertEquals("12345", statuses.get(0).getSerialNo()); - assertEquals(67890L, statuses.get(0).getLogId()); - } - - @Test - public void testGetSmsTemplate() throws Throwable { - // 准备参数 - Long apiTemplateId = randomLongId(); - String requestId = randomString(); - - // mock 方法 - DescribeSmsTemplateListResponse response = randomPojo(DescribeSmsTemplateListResponse.class, o -> { - DescribeTemplateListStatus[] describeTemplateListStatuses = new DescribeTemplateListStatus[1]; - DescribeTemplateListStatus templateStatus = new DescribeTemplateListStatus(); - templateStatus.setTemplateId(apiTemplateId); - templateStatus.setStatusCode(0L);// 设置模板通过 - describeTemplateListStatuses[0] = templateStatus; - o.setDescribeTemplateStatusSet(describeTemplateListStatuses); - o.setRequestId(requestId); - }); - when(client.DescribeSmsTemplateList(argThat(request -> { - assertEquals(apiTemplateId, request.getTemplateIdSet()[0]); - return true; - }))).thenReturn(response); - - // 调用 - SmsTemplateRespDTO result = smsClient.getSmsTemplate(apiTemplateId.toString()); - // 断言 - assertEquals(response.getDescribeTemplateStatusSet()[0].getTemplateId().toString(), result.getId()); - assertEquals(response.getDescribeTemplateStatusSet()[0].getTemplateContent(), result.getContent()); - assertEquals(SmsTemplateAuditStatusEnum.SUCCESS.getStatus(), result.getAuditStatus()); - assertEquals(response.getDescribeTemplateStatusSet()[0].getReviewReply(), result.getAuditReason()); - } - - @Test - public void testConvertSmsTemplateAuditStatus() { - assertEquals(SmsTemplateAuditStatusEnum.SUCCESS.getStatus(), - smsClient.convertSmsTemplateAuditStatus(0)); - assertEquals(SmsTemplateAuditStatusEnum.CHECKING.getStatus(), - smsClient.convertSmsTemplateAuditStatus(1)); - assertEquals(SmsTemplateAuditStatusEnum.FAIL.getStatus(), - smsClient.convertSmsTemplateAuditStatus(-1)); - assertThrows(IllegalArgumentException.class, () -> smsClient.convertSmsTemplateAuditStatus(3), - "未知审核状态(3)"); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml index c1a537613e..b831767fc6 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml @@ -66,13 +66,6 @@ true - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - - com.google.guava diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/pom.xml b/yudao-framework/yudao-spring-boot-starter-desensitize/pom.xml index c4a96ebe1e..90d30fa1c3 100644 --- a/yudao-framework/yudao-spring-boot-starter-desensitize/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-desensitize/pom.xml @@ -28,11 +28,5 @@ jackson-databind - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/src/test/java/cn/iocoder/yudao/framework/desensitize/core/DesensitizeTest.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/test/java/cn/iocoder/yudao/framework/desensitize/core/DesensitizeTest.java deleted file mode 100644 index c308a0eb55..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-desensitize/src/test/java/cn/iocoder/yudao/framework/desensitize/core/DesensitizeTest.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.framework.desensitize.core; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.desensitize.core.regex.annotation.EmailDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.regex.annotation.RegexDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.annotation.Address; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.BankCardDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.CarLicenseDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.ChineseNameDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.FixedPhoneDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.IdCardDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.PasswordDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.MobileDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.SliderDesensitize; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import lombok.Data; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link DesensitizeTest} 的单元测试 - */ -public class DesensitizeTest extends BaseMockitoUnitTest { - - @Test - public void test() { - // 准备参数 - DesensitizeDemo desensitizeDemo = new DesensitizeDemo(); - desensitizeDemo.setNickname("芋道源码"); - desensitizeDemo.setBankCard("9988002866797031"); - desensitizeDemo.setCarLicense("粤A66666"); - desensitizeDemo.setFixedPhone("01086551122"); - desensitizeDemo.setIdCard("530321199204074611"); - desensitizeDemo.setPassword("123456"); - desensitizeDemo.setPhoneNumber("13248765917"); - desensitizeDemo.setSlider1("ABCDEFG"); - desensitizeDemo.setSlider2("ABCDEFG"); - desensitizeDemo.setSlider3("ABCDEFG"); - desensitizeDemo.setEmail("1@email.com"); - desensitizeDemo.setRegex("你好,我是芋道源码"); - desensitizeDemo.setAddress("北京市海淀区上地十街10号"); - desensitizeDemo.setOrigin("芋道源码"); - - // 调用 - DesensitizeDemo d = JsonUtils.parseObject(JsonUtils.toJsonString(desensitizeDemo), DesensitizeDemo.class); - // 断言 - assertNotNull(d); - assertEquals("芋***", d.getNickname()); - assertEquals("998800********31", d.getBankCard()); - assertEquals("粤A6***6", d.getCarLicense()); - assertEquals("0108*****22", d.getFixedPhone()); - assertEquals("530321**********11", d.getIdCard()); - assertEquals("******", d.getPassword()); - assertEquals("132****5917", d.getPhoneNumber()); - assertEquals("#######", d.getSlider1()); - assertEquals("ABC*EFG", d.getSlider2()); - assertEquals("*******", d.getSlider3()); - assertEquals("1****@email.com", d.getEmail()); - assertEquals("你好,我是*", d.getRegex()); - assertEquals("北京市海淀区上地十街10号*", d.getAddress()); - assertEquals("芋道源码", d.getOrigin()); - } - - @Data - public static class DesensitizeDemo { - - @ChineseNameDesensitize - private String nickname; - @BankCardDesensitize - private String bankCard; - @CarLicenseDesensitize - private String carLicense; - @FixedPhoneDesensitize - private String fixedPhone; - @IdCardDesensitize - private String idCard; - @PasswordDesensitize - private String password; - @MobileDesensitize - private String phoneNumber; - @SliderDesensitize(prefixKeep = 6, suffixKeep = 1, replacer = "#") - private String slider1; - @SliderDesensitize(prefixKeep = 3, suffixKeep = 3) - private String slider2; - @SliderDesensitize(prefixKeep = 10) - private String slider3; - @EmailDesensitize - private String email; - @RegexDesensitize(regex = "芋道源码", replacer = "*") - private String regex; - @Address - private String address; - private String origin; - - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/src/test/java/cn/iocoder/yudao/framework/desensitize/core/annotation/Address.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/test/java/cn/iocoder/yudao/framework/desensitize/core/annotation/Address.java deleted file mode 100644 index 735d25b346..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-desensitize/src/test/java/cn/iocoder/yudao/framework/desensitize/core/annotation/Address.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.framework.desensitize.core.annotation; - -import cn.iocoder.yudao.framework.desensitize.core.DesensitizeTest; -import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy; -import cn.iocoder.yudao.framework.desensitize.core.handler.AddressHandler; -import com.fasterxml.jackson.annotation.JacksonAnnotationsInside; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 地址 - * - * 用于 {@link DesensitizeTest} 测试使用 - * - * @author gaibu - */ -@Documented -@Target({ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -@JacksonAnnotationsInside -@DesensitizeBy(handler = AddressHandler.class) -public @interface Address { - - String replacer() default "*"; - -} diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/src/test/java/cn/iocoder/yudao/framework/desensitize/core/handler/AddressHandler.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/test/java/cn/iocoder/yudao/framework/desensitize/core/handler/AddressHandler.java deleted file mode 100644 index 7a8455f8d1..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-desensitize/src/test/java/cn/iocoder/yudao/framework/desensitize/core/handler/AddressHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.framework.desensitize.core.handler; - -import cn.iocoder.yudao.framework.desensitize.core.DesensitizeTest; -import cn.iocoder.yudao.framework.desensitize.core.base.handler.DesensitizationHandler; -import cn.iocoder.yudao.framework.desensitize.core.annotation.Address; - -/** - * {@link Address} 的脱敏处理器 - * - * 用于 {@link DesensitizeTest} 测试使用 - */ -public class AddressHandler implements DesensitizationHandler

{ - - @Override - public String desensitize(String origin, Address annotation) { - return origin + annotation.replacer(); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-file/pom.xml b/yudao-framework/yudao-spring-boot-starter-file/pom.xml index 5ce48a857f..93fad220b5 100644 --- a/yudao-framework/yudao-spring-boot-starter-file/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-file/pom.xml @@ -72,12 +72,6 @@ minio - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - diff --git a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/config/package-info.java b/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/config/package-info.java deleted file mode 100644 index 113f3e5e5f..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/config/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位,避免 package 无法提交到 Git 仓库 - */ -package cn.iocoder.yudao.framework.file.config; diff --git a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/ftp/FtpFileClientTest.java b/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/ftp/FtpFileClientTest.java deleted file mode 100644 index 619e52db88..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/ftp/FtpFileClientTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.framework.file.core.client.ftp; - -import cn.hutool.core.io.resource.ResourceUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.extra.ftp.FtpMode; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -public class FtpFileClientTest { - - @Test - @Disabled - public void test() { - // 创建客户端 - FtpFileClientConfig config = new FtpFileClientConfig(); - config.setDomain("http://127.0.0.1:48080"); - config.setBasePath("/home/ftp"); - config.setHost("kanchai.club"); - config.setPort(221); - config.setUsername(""); - config.setPassword(""); - config.setMode(FtpMode.Passive.name()); - FtpFileClient client = new FtpFileClient(0L, config); - client.init(); - // 上传文件 - String path = IdUtil.fastSimpleUUID() + ".jpg"; - byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); - String fullPath = client.upload(content, path, "image/jpeg"); - System.out.println("访问地址:" + fullPath); - if (false) { - byte[] bytes = client.getContent(path); - System.out.println("文件内容:" + bytes); - } - if (false) { - client.delete(path); - } - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/local/LocalFileClientTest.java b/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/local/LocalFileClientTest.java deleted file mode 100644 index d48609bc6c..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/local/LocalFileClientTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.framework.file.core.client.local; - -import cn.hutool.core.io.resource.ResourceUtil; -import cn.hutool.core.util.IdUtil; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -public class LocalFileClientTest { - - @Test - @Disabled - public void test() { - // 创建客户端 - LocalFileClientConfig config = new LocalFileClientConfig(); - config.setDomain("http://127.0.0.1:48080"); - config.setBasePath("/Users/yunai/file_test"); - LocalFileClient client = new LocalFileClient(0L, config); - client.init(); - // 上传文件 - String path = IdUtil.fastSimpleUUID() + ".jpg"; - byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); - String fullPath = client.upload(content, path, "image/jpeg"); - System.out.println("访问地址:" + fullPath); - client.delete(path); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClientTest.java b/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClientTest.java deleted file mode 100644 index cbd41ab3e0..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClientTest.java +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.framework.file.core.client.s3; - -import cn.hutool.core.io.resource.ResourceUtil; -import cn.hutool.core.util.IdUtil; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import jakarta.validation.Validation; - -public class S3FileClientTest { - - @Test - @Disabled // MinIO,如果要集成测试,可以注释本行 - public void testMinIO() throws Exception { - S3FileClientConfig config = new S3FileClientConfig(); - // 配置成你自己的 - config.setAccessKey("admin"); - config.setAccessSecret("password"); - config.setBucket("yudaoyuanma"); - config.setDomain(null); - // 默认 9000 endpoint - config.setEndpoint("http://127.0.0.1:9000"); - - // 执行上传 - testExecuteUpload(config); - } - - @Test - @Disabled // 阿里云 OSS,如果要集成测试,可以注释本行 - public void testAliyun() throws Exception { - S3FileClientConfig config = new S3FileClientConfig(); - // 配置成你自己的 - config.setAccessKey(System.getenv("ALIYUN_ACCESS_KEY")); - config.setAccessSecret(System.getenv("ALIYUN_SECRET_KEY")); - config.setBucket("yunai-aoteman"); - config.setDomain(null); // 如果有自定义域名,则可以设置。http://ali-oss.iocoder.cn - // 默认北京的 endpoint - config.setEndpoint("oss-cn-beijing.aliyuncs.com"); - - // 执行上传 - testExecuteUpload(config); - } - - @Test - @Disabled // 腾讯云 COS,如果要集成测试,可以注释本行 - public void testQCloud() throws Exception { - S3FileClientConfig config = new S3FileClientConfig(); - // 配置成你自己的 - config.setAccessKey(System.getenv("QCLOUD_ACCESS_KEY")); - config.setAccessSecret(System.getenv("QCLOUD_SECRET_KEY")); - config.setBucket("aoteman-1255880240"); - config.setDomain(null); // 如果有自定义域名,则可以设置。http://tengxun-oss.iocoder.cn - // 默认上海的 endpoint - config.setEndpoint("cos.ap-shanghai.myqcloud.com"); - - // 执行上传 - testExecuteUpload(config); - } - - @Test - @Disabled // 七牛云存储,如果要集成测试,可以注释本行 - public void testQiniu() throws Exception { - S3FileClientConfig config = new S3FileClientConfig(); - // 配置成你自己的 -// config.setAccessKey(System.getenv("QINIU_ACCESS_KEY")); -// config.setAccessSecret(System.getenv("QINIU_SECRET_KEY")); - config.setAccessKey("b7yvuhBSAGjmtPhMFcn9iMOxUOY_I06cA_p0ZUx8"); - config.setAccessSecret("kXM1l5ia1RvSX3QaOEcwI3RLz3Y2rmNszWonKZtP"); - config.setBucket("ruoyi-vue-pro"); - config.setDomain("http://test.yudao.iocoder.cn"); // 如果有自定义域名,则可以设置。http://static.yudao.iocoder.cn - // 默认上海的 endpoint - config.setEndpoint("s3-cn-south-1.qiniucs.com"); - - // 执行上传 - testExecuteUpload(config); - } - - @Test - @Disabled // 华为云存储,如果要集成测试,可以注释本行 - public void testHuaweiCloud() throws Exception { - S3FileClientConfig config = new S3FileClientConfig(); - // 配置成你自己的 -// config.setAccessKey(System.getenv("HUAWEI_CLOUD_ACCESS_KEY")); -// config.setAccessSecret(System.getenv("HUAWEI_CLOUD_SECRET_KEY")); - config.setBucket("yudao"); - config.setDomain(null); // 如果有自定义域名,则可以设置。 - // 默认上海的 endpoint - config.setEndpoint("obs.cn-east-3.myhuaweicloud.com"); - - // 执行上传 - testExecuteUpload(config); - } - - private void testExecuteUpload(S3FileClientConfig config) throws Exception { - // 校验配置 - ValidationUtils.validate(Validation.buildDefaultValidatorFactory().getValidator(), config); - // 创建 Client - S3FileClient client = new S3FileClient(0L, config); - client.init(); - // 上传文件 - String path = IdUtil.fastSimpleUUID() + ".jpg"; - byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); - String fullPath = client.upload(content, path, "image/jpeg"); - System.out.println("访问地址:" + fullPath); - // 读取文件 - if (true) { - byte[] bytes = client.getContent(path); - System.out.println("文件内容:" + bytes.length); - } - // 删除文件 - if (false) { - client.delete(path); - } - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/sftp/SftpFileClientTest.java b/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/sftp/SftpFileClientTest.java deleted file mode 100644 index 4785c0d892..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/sftp/SftpFileClientTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.framework.file.core.client.sftp; - -import cn.hutool.core.io.resource.ResourceUtil; -import cn.hutool.core.util.IdUtil; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -public class SftpFileClientTest { - - @Test - @Disabled - public void test() { - // 创建客户端 - SftpFileClientConfig config = new SftpFileClientConfig(); - config.setDomain("http://127.0.0.1:48080"); - config.setBasePath("/home/ftp"); - config.setHost("kanchai.club"); - config.setPort(222); - config.setUsername(""); - config.setPassword(""); - SftpFileClient client = new SftpFileClient(0L, config); - client.init(); - // 上传文件 - String path = IdUtil.fastSimpleUUID() + ".jpg"; - byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); - String fullPath = client.upload(content, path, "image/jpeg"); - System.out.println("访问地址:" + fullPath); - if (false) { - byte[] bytes = client.getContent(path); - System.out.println("文件内容:" + bytes); - } - if (false) { - client.delete(path); - } - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/enums/package-info.java b/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/enums/package-info.java deleted file mode 100644 index e1da5db239..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/enums/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位,避免 package 无法提交到 Git 仓库 - */ -package cn.iocoder.yudao.framework.file.core.enums; diff --git a/yudao-framework/yudao-spring-boot-starter-file/src/test/resources/file/erweima.jpg b/yudao-framework/yudao-spring-boot-starter-file/src/test/resources/file/erweima.jpg deleted file mode 100644 index 1447283cdf..0000000000 Binary files a/yudao-framework/yudao-spring-boot-starter-file/src/test/resources/file/erweima.jpg and /dev/null differ diff --git a/yudao-framework/yudao-spring-boot-starter-flowable/pom.xml b/yudao-framework/yudao-spring-boot-starter-flowable/pom.xml deleted file mode 100644 index ac24f27aeb..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-flowable/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - yudao-framework - cn.iocoder.boot - ${revision} - - 4.0.0 - - yudao-spring-boot-starter-flowable - - - - cn.iocoder.boot - yudao-common - - - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - org.flowable - flowable-spring-boot-starter-process - - - org.flowable - flowable-spring-boot-starter-actuator - - - - diff --git a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/config/YudaoFlowableConfiguration.java b/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/config/YudaoFlowableConfiguration.java deleted file mode 100644 index 7c29a64626..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/config/YudaoFlowableConfiguration.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.framework.flowable.config; - -import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum; -import cn.iocoder.yudao.framework.flowable.core.web.FlowableWebFilter; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.core.task.AsyncListenableTaskExecutor; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -@AutoConfiguration -public class YudaoFlowableConfiguration { - - /** - * 参考 {@link org.flowable.spring.boot.FlowableJobConfiguration} 类,创建对应的 AsyncListenableTaskExecutor Bean - * - * 如果不创建,会导致项目启动时,Flowable 报错的问题 - */ - @Bean - public AsyncListenableTaskExecutor taskExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(8); - executor.setMaxPoolSize(8); - executor.setQueueCapacity(100); - executor.setThreadNamePrefix("flowable-task-Executor-"); - executor.setAwaitTerminationSeconds(30); - executor.setWaitForTasksToCompleteOnShutdown(true); - executor.setAllowCoreThreadTimeOut(true); - executor.initialize(); - return executor; - } - - /** - * 配置 flowable Web 过滤器 - */ - @Bean - public FilterRegistrationBean flowableWebFilter() { - FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - registrationBean.setFilter(new FlowableWebFilter()); - registrationBean.setOrder(WebFilterOrderEnum.FLOWABLE_FILTER); - return registrationBean; - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/context/FlowableContextHolder.java b/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/context/FlowableContextHolder.java deleted file mode 100644 index efc6d5340d..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/context/FlowableContextHolder.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.framework.flowable.core.context; - -import cn.hutool.core.collection.CollUtil; -import com.alibaba.ttl.TransmittableThreadLocal; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * 工作流--用户用到的上下文相关信息 - */ -public class FlowableContextHolder { - - private static final ThreadLocal>> ASSIGNEE = new TransmittableThreadLocal<>(); - - /** - * 通过流程任务的定义 key ,拿到提前选好的审批人 - * 此方法目的:首次创建流程实例时,数据库中还查询不到 assignee 字段,所以存入上下文中获取 - * - * @param taskDefinitionKey 流程任务 key - * @return 审批人 ID 集合 - */ - public static List getAssigneeByTaskDefinitionKey(String taskDefinitionKey) { - if (CollUtil.isNotEmpty(ASSIGNEE.get())) { - return ASSIGNEE.get().get(taskDefinitionKey); - } - return Collections.emptyList(); - } - - /** - * 存入提前选好的审批人到上下文线程变量中 - * - * @param assignee 流程任务 key -> 审批人 ID 炅和 - */ - public static void setAssignee(Map> assignee) { - ASSIGNEE.set(assignee); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/package-info.java b/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/package-info.java deleted file mode 100644 index de8d6279d7..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.framework.flowable.core; diff --git a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/util/BpmnModelUtils.java b/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/util/BpmnModelUtils.java deleted file mode 100644 index 7b23a467a0..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/util/BpmnModelUtils.java +++ /dev/null @@ -1,309 +0,0 @@ -package cn.iocoder.yudao.framework.flowable.core.util; - -import cn.hutool.core.collection.CollUtil; -import org.flowable.bpmn.converter.BpmnXMLConverter; -import org.flowable.bpmn.model.Process; -import org.flowable.bpmn.model.*; - -import java.util.*; - -/** - * 流程模型转操作工具类 - */ -public class BpmnModelUtils { - - /** - * 根据节点,获取入口连线 - * - * @param source 起始节点 - * @return 入口连线列表 - */ - public static List getElementIncomingFlows(FlowElement source) { - if (source instanceof FlowNode) { - return ((FlowNode) source).getIncomingFlows(); - } - return new ArrayList<>(); - } - - /** - * 根据节点,获取出口连线 - * - * @param source 起始节点 - * @return 出口连线列表 - */ - public static List getElementOutgoingFlows(FlowElement source) { - if (source instanceof FlowNode) { - return ((FlowNode) source).getOutgoingFlows(); - } - return new ArrayList<>(); - } - - /** - * 获取流程元素信息 - * - * @param model bpmnModel 对象 - * @param flowElementId 元素 ID - * @return 元素信息 - */ - public static FlowElement getFlowElementById(BpmnModel model, String flowElementId) { - Process process = model.getMainProcess(); - return process.getFlowElement(flowElementId); - } - - /** - * 获得 BPMN 流程中,指定的元素们 - * - * @param model - * @param clazz 指定元素。例如说,{@link UserTask}、{@link Gateway} 等等 - * @return 元素们 - */ - public static List getBpmnModelElements(BpmnModel model, Class clazz) { - List result = new ArrayList<>(); - model.getProcesses().forEach(process -> { - process.getFlowElements().forEach(flowElement -> { - if (flowElement.getClass().isAssignableFrom(clazz)) { - result.add((T) flowElement); - } - }); - }); - return result; - } - - /** - * 比较 两个bpmnModel 是否相同 - * @param oldModel 老的bpmn model - * @param newModel 新的bpmn model - */ - public static boolean equals(BpmnModel oldModel, BpmnModel newModel) { - // 由于 BpmnModel 未提供 equals 方法,所以只能转成字节数组,进行比较 - return Arrays.equals(getBpmnBytes(oldModel), getBpmnBytes(newModel)); - } - - /** - * 把 bpmnModel 转换成 byte[] - * @param model bpmnModel - */ - public static byte[] getBpmnBytes(BpmnModel model) { - if (model == null) { - return new byte[0]; - } - BpmnXMLConverter converter = new BpmnXMLConverter(); - return converter.convertToXML(model); - } - - // ========== 遍历相关的方法 ========== - - /** - * 找到 source 节点之前的所有用户任务节点 - * - * @param source 起始节点 - * @param hasSequenceFlow 已经经过的连线的 ID,用于判断线路是否重复 - * @param userTaskList 已找到的用户任务节点 - * @return 用户任务节点 数组 - */ - public static List getPreviousUserTaskList(FlowElement source, Set hasSequenceFlow, List userTaskList) { - userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; - hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; - // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 - if (source instanceof StartEvent && source.getSubProcess() != null) { - userTaskList = getPreviousUserTaskList(source.getSubProcess(), hasSequenceFlow, userTaskList); - } - - // 根据类型,获取入口连线 - List sequenceFlows = getElementIncomingFlows(source); - if (sequenceFlows == null) { - return userTaskList; - } - // 循环找到目标元素 - for (SequenceFlow sequenceFlow : sequenceFlows) { - // 如果发现连线重复,说明循环了,跳过这个循环 - if (hasSequenceFlow.contains(sequenceFlow.getId())) { - continue; - } - // 添加已经走过的连线 - hasSequenceFlow.add(sequenceFlow.getId()); - // 类型为用户节点,则新增父级节点 - if (sequenceFlow.getSourceFlowElement() instanceof UserTask) { - userTaskList.add((UserTask) sequenceFlow.getSourceFlowElement()); - } - // 类型为子流程,则添加子流程开始节点出口处相连的节点 - if (sequenceFlow.getSourceFlowElement() instanceof SubProcess) { - // 获取子流程用户任务节点 - List childUserTaskList = findChildProcessUserTaskList((StartEvent) ((SubProcess) sequenceFlow.getSourceFlowElement()).getFlowElements().toArray()[0], null, null); - // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 - if (CollUtil.isNotEmpty(childUserTaskList)) { - userTaskList.addAll(childUserTaskList); - } - } - // 继续迭代 - userTaskList = getPreviousUserTaskList(sequenceFlow.getSourceFlowElement(), hasSequenceFlow, userTaskList); - } - return userTaskList; - } - - /** - * 迭代获取子流程用户任务节点 - * - * @param source 起始节点 - * @param hasSequenceFlow 已经经过的连线的 ID,用于判断线路是否重复 - * @param userTaskList 需要撤回的用户任务列表 - * @return 用户任务节点 - */ - public static List findChildProcessUserTaskList(FlowElement source, Set hasSequenceFlow, List userTaskList) { - hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; - userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; - - // 根据类型,获取出口连线 - List sequenceFlows = getElementOutgoingFlows(source); - if (sequenceFlows == null) { - return userTaskList; - } - // 循环找到目标元素 - for (SequenceFlow sequenceFlow : sequenceFlows) { - // 如果发现连线重复,说明循环了,跳过这个循环 - if (hasSequenceFlow.contains(sequenceFlow.getId())) { - continue; - } - // 添加已经走过的连线 - hasSequenceFlow.add(sequenceFlow.getId()); - // 如果为用户任务类型,且任务节点的 Key 正在运行的任务中存在,添加 - if (sequenceFlow.getTargetFlowElement() instanceof UserTask) { - userTaskList.add((UserTask) sequenceFlow.getTargetFlowElement()); - continue; - } - // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 - if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { - List childUserTaskList = findChildProcessUserTaskList((FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), hasSequenceFlow, null); - // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 - if (CollUtil.isNotEmpty(childUserTaskList)) { - userTaskList.addAll(childUserTaskList); - continue; - } - } - // 继续迭代 - userTaskList = findChildProcessUserTaskList(sequenceFlow.getTargetFlowElement(), hasSequenceFlow, userTaskList); - } - return userTaskList; - } - - - /** - * 迭代从后向前扫描,判断目标节点相对于当前节点是否是串行 - * 不存在直接回退到子流程中的情况,但存在从子流程出去到父流程情况 - * - * @param source 起始节点 - * @param target 目标节点 - * @param visitedElements 已经经过的连线的 ID,用于判断线路是否重复 - * @return 结果 - */ - public static boolean isSequentialReachable(FlowElement source, FlowElement target, Set visitedElements) { - visitedElements = visitedElements == null ? new HashSet<>() : visitedElements; - // 不能是开始事件和子流程 - if (source instanceof StartEvent && isInEventSubprocess(source)) { - return false; - } - - // 根据类型,获取入口连线 - List sequenceFlows = getElementIncomingFlows(source); - if (CollUtil.isEmpty(sequenceFlows)) { - return true; - } - // 循环找到目标元素 - for (SequenceFlow sequenceFlow : sequenceFlows) { - // 如果发现连线重复,说明循环了,跳过这个循环 - if (visitedElements.contains(sequenceFlow.getId())) { - continue; - } - // 添加已经走过的连线 - visitedElements.add(sequenceFlow.getId()); - // 这条线路存在目标节点,这条线路完成,进入下个线路 - FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement(); - if (target.getId().equals(sourceFlowElement.getId())) { - continue; - } - // 如果目标节点为并行网关,则不继续 - if (sourceFlowElement instanceof ParallelGateway) { - return false; - } - // 否则就继续迭代 - if (!isSequentialReachable(sourceFlowElement, target, visitedElements)) { - return false; - } - } - return true; - } - - /** - * 判断当前节点是否属于不同的子流程 - * - * @param flowElement 被判断的节点 - * @return true 表示属于子流程 - */ - private static boolean isInEventSubprocess(FlowElement flowElement) { - FlowElementsContainer flowElementsContainer = flowElement.getParentContainer(); - while (flowElementsContainer != null) { - if (flowElementsContainer instanceof EventSubProcess) { - return true; - } - - if (flowElementsContainer instanceof FlowElement) { - flowElementsContainer = ((FlowElement) flowElementsContainer).getParentContainer(); - } else { - flowElementsContainer = null; - } - } - return false; - } - - /** - * 根据正在运行的任务节点,迭代获取子级任务节点列表,向后找 - * - * @param source 起始节点 - * @param runTaskKeyList 正在运行的任务 Key,用于校验任务节点是否是正在运行的节点 - * @param hasSequenceFlow 已经经过的连线的 ID,用于判断线路是否重复 - * @param userTaskList 需要撤回的用户任务列表 - * @return 子级任务节点列表 - */ - public static List iteratorFindChildUserTasks(FlowElement source, List runTaskKeyList, - Set hasSequenceFlow, List userTaskList) { - hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; - userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; - // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 - if (source instanceof StartEvent && source.getSubProcess() != null) { - userTaskList = iteratorFindChildUserTasks(source.getSubProcess(), runTaskKeyList, hasSequenceFlow, userTaskList); - } - - // 根据类型,获取出口连线 - List sequenceFlows = getElementOutgoingFlows(source); - if (sequenceFlows == null) { - return userTaskList; - } - // 循环找到目标元素 - for (SequenceFlow sequenceFlow : sequenceFlows) { - // 如果发现连线重复,说明循环了,跳过这个循环 - if (hasSequenceFlow.contains(sequenceFlow.getId())) { - continue; - } - // 添加已经走过的连线 - hasSequenceFlow.add(sequenceFlow.getId()); - // 如果为用户任务类型,且任务节点的 Key 正在运行的任务中存在,添加 - if (sequenceFlow.getTargetFlowElement() instanceof UserTask && runTaskKeyList.contains((sequenceFlow.getTargetFlowElement()).getId())) { - userTaskList.add((UserTask) sequenceFlow.getTargetFlowElement()); - continue; - } - // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 - if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { - List childUserTaskList = iteratorFindChildUserTasks((FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), runTaskKeyList, hasSequenceFlow, null); - // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 - if (CollUtil.isNotEmpty(childUserTaskList)) { - userTaskList.addAll(childUserTaskList); - continue; - } - } - // 继续迭代 - userTaskList = iteratorFindChildUserTasks(sequenceFlow.getTargetFlowElement(), runTaskKeyList, hasSequenceFlow, userTaskList); - } - return userTaskList; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/util/FlowableUtils.java b/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/util/FlowableUtils.java deleted file mode 100644 index 2a0fc38ac5..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/util/FlowableUtils.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.framework.flowable.core.util; - -import org.flowable.common.engine.impl.identity.Authentication; - -/** - * Flowable 相关的工具方法 - * - * @author 芋道源码 - */ -public class FlowableUtils { - - // ========== User 相关的工具方法 ========== - - public static void setAuthenticatedUserId(Long userId) { - Authentication.setAuthenticatedUserId(String.valueOf(userId)); - } - - public static void clearAuthenticatedUserId() { - Authentication.setAuthenticatedUserId(null); - } - - // ========== Execution 相关的工具方法 ========== - - public static String formatCollectionVariable(String activityId) { - return activityId + "_assignees"; - } - - public static String formatCollectionElementVariable(String activityId) { - return activityId + "_assignee"; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/web/FlowableWebFilter.java b/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/web/FlowableWebFilter.java deleted file mode 100644 index d2135290fd..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/web/FlowableWebFilter.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.framework.flowable.core.web; - -import cn.iocoder.yudao.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import org.springframework.web.filter.OncePerRequestFilter; - -import jakarta.servlet.FilterChain; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import java.io.IOException; -/** - * flowable Web 过滤器,将 userId 设置到 {@link org.flowable.common.engine.impl.identity.Authentication} 中 - * - * @author jason - */ -public class FlowableWebFilter extends OncePerRequestFilter { - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) - throws ServletException, IOException { - try { - // 设置工作流的用户 - Long userId = SecurityFrameworkUtils.getLoginUserId(); - if (userId != null) { - FlowableUtils.setAuthenticatedUserId(userId); - } - // 过滤 - chain.doFilter(request, response); - } finally { - // 清理 - FlowableUtils.clearAuthenticatedUserId(); - } - } -} diff --git a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/package-info.java b/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/package-info.java deleted file mode 100644 index 324d3de0ec..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.framework.flowable; diff --git a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/yudao-framework/yudao-spring-boot-starter-flowable/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 1df61598ce..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1 +0,0 @@ -cn.iocoder.yudao.framework.flowable.config.YudaoFlowableConfiguration \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-test/pom.xml b/yudao-framework/yudao-spring-boot-starter-test/pom.xml deleted file mode 100644 index 04576fee6c..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - cn.iocoder.boot - yudao-framework - ${revision} - - 4.0.0 - yudao-spring-boot-starter-test - jar - - ${project.artifactId} - 测试组件,用于单元测试、集成测试 - https://github.com/YunaiV/ruoyi-vue-pro - - - - cn.iocoder.boot - yudao-common - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.boot - yudao-spring-boot-starter-redis - - - - - org.mockito - mockito-inline - - - org.springframework.boot - spring-boot-starter-test - - - - com.h2database - h2 - - - - com.github.fppt - jedis-mock - - - - uk.co.jemos.podam - podam - - - diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/config/RedisTestConfiguration.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/config/RedisTestConfiguration.java deleted file mode 100644 index 46222911e9..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/config/RedisTestConfiguration.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.framework.test.config; - -import com.github.fppt.jedismock.RedisServer; -import org.springframework.boot.autoconfigure.data.redis.RedisProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; - -import java.io.IOException; - -/** - * Redis 测试 Configuration,主要实现内嵌 Redis 的启动 - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -@Lazy(false) // 禁止延迟加载 -@EnableConfigurationProperties(RedisProperties.class) -public class RedisTestConfiguration { - - /** - * 创建模拟的 Redis Server 服务器 - */ - @Bean - public RedisServer redisServer(RedisProperties properties) throws IOException { - RedisServer redisServer = new RedisServer(properties.getPort()); - // 一次执行多个单元测试时,貌似创建多个 spring 容器,导致不进行 stop。这样,就导致端口被占用,无法启动。。。 - try { - redisServer.start(); - } catch (Exception ignore) {} - return redisServer; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/config/SqlInitializationTestConfiguration.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/config/SqlInitializationTestConfiguration.java deleted file mode 100644 index abaec9d84f..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/config/SqlInitializationTestConfiguration.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.framework.test.config; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate; -import org.springframework.boot.autoconfigure.sql.init.SqlInitializationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer; -import org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer; -import org.springframework.boot.sql.init.DatabaseInitializationSettings; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; - -import javax.sql.DataSource; - -/** - * SQL 初始化的测试 Configuration - * - * 为什么不使用 org.springframework.boot.autoconfigure.sql.init.DataSourceInitializationConfiguration 呢? - * 因为我们在单元测试会使用 spring.main.lazy-initialization 为 true,开启延迟加载。此时,会导致 DataSourceInitializationConfiguration 初始化 - * 不过呢,当前类的实现代码,基本是复制 DataSourceInitializationConfiguration 的哈! - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnMissingBean(AbstractScriptDatabaseInitializer.class) -@ConditionalOnSingleCandidate(DataSource.class) -@ConditionalOnClass(name = "org.springframework.jdbc.datasource.init.DatabasePopulator") -@Lazy(value = false) // 禁止延迟加载 -@EnableConfigurationProperties(SqlInitializationProperties.class) -public class SqlInitializationTestConfiguration { - - @Bean - public DataSourceScriptDatabaseInitializer dataSourceScriptDatabaseInitializer(DataSource dataSource, - SqlInitializationProperties initializationProperties) { - DatabaseInitializationSettings settings = createFrom(initializationProperties); - return new DataSourceScriptDatabaseInitializer(dataSource, settings); - } - - static DatabaseInitializationSettings createFrom(SqlInitializationProperties properties) { - DatabaseInitializationSettings settings = new DatabaseInitializationSettings(); - settings.setSchemaLocations(properties.getSchemaLocations()); - settings.setDataLocations(properties.getDataLocations()); - settings.setContinueOnError(properties.isContinueOnError()); - settings.setSeparator(properties.getSeparator()); - settings.setEncoding(properties.getEncoding()); - settings.setMode(properties.getMode()); - return settings; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java deleted file mode 100644 index 71f1db5537..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.framework.test.core.ut; - -import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; -import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import cn.iocoder.yudao.framework.test.config.RedisTestConfiguration; -import cn.iocoder.yudao.framework.test.config.SqlInitializationTestConfiguration; -import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure; -import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; -import org.redisson.spring.starter.RedissonAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; - -/** - * 依赖内存 DB + Redis 的单元测试 - * - * 相比 {@link BaseDbUnitTest} 来说,额外增加了内存 Redis - * - * @author 芋道源码 - */ -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbAndRedisUnitTest.Application.class) -@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件 -@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) // 每个单元测试结束后,清理 DB -public class BaseDbAndRedisUnitTest { - - @Import({ - // DB 配置类 - YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 - DataSourceAutoConfiguration.class, // Spring DB 自动配置类 - DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 - DruidDataSourceAutoConfigure.class, // Druid 自动配置类 - SqlInitializationTestConfiguration.class, // SQL 初始化 - // MyBatis 配置类 - YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 - MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 - - // Redis 配置类 - RedisTestConfiguration.class, // Redis 测试配置类,用于启动 RedisServer - YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 - RedisAutoConfiguration.class, // Spring Redis 自动配置类 - RedissonAutoConfiguration.class, // Redisson 自动高配置类 - }) - public static class Application { - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbUnitTest.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbUnitTest.java deleted file mode 100644 index ee43fcb43b..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbUnitTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.framework.test.core.ut; - -import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; -import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; -import cn.iocoder.yudao.framework.test.config.SqlInitializationTestConfiguration; -import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure; -import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; -import com.github.yulichang.autoconfigure.MybatisPlusJoinAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; - -/** - * 依赖内存 DB 的单元测试 - * - * 注意,Service 层同样适用。对于 Service 层的单元测试,我们针对自己模块的 Mapper 走的是 H2 内存数据库,针对别的模块的 Service 走的是 Mock 方法 - * - * @author 芋道源码 - */ -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbUnitTest.Application.class) -@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件 -@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) // 每个单元测试结束后,清理 DB -public class BaseDbUnitTest { - - @Import({ - // DB 配置类 - YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 - DataSourceAutoConfiguration.class, // Spring DB 自动配置类 - DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 - DruidDataSourceAutoConfigure.class, // Druid 自动配置类 - SqlInitializationTestConfiguration.class, // SQL 初始化 - // MyBatis 配置类 - YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 - MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 - MybatisPlusJoinAutoConfiguration.class, // MyBatis 的Join配置类 - }) - public static class Application { - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseMockitoUnitTest.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseMockitoUnitTest.java deleted file mode 100644 index 26048695c5..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseMockitoUnitTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.framework.test.core.ut; - -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -/** - * 纯 Mockito 的单元测试 - * - * @author 芋道源码 - */ -@ExtendWith(MockitoExtension.class) -public class BaseMockitoUnitTest { -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseRedisUnitTest.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseRedisUnitTest.java deleted file mode 100644 index 7a112e05d3..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseRedisUnitTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.framework.test.core.ut; - -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import cn.iocoder.yudao.framework.test.config.RedisTestConfiguration; -import org.redisson.spring.starter.RedissonAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -/** - * 依赖内存 Redis 的单元测试 - * - * 相比 {@link BaseDbUnitTest} 来说,从内存 DB 改成了内存 Redis - * - * @author 芋道源码 - */ -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseRedisUnitTest.Application.class) -@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件 -public class BaseRedisUnitTest { - - @Import({ - // Redis 配置类 - RedisTestConfiguration.class, // Redis 测试配置类,用于启动 RedisServer - RedisAutoConfiguration.class, // Spring Redis 自动配置类 - YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 - RedissonAutoConfiguration.class, // Redisson 自动高配置类 - }) - public static class Application { - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/package-info.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/package-info.java deleted file mode 100644 index bda7aad252..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 提供单元测试 Unit Test 的基类 - */ -package cn.iocoder.yudao.framework.test.core.ut; diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/AssertUtils.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/AssertUtils.java deleted file mode 100644 index e98f4980fc..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/AssertUtils.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.framework.test.core.util; - -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.common.exception.ErrorCode; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.function.Executable; - -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.Objects; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -/** - * 单元测试,assert 断言工具类 - * - * @author 芋道源码 - */ -public class AssertUtils { - - /** - * 比对两个对象的属性是否一致 - * - * 注意,如果 expected 存在的属性,actual 不存在的时候,会进行忽略 - * - * @param expected 期望对象 - * @param actual 实际对象 - * @param ignoreFields 忽略的属性数组 - */ - public static void assertPojoEquals(Object expected, Object actual, String... ignoreFields) { - Field[] expectedFields = ReflectUtil.getFields(expected.getClass()); - Arrays.stream(expectedFields).forEach(expectedField -> { - // 忽略 jacoco 自动生成的 $jacocoData 属性的情况 - if (expectedField.isSynthetic()) { - return; - } - // 如果是忽略的属性,则不进行比对 - if (ArrayUtil.contains(ignoreFields, expectedField.getName())) { - return; - } - // 忽略不存在的属性 - Field actualField = ReflectUtil.getField(actual.getClass(), expectedField.getName()); - if (actualField == null) { - return; - } - // 比对 - Assertions.assertEquals( - ReflectUtil.getFieldValue(expected, expectedField), - ReflectUtil.getFieldValue(actual, actualField), - String.format("Field(%s) 不匹配", expectedField.getName()) - ); - }); - } - - /** - * 比对两个对象的属性是否一致 - * - * 注意,如果 expected 存在的属性,actual 不存在的时候,会进行忽略 - * - * @param expected 期望对象 - * @param actual 实际对象 - * @param ignoreFields 忽略的属性数组 - * @return 是否一致 - */ - public static boolean isPojoEquals(Object expected, Object actual, String... ignoreFields) { - Field[] expectedFields = ReflectUtil.getFields(expected.getClass()); - return Arrays.stream(expectedFields).allMatch(expectedField -> { - // 如果是忽略的属性,则不进行比对 - if (ArrayUtil.contains(ignoreFields, expectedField.getName())) { - return true; - } - // 忽略不存在的属性 - Field actualField = ReflectUtil.getField(actual.getClass(), expectedField.getName()); - if (actualField == null) { - return true; - } - return Objects.equals(ReflectUtil.getFieldValue(expected, expectedField), - ReflectUtil.getFieldValue(actual, actualField)); - }); - } - - /** - * 执行方法,校验抛出的 Service 是否符合条件 - * - * @param executable 业务异常 - * @param errorCode 错误码对象 - * @param messageParams 消息参数 - */ - public static void assertServiceException(Executable executable, ErrorCode errorCode, Object... messageParams) { - // 调用方法 - ServiceException serviceException = assertThrows(ServiceException.class, executable); - // 校验错误码 - Assertions.assertEquals(errorCode.getCode(), serviceException.getCode(), "错误码不匹配"); - String message = ServiceExceptionUtil.doFormat(errorCode.getCode(), errorCode.getMsg(), messageParams); - Assertions.assertEquals(message, serviceException.getMessage(), "错误提示不匹配"); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/RandomUtils.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/RandomUtils.java deleted file mode 100644 index 66d15c5bfa..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/RandomUtils.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.framework.test.core.util; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.RandomUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import uk.co.jemos.podam.api.PodamFactory; -import uk.co.jemos.podam.api.PodamFactoryImpl; - -import java.lang.reflect.Type; -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Set; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * 随机工具类 - * - * @author 芋道源码 - */ -public class RandomUtils { - - private static final int RANDOM_STRING_LENGTH = 10; - - private static final int TINYINT_MAX = 127; - - private static final int RANDOM_DATE_MAX = 30; - - private static final int RANDOM_COLLECTION_LENGTH = 5; - - private static final PodamFactory PODAM_FACTORY = new PodamFactoryImpl(); - - static { - // 字符串 - PODAM_FACTORY.getStrategy().addOrReplaceTypeManufacturer(String.class, - (dataProviderStrategy, attributeMetadata, map) -> randomString()); - // Integer - PODAM_FACTORY.getStrategy().addOrReplaceTypeManufacturer(Integer.class, (dataProviderStrategy, attributeMetadata, map) -> { - // 如果是 status 的字段,返回 0 或 1 - if ("status".equals(attributeMetadata.getAttributeName())) { - return RandomUtil.randomEle(CommonStatusEnum.values()).getStatus(); - } - // 如果是 type、status 结尾的字段,返回 tinyint 范围 - if (StrUtil.endWithAnyIgnoreCase(attributeMetadata.getAttributeName(), - "type", "status", "category", "scope", "result")) { - return RandomUtil.randomInt(0, TINYINT_MAX + 1); - } - return RandomUtil.randomInt(); - }); - // LocalDateTime - PODAM_FACTORY.getStrategy().addOrReplaceTypeManufacturer(LocalDateTime.class, - (dataProviderStrategy, attributeMetadata, map) -> randomLocalDateTime()); - // Boolean - PODAM_FACTORY.getStrategy().addOrReplaceTypeManufacturer(Boolean.class, (dataProviderStrategy, attributeMetadata, map) -> { - // 如果是 deleted 的字段,返回非删除 - if ("deleted".equals(attributeMetadata.getAttributeName())) { - return false; - } - return RandomUtil.randomBoolean(); - }); - } - - public static String randomString() { - return RandomUtil.randomString(RANDOM_STRING_LENGTH); - } - - public static Long randomLongId() { - return RandomUtil.randomLong(0, Long.MAX_VALUE); - } - - public static Integer randomInteger() { - return RandomUtil.randomInt(0, Integer.MAX_VALUE); - } - - public static Date randomDate() { - return RandomUtil.randomDay(0, RANDOM_DATE_MAX); - } - - public static LocalDateTime randomLocalDateTime() { - // 设置 Nano 为零的原因,避免 MySQL、H2 存储不到时间戳 - return LocalDateTimeUtil.of(randomDate()).withNano(0); - } - - public static Short randomShort() { - return (short) RandomUtil.randomInt(0, Short.MAX_VALUE); - } - - public static Set randomSet(Class clazz) { - return Stream.iterate(0, i -> i).limit(RandomUtil.randomInt(1, RANDOM_COLLECTION_LENGTH)) - .map(i -> randomPojo(clazz)).collect(Collectors.toSet()); - } - - public static Integer randomCommonStatus() { - return RandomUtil.randomEle(CommonStatusEnum.values()).getStatus(); - } - - public static String randomEmail() { - return randomString() + "@qq.com"; - } - - public static String randomURL() { - return "https://www.iocoder.cn/" + randomString(); - } - - @SafeVarargs - public static T randomPojo(Class clazz, Consumer... consumers) { - T pojo = PODAM_FACTORY.manufacturePojo(clazz); - // 非空时,回调逻辑。通过它,可以实现 Pojo 的进一步处理 - if (ArrayUtil.isNotEmpty(consumers)) { - Arrays.stream(consumers).forEach(consumer -> consumer.accept(pojo)); - } - return pojo; - } - - @SafeVarargs - public static T randomPojo(Class clazz, Type type, Consumer... consumers) { - T pojo = PODAM_FACTORY.manufacturePojo(clazz, type); - // 非空时,回调逻辑。通过它,可以实现 Pojo 的进一步处理 - if (ArrayUtil.isNotEmpty(consumers)) { - Arrays.stream(consumers).forEach(consumer -> consumer.accept(pojo)); - } - return pojo; - } - - @SafeVarargs - public static List randomPojoList(Class clazz, Consumer... consumers) { - int size = RandomUtil.randomInt(1, RANDOM_COLLECTION_LENGTH); - return Stream.iterate(0, i -> i).limit(size).map(o -> randomPojo(clazz, consumers)) - .collect(Collectors.toList()); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/package-info.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/package-info.java deleted file mode 100644 index 3a17f51900..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 测试组件,用于单元测试、集成测试等等 - */ -package cn.iocoder.yudao.framework.test; diff --git "a/yudao-framework/yudao-spring-boot-starter-test/\343\200\212\350\212\213\351\201\223 Spring Boot \345\215\225\345\205\203\346\265\213\350\257\225 Test \345\205\245\351\227\250\343\200\213.md" "b/yudao-framework/yudao-spring-boot-starter-test/\343\200\212\350\212\213\351\201\223 Spring Boot \345\215\225\345\205\203\346\265\213\350\257\225 Test \345\205\245\351\227\250\343\200\213.md" deleted file mode 100644 index c6d0e9a905..0000000000 --- "a/yudao-framework/yudao-spring-boot-starter-test/\343\200\212\350\212\213\351\201\223 Spring Boot \345\215\225\345\205\203\346\265\213\350\257\225 Test \345\205\245\351\227\250\343\200\213.md" +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-bpm/pom.xml b/yudao-module-bpm/pom.xml deleted file mode 100644 index 95b798904c..0000000000 --- a/yudao-module-bpm/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - yudao - cn.iocoder.boot - ${revision} - - 4.0.0 - - yudao-module-bpm-api - yudao-module-bpm-biz - - yudao-module-bpm - pom - - ${project.artifactId} - - bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能。 - 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - bpm 解释:https://baike.baidu.com/item/BPM/1933 - - 工作流基于 Flowable 6 实现,分成流程定义、流程表单、流程实例、流程任务等功能模块。 - - - diff --git a/yudao-module-bpm/yudao-module-bpm-api/pom.xml b/yudao-module-bpm/yudao-module-bpm-api/pom.xml deleted file mode 100644 index 06554d7ff0..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-bpm - ${revision} - - 4.0.0 - yudao-module-bpm-api - jar - - ${project.artifactId} - - bpm 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java deleted file mode 100644 index 37a92219f9..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * bpm API 包,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.bpm.api; diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java deleted file mode 100644 index e4eddf6ebd..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.bpm.api.task; - -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; - -import jakarta.validation.Valid; - -/** - * 流程实例 Api 接口 - * - * @author 芋道源码 - */ -public interface BpmProcessInstanceApi { - - /** - * 创建流程实例(提供给内部) - * - * @param userId 用户编号 - * @param reqDTO 创建信息 - * @return 实例的编号 - */ - String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO reqDTO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java deleted file mode 100644 index b20a449df5..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.bpm.api.task.dto; - -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import java.util.List; -import java.util.Map; - -/** - * 流程实例的创建 Request DTO - * - * @author 芋道源码 - */ -@Data -public class BpmProcessInstanceCreateReqDTO { - - /** - * 流程定义的标识 - */ - @NotEmpty(message = "流程定义的标识不能为空") - private String processDefinitionKey; - /** - * 变量实例 - */ - private Map variables; - - /** - * 业务的唯一标识 - * - * 例如说,请假申请的编号。通过它,可以查询到对应的实例 - */ - @NotEmpty(message = "业务的唯一标识") - private String businessKey; - - // TODO @hai:assignees 复数 - /** - * 提前指派的审批人 - * - * key:taskKey 任务编码 - * value:审批人的数组 - * 例如: { taskKey1 :[1, 2] },则表示 taskKey1 这个任务,提前设定了,由 userId 为 1,2 的用户进行审批 - */ - private Map> assignee; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java deleted file mode 100644 index 7abb3e1dbc..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums; - -/** - * BPM 字典类型的枚举类 - * - * @author 芋道源码 - */ -public interface DictTypeConstants { - - String TASK_ASSIGN_RULE_TYPE = "bpm_task_assign_rule_type"; // 任务分配规则类型 - String TASK_ASSIGN_SCRIPT = "bpm_task_assign_script"; // 任务分配自定义脚本 - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java deleted file mode 100644 index 51eebda236..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Bpm 错误码枚举类 - *

- * bpm 系统,使用 1-009-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 通用流程处理 模块 1-009-000-000 ========== - ErrorCode HIGHLIGHT_IMG_ERROR = new ErrorCode(1_009_000_002, "获取高亮流程图异常"); - - // ========== OA 流程模块 1-009-001-000 ========== - ErrorCode OA_LEAVE_NOT_EXISTS = new ErrorCode(1_009_001_001, "请假申请不存在"); - ErrorCode OA_PM_POST_NOT_EXISTS = new ErrorCode(1_009_001_002, "项目经理岗位未设置"); - ErrorCode OA_DEPART_PM_POST_NOT_EXISTS = new ErrorCode(1_009_001_009, "部门的项目经理不存在"); - ErrorCode OA_BM_POST_NOT_EXISTS = new ErrorCode(1_009_001_004, "部门经理岗位未设置"); - ErrorCode OA_DEPART_BM_POST_NOT_EXISTS = new ErrorCode(1_009_001_005, "部门的部门经理不存在"); - ErrorCode OA_HR_POST_NOT_EXISTS = new ErrorCode(1_009_001_006, "HR岗位未设置"); - ErrorCode OA_DAY_LEAVE_ERROR = new ErrorCode(1_009_001_007, "请假天数必须>=1"); - - // ========== 流程模型 1-009-002-000 ========== - ErrorCode MODEL_KEY_EXISTS = new ErrorCode(1_009_002_000, "已经存在流程标识为【{}】的流程"); - ErrorCode MODEL_NOT_EXISTS = new ErrorCode(1_009_002_001, "流程模型不存在"); - ErrorCode MODEL_KEY_VALID = new ErrorCode(1_009_002_002, "流程标识格式不正确,需要以字母或下划线开头,后接任意字母、数字、中划线、下划线、句点!"); - ErrorCode MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG = new ErrorCode(1_009_002_003, "部署流程失败,原因:流程表单未配置,请点击【修改流程】按钮进行配置"); - ErrorCode MODEL_DEPLOY_FAIL_TASK_ASSIGN_RULE_NOT_CONFIG = new ErrorCode(1_009_002_004, "部署流程失败," + - "原因:用户任务({})未配置分配规则,请点击【修改流程】按钮进行配置"); - ErrorCode MODEL_DEPLOY_FAIL_TASK_INFO_EQUALS = new ErrorCode(1_009_003_005, "流程定义部署失败,原因:信息未发生变化"); - - // ========== 流程定义 1-009-003-000 ========== - ErrorCode PROCESS_DEFINITION_KEY_NOT_MATCH = new ErrorCode(1_009_003_000, "流程定义的标识期望是({}),当前是({}),请修改 BPMN 流程图"); - ErrorCode PROCESS_DEFINITION_NAME_NOT_MATCH = new ErrorCode(1_009_003_001, "流程定义的名字期望是({}),当前是({}),请修改 BPMN 流程图"); - ErrorCode PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1_009_003_002, "流程定义不存在"); - ErrorCode PROCESS_DEFINITION_IS_SUSPENDED = new ErrorCode(1_009_003_003, "流程定义处于挂起状态"); - ErrorCode PROCESS_DEFINITION_BPMN_MODEL_NOT_EXISTS = new ErrorCode(1_009_003_004, "流程定义的模型不存在"); - - // ========== 流程实例 1-009-004-000 ========== - ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1_009_004_000, "流程实例不存在"); - ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS = new ErrorCode(1_009_004_001, "流程取消失败,流程不处于运行中"); - ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF = new ErrorCode(1_009_004_002, "流程取消失败,该流程不是你发起的"); - - // ========== 流程任务 1-009-005-000 ========== - ErrorCode TASK_OPERATE_FAIL_ASSIGN_NOT_SELF = new ErrorCode(1_009_005_001, "操作失败,原因:该任务的审批人不是你"); - ErrorCode TASK_NOT_EXISTS = new ErrorCode(1_009_005_002, "流程任务不存在"); - ErrorCode TASK_IS_PENDING = new ErrorCode(1_009_005_003, "当前任务处于挂起状态,不能操作"); - ErrorCode TASK_TARGET_NODE_NOT_EXISTS = new ErrorCode(1_009_005_004, " 目标节点不存在"); - ErrorCode TASK_RETURN_FAIL_SOURCE_TARGET_ERROR = new ErrorCode(1_009_005_006, "回退任务失败,目标节点是在并行网关上或非同一路线上,不可跳转"); - ErrorCode TASK_DELEGATE_FAIL_USER_REPEAT = new ErrorCode(1_009_005_007, "任务委派失败,委派人和当前审批人为同一人"); - ErrorCode TASK_DELEGATE_FAIL_USER_NOT_EXISTS = new ErrorCode(1_009_005_008, "任务委派失败,被委派人不存在"); - ErrorCode TASK_ADD_SIGN_USER_NOT_EXIST = new ErrorCode(1_009_005_009, "任务加签:选择的用户不存在"); - ErrorCode TASK_ADD_SIGN_TYPE_ERROR = new ErrorCode(1_009_005_010, "任务加签:当前任务已经{},不能{}"); - ErrorCode TASK_ADD_SIGN_USER_REPEAT = new ErrorCode(1_009_005_011, "任务加签失败,加签人与现有审批人[{}]重复"); - ErrorCode TASK_SUB_SIGN_NO_PARENT = new ErrorCode(1_009_005_011, "任务减签失败,被减签的任务必须是通过加签生成的任务"); - - // ========== 流程任务分配规则 1-009-006-000 ========== - ErrorCode TASK_ASSIGN_RULE_EXISTS = new ErrorCode(1_009_006_000, "流程({}) 的任务({}) 已经存在分配规则"); - ErrorCode TASK_ASSIGN_RULE_NOT_EXISTS = new ErrorCode(1_009_006_001, "流程任务分配规则不存在"); - ErrorCode TASK_UPDATE_FAIL_NOT_MODEL = new ErrorCode(1_009_006_002, "只有流程模型的任务分配规则,才允许被修改"); - ErrorCode TASK_CREATE_FAIL_NO_CANDIDATE_USER = new ErrorCode(1_009_006_003, "操作失败,原因:找不到任务的审批人!"); - ErrorCode TASK_ASSIGN_SCRIPT_NOT_EXISTS = new ErrorCode(1_009_006_004, "操作失败,原因:任务分配脚本({}) 不存在"); - - // ========== 动态表单模块 1-009-010-000 ========== - ErrorCode FORM_NOT_EXISTS = new ErrorCode(1_009_010_000, "动态表单不存在"); - ErrorCode FORM_FIELD_REPEAT = new ErrorCode(1_009_010_001, "表单项({}) 和 ({}) 使用了相同的字段名({})"); - - // ========== 用户组模块 1-009-011-000 ========== - ErrorCode USER_GROUP_NOT_EXISTS = new ErrorCode(1_009_011_000, "用户组不存在"); - ErrorCode USER_GROUP_IS_DISABLE = new ErrorCode(1_009_011_001, "名字为【{}】的用户组已被禁用"); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java deleted file mode 100644 index c21d6f9991..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.definition; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * BPM 模型的表单类型的枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmModelFormTypeEnum { - - NORMAL(10, "流程表单"), // 对应 BpmFormDO - CUSTOM(20, "业务表单") // 业务自己定义的表单,自己进行数据的存储 - ; - - private final Integer type; - private final String desc; -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java deleted file mode 100644 index b7ccc7ae82..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.definition; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * BPM 任务分配规则的类型枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmTaskAssignRuleTypeEnum { - - ROLE(10, "角色"), - DEPT_MEMBER(20, "部门的成员"), // 包括负责人 - DEPT_LEADER(21, "部门的负责人"), - POST(22, "岗位"), - USER(30, "用户"), - USER_GROUP(40, "用户组"), - SCRIPT(50, "自定义脚本"), // 例如说,发起人所在部门的领导、发起人所在部门的领导的领导 - ; - - /** - * 类型 - */ - private final Integer type; - /** - * 描述 - */ - private final String desc; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskRuleScriptEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskRuleScriptEnum.java deleted file mode 100644 index 7fc0e3b8bc..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskRuleScriptEnum.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.definition; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * BPM 任务规则的脚本枚举 - * 目前暂时通过 TODO 芋艿:硬编码,未来可以考虑 Groovy 动态脚本的方式 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmTaskRuleScriptEnum { - - START_USER(10L, "流程发起人"), - - LEADER_X1(20L, "流程发起人的一级领导"), - LEADER_X2(21L, "流程发起人的二级领导"); - - /** - * 脚本编号 - */ - private final Long id; - /** - * 脚本描述 - */ - private final String desc; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java deleted file mode 100644 index 79001fccd3..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.message; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * Bpm 消息的枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum BpmMessageEnum { - - PROCESS_INSTANCE_APPROVE("bpm_process_instance_approve"), // 流程任务被审批通过时,发送给申请人 - PROCESS_INSTANCE_REJECT("bpm_process_instance_reject"), // 流程任务被审批不通过时,发送给申请人 - TASK_ASSIGNED("bpm_task_assigned"); // 任务被分配时,发送给审批人 - - /** - * 短信模板的标识 - * - * 关联 SmsTemplateDO 的 code 属性 - */ - private final String smsTemplateCode; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmCommentTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmCommentTypeEnum.java deleted file mode 100644 index 89d56b3c08..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmCommentTypeEnum.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程任务 -- comment类型枚举 - */ -@Getter -@AllArgsConstructor -public enum BpmCommentTypeEnum { - - APPROVE(1, "通过", ""), - REJECT(2, "不通过", ""), - CANCEL(3, "已取消", ""), - BACK(4, "退回", ""), - DELEGATE(5, "委派", ""), - ADD_SIGN(6, "加签", "[{}]{}给了[{}],理由为:{}"), - SUB_SIGN(7, "减签", "[{}]操作了【减签】,审批人[{}]的任务被取消"), - ; - - /** - * 操作类型 - */ - private final Integer type; - /** - * 操作名字 - */ - private final String name; - /** - * 操作描述 - */ - private final String comment; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java deleted file mode 100644 index 4f99d0a3dc..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import cn.hutool.core.util.StrUtil; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程实例的删除原因 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmProcessInstanceDeleteReasonEnum { - - REJECT_TASK("不通过任务,原因:{}"), // 修改文案时,需要注意 isRejectReason 方法 - CANCEL_TASK("主动取消任务,原因:{}"), - - // ========== 流程任务的独有原因 ========== - MULTI_TASK_END("系统自动取消,原因:多任务审批已经满足条件,无需审批该任务"), // 多实例满足 condition 而结束时,其它任务实例任务会被取消,对应的删除原因是 MI_END - - ; - - private final String reason; - - /** - * 格式化理由 - * - * @param args 参数 - * @return 理由 - */ - public String format(Object... args) { - return StrUtil.format(reason, args); - } - - // ========== 逻辑 ========== - - public static boolean isRejectReason(String reason) { - return StrUtil.startWith(reason, "不通过任务,原因:"); - } - - /** - * 将 Flowable 的删除原因,翻译成对应的中文原因 - * - * @param reason 原始原因 - * @return 原因 - */ - public static String translateReason(String reason) { - if (StrUtil.isEmpty(reason)) { - return reason; - } - switch (reason) { - case "MI_END": return MULTI_TASK_END.getReason(); - default: return reason; - } - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java deleted file mode 100644 index 615416c736..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; -import java.util.List; - -/** - * 流程实例的结果 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum BpmProcessInstanceResultEnum { - - PROCESS(1, "处理中"), - APPROVE(2, "通过"), - REJECT(3, "不通过"), - CANCEL(4, "已取消"), - - // ========== 流程任务独有的状态 ========== - - BACK(5, "驳回"), // 退回 - DELEGATE(6, "委派"), - /** - * 【加签】源任务已经审批完成,但是它使用了后加签,后加签的任务未完成,源任务就会是这个状态 - * 相当于是 通过 APPROVE 的特殊状态 - * 例如:A审批, A 后加签了 B,并且审批通过了任务,但是 B 还未审批,则当前任务状态为“待后加签任务完成” - */ - SIGN_AFTER(7, "待后加签任务完成"), - /** - * 【加签】源任务未审批,但是向前加签了,所以源任务状态变为“待前加签任务完成” - * 相当于是 处理中 PROCESS 的特殊状态 - * 例如:A 审批, A 前加签了 B,B 还未审核 - */ - SIGN_BEFORE(8, "待前加签任务完成"), - /** - * 【加签】后加签任务被创建时的初始状态 - * 相当于是 处理中 PROCESS 的特殊状态 - * 因为需要源任务先完成,才能到后加签的人来审批,所以加了一个状态区分 - */ - WAIT_BEFORE_TASK(9, "待前置任务完成"); - - /** - * 能被减签的状态 - */ - public static final List CAN_SUB_SIGN_STATUS_LIST = Arrays.asList(PROCESS.result, WAIT_BEFORE_TASK.result); - - /** - * 结果 - *

- * 如果新增时,注意 {@link #isEndResult(Integer)} 是否需要变更 - */ - private final Integer result; - /** - * 描述 - */ - private final String desc; - - /** - * 判断该结果是否已经处于 End 最终结果 - *

- * 主要用于一些结果更新的逻辑,如果已经是最终结果,就不再进行更新 - * - * @param result 结果 - * @return 是否 - */ - public static boolean isEndResult(Integer result) { - return ObjectUtils.equalsAny(result, APPROVE.getResult(), REJECT.getResult(), - CANCEL.getResult(), BACK.getResult(), - SIGN_AFTER.getResult()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java deleted file mode 100644 index 70a31dd342..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程实例的状态 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmProcessInstanceStatusEnum { - - RUNNING(1, "进行中"), - FINISH(2, "已完成"); - - /** - * 状态 - */ - private final Integer status; - /** - * 描述 - */ - private final String desc; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskAddSignTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskAddSignTypeEnum.java deleted file mode 100644 index 42c212e28c..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskAddSignTypeEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程任务 -- 加签类型枚举类型 - */ -@Getter -@AllArgsConstructor -public enum BpmTaskAddSignTypeEnum { - - /** - * 向前加签,需要前置任务审批完成,才回到原审批人 - */ - BEFORE("before", "向前加签"), - /** - * 向后加签,需要后置任务全部审批完,才会通过原审批人节点 - */ - AFTER("after", "向后加签"), - /** - * 创建后置加签时的过度状态,用于控制向后加签生成的任务状态 - */ - AFTER_CHILDREN_TASK("afterChildrenTask", "向后加签生成的子任务"); - - private final String type; - - private final String desc; - - public static String formatDesc(String type) { - for (BpmTaskAddSignTypeEnum value : values()) { - if (value.type.equals(type)) { - return value.desc; - } - } - return null; - } - -} - \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/pom.xml b/yudao-module-bpm/yudao-module-bpm-biz/pom.xml deleted file mode 100644 index 12d5c5beba..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-bpm - ${revision} - - 4.0.0 - yudao-module-bpm-biz - - ${project.artifactId} - - bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能,基于 Flowable 6 版本实现。 - 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - - - - cn.iocoder.boot - yudao-module-bpm-api - ${revision} - - - cn.iocoder.boot - yudao-module-system-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-data-permission - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.boot - yudao-spring-boot-starter-web - - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - - - - cn.iocoder.boot - yudao-spring-boot-starter-flowable - - - diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java deleted file mode 100644 index 2137e22031..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * bpm API 实现类,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.bpm.api; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java deleted file mode 100644 index f8aea4d74e..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.api.task; - -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -/** - * Flowable 流程实例 Api 实现类 - * - * @author 芋道源码 - * @author jason - */ -@Service -@Validated -public class BpmProcessInstanceApiImpl implements BpmProcessInstanceApi { - - @Resource - private BpmProcessInstanceService processInstanceService; - - @Override - public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO reqDTO) { - return processInstanceService.createProcessInstance(userId, reqDTO); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java deleted file mode 100644 index b5065ed48e..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java +++ /dev/null @@ -1,79 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.*; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmFormConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 动态表单") -@RestController -@RequestMapping("/bpm/form") -@Validated -public class BpmFormController { - - @Resource - private BpmFormService formService; - - @PostMapping("/create") - @Operation(summary = "创建动态表单") - @PreAuthorize("@ss.hasPermission('bpm:form:create')") - public CommonResult createForm(@Valid @RequestBody BpmFormCreateReqVO createReqVO) { - return success(formService.createForm(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新动态表单") - @PreAuthorize("@ss.hasPermission('bpm:form:update')") - public CommonResult updateForm(@Valid @RequestBody BpmFormUpdateReqVO updateReqVO) { - formService.updateForm(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除动态表单") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:form:delete')") - public CommonResult deleteForm(@RequestParam("id") Long id) { - formService.deleteForm(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得动态表单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:form:query')") - public CommonResult getForm(@RequestParam("id") Long id) { - BpmFormDO form = formService.getForm(id); - return success(BpmFormConvert.INSTANCE.convert(form)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获得动态表单的精简列表", description = "用于表单下拉框") - public CommonResult> getSimpleForms() { - List list = formService.getFormList(); - return success(BpmFormConvert.INSTANCE.convertList2(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得动态表单分页") - @PreAuthorize("@ss.hasPermission('bpm:form:query')") - public CommonResult> getFormPage(@Valid BpmFormPageReqVO pageVO) { - PageResult pageResult = formService.getFormPage(pageVO); - return success(BpmFormConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java deleted file mode 100644 index 824a2f862d..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.io.IoUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert; -import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import java.io.IOException; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 流程模型") -@RestController -@RequestMapping("/bpm/model") -@Validated -public class BpmModelController { - - @Resource - private BpmModelService modelService; - - @GetMapping("/page") - @Operation(summary = "获得模型分页") - public CommonResult> getModelPage(BpmModelPageReqVO pageVO) { - return success(modelService.getModelPage(pageVO)); - } - - @GetMapping("/get") - @Operation(summary = "获得模型") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:model:query')") - public CommonResult getModel(@RequestParam("id") String id) { - BpmModelRespVO model = modelService.getModel(id); - return success(model); - } - - @PostMapping("/create") - @Operation(summary = "新建模型") - @PreAuthorize("@ss.hasPermission('bpm:model:create')") - public CommonResult createModel(@Valid @RequestBody BpmModelCreateReqVO createRetVO) { - return success(modelService.createModel(createRetVO, null)); - } - - @PutMapping("/update") - @Operation(summary = "修改模型") - @PreAuthorize("@ss.hasPermission('bpm:model:update')") - public CommonResult updateModel(@Valid @RequestBody BpmModelUpdateReqVO modelVO) { - modelService.updateModel(modelVO); - return success(true); - } - - @PostMapping("/import") - @Operation(summary = "导入模型") - @PreAuthorize("@ss.hasPermission('bpm:model:import')") - public CommonResult importModel(@Valid BpmModeImportReqVO importReqVO) throws IOException { - BpmModelCreateReqVO createReqVO = BpmModelConvert.INSTANCE.convert(importReqVO); - // 读取文件 - String bpmnXml = IoUtils.readUtf8(importReqVO.getBpmnFile().getInputStream(), false); - return success(modelService.createModel(createReqVO, bpmnXml)); - } - - @PostMapping("/deploy") - @Operation(summary = "部署模型") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:model:deploy')") - public CommonResult deployModel(@RequestParam("id") String id) { - modelService.deployModel(id); - return success(true); - } - - @PutMapping("/update-state") - @Operation(summary = "修改模型的状态", description = "实际更新的部署的流程定义的状态") - @PreAuthorize("@ss.hasPermission('bpm:model:update')") - public CommonResult updateModelState(@Valid @RequestBody BpmModelUpdateStateReqVO reqVO) { - modelService.updateModelState(reqVO.getId(), reqVO.getState()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除模型") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:model:delete')") - public CommonResult deleteModel(@RequestParam("id") String id) { - modelService.deleteModel(id); - return success(true); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java deleted file mode 100644 index 0c0fcd7d34..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionListReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageItemRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; - -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 流程定义") -@RestController -@RequestMapping("/bpm/process-definition") -@Validated -public class BpmProcessDefinitionController { - - @Resource - private BpmProcessDefinitionService bpmDefinitionService; - - @GetMapping("/page") - @Operation(summary = "获得流程定义分页") - @PreAuthorize("@ss.hasPermission('bpm:process-definition:query')") - public CommonResult> getProcessDefinitionPage( - BpmProcessDefinitionPageReqVO pageReqVO) { - return success(bpmDefinitionService.getProcessDefinitionPage(pageReqVO)); - } - - @GetMapping ("/list") - @Operation(summary = "获得流程定义列表") - @PreAuthorize("@ss.hasPermission('bpm:process-definition:query')") - public CommonResult> getProcessDefinitionList( - BpmProcessDefinitionListReqVO listReqVO) { - return success(bpmDefinitionService.getProcessDefinitionList(listReqVO)); - } - - @GetMapping ("/get-bpmn-xml") - @Operation(summary = "获得流程定义的 BPMN XML") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:process-definition:query')") - public CommonResult getProcessDefinitionBpmnXML(@RequestParam("id") String id) { - String bpmnXML = bpmDefinitionService.getProcessDefinitionBpmnXML(id); - return success(bpmnXML); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.java deleted file mode 100644 index 3c7e404de7..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleUpdateReqVO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 任务分配规则") -@RestController -@RequestMapping("/bpm/task-assign-rule") -@Validated -public class BpmTaskAssignRuleController { - - @Resource - private BpmTaskAssignRuleService taskAssignRuleService; - - @GetMapping("/list") - @Operation(summary = "获得任务分配规则列表") - @Parameters({ - @Parameter(name = "modelId", description = "模型编号", example = "1024"), - @Parameter(name = "processDefinitionId", description = "流程定义的编号", example = "2048") - }) - @PreAuthorize("@ss.hasPermission('bpm:task-assign-rule:query')") - public CommonResult> getTaskAssignRuleList( - @RequestParam(value = "modelId", required = false) String modelId, - @RequestParam(value = "processDefinitionId", required = false) String processDefinitionId) { - return success(taskAssignRuleService.getTaskAssignRuleList(modelId, processDefinitionId)); - } - - @PostMapping("/create") - @Operation(summary = "创建任务分配规则") - @PreAuthorize("@ss.hasPermission('bpm:task-assign-rule:create')") - public CommonResult createTaskAssignRule(@Valid @RequestBody BpmTaskAssignRuleCreateReqVO reqVO) { - return success(taskAssignRuleService.createTaskAssignRule(reqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新任务分配规则") - @PreAuthorize("@ss.hasPermission('bpm:task-assign-rule:update')") - public CommonResult updateTaskAssignRule(@Valid @RequestBody BpmTaskAssignRuleUpdateReqVO reqVO) { - taskAssignRuleService.updateTaskAssignRule(reqVO); - return success(true); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java deleted file mode 100644 index 82404b9253..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmUserGroupConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 用户组") -@RestController -@RequestMapping("/bpm/user-group") -@Validated -public class BpmUserGroupController { - - @Resource - private BpmUserGroupService userGroupService; - - @PostMapping("/create") - @Operation(summary = "创建用户组") - @PreAuthorize("@ss.hasPermission('bpm:user-group:create')") - public CommonResult createUserGroup(@Valid @RequestBody BpmUserGroupCreateReqVO createReqVO) { - return success(userGroupService.createUserGroup(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新用户组") - @PreAuthorize("@ss.hasPermission('bpm:user-group:update')") - public CommonResult updateUserGroup(@Valid @RequestBody BpmUserGroupUpdateReqVO updateReqVO) { - userGroupService.updateUserGroup(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除用户组") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:user-group:delete')") - public CommonResult deleteUserGroup(@RequestParam("id") Long id) { - userGroupService.deleteUserGroup(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得用户组") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:user-group:query')") - public CommonResult getUserGroup(@RequestParam("id") Long id) { - BpmUserGroupDO userGroup = userGroupService.getUserGroup(id); - return success(BpmUserGroupConvert.INSTANCE.convert(userGroup)); - } - - @GetMapping("/page") - @Operation(summary = "获得用户组分页") - @PreAuthorize("@ss.hasPermission('bpm:user-group:query')") - public CommonResult> getUserGroupPage(@Valid BpmUserGroupPageReqVO pageVO) { - PageResult pageResult = userGroupService.getUserGroupPage(pageVO); - return success(BpmUserGroupConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取用户组精简信息列表", description = "只包含被开启的用户组,主要用于前端的下拉选项") - public CommonResult> getSimpleUserGroups() { - // 获用户门列表,只要开启状态的 - List list = userGroupService.getUserGroupListByStatus(CommonStatusEnum.ENABLE.getStatus()); - // 排序后,返回给前端 - return success(BpmUserGroupConvert.INSTANCE.convertList2(list)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormBaseVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormBaseVO.java deleted file mode 100644 index fcc0cc167a..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormBaseVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import jakarta.validation.constraints.*; - -/** -* 动态表单 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class BpmFormBaseVO { - - @Schema(description = "表单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotNull(message = "表单名称不能为空") - private String name; - - @Schema(description = "表单状态-参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "表单状态不能为空") - private Integer status; - - @Schema(description = "备注", example = "我是备注") - private String remark; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormCreateReqVO.java deleted file mode 100644 index aa014a584d..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormCreateReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 动态表单创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmFormCreateReqVO extends BpmFormBaseVO { - - @Schema(description = "表单的配置-JSON 字符串", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单的配置不能为空") - private String conf; - - @Schema(description = "表单项的数组-JSON 字符串的数组", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单项的数组不能为空") - private List fields; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java deleted file mode 100644 index 0227e0ad92..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 动态表单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmFormPageReqVO extends PageParam { - - @Schema(description = "表单名称", example = "芋道") - private String name; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java deleted file mode 100644 index b8c8f531fe..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 动态表单 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmFormRespVO extends BpmFormBaseVO { - - @Schema(description = "表单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "表单的配置-JSON 字符串", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单的配置不能为空") - private String conf; - - @Schema(description = "表单项的数组-JSON 字符串的数组", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单项的数组不能为空") - private List fields; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSimpleRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSimpleRespVO.java deleted file mode 100644 index 71d8a1f802..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSimpleRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 流程表单精简 Response VO") -@Data -public class BpmFormSimpleRespVO { - - @Schema(description = "表单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "表单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormUpdateReqVO.java deleted file mode 100644 index 4248547802..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormUpdateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import jakarta.validation.constraints.*; -import java.util.List; - -@Schema(description = "管理后台 - 动态表单更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmFormUpdateReqVO extends BpmFormBaseVO { - - @Schema(description = "表单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "表单编号不能为空") - private Long id; - - @Schema(description = "表单的配置-JSON 字符串", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单的配置不能为空") - private String conf; - - @Schema(description = "表单项的数组-JSON 字符串的数组", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单项的数组不能为空") - private List fields; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupBaseVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupBaseVO.java deleted file mode 100644 index efe1155c3c..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupBaseVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; -import java.util.Set; - -/** -* 用户组 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class BpmUserGroupBaseVO { - - @Schema(description = "组名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotNull(message = "组名不能为空") - private String name; - - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @NotNull(message = "描述不能为空") - private String description; - - @Schema(description = "成员编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3") - @NotNull(message = "成员编号数组不能为空") - private Set memberUserIds; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupCreateReqVO.java deleted file mode 100644 index 416c4793ae..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupCreateReqVO.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -@Schema(description = "管理后台 - 用户组创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmUserGroupCreateReqVO extends BpmUserGroupBaseVO { - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java deleted file mode 100644 index 05f17788ab..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户组分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmUserGroupPageReqVO extends PageParam { - - @Schema(description = "组名", example = "芋道") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - - @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java deleted file mode 100644 index 0f89e95388..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户组 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmUserGroupRespVO extends BpmUserGroupBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSimpleRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSimpleRespVO.java deleted file mode 100644 index e5e2060bb7..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSimpleRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - 用户组精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class BpmUserGroupSimpleRespVO { - - @Schema(description = "用户组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "用户组名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupUpdateReqVO.java deleted file mode 100644 index 02bb2b31c4..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupUpdateReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import jakarta.validation.constraints.*; - -@Schema(description = "管理后台 - 用户组更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmUserGroupUpdateReqVO extends BpmUserGroupBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java deleted file mode 100644 index 798355057f..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.web.multipart.MultipartFile; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 流程模型的导入 Request VO 相比流程模型的新建来说,只是多了一个 bpmnFile 文件") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmModeImportReqVO extends BpmModelCreateReqVO { - - @Schema(description = "BPMN 文件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "BPMN 文件不能为空") - private MultipartFile bpmnFile; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelBaseVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelBaseVO.java deleted file mode 100644 index c0b1443cbe..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelBaseVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; - -/** -* 流程模型 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class BpmModelBaseVO { - - @Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "process_yudao") - @NotEmpty(message = "流程标识不能为空") - private String key; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotEmpty(message = "流程名称不能为空") - private String name; - - @Schema(description = "流程描述", example = "我是描述") - private String description; - - @Schema(description = "流程分类-参见 bpm_model_category 数据字典", example = "1") - @NotEmpty(message = "流程分类不能为空") - private String category; - - @Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1") - private Integer formType; - @Schema(description = "表单编号-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", example = "1024") - private Long formId; - @Schema(description = "自定义表单的提交路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/create") - private String formCustomCreatePath; - @Schema(description = "自定义表单的查看路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/view") - private String formCustomViewPath; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java deleted file mode 100644 index cd4a2c1660..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 流程模型的创建 Request VO") -@Data -public class BpmModelCreateReqVO { - - @Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "process_yudao") - @NotEmpty(message = "流程标识不能为空") - private String key; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotEmpty(message = "流程名称不能为空") - private String name; - - @Schema(description = "流程描述", example = "我是描述") - private String description; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageItemRespVO.java deleted file mode 100644 index 4fc5b61d49..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageItemRespVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程模型的分页的每一项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmModelPageItemRespVO extends BpmModelBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "表单名字", example = "请假表单") - private String formName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - /** - * 最新部署的流程定义 - */ - private ProcessDefinition processDefinition; - - @Schema(description = "流程定义") - @Data - public static class ProcessDefinition { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "版本", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer version; - - @Schema(description = "部署时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime deploymentTime; - - @Schema(description = "中断状态-参见 SuspensionState 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer suspensionState; - - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java deleted file mode 100644 index 15283208e4..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - - -@Schema(description = "管理后台 - 流程模型分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmModelPageReqVO extends PageParam { - - @Schema(description = "标识-精准匹配", example = "process1641042089407") - private String key; - - @Schema(description = "名字-模糊匹配", example = "芋道") - private String name; - - @Schema(description = "流程分类-参见 bpm_model_category 数据字典", example = "1") - private String category; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java deleted file mode 100644 index df4abf750b..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程模型的创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmModelRespVO extends BpmModelBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "BPMN XML", requiredMode = Schema.RequiredMode.REQUIRED) - private String bpmnXml; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java deleted file mode 100644 index 9cfb7bbbe3..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 流程模型的更新 Request VO") -@Data -public class BpmModelUpdateReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "编号不能为空") - private String id; - - @Schema(description = "流程名称", example = "芋道") - private String name; - - @Schema(description = "流程描述", example = "我是描述") - private String description; - - @Schema(description = "流程分类-参见 bpm_model_category 数据字典", example = "1") - private String category; - - @Schema(description = "BPMN XML", requiredMode = Schema.RequiredMode.REQUIRED) - private String bpmnXml; - - @Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1") - private Integer formType; - @Schema(description = "表单编号-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", example = "1024") - private Long formId; - @Schema(description = "自定义表单的提交路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/create") - private String formCustomCreatePath; - @Schema(description = "自定义表单的查看路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/view") - private String formCustomViewPath; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java deleted file mode 100644 index 4d583dac23..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 流程模型更新状态 Request VO") -@Data -public class BpmModelUpdateStateReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private String id; - - @Schema(description = "状态-见 SuspensionState 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer state; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionListReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionListReqVO.java deleted file mode 100644 index 35243d2ac7..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionListReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 流程定义列表 Request VO") -@Data -@ToString(callSuper = true) -@EqualsAndHashCode(callSuper = true) -public class BpmProcessDefinitionListReqVO extends PageParam { - - @Schema(description = "中断状态-参见 SuspensionState 枚举", example = "1") - private Integer suspensionState; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageItemRespVO.java deleted file mode 100644 index 901c8aa770..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageItemRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程定义的分页的每一项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmProcessDefinitionPageItemRespVO extends BpmProcessDefinitionRespVO { - - @Schema(description = "表单名字", example = "请假表单") - private String formName; - - @Schema(description = "部署时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime deploymentTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java deleted file mode 100644 index f5c7f36d61..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 流程定义分页 Request VO") -@Data -@ToString(callSuper = true) -@EqualsAndHashCode(callSuper = true) -public class BpmProcessDefinitionPageReqVO extends PageParam { - - @Schema(description = "标识-精准匹配", example = "process1641042089407") - private String key; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java deleted file mode 100644 index c649c8219f..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import java.util.List; - -@Schema(description = "管理后台 - 流程定义 Response VO") -@Data -public class BpmProcessDefinitionRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "版本", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer version; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotEmpty(message = "流程名称不能为空") - private String name; - - @Schema(description = "流程描述", example = "我是描述") - private String description; - - @Schema(description = "流程分类-参见 bpm_model_category 数据字典", example = "1") - @NotEmpty(message = "流程分类不能为空") - private String category; - - @Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1") - private Integer formType; - @Schema(description = "表单编号-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", example = "1024") - private Long formId; - @Schema(description = "表单的配置-JSON 字符串。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", requiredMode = Schema.RequiredMode.REQUIRED) - private String formConf; - @Schema(description = "表单项的数组-JSON 字符串的数组。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", requiredMode = Schema.RequiredMode.REQUIRED) - private List formFields; - @Schema(description = "自定义表单的提交路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/create") - private String formCustomCreatePath; - @Schema(description = "自定义表单的查看路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/view") - private String formCustomViewPath; - - @Schema(description = "中断状态-参见 SuspensionState 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer suspensionState; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleBaseVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleBaseVO.java deleted file mode 100644 index 1521abc8e0..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleBaseVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; -import java.util.Set; - -/** - * 流程任务分配规则 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BpmTaskAssignRuleBaseVO { - - @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "bpm_task_assign_rule_type") - @NotNull(message = "规则类型不能为空") - private Integer type; - - @Schema(description = "规则值数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3") - @NotNull(message = "规则值数组不能为空") - private Set options; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleCreateReqVO.java deleted file mode 100644 index 90e6b7e33e..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleCreateReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 流程任务分配规则的创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmTaskAssignRuleCreateReqVO extends BpmTaskAssignRuleBaseVO { - - @Schema(description = "流程模型的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "流程模型的编号不能为空") - private String modelId; - - @Schema(description = "流程任务定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotEmpty(message = "流程任务定义的编号不能为空") - private String taskDefinitionKey; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleRespVO.java deleted file mode 100644 index ac4f85e789..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 流程任务分配规则的 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmTaskAssignRuleRespVO extends BpmTaskAssignRuleBaseVO { - - @Schema(description = "任务分配规则的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "流程模型的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private String modelId; - - @Schema(description = "流程定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") - private String processDefinitionId; - - @Schema(description = "流程任务定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private String taskDefinitionKey; - @Schema(description = "流程任务定义的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "关注芋道") - private String taskDefinitionName; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleUpdateReqVO.java deleted file mode 100644 index 7d13cc07ad..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 流程任务分配规则的更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmTaskAssignRuleUpdateReqVO extends BpmTaskAssignRuleBaseVO { - - @Schema(description = "任务分配规则的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "任务分配规则的编号不能为空") - private Long id; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http deleted file mode 100644 index 96bbf964db..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http +++ /dev/null @@ -1,12 +0,0 @@ -### 请求 /bpm/oa/leave/create 接口 => 成功 -POST {{baseUrl}}/bpm/oa/leave/create -Content-Type: application/json -tenant-id: 1 -Authorization: Bearer {{token}} - -{ - "startTime": "2022-03-01", - "endTime": "2022-03-05", - "type": 1, - "reason": "我要请假啦啦啦!" -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java deleted file mode 100644 index b964694a5a..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa; - -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveRespVO; -import cn.iocoder.yudao.module.bpm.convert.oa.BpmOALeaveConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -/** - * OA 请假申请 Controller,用于演示自己存储数据,接入工作流的例子 - * - * @author jason - * @author 芋道源码 - */ -@Tag(name = "管理后台 - OA 请假申请") -@RestController -@RequestMapping("/bpm/oa/leave") -@Validated -public class BpmOALeaveController { - - @Resource - private BpmOALeaveService leaveService; - - @PostMapping("/create") - @PreAuthorize("@ss.hasPermission('bpm:oa-leave:create')") - @Operation(summary = "创建请求申请") - public CommonResult createLeave(@Valid @RequestBody BpmOALeaveCreateReqVO createReqVO) { - return success(leaveService.createLeave(getLoginUserId(), createReqVO)); - } - - @GetMapping("/get") - @PreAuthorize("@ss.hasPermission('bpm:oa-leave:query')") - @Operation(summary = "获得请假申请") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getLeave(@RequestParam("id") Long id) { - BpmOALeaveDO leave = leaveService.getLeave(id); - return success(BpmOALeaveConvert.INSTANCE.convert(leave)); - } - - @GetMapping("/page") - @PreAuthorize("@ss.hasPermission('bpm:oa-leave:query')") - @Operation(summary = "获得请假申请分页") - public CommonResult> getLeavePage(@Valid BpmOALeavePageReqVO pageVO) { - PageResult pageResult = leaveService.getLeavePage(getLoginUserId(), pageVO); - return success(BpmOALeaveConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java deleted file mode 100644 index 7028708b1e..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * OA 示例,用于演示外部业务接入 BPM 工作流的示例 - * 一般的接入方式,只需要调用 接口,后续 Admin 用户在管理后台的【待办事务】进行审批 - */ -package cn.iocoder.yudao.module.bpm.controller.admin.oa; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveBaseVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveBaseVO.java deleted file mode 100644 index f7089f8594..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveBaseVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; -import jakarta.validation.constraints.*; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 请假申请 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class BpmOALeaveBaseVO { - - @Schema(description = "请假的开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - @Schema(description = "请假的结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "请假类型-参见 bpm_oa_type 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - @Schema(description = "原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "阅读芋道源码") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java deleted file mode 100644 index 56ee98b337..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.AssertTrue; - -@Schema(description = "管理后台 - 请假申请创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmOALeaveCreateReqVO extends BpmOALeaveBaseVO { - - @AssertTrue(message = "结束时间,需要在开始时间之后") - public boolean isEndTimeValid() { - return !getEndTime().isBefore(getStartTime()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java deleted file mode 100644 index 903a0fcf27..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 请假申请分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmOALeavePageReqVO extends PageParam { - - @Schema(description = "状态-参见 bpm_process_instance_result 枚举", example = "1") - private Integer result; - - @Schema(description = "请假类型-参见 bpm_oa_type", example = "1") - private Integer type; - - @Schema(description = "原因-模糊匹配", example = "阅读芋道源码") - private String reason; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "申请时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java deleted file mode 100644 index 669e309e7e..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 请假申请 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmOALeaveRespVO extends BpmOALeaveBaseVO { - - @Schema(description = "请假表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "状态-参见 bpm_process_instance_result 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer result; - - @Schema(description = "申请时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "申请时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime createTime; - - @Schema(description = "流程id") - private String processInstanceId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java deleted file mode 100644 index 8e7e76a3e1..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 流程活动实例") -@RestController -@RequestMapping("/bpm/activity") -@Validated -public class BpmActivityController { - - @Resource - private BpmActivityService activityService; - - @GetMapping("/list") - @Operation(summary = "生成指定流程实例的高亮流程图", - description = "只高亮进行中的任务。不过要注意,该接口暂时没用,通过前端的 ProcessViewer.vue 界面的 highlightDiagram 方法生成") - @Parameter(name = "processInstanceId", description = "流程实例的编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getActivityList( - @RequestParam("processInstanceId") String processInstanceId) { - return success(activityService.getActivityListByProcessInstanceId(processInstanceId)); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java deleted file mode 100644 index af8e8edcd1..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 流程实例") // 流程实例,通过流程定义创建的一次“申请” -@RestController -@RequestMapping("/bpm/process-instance") -@Validated -public class BpmProcessInstanceController { - - @Resource - private BpmProcessInstanceService processInstanceService; - - @GetMapping("/my-page") - @Operation(summary = "获得我的实例分页列表", description = "在【我的流程】菜单中,进行调用") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')") - public CommonResult> getMyProcessInstancePage( - @Valid BpmProcessInstanceMyPageReqVO pageReqVO) { - return success(processInstanceService.getMyProcessInstancePage(getLoginUserId(), pageReqVO)); - } - - @PostMapping("/create") - @Operation(summary = "新建流程实例") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')") - public CommonResult createProcessInstance(@Valid @RequestBody BpmProcessInstanceCreateReqVO createReqVO) { - return success(processInstanceService.createProcessInstance(getLoginUserId(), createReqVO)); - } - - @GetMapping("/get") - @Operation(summary = "获得指定流程实例", description = "在【流程详细】界面中,进行调用") - @Parameter(name = "id", description = "流程实例的编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')") - public CommonResult getProcessInstance(@RequestParam("id") String id) { - return success(processInstanceService.getProcessInstanceVO(id)); - } - - @DeleteMapping("/cancel") - @Operation(summary = "取消流程实例", description = "撤回发起的流程") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:cancel')") - public CommonResult cancelProcessInstance(@Valid @RequestBody BpmProcessInstanceCancelReqVO cancelReqVO) { - processInstanceService.cancelProcessInstance(getLoginUserId(), cancelReqVO); - return success(true); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java deleted file mode 100644 index ba14b61f1d..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 流程任务实例") -@RestController -@RequestMapping("/bpm/task") -@Validated -public class BpmTaskController { - - @Resource - private BpmTaskService taskService; - - @GetMapping("todo-page") - @Operation(summary = "获取 Todo 待办任务分页") - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getTodoTaskPage(@Valid BpmTaskTodoPageReqVO pageVO) { - return success(taskService.getTodoTaskPage(getLoginUserId(), pageVO)); - } - - @GetMapping("done-page") - @Operation(summary = "获取 Done 已办任务分页") - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getDoneTaskPage(@Valid BpmTaskDonePageReqVO pageVO) { - return success(taskService.getDoneTaskPage(getLoginUserId(), pageVO)); - } - - @GetMapping("/list-by-process-instance-id") - @Operation(summary = "获得指定流程实例的任务列表", description = "包括完成的、未完成的") - @Parameter(name = "processInstanceId", description = "流程实例的编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getTaskListByProcessInstanceId( - @RequestParam("processInstanceId") String processInstanceId) { - return success(taskService.getTaskListByProcessInstanceId(processInstanceId)); - } - - @PutMapping("/approve") - @Operation(summary = "通过任务") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult approveTask(@Valid @RequestBody BpmTaskApproveReqVO reqVO) { - taskService.approveTask(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/reject") - @Operation(summary = "不通过任务") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult rejectTask(@Valid @RequestBody BpmTaskRejectReqVO reqVO) { - taskService.rejectTask(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/update-assignee") - @Operation(summary = "更新任务的负责人", description = "用于【流程详情】的【转派】按钮") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult updateTaskAssignee(@Valid @RequestBody BpmTaskUpdateAssigneeReqVO reqVO) { - taskService.updateTaskAssignee(getLoginUserId(), reqVO); - return success(true); - } - - @GetMapping("/return-list") - @Operation(summary = "获取所有可回退的节点", description = "用于【流程详情】的【回退】按钮") - @Parameter(name = "taskId", description = "当前任务ID", required = true) - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult> getReturnList(@RequestParam("taskId") String taskId) { - return success(taskService.getReturnTaskList(taskId)); - } - - @PutMapping("/return") - @Operation(summary = "回退任务", description = "用于【流程详情】的【回退】按钮") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult returnTask(@Valid @RequestBody BpmTaskReturnReqVO reqVO) { - taskService.returnTask(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/delegate") - @Operation(summary = "委派任务", description = "用于【流程详情】的【委派】按钮。和向前【加签】有点像,唯一区别是【委托】没有单独创立任务") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult delegateTask(@Valid @RequestBody BpmTaskDelegateReqVO reqVO) { - taskService.delegateTask(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/create-sign") - @Operation(summary = "加签", description = "before 前加签,after 后加签") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult createSignTask(@Valid @RequestBody BpmTaskAddSignReqVO reqVO) { - taskService.createSignTask(getLoginUserId(), reqVO); - return success(true); - } - - @DeleteMapping("/delete-sign") - @Operation(summary = "减签") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult deleteSignTask(@Valid @RequestBody BpmTaskSubSignReqVO reqVO) { - taskService.deleteSignTask(getLoginUserId(), reqVO); - return success(true); - } - - @GetMapping("children-list") - @Operation(summary = "获取能被减签的任务") - @Parameter(name = "parentId", description = "父级任务 ID", required = true) - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult> getChildrenTaskList(@RequestParam("parentId") String parentId) { - return success(taskService.getChildrenTaskList(parentId)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java deleted file mode 100644 index ab6468204c..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程活动的 Response VO") -@Data -public class BpmActivityRespVO { - - @Schema(description = "流程活动的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String key; - @Schema(description = "流程活动的类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "StartEvent") - private String type; - - @Schema(description = "流程活动的开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - @Schema(description = "流程活动的结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "关联的流程任务的编号-关联的流程任务,只有 UserTask 等类型才有", example = "2048") - private String taskId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java deleted file mode 100644 index 36d4724a09..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 流程实例的取消 Request VO") -@Data -public class BpmProcessInstanceCancelReqVO { - - @Schema(description = "流程实例的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "流程实例的编号不能为空") - private String id; - - @Schema(description = "取消原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "不请假了!") - @NotEmpty(message = "取消原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java deleted file mode 100644 index 93c22dddc8..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - 流程实例的创建 Request VO") -@Data -public class BpmProcessInstanceCreateReqVO { - - @Schema(description = "流程定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "流程定义编号不能为空") - private String processDefinitionId; - - @Schema(description = "变量实例") - private Map variables; - - // TODO @hai:assignees 复数 - @Schema(description = "提前指派的审批人", requiredMode = Schema.RequiredMode.REQUIRED, example = "{taskKey1: [1, 2]}") - private Map> assignee; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceMyPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceMyPageReqVO.java deleted file mode 100644 index 5b5d9fb26d..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceMyPageReqVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 流程实例的分页 Item Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmProcessInstanceMyPageReqVO extends PageParam { - - @Schema(description = "流程名称", example = "芋道") - private String name; - - @Schema(description = "流程定义的编号", example = "2048") - private String processDefinitionId; - - @Schema(description = "流程实例的状态-参见 bpm_process_instance_status", example = "1") - private Integer status; - - @Schema(description = "流程实例的结果-参见 bpm_process_instance_result", example = "2") - private Integer result; - - @Schema(description = "流程分类-参见 bpm_model_category 数据字典", example = "1") - private String category; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageItemRespVO.java deleted file mode 100644 index 6bb269f1d1..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageItemRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 流程实例的分页 Item Response VO") -@Data -public class BpmProcessInstancePageItemRespVO { - - @Schema(description = "流程实例的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "流程定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private String processDefinitionId; - - @Schema(description = "流程分类-参见 bpm_model_category 数据字典", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String category; - - @Schema(description = "流程实例的状态-参见 bpm_process_instance_status", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "流程实例的结果-参见 bpm_process_instance_result", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer result; - - @Schema(description = "提交时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - /** - * 当前任务 - */ - private List tasks; - - @Schema(description = "流程任务") - @Data - public static class Task { - - @Schema(description = "流程任务的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java deleted file mode 100644 index a9cc810f72..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - 流程实例的 Response VO") -@Data -public class BpmProcessInstanceRespVO { - - @Schema(description = "流程实例的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "流程分类-参见 bpm_model_category 数据字典", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String category; - - @Schema(description = "流程实例的状态-参见 bpm_process_instance_status", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "流程实例的结果-参见 bpm_process_instance_result", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer result; - - @Schema(description = "提交时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "提交的表单值", requiredMode = Schema.RequiredMode.REQUIRED) - private Map formVariables; - - @Schema(description = "业务的唯一标识-例如说,请假申请的编号", example = "1") - private String businessKey; - - /** - * 发起流程的用户 - */ - private User startUser; - - /** - * 流程定义 - */ - private ProcessDefinition processDefinition; - - @Schema(description = "用户信息") - @Data - public static class User { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String nickname; - - @Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long deptId; - @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "研发部") - private String deptName; - - } - - @Schema(description = "流程定义信息") - @Data - public static class ProcessDefinition { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1") - private Integer formType; - @Schema(description = "表单编号-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", example = "1024") - private Long formId; - @Schema(description = "表单的配置-JSON 字符串。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", requiredMode = Schema.RequiredMode.REQUIRED) - private String formConf; - @Schema(description = "表单项的数组-JSON 字符串的数组。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", requiredMode = Schema.RequiredMode.REQUIRED) - private List formFields; - @Schema(description = "自定义表单的提交路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/create") - private String formCustomCreatePath; - @Schema(description = "自定义表单的查看路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/view") - private String formCustomViewPath; - - @Schema(description = "BPMN XML", requiredMode = Schema.RequiredMode.REQUIRED) - private String bpmnXml; - - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskAddSignReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskAddSignReqVO.java deleted file mode 100644 index 68369696b5..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskAddSignReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import java.util.Set; - -// TODO @海洋:类名,应该是 create 哈 -@Schema(description = "管理后台 - 加签流程任务的 Request VO") -@Data -public class BpmTaskAddSignReqVO { - - @Schema(description = "需要加签的任务 ID") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "加签的用户 ID") - @NotEmpty(message = "加签用户 ID 不能为空") - private Set userIdList; - - @Schema(description = "加签类型,before 向前加签,after 向后加签") - @NotEmpty(message = "加签类型不能为空") - private String type; - - @Schema(description = "加签原因") - @NotEmpty(message = "加签原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java deleted file mode 100644 index 14dca13ea6..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 通过流程任务的 Request VO") -@Data -public class BpmTaskApproveReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!") - @NotEmpty(message = "审批意见不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDelegateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDelegateReqVO.java deleted file mode 100644 index 2d16206617..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDelegateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 委派流程任务的 Request VO") -@Data -public class BpmTaskDelegateReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "被委派人 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "被委派人 ID 不能为空") - private Long delegateUserId; - - @Schema(description = "委派原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "做不了决定,需要你先帮忙瞅瞅") - @NotEmpty(message = "委派原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageItemRespVO.java deleted file mode 100644 index 8f51441587..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageItemRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程任务的 Done 已完成的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmTaskDonePageItemRespVO extends BpmTaskTodoPageItemRespVO { - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - @Schema(description = "持续时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Long durationInMillis; - - @Schema(description = "任务结果-参见 bpm_process_instance_result", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer result; - @Schema(description = "审批建议", requiredMode = Schema.RequiredMode.REQUIRED, example = "不请假了!") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageReqVO.java deleted file mode 100644 index 52daea445e..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 流程任务的 Done 已办的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmTaskDonePageReqVO extends PageParam { - - @Schema(description = "流程任务名", example = "芋道") - private String name; - - @Schema(description = "开始的创建收间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime beginCreateTime; - - @Schema(description = "结束的创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endCreateTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java deleted file mode 100644 index acb4ee91d3..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 不通过流程任务的 Request VO") -@Data -public class BpmTaskRejectReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!") - @NotEmpty(message = "审批意见不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java deleted file mode 100644 index 1af839e26b..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 流程任务的 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmTaskRespVO extends BpmTaskDonePageItemRespVO { - - @Schema(description = "任务定义的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "user-001") - private String definitionKey; - - /** - * 审核的用户信息 - */ - private User assigneeUser; - - /** - * 父任务ID - */ - private String parentTaskId; - - @Schema(description = "子任务(由加签生成)", requiredMode = Schema.RequiredMode.REQUIRED, example = "childrenTask") - private List children; - - @Schema(description = "用户信息") - @Data - public static class User { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String nickname; - - @Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long deptId; - @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "研发部") - private String deptName; - - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskReturnReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskReturnReqVO.java deleted file mode 100644 index ca27ff6d5d..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskReturnReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 回退流程任务的 Request VO") -@Data -public class BpmTaskReturnReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "回退到的任务 Key", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotEmpty(message = "回退到的任务 Key 不能为空") - private String targetDefinitionKey; - - @Schema(description = "回退意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "我就是想驳回") - @NotEmpty(message = "回退意见不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSimpleRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSimpleRespVO.java deleted file mode 100644 index b98a25a222..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSimpleRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 流程任务的精简 Response VO") -@Data -public class BpmTaskSimpleRespVO { - - @Schema(description = "任务定义的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "Activity_one") - private String definitionKey; - - @Schema(description = "任务名词", requiredMode = Schema.RequiredMode.REQUIRED, example = "经理审批") - private String name; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSubSignReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSubSignReqVO.java deleted file mode 100644 index a2966a399e..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSubSignReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; - -// TODO @海洋:类名,应该是 delete 哈 -@Schema(description = "管理后台 - 减签流程任务的 Request VO") -@Data -public class BpmTaskSubSignReqVO { - - @Schema(description = "被减签的任务 ID") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "加签原因") - @NotEmpty(message = "加签原因不能为空") - private String reason; -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSubSignRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSubSignRespVO.java deleted file mode 100644 index efecbf5821..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSubSignRespVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 减签流程任务的 Response VO") -@Data -public class BpmTaskSubSignRespVO { - @Schema(description = "审核的用户信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "小李") - private BpmTaskRespVO.User assigneeUser; - @Schema(description = "任务 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "12312") - private String id; - @Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "经理审批") - private String name; -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageItemRespVO.java deleted file mode 100644 index 4b57f47770..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageItemRespVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程任务的 Running 进行中的分页项 Response VO") -@Data -public class BpmTaskTodoPageItemRespVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "任务名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "接收时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime claimTime; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "激活状态-参见 SuspensionState 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer suspensionState; - - /** - * 所属流程实例 - */ - private ProcessInstance processInstance; - - @Data - @Schema(description = "流程实例") - public static class ProcessInstance { - - @Schema(description = "流程实例编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "流程实例名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "发起人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long startUserId; - - @Schema(description = "发起人的用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String startUserNickname; - - @Schema(description = "流程定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private String processDefinitionId; - - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageReqVO.java deleted file mode 100644 index 605007ef5c..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 流程任务的 TODO 待办的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmTaskTodoPageReqVO extends PageParam { - - @Schema(description = "流程任务名", example = "芋道") - private String name; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskUpdateAssigneeReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskUpdateAssigneeReqVO.java deleted file mode 100644 index 51c10bfc58..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskUpdateAssigneeReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 流程任务的更新负责人的 Request VO") -@Data -public class BpmTaskUpdateAssigneeReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "新审批人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "新审批人的用户编号不能为空") - private Long assigneeUserId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java deleted file mode 100644 index e8d285e359..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.bpm.controller.app; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java deleted file mode 100644 index d1930bd6ac..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.bpm.controller; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmFormConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmFormConvert.java deleted file mode 100644 index 6ba7574170..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmFormConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.definition; - -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormSimpleRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormUpdateReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 动态表单 Convert - * - * @author 芋艿 - */ -@Mapper -public interface BpmFormConvert { - - BpmFormConvert INSTANCE = Mappers.getMapper(BpmFormConvert.class); - - BpmFormDO convert(BpmFormCreateReqVO bean); - - BpmFormDO convert(BpmFormUpdateReqVO bean); - - BpmFormRespVO convert(BpmFormDO bean); - - List convertList2(List list); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java deleted file mode 100644 index 9f79032f60..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java +++ /dev/null @@ -1,141 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.definition; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.Model; -import org.flowable.engine.repository.ProcessDefinition; -import org.mapstruct.Mapper; -import org.mapstruct.MappingTarget; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * 流程模型 Convert - * - * @author yunlongn - */ -@Mapper -public interface BpmModelConvert { - - BpmModelConvert INSTANCE = Mappers.getMapper(BpmModelConvert.class); - - default List convertList(List list, Map formMap, - Map deploymentMap, - Map processDefinitionMap) { - return CollectionUtils.convertList(list, model -> { - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); - BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null; - Deployment deployment = model.getDeploymentId() != null ? deploymentMap.get(model.getDeploymentId()) : null; - ProcessDefinition processDefinition = model.getDeploymentId() != null ? processDefinitionMap.get(model.getDeploymentId()) : null; - return convert(model, form, deployment, processDefinition); - }); - } - - default BpmModelPageItemRespVO convert(Model model, BpmFormDO form, Deployment deployment, ProcessDefinition processDefinition) { - BpmModelPageItemRespVO modelRespVO = new BpmModelPageItemRespVO(); - modelRespVO.setId(model.getId()); - modelRespVO.setCreateTime(DateUtils.of(model.getCreateTime())); - // 通用 copy - copyTo(model, modelRespVO); - // Form - if (form != null) { - modelRespVO.setFormId(form.getId()); - modelRespVO.setFormName(form.getName()); - } - // ProcessDefinition - modelRespVO.setProcessDefinition(this.convert(processDefinition)); - if (modelRespVO.getProcessDefinition() != null) { - modelRespVO.getProcessDefinition().setSuspensionState(processDefinition.isSuspended() ? - SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode()); - modelRespVO.getProcessDefinition().setDeploymentTime(DateUtils.of(deployment.getDeploymentTime())); - } - return modelRespVO; - } - - default BpmModelRespVO convert(Model model) { - BpmModelRespVO modelRespVO = new BpmModelRespVO(); - modelRespVO.setId(model.getId()); - modelRespVO.setCreateTime(DateUtils.of(model.getCreateTime())); - // 通用 copy - copyTo(model, modelRespVO); - return modelRespVO; - } - - default void copyTo(Model model, BpmModelBaseVO to) { - to.setName(model.getName()); - to.setKey(model.getKey()); - to.setCategory(model.getCategory()); - // metaInfo - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); - copyTo(metaInfo, to); - } - - BpmModelCreateReqVO convert(BpmModeImportReqVO bean); - - default BpmProcessDefinitionCreateReqDTO convert2(Model model, BpmFormDO form) { - BpmProcessDefinitionCreateReqDTO createReqDTO = new BpmProcessDefinitionCreateReqDTO(); - createReqDTO.setModelId(model.getId()); - createReqDTO.setName(model.getName()); - createReqDTO.setKey(model.getKey()); - createReqDTO.setCategory(model.getCategory()); - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); - // metaInfo - copyTo(metaInfo, createReqDTO); - // form - if (form != null) { - createReqDTO.setFormConf(form.getConf()); - createReqDTO.setFormFields(form.getFields()); - } - return createReqDTO; - } - - void copyTo(BpmModelMetaInfoRespDTO from, @MappingTarget BpmProcessDefinitionCreateReqDTO to); - - void copyTo(BpmModelMetaInfoRespDTO from, @MappingTarget BpmModelBaseVO to); - - BpmModelPageItemRespVO.ProcessDefinition convert(ProcessDefinition bean); - - default void copy(Model model, BpmModelCreateReqVO bean) { - model.setName(bean.getName()); - model.setKey(bean.getKey()); - model.setMetaInfo(buildMetaInfoStr(null, bean.getDescription(), null, null, - null, null)); - } - - default void copy(Model model, BpmModelUpdateReqVO bean) { - model.setName(bean.getName()); - model.setCategory(bean.getCategory()); - model.setMetaInfo(buildMetaInfoStr(JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class), - bean.getDescription(), bean.getFormType(), bean.getFormId(), - bean.getFormCustomCreatePath(), bean.getFormCustomViewPath())); - } - - default String buildMetaInfoStr(BpmModelMetaInfoRespDTO metaInfo, String description, Integer formType, - Long formId, String formCustomCreatePath, String formCustomViewPath) { - if (metaInfo == null) { - metaInfo = new BpmModelMetaInfoRespDTO(); - } - // 只有非空,才进行设置,避免更新时的覆盖 - if (StrUtil.isNotEmpty(description)) { - metaInfo.setDescription(description); - } - if (Objects.nonNull(formType)) { - metaInfo.setFormType(formType); - metaInfo.setFormId(formId); - metaInfo.setFormCustomCreatePath(formCustomCreatePath); - metaInfo.setFormCustomViewPath(formCustomViewPath); - } - return JsonUtils.toJsonString(metaInfo); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java deleted file mode 100644 index b52b48ee9e..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.definition; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageItemRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.ProcessDefinition; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.MappingTarget; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * Bpm 流程定义的 Convert - * - * @author yunlong.li - */ -@Mapper -public interface BpmProcessDefinitionConvert { - - BpmProcessDefinitionConvert INSTANCE = Mappers.getMapper(BpmProcessDefinitionConvert.class); - - BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean); - - BpmProcessDefinitionExtDO convert2(BpmProcessDefinitionCreateReqDTO bean); - - default List convertList(List list, Map deploymentMap, - Map processDefinitionDOMap, Map formMap) { - return CollectionUtils.convertList(list, definition -> { - Deployment deployment = definition.getDeploymentId() != null ? deploymentMap.get(definition.getDeploymentId()) : null; - BpmProcessDefinitionExtDO definitionDO = processDefinitionDOMap.get(definition.getId()); - BpmFormDO form = definitionDO != null ? formMap.get(definitionDO.getFormId()) : null; - return convert(definition, deployment, definitionDO, form); - }); - } - - default List convertList3(List list, - Map processDefinitionDOMap) { - return CollectionUtils.convertList(list, processDefinition -> { - BpmProcessDefinitionRespVO respVO = convert3(processDefinition); - BpmProcessDefinitionExtDO processDefinitionExtDO = processDefinitionDOMap.get(processDefinition.getId()); - // 复制通用属性 - copyTo(processDefinitionExtDO, respVO); - return respVO; - }); - } - - @Mapping(source = "suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState") - BpmProcessDefinitionRespVO convert3(ProcessDefinition bean); - - @Named("convertSuspendedToSuspensionState") - default Integer convertSuspendedToSuspensionState(boolean suspended) { - return suspended ? SuspensionState.SUSPENDED.getStateCode() : - SuspensionState.ACTIVE.getStateCode(); - } - - default BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean, Deployment deployment, - BpmProcessDefinitionExtDO processDefinitionExtDO, BpmFormDO form) { - BpmProcessDefinitionPageItemRespVO respVO = convert(bean); - respVO.setSuspensionState(bean.isSuspended() ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode()); - if (deployment != null) { - respVO.setDeploymentTime(LocalDateTimeUtil.of(deployment.getDeploymentTime())); - } - if (form != null) { - respVO.setFormName(form.getName()); - } - // 复制通用属性 - copyTo(processDefinitionExtDO, respVO); - return respVO; - } - - @Mapping(source = "from.id", target = "to.id", ignore = true) - void copyTo(BpmProcessDefinitionExtDO from, @MappingTarget BpmProcessDefinitionRespVO to); -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmTaskAssignRuleConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmTaskAssignRuleConvert.java deleted file mode 100644 index c616e90b09..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmTaskAssignRuleConvert.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.definition; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleUpdateReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; -import org.flowable.bpmn.model.UserTask; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -@Mapper -public interface BpmTaskAssignRuleConvert { - BpmTaskAssignRuleConvert INSTANCE = Mappers.getMapper(BpmTaskAssignRuleConvert.class); - - default List convertList(List tasks, List rules) { - Map ruleMap = CollectionUtils.convertMap(rules, BpmTaskAssignRuleDO::getTaskDefinitionKey); - // 以 UserTask 为主维度,原因是:流程图编辑后,一些规则实际就没用了。 - return CollectionUtils.convertList(tasks, task -> { - BpmTaskAssignRuleRespVO respVO = convert(ruleMap.get(task.getId())); - if (respVO == null) { - respVO = new BpmTaskAssignRuleRespVO(); - respVO.setTaskDefinitionKey(task.getId()); - } - respVO.setTaskDefinitionName(task.getName()); - return respVO; - }); - } - - BpmTaskAssignRuleRespVO convert(BpmTaskAssignRuleDO bean); - - BpmTaskAssignRuleDO convert(BpmTaskAssignRuleCreateReqVO bean); - - BpmTaskAssignRuleDO convert(BpmTaskAssignRuleUpdateReqVO bean); - - List convertList2(List list); -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmUserGroupConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmUserGroupConvert.java deleted file mode 100644 index bbf00ba524..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmUserGroupConvert.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.definition; - -import java.util.*; - -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import org.mapstruct.Mapper; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -/** - * 用户组 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BpmUserGroupConvert { - - BpmUserGroupConvert INSTANCE = Mappers.getMapper(BpmUserGroupConvert.class); - - BpmUserGroupDO convert(BpmUserGroupCreateReqVO bean); - - BpmUserGroupDO convert(BpmUserGroupUpdateReqVO bean); - - BpmUserGroupRespVO convert(BpmUserGroupDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - @Named("convertList2") - List convertList2(List list); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java deleted file mode 100644 index 99b7bebf23..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.message; - -import cn.iocoder.yudao.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.Map; - -@Mapper -public interface BpmMessageConvert { - - BpmMessageConvert INSTANCE = Mappers.getMapper(BpmMessageConvert.class); - - @Mapping(target = "mobile", ignore = true) - @Mapping(source = "userId", target = "userId") - @Mapping(source = "templateCode", target = "templateCode") - @Mapping(source = "templateParams", target = "templateParams") - SmsSendSingleToUserReqDTO convert(Long userId, String templateCode, Map templateParams); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/oa/BpmOALeaveConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/oa/BpmOALeaveConvert.java deleted file mode 100644 index f87531bfc5..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/oa/BpmOALeaveConvert.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.oa; - -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 请假申请 Convert - * - * @author 芋艿 - */ -@Mapper -public interface BpmOALeaveConvert { - - BpmOALeaveConvert INSTANCE = Mappers.getMapper(BpmOALeaveConvert.class); - - BpmOALeaveDO convert(BpmOALeaveCreateReqVO bean); - - BpmOALeaveRespVO convert(BpmOALeaveDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java deleted file mode 100644 index 6db6ebc461..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.bpm.convert; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java deleted file mode 100644 index 3cb674c1c3..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; - -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import org.flowable.engine.history.HistoricActivityInstance; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * BPM 活动 Convert - * - * @author 芋道源码 - */ -@Mapper(uses = DateUtils.class) -public interface BpmActivityConvert { - - BpmActivityConvert INSTANCE = Mappers.getMapper(BpmActivityConvert.class); - - List convertList(List list); - - @Mappings({ - @Mapping(source = "activityId", target = "key"), - @Mapping(source = "activityType", target = "type") - }) - BpmActivityRespVO convert(HistoricActivityInstance bean); -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java deleted file mode 100644 index 8296b8bb3a..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java +++ /dev/null @@ -1,115 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstancePageItemRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO; -import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEvent; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.repository.ProcessDefinition; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.Task; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.MappingTarget; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 流程实例 Convert - * - * @author 芋道源码 - */ -@Mapper(uses = DateUtils.class) -public interface BpmProcessInstanceConvert { - - BpmProcessInstanceConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceConvert.class); - - default PageResult convertPage(PageResult page, - Map> taskMap) { - List list = convertList(page.getList()); - list.forEach(respVO -> respVO.setTasks(convertList2(taskMap.get(respVO.getId())))); - return new PageResult<>(list, page.getTotal()); - } - - List convertList(List list); - - @Mapping(source = "processInstanceId", target = "id") - BpmProcessInstancePageItemRespVO convert(BpmProcessInstanceExtDO bean); - - List convertList2(List tasks); - - default BpmProcessInstanceRespVO convert2(HistoricProcessInstance processInstance, BpmProcessInstanceExtDO processInstanceExt, - ProcessDefinition processDefinition, BpmProcessDefinitionExtDO processDefinitionExt, - String bpmnXml, AdminUserRespDTO startUser, DeptRespDTO dept) { - BpmProcessInstanceRespVO respVO = convert2(processInstance); - copyTo(processInstanceExt, respVO); - // definition - respVO.setProcessDefinition(convert2(processDefinition)); - copyTo(processDefinitionExt, respVO.getProcessDefinition()); - respVO.getProcessDefinition().setBpmnXml(bpmnXml); - // user - if (startUser != null) { - respVO.setStartUser(convert2(startUser)); - if (dept != null) { - respVO.getStartUser().setDeptName(dept.getName()); - } - } - return respVO; - } - - BpmProcessInstanceRespVO convert2(HistoricProcessInstance bean); - - @Mapping(source = "from.id", target = "to.id", ignore = true) - void copyTo(BpmProcessInstanceExtDO from, @MappingTarget BpmProcessInstanceRespVO to); - - BpmProcessInstanceRespVO.ProcessDefinition convert2(ProcessDefinition bean); - - @Mapping(source = "from.id", target = "to.id", ignore = true) - void copyTo(BpmProcessDefinitionExtDO from, @MappingTarget BpmProcessInstanceRespVO.ProcessDefinition to); - - BpmProcessInstanceRespVO.User convert2(AdminUserRespDTO bean); - - default BpmProcessInstanceResultEvent convert(Object source, HistoricProcessInstance instance, Integer result) { - BpmProcessInstanceResultEvent event = new BpmProcessInstanceResultEvent(source); - event.setId(instance.getId()); - event.setProcessDefinitionKey(instance.getProcessDefinitionKey()); - event.setBusinessKey(instance.getBusinessKey()); - event.setResult(result); - return event; - } - - default BpmProcessInstanceResultEvent convert(Object source, ProcessInstance instance, Integer result) { - BpmProcessInstanceResultEvent event = new BpmProcessInstanceResultEvent(source); - event.setId(instance.getId()); - event.setProcessDefinitionKey(instance.getProcessDefinitionKey()); - event.setBusinessKey(instance.getBusinessKey()); - event.setResult(result); - return event; - } - - default BpmMessageSendWhenProcessInstanceApproveReqDTO convert2ApprovedReq(ProcessInstance instance){ - return new BpmMessageSendWhenProcessInstanceApproveReqDTO() - .setStartUserId(NumberUtils.parseLong(instance.getStartUserId())) - .setProcessInstanceId(instance.getId()) - .setProcessInstanceName(instance.getName()); - } - - default BpmMessageSendWhenProcessInstanceRejectReqDTO convert2RejectReq(ProcessInstance instance, String reason) { - return new BpmMessageSendWhenProcessInstanceRejectReqDTO() - .setProcessInstanceName(instance.getName()) - .setProcessInstanceId(instance.getId()) - .setReason(reason) - .setStartUserId(NumberUtils.parseLong(instance.getStartUserId())); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java deleted file mode 100644 index 60ce840218..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java +++ /dev/null @@ -1,201 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.bpmn.model.FlowElement; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.Task; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl; -import org.mapstruct.*; -import org.mapstruct.factory.Mappers; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; - -/** - * Bpm 任务 Convert - * - * @author 芋道源码 - */ -@Mapper(uses = DateUtils.class) -public interface BpmTaskConvert { - - BpmTaskConvert INSTANCE = Mappers.getMapper(BpmTaskConvert.class); - - default List convertList1(List tasks, - Map processInstanceMap, - Map userMap) { - return CollectionUtils.convertList(tasks, task -> { - BpmTaskTodoPageItemRespVO respVO = convert1(task); - ProcessInstance processInstance = processInstanceMap.get(task.getProcessInstanceId()); - if (processInstance != null) { - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); - respVO.setProcessInstance(convert(processInstance, startUser)); - } - return respVO; - }); - } - - @Mapping(source = "suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState") - BpmTaskTodoPageItemRespVO convert1(Task bean); - - @Named("convertSuspendedToSuspensionState") - default Integer convertSuspendedToSuspensionState(boolean suspended) { - return suspended ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode(); - } - - default List convertList2(List tasks, - Map bpmTaskExtDOMap, Map historicProcessInstanceMap, - Map userMap) { - return CollectionUtils.convertList(tasks, task -> { - BpmTaskDonePageItemRespVO respVO = convert2(task); - BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId()); - copyTo(taskExtDO, respVO); - HistoricProcessInstance processInstance = historicProcessInstanceMap.get(task.getProcessInstanceId()); - if (processInstance != null) { - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); - respVO.setProcessInstance(convert(processInstance, startUser)); - } - return respVO; - }); - } - - BpmTaskDonePageItemRespVO convert2(HistoricTaskInstance bean); - - @Mappings({ - @Mapping(source = "processInstance.id", target = "id"), - @Mapping(source = "processInstance.name", target = "name"), - @Mapping(source = "processInstance.startUserId", target = "startUserId"), - @Mapping(source = "processInstance.processDefinitionId", target = "processDefinitionId"), - @Mapping(source = "startUser.nickname", target = "startUserNickname") - }) - BpmTaskTodoPageItemRespVO.ProcessInstance convert(ProcessInstance processInstance, AdminUserRespDTO startUser); - - default List convertList3(List tasks, - Map bpmTaskExtDOMap, HistoricProcessInstance processInstance, - Map userMap, Map deptMap) { - return CollectionUtils.convertList(tasks, task -> { - BpmTaskRespVO respVO = convert3(task); - BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId()); - copyTo(taskExtDO, respVO); - if (processInstance != null) { - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); - respVO.setProcessInstance(convert(processInstance, startUser)); - } - AdminUserRespDTO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee())); - if (assignUser != null) { - respVO.setAssigneeUser(convert3(assignUser)); - DeptRespDTO dept = deptMap.get(assignUser.getDeptId()); - if (dept != null) { - respVO.getAssigneeUser().setDeptName(dept.getName()); - } - } - return respVO; - }); - } - - @Mapping(source = "taskDefinitionKey", target = "definitionKey") - BpmTaskRespVO convert3(HistoricTaskInstance bean); - - BpmTaskRespVO.User convert3(AdminUserRespDTO bean); - - @Mapping(target = "id", ignore = true) - void copyTo(BpmTaskExtDO from, @MappingTarget BpmTaskDonePageItemRespVO to); - - @Mappings({@Mapping(source = "processInstance.id", target = "id"), - @Mapping(source = "processInstance.name", target = "name"), - @Mapping(source = "processInstance.startUserId", target = "startUserId"), - @Mapping(source = "processInstance.processDefinitionId", target = "processDefinitionId"), - @Mapping(source = "startUser.nickname", target = "startUserNickname")}) - BpmTaskTodoPageItemRespVO.ProcessInstance convert(HistoricProcessInstance processInstance, - AdminUserRespDTO startUser); - - default BpmTaskExtDO convert2TaskExt(Task task) { - BpmTaskExtDO taskExtDO = new BpmTaskExtDO().setTaskId(task.getId()) - .setAssigneeUserId(NumberUtils.parseLong(task.getAssignee())).setName(task.getName()) - .setProcessDefinitionId(task.getProcessDefinitionId()).setProcessInstanceId(task.getProcessInstanceId()); - taskExtDO.setCreateTime(LocalDateTimeUtil.of(task.getCreateTime())); - return taskExtDO; - } - - default BpmMessageSendWhenTaskCreatedReqDTO convert(ProcessInstance processInstance, AdminUserRespDTO startUser, - Task task) { - BpmMessageSendWhenTaskCreatedReqDTO reqDTO = new BpmMessageSendWhenTaskCreatedReqDTO(); - reqDTO.setProcessInstanceId(processInstance.getProcessInstanceId()) - .setProcessInstanceName(processInstance.getName()).setStartUserId(startUser.getId()) - .setStartUserNickname(startUser.getNickname()).setTaskId(task.getId()).setTaskName(task.getName()) - .setAssigneeUserId(NumberUtils.parseLong(task.getAssignee())); - return reqDTO; - } - - default List convertList(List elementList) { - return CollectionUtils.convertList(elementList, element -> new BpmTaskSimpleRespVO() - .setName(element.getName()) - .setDefinitionKey(element.getId())); - } - - //此处不用 mapstruct 映射,因为 TaskEntityImpl 还有很多其他属性,这里我们只设置我们需要的 - //使用 mapstruct 会将里面嵌套的各个属性值都设置进去,会出现意想不到的问题 - default TaskEntityImpl convert(TaskEntityImpl task,TaskEntityImpl parentTask){ - task.setCategory(parentTask.getCategory()); - task.setDescription(parentTask.getDescription()); - task.setTenantId(parentTask.getTenantId()); - task.setName(parentTask.getName()); - task.setParentTaskId(parentTask.getId()); - task.setProcessDefinitionId(parentTask.getProcessDefinitionId()); - task.setProcessInstanceId(parentTask.getProcessInstanceId()); - task.setTaskDefinitionKey(parentTask.getTaskDefinitionKey()); - task.setTaskDefinitionId(parentTask.getTaskDefinitionId()); - task.setPriority(parentTask.getPriority()); - task.setCreateTime(new Date()); - return task; - } - - default List convertList(List bpmTaskExtDOList, - Map userMap, - Map idTaskMap){ - return CollectionUtils.convertList(bpmTaskExtDOList, task -> { - BpmTaskSubSignRespVO bpmTaskSubSignRespVO = new BpmTaskSubSignRespVO() - .setId(task.getTaskId()).setName(task.getName()); - // 后加签任务不会直接设置 assignee ,所以不存在 assignee 的情况,则去取 owner - Task sourceTask = idTaskMap.get(task.getTaskId()); - String assignee = ObjectUtil.defaultIfBlank(sourceTask.getOwner(),sourceTask.getAssignee()); - MapUtils.findAndThen(userMap,NumberUtils.parseLong(assignee), - assignUser-> bpmTaskSubSignRespVO.setAssigneeUser(convert3(assignUser))); - return bpmTaskSubSignRespVO; - }); - } - - /** - * 转换任务为父子级 - * - * @param sourceList 原始数据 - * @return 转换后的父子级数组 - */ - default List convertChildrenList(List sourceList) { - List childrenTaskList = filterList(sourceList, r -> StrUtil.isNotEmpty(r.getParentTaskId())); - Map> parentChildrenTaskListMap = convertMultiMap(childrenTaskList, BpmTaskRespVO::getParentTaskId); - for (BpmTaskRespVO bpmTaskRespVO : sourceList) { - bpmTaskRespVO.setChildren(parentChildrenTaskListMap.get(bpmTaskRespVO.getId())); - } - return filterList(sourceList, r -> StrUtil.isEmpty(r.getParentTaskId())); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/package-info.java deleted file mode 100644 index 6a53114a8c..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; diff --git "a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" "b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" deleted file mode 100644 index 8153487b72..0000000000 --- "a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java deleted file mode 100644 index 76bf777e5d..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 工作流的表单定义 - * 用于工作流的申请表单,需要动态配置的场景 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_form", autoResultMap = true) -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmFormDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 表单名 - */ - private String name; - /** - * 状态 - */ - private Integer status; - /** - * 表单的配置 - */ - private String conf; - /** - * 表单项的数组 - * - * 目前直接将 https://github.com/JakHuang/form-generator 生成的 JSON 串,直接保存 - * 定义:https://github.com/JakHuang/form-generator/issues/46 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List fields; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java deleted file mode 100644 index 57abc0b99b..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * Bpm 流程定义的拓展表 - * 主要解决 Activiti {@link ProcessDefinition} 不支持拓展字段,所以新建拓展表 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_process_definition_ext", autoResultMap = true) -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmProcessDefinitionExtDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 流程定义的编号 - * - * 关联 ProcessDefinition 的 id 属性 - */ - private String processDefinitionId; - /** - * 流程模型的编号 - * - * 关联 Model 的 id 属性 - */ - private String modelId; - /** - * 描述 - */ - private String description; - - /** - * 表单类型 - * - * 关联 {@link BpmModelFormTypeEnum} - */ - private Integer formType; - /** - * 动态表单编号 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - * - * 关联 {@link BpmFormDO#getId()} - */ - private Long formId; - /** - * 表单的配置 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - * - * 冗余 {@link BpmFormDO#getConf()} - */ - private String formConf; - /** - * 表单项的数组 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - * - * 冗余 {@link BpmFormDO#getFields()} ()} - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List formFields; - /** - * 自定义表单的提交路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomCreatePath; - /** - * 自定义表单的查看路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomViewPath; - - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskAssignRuleDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskAssignRuleDO.java deleted file mode 100644 index e65764f1a8..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskAssignRuleDO.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.Set; - -/** - * Bpm 任务分配的规则表,用于自定义配置每个任务的负责人、候选人的分配规则。 - * 也就是说,废弃 BPMN 原本的 UserTask 设置的 assignee、candidateUsers 等配置,而是通过使用该规则进行计算对应的负责人。 - * - * 1. 默认情况下,{@link #processDefinitionId} 为 {@link #PROCESS_DEFINITION_ID_NULL} 值,表示贵改则与流程模型关联 - * 2. 在流程模型部署后,会将他的所有规则记录,复制出一份新部署出来的流程定义,通过设置 {@link #processDefinitionId} 为新的流程定义的编号进行关联 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_task_assign_rule", autoResultMap = true) -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmTaskAssignRuleDO extends BaseDO { - - /** - * {@link #processDefinitionId} 空串,用于标识属于流程模型,而不属于流程定义 - */ - public static final String PROCESS_DEFINITION_ID_NULL = ""; - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 流程模型编号 - * - * 关联 Model 的 id 属性 - */ - private String modelId; - /** - * 流程定义编号 - * - * 关联 ProcessDefinition 的 id 属性 - */ - private String processDefinitionId; - /** - * 流程任务的定义 Key - * - * 关联 Task 的 taskDefinitionKey 属性 - */ - private String taskDefinitionKey; - - /** - * 规则类型 - * - * 枚举 {@link BpmTaskAssignRuleTypeEnum} - */ - @TableField("`type`") - private Integer type; - /** - * 规则值数组,一般关联指定表的编号 - * 根据 type 不同,对应的值是不同的: - * - * 1. {@link BpmTaskAssignRuleTypeEnum#ROLE} 时:角色编号 - * 2. {@link BpmTaskAssignRuleTypeEnum#DEPT_MEMBER} 时:部门编号 - * 3. {@link BpmTaskAssignRuleTypeEnum#DEPT_LEADER} 时:部门编号 - * 4. {@link BpmTaskAssignRuleTypeEnum#USER} 时:用户编号 - * 5. {@link BpmTaskAssignRuleTypeEnum#USER_GROUP} 时:用户组编号 - * 6. {@link BpmTaskAssignRuleTypeEnum#SCRIPT} 时:脚本编号,目前通过 {@link BpmTaskRuleScriptEnum#getId()} 标识 - */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) - private Set options; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskMessageRuleDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskMessageRuleDO.java deleted file mode 100644 index db204c0273..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskMessageRuleDO.java +++ /dev/null @@ -1,5 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -// TODO 芋艿:先埋个坑。任务消息的配置规则。说白了,就是不同的 -public class BpmTaskMessageRuleDO { -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java deleted file mode 100644 index ec11681805..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.Set; - -/** - * Bpm 用户组 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_user_group", autoResultMap = true) -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmUserGroupDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - /** - * 组名 - */ - private String name; - /** - * 描述 - */ - private String description; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 成员用户编号数组 - */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) - private Set memberUserIds; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java deleted file mode 100644 index 4e4e68d6f7..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.oa; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * OA 请假申请 DO - * - * {@link #day} 请假天数,目前先简单做。一般是分成请假上午和下午,可以是 1 整天,可以是 0.5 半天 - * - * @author jason - * @author 芋道源码 - */ -@TableName("bpm_oa_leave") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmOALeaveDO extends BaseDO { - - /** - * 请假表单主键 - */ - @TableId - private Long id; - /** - * 申请人的用户编号 - * - * 关联 AdminUserDO 的 id 属性 - */ - private Long userId; - /** - * 请假类型 - */ - private String type; - /** - * 原因 - */ - private String reason; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 请假天数 - */ - private Long day; - /** - * 请假的结果 - * - * 枚举 {@link BpmProcessInstanceResultEnum} - * 考虑到简单,所以直接复用了 BpmProcessInstanceResultEnum 枚举,也可以自己定义一个枚举哈 - */ - private Integer result; - - /** - * 对应的流程编号 - * - * 关联 ProcessInstance 的 id 属性 - */ - private String processInstanceId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java deleted file mode 100644 index 5a481fff0f..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.task; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -/** - * Bpm 流程实例的拓展表 - * 主要解决 Activiti ProcessInstance 和 HistoricProcessInstance 不支持拓展字段,所以新建拓展表 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_process_instance_ext", autoResultMap = true) -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmProcessInstanceExtDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - /** - * 发起流程的用户编号 - * - * 冗余 HistoricProcessInstance 的 startUserId 属性 - */ - private Long startUserId; - /** - * 流程实例的名字 - * - * 冗余 ProcessInstance 的 name 属性,用于筛选 - */ - private String name; - /** - * 流程实例的编号 - * - * 关联 ProcessInstance 的 id 属性 - */ - private String processInstanceId; - /** - * 流程定义的编号 - * - * 关联 ProcessDefinition 的 id 属性 - */ - private String processDefinitionId; - /** - * 流程分类 - * - * 冗余 ProcessDefinition 的 category 属性 - * 数据字典 bpm_model_category - */ - private String category; - /** - * 流程实例的状态 - * - * 枚举 {@link BpmProcessInstanceStatusEnum} - */ - private Integer status; - /** - * 流程实例的结果 - * - * 枚举 {@link BpmProcessInstanceResultEnum} - */ - private Integer result; - /** - * 结束时间 - * - * 冗余 HistoricProcessInstance 的 endTime 属性 - */ - private LocalDateTime endTime; - - /** - * 提交的表单值 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private Map formVariables; - - // TODO @hai:assignees 复数 - /** - * 提前设定好的审批人 - */ - @TableField(typeHandler = JacksonTypeHandler.class, exist = false) // TODO 芋艿:临时 exist = false,避免 db 报错; - private Map> assignee; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmTaskExtDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmTaskExtDO.java deleted file mode 100644 index a79fce4128..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmTaskExtDO.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.task; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -/** - * Bpm 流程任务的拓展表 - * 主要解决 Flowable Task 和 HistoricTaskInstance 不支持拓展字段,所以新建拓展表 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_task_ext", autoResultMap = true) -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmTaskExtDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 任务的审批人 - * - * 冗余 Task 的 assignee 属性 - */ - private Long assigneeUserId; - /** - * 任务的名字 - * - * 冗余 Task 的 name 属性,为了筛选 - */ - private String name; - /** - * 任务的编号 - * - * 关联 Task 的 id 属性 - */ - private String taskId; -// /** -// * 任务的标识 -// * -// * 关联 {@link Task#getTaskDefinitionKey()} -// */ -// private String definitionKey; - /** - * 任务的结果 - * - * 枚举 {@link BpmProcessInstanceResultEnum} - */ - private Integer result; - /** - * 审批建议 - */ - private String reason; - /** - * 任务的结束时间 - * - * 冗余 HistoricTaskInstance 的 endTime 属性 - */ - private LocalDateTime endTime; - - /** - * 流程实例的编号 - * - * 关联 ProcessInstance 的 id 属性 - */ - private String processInstanceId; - /** - * 流程定义的编号 - * - * 关联 ProcessDefinition 的 id 属性 - */ - private String processDefinitionId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java deleted file mode 100644 index 53c01d92e5..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - - -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import org.apache.ibatis.annotations.Mapper; - -/** - * 动态表单 Mapper - * - * @author 风里雾里 - */ -@Mapper -public interface BpmFormMapper extends BaseMapperX { - - default PageResult selectPage(BpmFormPageReqVO reqVO) { - return selectPage(reqVO, new QueryWrapperX() - .likeIfPresent("name", reqVO.getName()) - .orderByDesc("id")); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java deleted file mode 100644 index 3ff53f2d9c..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface BpmProcessDefinitionExtMapper extends BaseMapperX { - - default List selectListByProcessDefinitionIds(Collection processDefinitionIds) { - return selectList("process_definition_id", processDefinitionIds); - } - - default BpmProcessDefinitionExtDO selectByProcessDefinitionId(String processDefinitionId) { - return selectOne("process_definition_id", processDefinitionId); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmTaskAssignRuleMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmTaskAssignRuleMapper.java deleted file mode 100644 index c4061c0f88..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmTaskAssignRuleMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import org.apache.ibatis.annotations.Mapper; -import org.springframework.lang.Nullable; - -import java.util.List; - -@Mapper -public interface BpmTaskAssignRuleMapper extends BaseMapperX { - - default List selectListByProcessDefinitionId(String processDefinitionId, - @Nullable String taskDefinitionKey) { - return selectList(new QueryWrapperX() - .eq("process_definition_id", processDefinitionId) - .eqIfPresent("task_definition_key", taskDefinitionKey)); - } - - default List selectListByModelId(String modelId) { - return selectList(new QueryWrapperX() - .eq("model_id", modelId) - .eq("process_definition_id", BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL)); - } - - default BpmTaskAssignRuleDO selectListByModelIdAndTaskDefinitionKey(String modelId, - String taskDefinitionKey) { - return selectOne(new QueryWrapperX() - .eq("model_id", modelId) - .eq("process_definition_id", BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL) - .eq("task_definition_key", taskDefinitionKey)); - } - - - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java deleted file mode 100644 index ed076276ce..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 用户组 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface BpmUserGroupMapper extends BaseMapperX { - - default PageResult selectPage(BpmUserGroupPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BpmUserGroupDO::getName, reqVO.getName()) - .eqIfPresent(BpmUserGroupDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BpmUserGroupDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BpmUserGroupDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(BpmUserGroupDO::getStatus, status); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java deleted file mode 100644 index ad05b98041..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.oa; - -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import org.apache.ibatis.annotations.Mapper; - -/** - * 请假申请 Mapper - * - * @author jason - * @author 芋道源码 - */ -@Mapper -public interface BpmOALeaveMapper extends BaseMapperX { - - default PageResult selectPage(Long userId, BpmOALeavePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BpmOALeaveDO::getUserId, userId) - .eqIfPresent(BpmOALeaveDO::getResult, reqVO.getResult()) - .eqIfPresent(BpmOALeaveDO::getType, reqVO.getType()) - .likeIfPresent(BpmOALeaveDO::getReason, reqVO.getReason()) - .betweenIfPresent(BpmOALeaveDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BpmOALeaveDO::getId)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java deleted file mode 100644 index 52e66219c2..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceMyPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface BpmProcessInstanceExtMapper extends BaseMapperX { - - default PageResult selectPage(Long userId, BpmProcessInstanceMyPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BpmProcessInstanceExtDO::getStartUserId, userId) - .likeIfPresent(BpmProcessInstanceExtDO::getName, reqVO.getName()) - .eqIfPresent(BpmProcessInstanceExtDO::getProcessDefinitionId, reqVO.getProcessDefinitionId()) - .eqIfPresent(BpmProcessInstanceExtDO::getCategory, reqVO.getCategory()) - .eqIfPresent(BpmProcessInstanceExtDO::getStatus, reqVO.getStatus()) - .eqIfPresent(BpmProcessInstanceExtDO::getResult, reqVO.getResult()) - .betweenIfPresent(BpmProcessInstanceExtDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BpmProcessInstanceExtDO::getId)); - } - - default BpmProcessInstanceExtDO selectByProcessInstanceId(String processInstanceId) { - return selectOne(BpmProcessInstanceExtDO::getProcessInstanceId, processInstanceId); - } - - default void updateByProcessInstanceId(BpmProcessInstanceExtDO updateObj) { - update(updateObj, new LambdaQueryWrapperX() - .eq(BpmProcessInstanceExtDO::getProcessInstanceId, updateObj.getProcessInstanceId())); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java deleted file mode 100644 index 8108e613da..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.task; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface BpmTaskExtMapper extends BaseMapperX { - - default void updateByTaskId(BpmTaskExtDO entity) { - update(entity, new LambdaQueryWrapper().eq(BpmTaskExtDO::getTaskId, entity.getTaskId())); - } - - default List selectListByTaskIds(Collection taskIds) { - return selectList(BpmTaskExtDO::getTaskId, taskIds); - } - - // TODO @海:BpmProcessInstanceResultEnum.CAN_SUB_SIGN_STATUS_LIST) 应该作为条件,mapper 不要有业务 - default List selectProcessListByTaskIds(Collection taskIds) { - return selectList(new LambdaQueryWrapperX() - .in(BpmTaskExtDO::getTaskId, taskIds) - .in(BpmTaskExtDO::getResult, BpmProcessInstanceResultEnum.CAN_SUB_SIGN_STATUS_LIST)); - } - - default BpmTaskExtDO selectByTaskId(String taskId) { - return selectOne(BpmTaskExtDO::getTaskId, taskId); - } - - default void updateBatchByTaskIdList(List taskIdList, BpmTaskExtDO updateObj) { - update(updateObj, new LambdaQueryWrapper().in(BpmTaskExtDO::getTaskId, taskIdList)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCommonConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCommonConfiguration.java deleted file mode 100644 index 7a6ca7711d..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCommonConfiguration.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.bpm.config; - -import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventPublisher; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * BPM 通用的 Configuration 配置类,提供给 Activiti 和 Flowable - */ -@Configuration(proxyBeanMethods = false) -public class BpmCommonConfiguration { - - @Bean - public BpmProcessInstanceResultEventPublisher processInstanceResultEventPublisher(ApplicationEventPublisher publisher) { - return new BpmProcessInstanceResultEventPublisher(publisher); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEvent.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEvent.java deleted file mode 100644 index f94f20ac3b..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.bpm.core.event; - -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO; -import lombok.Data; -import org.springframework.context.ApplicationEvent; - -import jakarta.validation.constraints.NotNull; - -/** - * 流程实例的结果发生变化的 Event - * 定位:由于额外增加了 {@link BpmProcessInstanceExtDO#getResult()} 结果,所以增加该事件 - * - * @author 芋道源码 - */ -@SuppressWarnings("ALL") -@Data -public class BpmProcessInstanceResultEvent extends ApplicationEvent { - - /** - * 流程实例的编号 - */ - @NotNull(message = "流程实例的编号不能为空") - private String id; - /** - * 流程实例的 key - */ - @NotNull(message = "流程实例的 key 不能为空") - private String processDefinitionKey; - /** - * 流程实例的结果 - */ - @NotNull(message = "流程实例的结果不能为空") - private Integer result; - /** - * 流程实例对应的业务标识 - * 例如说,请假 - */ - private String businessKey; - - public BpmProcessInstanceResultEvent(Object source) { - super(source); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventListener.java deleted file mode 100644 index c2b2153942..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventListener.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.bpm.core.event; - -import cn.hutool.core.util.StrUtil; -import org.springframework.context.ApplicationListener; - -/** - * {@link BpmProcessInstanceResultEvent} 的监听器 - * - * @author 芋道源码 - */ -public abstract class BpmProcessInstanceResultEventListener - implements ApplicationListener { - - @Override - public final void onApplicationEvent(BpmProcessInstanceResultEvent event) { - if (!StrUtil.equals(event.getProcessDefinitionKey(), getProcessDefinitionKey())) { - return; - } - onEvent(event); - } - - /** - * @return 返回监听的流程定义 Key - */ - protected abstract String getProcessDefinitionKey(); - - /** - * 处理事件 - * - * @param event 事件 - */ - protected abstract void onEvent(BpmProcessInstanceResultEvent event); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventPublisher.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventPublisher.java deleted file mode 100644 index 05434f7c22..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventPublisher.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.bpm.core.event; - -import lombok.AllArgsConstructor; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.validation.annotation.Validated; - -import jakarta.validation.Valid; - -/** - * {@link BpmProcessInstanceResultEvent} 的生产者 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Validated -public class BpmProcessInstanceResultEventPublisher { - - private final ApplicationEventPublisher publisher; - - public void sendProcessInstanceResultEvent(@Valid BpmProcessInstanceResultEvent event) { - publisher.publishEvent(event); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/package-info.java deleted file mode 100644 index c4a1311289..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 自定义 Event 实现,提供方便业务接入的 Listener! - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.framework.bpm.core.event; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/package-info.java deleted file mode 100644 index b97cb4c8ae..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.bpm.framework.bpm.core; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/package-info.java deleted file mode 100644 index 9a5e3ea962..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供给 Activiti 和 Flowable 的通用封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.framework.bpm; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java deleted file mode 100644 index c048d9c732..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.config; - -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.BpmActivityBehaviorFactory; -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService; -import org.flowable.common.engine.api.delegate.event.FlowableEventListener; -import org.flowable.spring.SpringProcessEngineConfiguration; -import org.flowable.spring.boot.EngineConfigurationConfigurer; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * BPM 模块的 Flowable 配置类 - * - * @author jason - */ -@Configuration(proxyBeanMethods = false) -public class BpmFlowableConfiguration { - - /** - * BPM 模块的 ProcessEngineConfigurationConfigurer 实现类: - * - * 1. 设置各种监听器 - * 2. 设置自定义的 ActivityBehaviorFactory 实现 - */ - @Bean - public EngineConfigurationConfigurer bpmProcessEngineConfigurationConfigurer( - ObjectProvider listeners, - BpmActivityBehaviorFactory bpmActivityBehaviorFactory) { - return configuration -> { - // 注册监听器,例如说 BpmActivityEventListener - configuration.setEventListeners(ListUtil.toList(listeners.iterator())); - // 设置 ActivityBehaviorFactory 实现类,用于流程任务的审核人的自定义 - configuration.setActivityBehaviorFactory(bpmActivityBehaviorFactory); - }; - } - - @Bean - public BpmActivityBehaviorFactory bpmActivityBehaviorFactory(BpmTaskAssignRuleService taskRuleService) { - BpmActivityBehaviorFactory bpmActivityBehaviorFactory = new BpmActivityBehaviorFactory(); - bpmActivityBehaviorFactory.setBpmTaskRuleService(taskRuleService); - return bpmActivityBehaviorFactory; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java deleted file mode 100644 index dced1c5bdc..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.Setter; -import lombok.ToString; -import org.flowable.bpmn.model.Activity; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior; -import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior; -import org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior; -import org.flowable.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory; - -/** - * 自定义的 ActivityBehaviorFactory 实现类,目的如下: - * 1. 自定义 {@link #createUserTaskActivityBehavior(UserTask)}:实现自定义的流程任务的 assignee 负责人的分配 - * - * @author 芋道源码 - */ -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory { - - @Setter - private BpmTaskAssignRuleService bpmTaskRuleService; - - @Override - public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask) { - return new BpmUserTaskActivityBehavior(userTask) - .setBpmTaskRuleService(bpmTaskRuleService); - } - - @Override - public ParallelMultiInstanceBehavior createParallelMultiInstanceBehavior(Activity activity, - AbstractBpmnActivityBehavior innerActivityBehavior) { - return new BpmParallelMultiInstanceBehavior(activity, innerActivityBehavior) - .setBpmTaskRuleService(bpmTaskRuleService); - } - - // TODO @ke:SequentialMultiInstanceBehavior 这个抽空也可以看看 - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java deleted file mode 100644 index 0b60faa067..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.iocoder.yudao.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.Activity; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior; -import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior; - -import java.util.Set; - -/** - * 自定义的【并行】的【多个】流程任务的 assignee 负责人的分配 - * 第一步,基于分配规则,计算出分配任务的【多个】候选人们。 - * 第二步,将【多个】任务候选人们,设置到 DelegateExecution 的 collectionVariable 变量中,以便 BpmUserTaskActivityBehavior 使用它 - * - * @author kemengkai - * @date 2022-04-21 16:57 - */ -@Slf4j -public class BpmParallelMultiInstanceBehavior extends ParallelMultiInstanceBehavior { - - @Setter - private BpmTaskAssignRuleService bpmTaskRuleService; - - public BpmParallelMultiInstanceBehavior(Activity activity, - AbstractBpmnActivityBehavior innerActivityBehavior) { - super(activity, innerActivityBehavior); - } - - /** - * 重写该方法,主要实现两个功能: - * 1. 忽略原有的 collectionVariable、collectionElementVariable 表达式,而是采用自己定义的 - * 2. 获得任务的处理人,并设置到 collectionVariable 中,用于 BpmUserTaskActivityBehavior 从中可以获取任务的处理人 - * - * 注意,多个任务实例,每个任务实例对应一个处理人,所以返回的数量就是任务处理人的数量 - * - * @param execution 执行任务 - * @return 数量 - */ - @Override - protected int resolveNrOfInstances(DelegateExecution execution) { - // 第一步,设置 collectionVariable 和 CollectionVariable - // 从 execution.getVariable() 读取所有任务处理人的 key - super.collectionExpression = null; // collectionExpression 和 collectionVariable 是互斥的 - super.collectionVariable = FlowableUtils.formatCollectionVariable(execution.getCurrentActivityId()); - // 从 execution.getVariable() 读取当前所有任务处理的人的 key - super.collectionElementVariable = FlowableUtils.formatCollectionElementVariable(execution.getCurrentActivityId()); - - // 第二步,获取任务的所有处理人 - Set assigneeUserIds = bpmTaskRuleService.calculateTaskCandidateUsers(execution); - execution.setVariable(super.collectionVariable, assigneeUserIds); - return assigneeUserIds.size(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java deleted file mode 100644 index aeda4d52c4..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.UserTask; -import org.flowable.common.engine.impl.el.ExpressionManager; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.util.TaskHelper; -import org.flowable.task.service.TaskService; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; - -import java.util.List; -import java.util.Set; - -/** - * 自定义的【单个】流程任务的 assignee 负责人的分配 - * 第一步,基于分配规则,计算出分配任务的【单个】候选人。如果找不到,则直接报业务异常,不继续执行后续的流程; - * 第二步,随机选择一个候选人,则选择作为 assignee 负责人。 - * - * @author 芋道源码 - */ -@Slf4j -public class BpmUserTaskActivityBehavior extends UserTaskActivityBehavior { - - @Setter - private BpmTaskAssignRuleService bpmTaskRuleService; - - public BpmUserTaskActivityBehavior(UserTask userTask) { - super(userTask); - } - - @Override - protected void handleAssignments(TaskService taskService, String assignee, String owner, - List candidateUsers, List candidateGroups, TaskEntity task, ExpressionManager expressionManager, - DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) { - // 第一步,获得任务的候选用户 - Long assigneeUserId = calculateTaskCandidateUsers(execution); - Assert.notNull(assigneeUserId, "任务处理人不能为空"); - // 第二步,设置作为负责人 - TaskHelper.changeTaskAssignee(task, String.valueOf(assigneeUserId)); - } - - private Long calculateTaskCandidateUsers(DelegateExecution execution) { - // 情况一,如果是多实例的任务,例如说会签、或签等情况,则从 Variable 中获取。它的任务处理人在 BpmParallelMultiInstanceBehavior 中已经被分配了 - if (super.multiInstanceActivityBehavior != null) { - return execution.getVariable(super.multiInstanceActivityBehavior.getCollectionElementVariable(), Long.class); - } - - // 情况二,如果非多实例的任务,则计算任务处理人 - // 第一步,先计算可处理该任务的处理人们 - Set candidateUserIds = bpmTaskRuleService.calculateTaskCandidateUsers(execution); - // 第二步,后随机选择一个任务的处理人 - // 疑问:为什么一定要选择一个任务处理人? - // 解答:项目对 bpm 的任务是责任到人,所以每个任务有且仅有一个处理人。 - // 如果希望一个任务可以同时被多个人处理,可以考虑使用 BpmParallelMultiInstanceBehavior 实现的会签 or 或签。 - int index = RandomUtil.randomInt(candidateUserIds.size()); - return CollUtil.get(candidateUserIds, index); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/BpmTaskAssignScript.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/BpmTaskAssignScript.java deleted file mode 100644 index b5c91ebad8..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/BpmTaskAssignScript.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import org.flowable.engine.delegate.DelegateExecution; - -import java.util.Set; - -/** - * Bpm 任务分配的自定义 Script 脚本 - * 使用场景: - * 1. 设置审批人为发起人 - * 2. 设置审批人为发起人的 Leader - * 3. 甚至审批人为发起人的 Leader 的 Leader - * - * @author 芋道源码 - */ -public interface BpmTaskAssignScript { - - /** - * 基于执行任务,获得任务的候选用户们 - * - * @param execution 执行任务 - * @return 候选人用户的编号数组 - */ - Set calculateTaskCandidateUsers(DelegateExecution execution); - - /** - * 获得枚举值 - * - * @return 枚举值 - */ - BpmTaskRuleScriptEnum getEnum(); -} - diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderAbstractScript.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderAbstractScript.java deleted file mode 100644 index 9ef7d3b30c..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderAbstractScript.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl; - -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.runtime.ProcessInstance; -import org.springframework.context.annotation.Lazy; -import org.springframework.util.Assert; - -import jakarta.annotation.Resource; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static java.util.Collections.emptySet; - -/** - * 分配给发起人的 Leader 审批的 Script 实现类 - * 目前 Leader 的定义是, - * - * @author 芋道源码 - */ -public abstract class BpmTaskAssignLeaderAbstractScript implements BpmTaskAssignScript { - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - @Resource - @Lazy // 解决循环依赖 - private BpmProcessInstanceService bpmProcessInstanceService; - - protected Set calculateTaskCandidateUsers(DelegateExecution execution, int level) { - Assert.isTrue(level > 0, "level 必须大于 0"); - // 获得发起人 - ProcessInstance processInstance = bpmProcessInstanceService.getProcessInstance(execution.getProcessInstanceId()); - Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId()); - // 获得对应 leve 的部门 - DeptRespDTO dept = null; - for (int i = 0; i < level; i++) { - // 获得 level 对应的部门 - if (dept == null) { - dept = getStartUserDept(startUserId); - if (dept == null) { // 找不到发起人的部门,所以无法使用该规则 - return emptySet(); - } - } else { - DeptRespDTO parentDept = deptApi.getDept(dept.getParentId()); - if (parentDept == null) { // 找不到父级部门,所以只好结束寻找。原因是:例如说,级别比较高的人,所在部门层级比较少 - break; - } - dept = parentDept; - } - } - return dept.getLeaderUserId() != null ? asSet(dept.getLeaderUserId()) : emptySet(); - } - - private DeptRespDTO getStartUserDept(Long startUserId) { - AdminUserRespDTO startUser = adminUserApi.getUser(startUserId); - if (startUser.getDeptId() == null) { // 找不到部门,所以无法使用该规则 - return null; - } - return deptApi.getDept(startUser.getDeptId()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX1Script.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX1Script.java deleted file mode 100644 index af7d8b5a74..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX1Script.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import java.util.Set; - -/** - * 分配给发起人的一级 Leader 审批的 Script 实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskAssignLeaderX1Script extends BpmTaskAssignLeaderAbstractScript { - - @Override - public Set calculateTaskCandidateUsers(DelegateExecution execution) { - return calculateTaskCandidateUsers(execution, 1); - } - - @Override - public BpmTaskRuleScriptEnum getEnum() { - return BpmTaskRuleScriptEnum.LEADER_X1; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX2Script.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX2Script.java deleted file mode 100644 index 068ab3d2f3..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX2Script.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import java.util.Set; - -/** - * 分配给发起人的二级 Leader 审批的 Script 实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskAssignLeaderX2Script extends BpmTaskAssignLeaderAbstractScript { - - @Override - public Set calculateTaskCandidateUsers(DelegateExecution execution) { - return calculateTaskCandidateUsers(execution, 2); - } - - @Override - public BpmTaskRuleScriptEnum getEnum() { - return BpmTaskRuleScriptEnum.LEADER_X2; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignStartUserScript.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignStartUserScript.java deleted file mode 100644 index 8f4c2c2659..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignStartUserScript.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl; - -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.runtime.ProcessInstance; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.Set; - -/** - * 分配给发起人审批的 Script 实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskAssignStartUserScript implements BpmTaskAssignScript { - - @Resource - @Lazy // 解决循环依赖 - private BpmProcessInstanceService bpmProcessInstanceService; - - @Override - public Set calculateTaskCandidateUsers(DelegateExecution execution) { - ProcessInstance processInstance = bpmProcessInstanceService.getProcessInstance(execution.getProcessInstanceId()); - Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId()); - return SetUtils.asSet(startUserId); - } - - @Override - public BpmTaskRuleScriptEnum getEnum() { - return BpmTaskRuleScriptEnum.START_USER; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java deleted file mode 100644 index 441dc034da..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener; - -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import com.google.common.collect.ImmutableSet; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener; -import org.flowable.engine.delegate.event.FlowableCancelledEvent; -import org.flowable.engine.runtime.ProcessInstance; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.Set; - -/** - * 监听 {@link ProcessInstance} 的开始与完成,创建与更新对应的 {@link BpmProcessInstanceExtDO} 记录 - * - * @author jason - */ -@Component -public class BpmProcessInstanceEventListener extends AbstractFlowableEngineEventListener { - - @Resource - @Lazy - private BpmProcessInstanceService processInstanceService; - - public static final Set PROCESS_INSTANCE_EVENTS = ImmutableSet.builder() - .add(FlowableEngineEventType.PROCESS_CREATED) - .add(FlowableEngineEventType.PROCESS_CANCELLED) - .add(FlowableEngineEventType.PROCESS_COMPLETED) - .build(); - - public BpmProcessInstanceEventListener(){ - super(PROCESS_INSTANCE_EVENTS); - } - - @Override - protected void processCreated(FlowableEngineEntityEvent event) { - processInstanceService.createProcessInstanceExt((ProcessInstance)event.getEntity()); - } - - @Override - protected void processCancelled(FlowableCancelledEvent event) { - processInstanceService.updateProcessInstanceExtCancel(event); - } - - @Override - protected void processCompleted(FlowableEngineEntityEvent event) { - processInstanceService.updateProcessInstanceExtComplete((ProcessInstance)event.getEntity()); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java deleted file mode 100644 index 08638a9d3c..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; -import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -import com.google.common.collect.ImmutableSet; -import lombok.extern.slf4j.Slf4j; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener; -import org.flowable.engine.delegate.event.FlowableActivityCancelledEvent; -import org.flowable.engine.history.HistoricActivityInstance; -import org.flowable.task.api.Task; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.Set; - -/** - * 监听 {@link org.flowable.task.api.Task} 的开始与完成,创建与更新对应的 {@link BpmTaskExtDO} 记录 - * - * @author jason - */ -@Component -@Slf4j -public class BpmTaskEventListener extends AbstractFlowableEngineEventListener { - - @Resource - @Lazy // 解决循环依赖 - private BpmTaskService taskService; - - @Resource - @Lazy // 解决循环依赖 - private BpmActivityService activityService; - - public static final Set TASK_EVENTS = ImmutableSet.builder() - .add(FlowableEngineEventType.TASK_CREATED) - .add(FlowableEngineEventType.TASK_ASSIGNED) - .add(FlowableEngineEventType.TASK_COMPLETED) - .add(FlowableEngineEventType.ACTIVITY_CANCELLED) - .build(); - - public BpmTaskEventListener(){ - super(TASK_EVENTS); - } - - @Override - protected void taskCreated(FlowableEngineEntityEvent event) { - taskService.createTaskExt((Task) event.getEntity()); - } - - @Override - protected void taskCompleted(FlowableEngineEntityEvent event) { - taskService.updateTaskExtComplete((Task)event.getEntity()); - } - - @Override - protected void taskAssigned(FlowableEngineEntityEvent event) { - taskService.updateTaskExtAssign((Task)event.getEntity()); - } - - @Override - protected void activityCancelled(FlowableActivityCancelledEvent event) { - List activityList = activityService.getHistoricActivityListByExecutionId(event.getExecutionId()); - if (CollUtil.isEmpty(activityList)) { - log.error("[activityCancelled][使用 executionId({}) 查找不到对应的活动实例]", event.getExecutionId()); - return; - } - // 遍历处理 - activityList.forEach(activity -> { - if (StrUtil.isEmpty(activity.getTaskId())) { - return; - } - taskService.updateTaskExtCancel(activity.getTaskId()); - }); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java deleted file mode 100644 index 52fdb7f935..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 bpm 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.framework; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/config/BpmWebConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/config/BpmWebConfiguration.java deleted file mode 100644 index aa9daedab1..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/config/BpmWebConfiguration.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.web.config; - -import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration; -import org.springdoc.core.models.GroupedOpenApi; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * bpm 模块的 web 组件的 Configuration - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -public class BpmWebConfiguration { - - /** - * bpm 模块的 API 分组 - */ - @Bean - public GroupedOpenApi bpmGroupedOpenApi() { - return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("bpm"); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/package-info.java deleted file mode 100644 index c014170811..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * bpm 模块的 web 配置 - */ -package cn.iocoder.yudao.module.bpm.framework.web; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java deleted file mode 100644 index 9d02824f62..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能,基于 Flowable 6 版本实现。 - * 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - * - * bpm 解释:https://baike.baidu.com/item/BPM/1933 - * - * 1. Controller URL:以 /bpm/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 bpm_ 开头,方便在数据库中区分 - * - * 注意,由于 Bpm 模块下,容易和其它模块重名,所以类名都加载 Bpm 的前缀~ - */ -package cn.iocoder.yudao.module.bpm; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java deleted file mode 100644 index dd618226e5..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormUpdateReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - - -/** - * 动态表单 Service 接口 - * - * @author @风里雾里 - */ -public interface BpmFormService { - - /** - * 创建动态表单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createForm(@Valid BpmFormCreateReqVO createReqVO); - - /** - * 更新动态表单 - * - * @param updateReqVO 更新信息 - */ - void updateForm(@Valid BpmFormUpdateReqVO updateReqVO); - - /** - * 删除动态表单 - * - * @param id 编号 - */ - void deleteForm(Long id); - - /** - * 获得动态表单 - * - * @param id 编号 - * @return 动态表单 - */ - BpmFormDO getForm(Long id); - - /** - * 获得动态表单列表 - * - * @return 动态表单列表 - */ - List getFormList(); - - /** - * 获得动态表单列表 - * - * @param ids 编号 - * @return 动态表单列表 - */ - List getFormList(Collection ids); - - /** - * 获得动态表单 Map - * - * @param ids 编号 - * @return 动态表单 Map - */ - default Map getFormMap(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyMap(); - } - return CollectionUtils.convertMap(this.getFormList(ids), BpmFormDO::getId); - } - - /** - * 获得动态表单分页 - * - * @param pageReqVO 分页查询 - * @return 动态表单分页 - */ - PageResult getFormPage(BpmFormPageReqVO pageReqVO); - - /** - * 校验流程表单已配置 - * - * @param configStr configStr 字段 - * @return 流程表单 - */ - BpmFormDO checkFormConfig(String configStr); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java deleted file mode 100644 index 54bee9ce1e..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java +++ /dev/null @@ -1,132 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormUpdateReqVO; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmFormConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmFormMapper; -import cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmFormFieldRespDTO; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * 动态表单 Service 实现类 - * - * @author 风里雾里 - */ -@Service -@Validated -public class BpmFormServiceImpl implements BpmFormService { - - @Resource - private BpmFormMapper formMapper; - - @Override - public Long createForm(BpmFormCreateReqVO createReqVO) { - this.checkFields(createReqVO.getFields()); - // 插入 - BpmFormDO form = BpmFormConvert.INSTANCE.convert(createReqVO); - formMapper.insert(form); - // 返回 - return form.getId(); - } - - @Override - public void updateForm(BpmFormUpdateReqVO updateReqVO) { - this.checkFields(updateReqVO.getFields()); - // 校验存在 - this.validateFormExists(updateReqVO.getId()); - // 更新 - BpmFormDO updateObj = BpmFormConvert.INSTANCE.convert(updateReqVO); - formMapper.updateById(updateObj); - } - - @Override - public void deleteForm(Long id) { - // 校验存在 - this.validateFormExists(id); - // 删除 - formMapper.deleteById(id); - } - - private void validateFormExists(Long id) { - if (formMapper.selectById(id) == null) { - throw exception(ErrorCodeConstants.FORM_NOT_EXISTS); - } - } - - @Override - public BpmFormDO getForm(Long id) { - return formMapper.selectById(id); - } - - @Override - public List getFormList() { - return formMapper.selectList(); - } - - @Override - public List getFormList(Collection ids) { - return formMapper.selectBatchIds(ids); - } - - @Override - public PageResult getFormPage(BpmFormPageReqVO pageReqVO) { - return formMapper.selectPage(pageReqVO); - } - - - @Override - public BpmFormDO checkFormConfig(String configStr) { - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(configStr, BpmModelMetaInfoRespDTO.class); - if (metaInfo == null || metaInfo.getFormType() == null) { - throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); - } - // 校验表单存在 - if (Objects.equals(metaInfo.getFormType(), BpmModelFormTypeEnum.NORMAL.getType())) { - BpmFormDO form = getForm(metaInfo.getFormId()); - if (form == null) { - throw exception(FORM_NOT_EXISTS); - } - return form; - } - return null; - } - - /** - * 校验 Field,避免 field 重复 - * - * @param fields field 数组 - */ - private void checkFields(List fields) { - if (true) { // TODO 芋艿:兼容 Vue3 工作流:因为采用了新的表单设计器,所以暂时不校验 - return; - } - Map fieldMap = new HashMap<>(); // key 是 vModel,value 是 label - for (String field : fields) { - BpmFormFieldRespDTO fieldDTO = JsonUtils.parseObject(field, BpmFormFieldRespDTO.class); - Assert.notNull(fieldDTO); - String oldLabel = fieldMap.put(fieldDTO.getVModel(), fieldDTO.getLabel()); - // 如果不存在,则直接返回 - if (oldLabel == null) { - continue; - } - // 如果存在,则报错 - throw exception(ErrorCodeConstants.FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel()); - } - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java deleted file mode 100644 index d7cdd89cb5..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; -import org.flowable.bpmn.model.BpmnModel; - -import jakarta.validation.Valid; - -/** - * Flowable流程模型接口 - * - * @author yunlongn - */ -public interface BpmModelService { - - /** - * 获得流程模型分页 - * - * @param pageVO 分页查询 - * @return 流程模型分页 - */ - PageResult getModelPage(BpmModelPageReqVO pageVO); - - /** - * 创建流程模型 - * - * @param modelVO 创建信息 - * @param bpmnXml BPMN XML - * @return 创建的流程模型的编号 - */ - String createModel(@Valid BpmModelCreateReqVO modelVO, String bpmnXml); - - /** - * 获得流程模块 - * - * @param id 编号 - * @return 流程模型 - */ - BpmModelRespVO getModel(String id); - - /** - * 修改流程模型 - * - * @param updateReqVO 更新信息 - */ - void updateModel(@Valid BpmModelUpdateReqVO updateReqVO); - - /** - * 将流程模型,部署成一个流程定义 - * - * @param id 编号 - */ - void deployModel(String id); - - /** - * 删除模型 - * - * @param id 编号 - */ - void deleteModel(String id); - - /** - * 修改模型的状态,实际更新的部署的流程定义的状态 - * - * @param id 编号 - * @param state 状态 - */ - void updateModelState(String id, Integer state); - - /** - * 获得流程模型编号对应的 BPMN Model - * - * @param id 流程模型编号 - * @return BPMN Model - */ - BpmnModel getBpmnModel(String id); - - /** - * 获得流程定义编号对应的 BPMN Model - * - * @param processDefinitionId 流程定义编号 - * @return BPMN Model - */ - BpmnModel getBpmnModelByDefinitionId(String processDefinitionId); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java deleted file mode 100644 index 6be51bd8c8..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java +++ /dev/null @@ -1,291 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.converter.BpmnXMLConverter; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.common.engine.impl.util.io.BytesStreamSource; -import org.flowable.engine.RepositoryService; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.Model; -import org.flowable.engine.repository.ModelQuery; -import org.flowable.engine.repository.ProcessDefinition; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.ObjectUtils; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * Flowable流程模型实现 - * 主要进行 Flowable {@link Model} 的维护 - * - * @author yunlongn - * @author 芋道源码 - * @author jason - */ -@Service -@Validated -@Slf4j -public class BpmModelServiceImpl implements BpmModelService { - - @Resource - private RepositoryService repositoryService; - @Resource - private BpmProcessDefinitionService processDefinitionService; - @Resource - private BpmFormService bpmFormService; - @Resource - private BpmTaskAssignRuleService taskAssignRuleService; - - @Override - public PageResult getModelPage(BpmModelPageReqVO pageVO) { - ModelQuery modelQuery = repositoryService.createModelQuery(); - if (StrUtil.isNotBlank(pageVO.getKey())) { - modelQuery.modelKey(pageVO.getKey()); - } - if (StrUtil.isNotBlank(pageVO.getName())) { - modelQuery.modelNameLike("%" + pageVO.getName() + "%"); // 模糊匹配 - } - if (StrUtil.isNotBlank(pageVO.getCategory())) { - modelQuery.modelCategory(pageVO.getCategory()); - } - // 执行查询 - List models = modelQuery.orderByCreateTime().desc() - .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - - // 获得 Form Map - Set formIds = CollectionUtils.convertSet(models, model -> { - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); - return metaInfo != null ? metaInfo.getFormId() : null; - }); - Map formMap = bpmFormService.getFormMap(formIds); - - // 获得 Deployment Map - Set deploymentIds = new HashSet<>(); - models.forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getDeploymentId())); - Map deploymentMap = processDefinitionService.getDeploymentMap(deploymentIds); - // 获得 ProcessDefinition Map - List processDefinitions = processDefinitionService.getProcessDefinitionListByDeploymentIds(deploymentIds); - Map processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId); - - // 拼接结果 - long modelCount = modelQuery.count(); - return new PageResult<>(BpmModelConvert.INSTANCE.convertList(models, formMap, deploymentMap, processDefinitionMap), modelCount); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public String createModel(@Valid BpmModelCreateReqVO createReqVO, String bpmnXml) { - checkKeyNCName(createReqVO.getKey()); - // 校验流程标识已经存在 - Model keyModel = getModelByKey(createReqVO.getKey()); - if (keyModel != null) { - throw exception(MODEL_KEY_EXISTS, createReqVO.getKey()); - } - - // 创建流程定义 - Model model = repositoryService.newModel(); - BpmModelConvert.INSTANCE.copy(model, createReqVO); - // 保存流程定义 - repositoryService.saveModel(model); - // 保存 BPMN XML - saveModelBpmnXml(model, bpmnXml); - return model.getId(); - } - - private Model getModelByKey(String key) { - return repositoryService.createModelQuery().modelKey(key).singleResult(); - } - - @Override - public BpmModelRespVO getModel(String id) { - Model model = repositoryService.getModel(id); - if (model == null) { - return null; - } - BpmModelRespVO modelRespVO = BpmModelConvert.INSTANCE.convert(model); - // 拼接 bpmn XML - byte[] bpmnBytes = repositoryService.getModelEditorSource(id); - modelRespVO.setBpmnXml(StrUtil.utf8Str(bpmnBytes)); - return modelRespVO; - } - - @Override - @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 - public void updateModel(@Valid BpmModelUpdateReqVO updateReqVO) { - // 校验流程模型存在 - Model model = repositoryService.getModel(updateReqVO.getId()); - if (model == null) { - throw exception(MODEL_NOT_EXISTS); - } - - // 修改流程定义 - BpmModelConvert.INSTANCE.copy(model, updateReqVO); - // 更新模型 - repositoryService.saveModel(model); - // 更新 BPMN XML - saveModelBpmnXml(model, updateReqVO.getBpmnXml()); - } - - @Override - @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 - public void deployModel(String id) { - // 1.1 校验流程模型存在 - Model model = repositoryService.getModel(id); - if (ObjectUtils.isEmpty(model)) { - throw exception(MODEL_NOT_EXISTS); - } - // 1.2 校验流程图 - // TODO 芋艿:校验流程图的有效性;例如说,是否有开始的元素,是否有结束的元素; - byte[] bpmnBytes = repositoryService.getModelEditorSource(model.getId()); - if (bpmnBytes == null) { - throw exception(MODEL_NOT_EXISTS); - } - // 1.3 校验表单已配 - BpmFormDO form = checkFormConfig(model.getMetaInfo()); - // 1.4 校验任务分配规则已配置 - taskAssignRuleService.checkTaskAssignRuleAllConfig(id); - - // 1.5 校验模型是否发生修改。如果未修改,则不允许创建 - BpmProcessDefinitionCreateReqDTO definitionCreateReqDTO = BpmModelConvert.INSTANCE.convert2(model, form).setBpmnBytes(bpmnBytes); - if (processDefinitionService.isProcessDefinitionEquals(definitionCreateReqDTO)) { // 流程定义的信息相等 - ProcessDefinition oldProcessDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); - if (oldProcessDefinition != null && taskAssignRuleService.isTaskAssignRulesEquals(model.getId(), oldProcessDefinition.getId())) { - throw exception(MODEL_DEPLOY_FAIL_TASK_INFO_EQUALS); - } - } - - // 2.1 创建流程定义 - String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO); - - // 2.2 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。 - updateProcessDefinitionSuspended(model.getDeploymentId()); - - // 2.3 更新 model 的 deploymentId,进行关联 - ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId); - model.setDeploymentId(definition.getDeploymentId()); - repositoryService.saveModel(model); - - // 2.4 复制任务分配规则 - taskAssignRuleService.copyTaskAssignRules(id, definition.getId()); - } - - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteModel(String id) { - // 校验流程模型存在 - Model model = repositoryService.getModel(id); - if (model == null) { - throw exception(MODEL_NOT_EXISTS); - } - // 执行删除 - repositoryService.deleteModel(id); - // 禁用流程定义 - updateProcessDefinitionSuspended(model.getDeploymentId()); - } - - @Override - public void updateModelState(String id, Integer state) { - // 校验流程模型存在 - Model model = repositoryService.getModel(id); - if (model == null) { - throw exception(MODEL_NOT_EXISTS); - } - // 校验流程定义存在 - ProcessDefinition definition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); - if (definition == null) { - throw exception(PROCESS_DEFINITION_NOT_EXISTS); - } - - // 更新状态 - processDefinitionService.updateProcessDefinitionState(definition.getId(), state); - } - - @Override - public BpmnModel getBpmnModel(String id) { - byte[] bpmnBytes = repositoryService.getModelEditorSource(id); - if (ArrayUtil.isEmpty(bpmnBytes)) { - return null; - } - BpmnXMLConverter converter = new BpmnXMLConverter(); - return converter.convertToBpmnModel(new BytesStreamSource(bpmnBytes), true, true); - } - - @Override - public BpmnModel getBpmnModelByDefinitionId(String processDefinitionId) { - return repositoryService.getBpmnModel(processDefinitionId); - } - - private void checkKeyNCName(String key) { - if (!ValidationUtils.isXmlNCName(key)) { - throw exception(MODEL_KEY_VALID); - } - } - - /** - * 校验流程表单已配置 - * - * @param metaInfoStr 流程模型 metaInfo 字段 - * @return 流程表单 - */ - private BpmFormDO checkFormConfig(String metaInfoStr) { - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(metaInfoStr, BpmModelMetaInfoRespDTO.class); - if (metaInfo == null || metaInfo.getFormType() == null) { - throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); - } - // 校验表单存在 - if (Objects.equals(metaInfo.getFormType(), BpmModelFormTypeEnum.NORMAL.getType())) { - BpmFormDO form = bpmFormService.getForm(metaInfo.getFormId()); - if (form == null) { - throw exception(FORM_NOT_EXISTS); - } - return form; - } - return null; - } - - private void saveModelBpmnXml(Model model, String bpmnXml) { - if (StrUtil.isEmpty(bpmnXml)) { - return; - } - repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(bpmnXml)); - } - - /** - * 挂起 deploymentId 对应的流程定义。 这里一个deploymentId 只关联一个流程定义 - * @param deploymentId 流程发布Id. - */ - private void updateProcessDefinitionSuspended(String deploymentId) { - if (StrUtil.isEmpty(deploymentId)) { - return; - } - ProcessDefinition oldDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(deploymentId); - if (oldDefinition == null) { - return; - } - processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java deleted file mode 100644 index f2d5c9d0ec..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java +++ /dev/null @@ -1,159 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionListReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageItemRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.ProcessDefinition; - -import jakarta.validation.Valid; -import java.util.List; -import java.util.Map; -import java.util.Set; -/** - * Flowable流程定义接口 - * - * @author yunlong.li - * @author ZJQ - * @author 芋道源码 - */ -public interface BpmProcessDefinitionService { - - /** - * 获得流程定义分页 - * - * @param pageReqVO 分页入参 - * @return 流程定义 Page - */ - PageResult getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO); - - /** - * 获得流程定义列表 - * - * @param listReqVO 列表入参 - * @return 流程定义列表 - */ - List getProcessDefinitionList(BpmProcessDefinitionListReqVO listReqVO); - - /** - * 创建流程定义 - * - * @param createReqDTO 创建信息 - * @return 流程编号 - */ - String createProcessDefinition(@Valid BpmProcessDefinitionCreateReqDTO createReqDTO); - - /** - * 更新流程定义状态 - * - * @param id 流程定义的编号 - * @param state 状态 - */ - void updateProcessDefinitionState(String id, Integer state); - - /** - * 获得流程定义对应的 BPMN XML - * - * @param id 流程定义编号 - * @return BPMN XML - */ - String getProcessDefinitionBpmnXML(String id); - - /** - * 获得需要创建的流程定义,是否和当前激活的流程定义相等 - * - * @param createReqDTO 创建信息 - * @return 是否相等 - */ - boolean isProcessDefinitionEquals(@Valid BpmProcessDefinitionCreateReqDTO createReqDTO); - - /** - * 获得编号对应的 BpmProcessDefinitionExtDO - * - * @param id 编号 - * @return 流程定义拓展 - */ - BpmProcessDefinitionExtDO getProcessDefinitionExt(String id); - - /** - * 获得编号对应的 ProcessDefinition - * - * @param id 编号 - * @return 流程定义 - */ - ProcessDefinition getProcessDefinition(String id); - - /** - * 获得编号对应的 ProcessDefinition - * - * 相比 {@link #getProcessDefinition(String)} 方法,category 的取值是正确 - * - * @param id 编号 - * @return 流程定义 - */ - ProcessDefinition getProcessDefinition2(String id); - - /** - * 获得 deploymentId 对应的 ProcessDefinition - * - * @param deploymentId 部署编号 - * @return 流程定义 - */ - ProcessDefinition getProcessDefinitionByDeploymentId(String deploymentId); - - /** - * 获得 deploymentIds 对应的 ProcessDefinition 数组 - * - * @param deploymentIds 部署编号的数组 - * @return 流程定义的数组 - */ - List getProcessDefinitionListByDeploymentIds(Set deploymentIds); - - /** - * 获得流程定义标识对应的激活的流程定义 - * - * @param key 流程定义的标识 - * @return 流程定义 - */ - ProcessDefinition getActiveProcessDefinition(String key); - - /** - * 获得 ids 对应的 Deployment Map - * - * @param ids 部署编号的数组 - * @return 流程部署 Map - */ - default Map getDeploymentMap(Set ids) { - return CollectionUtils.convertMap(getDeployments(ids), Deployment::getId); - } - - /** - * 获得 ids 对应的 Deployment 数组 - * - * @param ids 部署编号的数组 - * @return 流程部署的数组 - */ - List getDeployments(Set ids); - - /** - * 获得 id 对应的 Deployment - * - * @param id 部署编号 - * @return 流程部署 - */ - Deployment getDeployment(String id); - - /** - * 获得 Bpmn 模型 - * - * @param processDefinitionId 流程定义的编号 - * @return Bpmn 模型 - */ - BpmnModel getBpmnModel(String processDefinitionId); -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java deleted file mode 100644 index 78c6a1e0ba..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java +++ /dev/null @@ -1,286 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionListReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageItemRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmProcessDefinitionConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionExtMapper; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.converter.BpmnXMLConverter; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.common.engine.impl.util.io.BytesStreamSource; -import org.flowable.engine.RepositoryService; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.ProcessDefinition; -import org.flowable.engine.repository.ProcessDefinitionQuery; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_KEY_NOT_MATCH; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_NAME_NOT_MATCH; -import static java.util.Collections.emptyList; - -/** - * 流程定义实现 - * 主要进行 Flowable {@link ProcessDefinition} 和 {@link Deployment} 的维护 - * - * @author yunlongn - * @author ZJQ - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionService { - - private static final String BPMN_FILE_SUFFIX = ".bpmn"; - - @Resource - private RepositoryService repositoryService; - - @Resource - private BpmProcessDefinitionExtMapper processDefinitionMapper; - - @Resource - private BpmFormService formService; - - @Override - public ProcessDefinition getProcessDefinition(String id) { - return repositoryService.getProcessDefinition(id); - } - - @Override - public ProcessDefinition getProcessDefinition2(String id) { - return repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult(); - } - - @Override - public ProcessDefinition getProcessDefinitionByDeploymentId(String deploymentId) { - if (StrUtil.isEmpty(deploymentId)) { - return null; - } - return repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult(); - } - - @Override - public List getProcessDefinitionListByDeploymentIds(Set deploymentIds) { - if (CollUtil.isEmpty(deploymentIds)) { - return emptyList(); - } - return repositoryService.createProcessDefinitionQuery().deploymentIds(deploymentIds).list(); - } - - @Override - public ProcessDefinition getActiveProcessDefinition(String key) { - return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).active().singleResult(); - } - - @Override - public List getDeployments(Set ids) { - if (CollUtil.isEmpty(ids)) { - return emptyList(); - } - List list = new ArrayList<>(ids.size()); - for (String id : ids) { - addIfNotNull(list, getDeployment(id)); - } - return list; - } - - @Override - public Deployment getDeployment(String id) { - if (StrUtil.isEmpty(id)) { - return null; - } - return repositoryService.createDeploymentQuery().deploymentId(id).singleResult(); - } - - @Override - public BpmnModel getBpmnModel(String processDefinitionId) { - return repositoryService.getBpmnModel(processDefinitionId); - } - - @Override - public String createProcessDefinition(@Valid BpmProcessDefinitionCreateReqDTO createReqDTO) { - // 创建 Deployment 部署 - Deployment deploy = repositoryService.createDeployment() - .key(createReqDTO.getKey()).name(createReqDTO.getName()).category(createReqDTO.getCategory()) - .addBytes(createReqDTO.getKey() + BPMN_FILE_SUFFIX, createReqDTO.getBpmnBytes()) - .deploy(); - - // 设置 ProcessDefinition 的 category 分类 - ProcessDefinition definition = repositoryService.createProcessDefinitionQuery() - .deploymentId(deploy.getId()).singleResult(); - repositoryService.setProcessDefinitionCategory(definition.getId(), createReqDTO.getCategory()); - // 注意 1,ProcessDefinition 的 key 和 name 是通过 BPMN 中的 的 id 和 name 决定 - // 注意 2,目前该项目的设计上,需要保证 Model、Deployment、ProcessDefinition 使用相同的 key,保证关联性。 - // 否则,会导致 ProcessDefinition 的分页无法查询到。 - if (!Objects.equals(definition.getKey(), createReqDTO.getKey())) { - throw exception(PROCESS_DEFINITION_KEY_NOT_MATCH, createReqDTO.getKey(), definition.getKey()); - } - if (!Objects.equals(definition.getName(), createReqDTO.getName())) { - throw exception(PROCESS_DEFINITION_NAME_NOT_MATCH, createReqDTO.getName(), definition.getName()); - } - - // 插入拓展表 - BpmProcessDefinitionExtDO definitionDO = BpmProcessDefinitionConvert.INSTANCE.convert2(createReqDTO) - .setProcessDefinitionId(definition.getId()); - processDefinitionMapper.insert(definitionDO); - return definition.getId(); - } - - @Override - public void updateProcessDefinitionState(String id, Integer state) { - // 激活 - if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), state)) { - repositoryService.activateProcessDefinitionById(id, false, null); - return; - } - // 挂起 - if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), state)) { - // suspendProcessInstances = false,进行中的任务,不进行挂起。 - // 原因:只要新的流程不允许发起即可,老流程继续可以执行。 - repositoryService.suspendProcessDefinitionById(id, false, null); - return; - } - log.error("[updateProcessDefinitionState][流程定义({}) 修改未知状态({})]", id, state); - } - - @Override - public String getProcessDefinitionBpmnXML(String id) { - BpmnModel bpmnModel = repositoryService.getBpmnModel(id); - if (bpmnModel == null) { - return null; - } - BpmnXMLConverter converter = new BpmnXMLConverter(); - return StrUtil.utf8Str(converter.convertToXML(bpmnModel)); - } - - @Override - public boolean isProcessDefinitionEquals(@Valid BpmProcessDefinitionCreateReqDTO createReqDTO) { - // 校验 name、description 是否更新 - ProcessDefinition oldProcessDefinition = getActiveProcessDefinition(createReqDTO.getKey()); - if (oldProcessDefinition == null) { - return false; - } - BpmProcessDefinitionExtDO oldProcessDefinitionExt = getProcessDefinitionExt(oldProcessDefinition.getId()); - if (!StrUtil.equals(createReqDTO.getName(), oldProcessDefinition.getName()) - || !StrUtil.equals(createReqDTO.getDescription(), oldProcessDefinitionExt.getDescription()) - || !StrUtil.equals(createReqDTO.getCategory(), oldProcessDefinition.getCategory())) { - return false; - } - // 校验 form 信息是否更新 - if (!ObjectUtil.equal(createReqDTO.getFormType(), oldProcessDefinitionExt.getFormType()) - || !ObjectUtil.equal(createReqDTO.getFormId(), oldProcessDefinitionExt.getFormId()) - || !ObjectUtil.equal(createReqDTO.getFormConf(), oldProcessDefinitionExt.getFormConf()) - || !ObjectUtil.equal(createReqDTO.getFormFields(), oldProcessDefinitionExt.getFormFields()) - || !ObjectUtil.equal(createReqDTO.getFormCustomCreatePath(), oldProcessDefinitionExt.getFormCustomCreatePath()) - || !ObjectUtil.equal(createReqDTO.getFormCustomViewPath(), oldProcessDefinitionExt.getFormCustomViewPath())) { - return false; - } - // 校验 BPMN XML 信息 - BpmnModel newModel = buildBpmnModel(createReqDTO.getBpmnBytes()); - BpmnModel oldModel = getBpmnModel(oldProcessDefinition.getId()); - // 对比字节变化 - if (!BpmnModelUtils.equals(oldModel, newModel)) { - return false; - } - // 最终发现都一致,则返回 true - return true; - } - - /** - * 构建对应的 BPMN Model - * - * @param bpmnBytes 原始的 BPMN XML 字节数组 - * @return BPMN Model - */ - private BpmnModel buildBpmnModel(byte[] bpmnBytes) { - // 转换成 BpmnModel 对象 - BpmnXMLConverter converter = new BpmnXMLConverter(); - return converter.convertToBpmnModel(new BytesStreamSource(bpmnBytes), true, true); - } - - @Override - public BpmProcessDefinitionExtDO getProcessDefinitionExt(String id) { - return processDefinitionMapper.selectByProcessDefinitionId(id); - } - - @Override - public List getProcessDefinitionList(BpmProcessDefinitionListReqVO listReqVO) { - // 拼接查询条件 - ProcessDefinitionQuery definitionQuery = repositoryService.createProcessDefinitionQuery(); - if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), listReqVO.getSuspensionState())) { - definitionQuery.suspended(); - } else if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), listReqVO.getSuspensionState())) { - definitionQuery.active(); - } - // 执行查询 - List processDefinitions = definitionQuery.list(); - if (CollUtil.isEmpty(processDefinitions)) { - return Collections.emptyList(); - } - - // 获得 BpmProcessDefinitionDO Map - List processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds( - convertList(processDefinitions, ProcessDefinition::getId)); - Map processDefinitionDOMap = convertMap(processDefinitionDOs, - BpmProcessDefinitionExtDO::getProcessDefinitionId); - // 执行查询,并返回 - return BpmProcessDefinitionConvert.INSTANCE.convertList3(processDefinitions, processDefinitionDOMap); - } - - @Override - public PageResult getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageVO) { - ProcessDefinitionQuery definitionQuery = repositoryService.createProcessDefinitionQuery(); - if (StrUtil.isNotBlank(pageVO.getKey())) { - definitionQuery.processDefinitionKey(pageVO.getKey()); - } - - // 执行查询 - List processDefinitions = definitionQuery.orderByProcessDefinitionVersion().desc() - .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - - if (CollUtil.isEmpty(processDefinitions)) { - return new PageResult<>(emptyList(), definitionQuery.count()); - } - // 获得 Deployment Map - Set deploymentIds = new HashSet<>(); - processDefinitions.forEach(definition -> addIfNotNull(deploymentIds, definition.getDeploymentId())); - Map deploymentMap = getDeploymentMap(deploymentIds); - - // 获得 BpmProcessDefinitionDO Map - List processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds( - convertList(processDefinitions, ProcessDefinition::getId)); - Map processDefinitionDOMap = convertMap(processDefinitionDOs, - BpmProcessDefinitionExtDO::getProcessDefinitionId); - - // 获得 Form Map - Set formIds = convertSet(processDefinitionDOs, BpmProcessDefinitionExtDO::getFormId); - Map formMap = formService.getFormMap(formIds); - - // 拼接结果 - long definitionCount = definitionQuery.count(); - return new PageResult<>(BpmProcessDefinitionConvert.INSTANCE.convertList(processDefinitions, deploymentMap, - processDefinitionDOMap, formMap), definitionCount); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleService.java deleted file mode 100644 index 47cf2c0ed2..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleService.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleUpdateReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.lang.Nullable; - -import jakarta.validation.Valid; -import java.util.List; -import java.util.Set; - -/** - * BPM 任务分配规则 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmTaskAssignRuleService { - - /** - * 获得流程定义的任务分配规则数组 - * - * @param processDefinitionId 流程定义的编号 - * @param taskDefinitionKey 流程任务定义的 Key。允许空 - * @return 任务规则数组 - */ - List getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId, - @Nullable String taskDefinitionKey); - - /** - * 获得流程模型的任务规则数组 - * - * @param modelId 流程模型的编号 - * @return 任务规则数组 - */ - List getTaskAssignRuleListByModelId(String modelId); - - /** - * 获得流程定义的任务分配规则数组 - * - * @param modelId 流程模型的编号 - * @param processDefinitionId 流程定义的编号 - * @return 任务规则数组 - */ - List getTaskAssignRuleList(String modelId, String processDefinitionId); - - /** - * 创建任务分配规则 - * - * @param reqVO 创建信息 - * @return 规则编号 - */ - Long createTaskAssignRule(@Valid BpmTaskAssignRuleCreateReqVO reqVO); - - /** - * 更新任务分配规则 - * - * @param reqVO 创建信息 - */ - void updateTaskAssignRule(@Valid BpmTaskAssignRuleUpdateReqVO reqVO); - - /** - * 判断指定流程模型和流程定义的分配规则是否相等 - * - * @param modelId 流程模型编号 - * @param processDefinitionId 流程定义编号 - * @return 是否相等 - */ - boolean isTaskAssignRulesEquals(String modelId, String processDefinitionId); - - /** - * 将流程流程模型的任务分配规则,复制一份给流程定义 - * 目的:每次流程模型部署时,都会生成一个新的流程定义,此时考虑到每次部署的流程不可变性,所以需要复制一份给该流程定义 - * - * @param fromModelId 流程模型编号 - * @param toProcessDefinitionId 流程定义编号 - */ - void copyTaskAssignRules(String fromModelId, String toProcessDefinitionId); - - /** - * 校验流程模型的任务分配规则全部都配置了 - * 目的:如果有规则未配置,会导致流程任务找不到负责人,进而流程无法进行下去! - * - * @param id 流程模型编号 - */ - void checkTaskAssignRuleAllConfig(String id); - - /** - * 计算当前执行任务的处理人 - * - * @param execution 执行任务 - * @return 处理人的编号数组 - */ - Set calculateTaskCandidateUsers(DelegateExecution execution); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java deleted file mode 100644 index e035be070c..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java +++ /dev/null @@ -1,357 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import cn.iocoder.yudao.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleUpdateReqVO; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmTaskAssignRuleConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmTaskAssignRuleMapper; -import cn.iocoder.yudao.module.bpm.enums.DictTypeConstants; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.dict.DictDataApi; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.permission.RoleApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.UserTask; -import org.flowable.common.engine.api.FlowableException; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.*; -import java.util.function.Function; - -import static cn.hutool.core.text.CharSequenceUtil.format; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * BPM 任务分配规则 Service 实现类 - */ -@Service -@Validated -@Slf4j -public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService { - - @Resource - private BpmTaskAssignRuleMapper taskRuleMapper; - @Resource - @Lazy // 解决循环依赖 - private BpmModelService modelService; - @Resource - @Lazy // 解决循环依赖 - private BpmProcessDefinitionService processDefinitionService; - @Resource - private BpmUserGroupService userGroupService; - @Resource - private RoleApi roleApi; - @Resource - private DeptApi deptApi; - @Resource - private PostApi postApi; - @Resource - private AdminUserApi adminUserApi; - @Resource - private DictDataApi dictDataApi; - @Resource - private PermissionApi permissionApi; - @Resource - @Lazy // 解决循环依赖 - private BpmProcessInstanceService processInstanceService; - /** - * 任务分配脚本 - */ - private Map scriptMap = Collections.emptyMap(); - - @Resource - public void setScripts(List scripts) { - this.scriptMap = convertMap(scripts, script -> script.getEnum().getId()); - } - - @Override - public List getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId, - String taskDefinitionKey) { - return taskRuleMapper.selectListByProcessDefinitionId(processDefinitionId, taskDefinitionKey); - } - - @Override - public List getTaskAssignRuleListByModelId(String modelId) { - return taskRuleMapper.selectListByModelId(modelId); - } - - @Override - public List getTaskAssignRuleList(String modelId, String processDefinitionId) { - // 获得规则 - List rules = Collections.emptyList(); - BpmnModel model = null; - if (StrUtil.isNotEmpty(modelId)) { - rules = getTaskAssignRuleListByModelId(modelId); - model = modelService.getBpmnModel(modelId); - } else if (StrUtil.isNotEmpty(processDefinitionId)) { - rules = getTaskAssignRuleListByProcessDefinitionId(processDefinitionId, null); - model = processDefinitionService.getBpmnModel(processDefinitionId); - } - if (model == null) { - return Collections.emptyList(); - } - // 获得用户任务,只有用户任务才可以设置分配规则 - List userTasks = BpmnModelUtils.getBpmnModelElements(model, UserTask.class); - if (CollUtil.isEmpty(userTasks)) { - return Collections.emptyList(); - } - // 转换数据 - return BpmTaskAssignRuleConvert.INSTANCE.convertList(userTasks, rules); - } - - @Override - public Long createTaskAssignRule(@Valid BpmTaskAssignRuleCreateReqVO reqVO) { - // 校验参数 - validTaskAssignRuleOptions(reqVO.getType(), reqVO.getOptions()); - // 校验是否已经配置 - BpmTaskAssignRuleDO existRule = - taskRuleMapper.selectListByModelIdAndTaskDefinitionKey(reqVO.getModelId(), reqVO.getTaskDefinitionKey()); - if (existRule != null) { - throw exception(TASK_ASSIGN_RULE_EXISTS, reqVO.getModelId(), reqVO.getTaskDefinitionKey()); - } - - // 存储 - BpmTaskAssignRuleDO rule = BpmTaskAssignRuleConvert.INSTANCE.convert(reqVO) - .setProcessDefinitionId(BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL); // 只有流程模型,才允许新建 - taskRuleMapper.insert(rule); - return rule.getId(); - } - - @Override - public void updateTaskAssignRule(@Valid BpmTaskAssignRuleUpdateReqVO reqVO) { - // 校验参数 - validTaskAssignRuleOptions(reqVO.getType(), reqVO.getOptions()); - // 校验是否存在 - BpmTaskAssignRuleDO existRule = taskRuleMapper.selectById(reqVO.getId()); - if (existRule == null) { - throw exception(TASK_ASSIGN_RULE_NOT_EXISTS); - } - // 只允许修改流程模型的规则 - if (!Objects.equals(BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL, existRule.getProcessDefinitionId())) { - throw exception(TASK_UPDATE_FAIL_NOT_MODEL); - } - - // 执行更新 - taskRuleMapper.updateById(BpmTaskAssignRuleConvert.INSTANCE.convert(reqVO)); - } - - @Override - public boolean isTaskAssignRulesEquals(String modelId, String processDefinitionId) { - // 调用 VO 接口的原因是,过滤掉流程模型不需要的规则,保持和 copyTaskAssignRules 方法的一致性 - List modelRules = getTaskAssignRuleList(modelId, null); - List processInstanceRules = getTaskAssignRuleList(null, processDefinitionId); - if (modelRules.size() != processInstanceRules.size()) { - return false; - } - - // 遍历,匹配对应的规则 - Map processInstanceRuleMap = - CollectionUtils.convertMap(processInstanceRules, BpmTaskAssignRuleRespVO::getTaskDefinitionKey); - for (BpmTaskAssignRuleRespVO modelRule : modelRules) { - BpmTaskAssignRuleRespVO processInstanceRule = processInstanceRuleMap.get(modelRule.getTaskDefinitionKey()); - if (processInstanceRule == null) { - return false; - } - if (!ObjectUtil.equals(modelRule.getType(), processInstanceRule.getType()) || !ObjectUtil.equal( - modelRule.getOptions(), processInstanceRule.getOptions())) { - return false; - } - } - return true; - } - - @Override - public void copyTaskAssignRules(String fromModelId, String toProcessDefinitionId) { - List rules = getTaskAssignRuleList(fromModelId, null); - if (CollUtil.isEmpty(rules)) { - return; - } - // 开始复制 - List newRules = BpmTaskAssignRuleConvert.INSTANCE.convertList2(rules); - newRules.forEach(rule -> rule.setProcessDefinitionId(toProcessDefinitionId).setId(null).setCreateTime(null) - .setUpdateTime(null)); - taskRuleMapper.insertBatch(newRules); - } - - @Override - public void checkTaskAssignRuleAllConfig(String id) { - // 一个用户任务都没配置,所以无需配置规则 - List taskAssignRules = getTaskAssignRuleList(id, null); - if (CollUtil.isEmpty(taskAssignRules)) { - return; - } - // 校验未配置规则的任务 - taskAssignRules.forEach(rule -> { - if (CollUtil.isEmpty(rule.getOptions())) { - throw exception(MODEL_DEPLOY_FAIL_TASK_ASSIGN_RULE_NOT_CONFIG, rule.getTaskDefinitionName()); - } - }); - } - - private void validTaskAssignRuleOptions(Integer type, Set options) { - if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.ROLE.getType())) { - roleApi.validRoleList(options); - } else if (ObjectUtils.equalsAny(type, BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), - BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType())) { - deptApi.validateDeptList(options); - } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.POST.getType())) { - postApi.validPostList(options); - } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER.getType())) { - adminUserApi.validateUserList(options); - } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER_GROUP.getType())) { - userGroupService.validUserGroups(options); - } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.SCRIPT.getType())) { - dictDataApi.validateDictDataList(DictTypeConstants.TASK_ASSIGN_SCRIPT, - CollectionUtils.convertSet(options, String::valueOf)); - } else { - throw new IllegalArgumentException(format("未知的规则类型({})", type)); - } - } - - @Override - @DataPermission(enable = false) // 忽略数据权限,不然分配会存在问题 - public Set calculateTaskCandidateUsers(DelegateExecution execution) { - // 1. 先从提前选好的审批人中获取 - List assignee = processInstanceService.getAssigneeByProcessInstanceIdAndTaskDefinitionKey( - execution.getProcessInstanceId(), execution.getCurrentActivityId()); - if (CollUtil.isNotEmpty(assignee)) { - // TODO @hai:new HashSet 即可 - return convertSet(assignee, Function.identity()); - } - // 2. 通过分配规则,计算审批人 - BpmTaskAssignRuleDO rule = getTaskRule(execution); - return calculateTaskCandidateUsers(execution, rule); - } - - @VisibleForTesting - BpmTaskAssignRuleDO getTaskRule(DelegateExecution execution) { - List taskRules = getTaskAssignRuleListByProcessDefinitionId( - execution.getProcessDefinitionId(), execution.getCurrentActivityId()); - if (CollUtil.isEmpty(taskRules)) { - throw new FlowableException(format("流程任务({}/{}/{}) 找不到符合的任务规则", - execution.getId(), execution.getProcessDefinitionId(), execution.getCurrentActivityId())); - } - if (taskRules.size() > 1) { - throw new FlowableException(format("流程任务({}/{}/{}) 找到过多任务规则({})", - execution.getId(), execution.getProcessDefinitionId(), execution.getCurrentActivityId())); - } - return taskRules.get(0); - } - - @VisibleForTesting - Set calculateTaskCandidateUsers(DelegateExecution execution, BpmTaskAssignRuleDO rule) { - Set assigneeUserIds = null; - if (Objects.equals(BpmTaskAssignRuleTypeEnum.ROLE.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByRole(rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByDeptMember(rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByDeptLeader(rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.POST.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByPost(rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByUser(rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByUserGroup(rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.SCRIPT.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByScript(execution, rule); - } - - // 移除被禁用的用户 - removeDisableUsers(assigneeUserIds); - // 如果候选人为空,抛出异常 - if (CollUtil.isEmpty(assigneeUserIds)) { - log.error("[calculateTaskCandidateUsers][流程任务({}/{}/{}) 任务规则({}) 找不到候选人]", execution.getId(), - execution.getProcessDefinitionId(), execution.getCurrentActivityId(), toJsonString(rule)); - throw exception(TASK_CREATE_FAIL_NO_CANDIDATE_USER); - } - return assigneeUserIds; - } - - private Set calculateTaskCandidateUsersByRole(BpmTaskAssignRuleDO rule) { - return permissionApi.getUserRoleIdListByRoleIds(rule.getOptions()); - } - - private Set calculateTaskCandidateUsersByDeptMember(BpmTaskAssignRuleDO rule) { - List users = adminUserApi.getUserListByDeptIds(rule.getOptions()); - return convertSet(users, AdminUserRespDTO::getId); - } - - private Set calculateTaskCandidateUsersByDeptLeader(BpmTaskAssignRuleDO rule) { - List depts = deptApi.getDeptList(rule.getOptions()); - return convertSet(depts, DeptRespDTO::getLeaderUserId); - } - - private Set calculateTaskCandidateUsersByPost(BpmTaskAssignRuleDO rule) { - List users = adminUserApi.getUserListByPostIds(rule.getOptions()); - return convertSet(users, AdminUserRespDTO::getId); - } - - private Set calculateTaskCandidateUsersByUser(BpmTaskAssignRuleDO rule) { - return rule.getOptions(); - } - - private Set calculateTaskCandidateUsersByUserGroup(BpmTaskAssignRuleDO rule) { - List userGroups = userGroupService.getUserGroupList(rule.getOptions()); - Set userIds = new HashSet<>(); - userGroups.forEach(group -> userIds.addAll(group.getMemberUserIds())); - return userIds; - } - - private Set calculateTaskCandidateUsersByScript(DelegateExecution execution, BpmTaskAssignRuleDO rule) { - // 获得对应的脚本 - List scripts = new ArrayList<>(rule.getOptions().size()); - rule.getOptions().forEach(id -> { - BpmTaskAssignScript script = scriptMap.get(id); - if (script == null) { - throw exception(TASK_ASSIGN_SCRIPT_NOT_EXISTS, id); - } - scripts.add(script); - }); - // 逐个计算任务 - Set userIds = new HashSet<>(); - scripts.forEach(script -> CollUtil.addAll(userIds, script.calculateTaskCandidateUsers(execution))); - return userIds; - } - - @VisibleForTesting - void removeDisableUsers(Set assigneeUserIds) { - if (CollUtil.isEmpty(assigneeUserIds)) { - return; - } - Map userMap = adminUserApi.getUserMap(assigneeUserIds); - assigneeUserIds.removeIf(id -> { - AdminUserRespDTO user = userMap.get(id); - return user == null || !CommonStatusEnum.ENABLE.getStatus().equals(user.getStatus()); - }); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java deleted file mode 100644 index 2ce14a2013..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import java.util.*; -import jakarta.validation.*; - -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -/** - * 用户组 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmUserGroupService { - - /** - * 创建用户组 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createUserGroup(@Valid BpmUserGroupCreateReqVO createReqVO); - - /** - * 更新用户组 - * - * @param updateReqVO 更新信息 - */ - void updateUserGroup(@Valid BpmUserGroupUpdateReqVO updateReqVO); - - /** - * 删除用户组 - * - * @param id 编号 - */ - void deleteUserGroup(Long id); - - /** - * 获得用户组 - * - * @param id 编号 - * @return 用户组 - */ - BpmUserGroupDO getUserGroup(Long id); - - /** - * 获得用户组列表 - * - * @param ids 编号 - * @return 用户组列表 - */ - List getUserGroupList(Collection ids); - - /** - * 获得指定状态的用户组列表 - * - * @param status 状态 - * @return 用户组列表 - */ - List getUserGroupListByStatus(Integer status); - - /** - * 获得用户组分页 - * - * @param pageReqVO 分页查询 - * @return 用户组分页 - */ - PageResult getUserGroupPage(BpmUserGroupPageReqVO pageReqVO); - - /** - * 校验用户组们是否有效。如下情况,视为无效: - * 1. 用户组编号不存在 - * 2. 用户组被禁用 - * - * @param ids 用户组编号数组 - */ - void validUserGroups(Set ids); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java deleted file mode 100644 index d41ae4c14d..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmUserGroupConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmUserGroupMapper; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * 用户组 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BpmUserGroupServiceImpl implements BpmUserGroupService { - - @Resource - private BpmUserGroupMapper userGroupMapper; - - @Override - public Long createUserGroup(BpmUserGroupCreateReqVO createReqVO) { - // 插入 - BpmUserGroupDO userGroup = BpmUserGroupConvert.INSTANCE.convert(createReqVO); - userGroupMapper.insert(userGroup); - // 返回 - return userGroup.getId(); - } - - @Override - public void updateUserGroup(BpmUserGroupUpdateReqVO updateReqVO) { - // 校验存在 - this.validateUserGroupExists(updateReqVO.getId()); - // 更新 - BpmUserGroupDO updateObj = BpmUserGroupConvert.INSTANCE.convert(updateReqVO); - userGroupMapper.updateById(updateObj); - } - - @Override - public void deleteUserGroup(Long id) { - // 校验存在 - this.validateUserGroupExists(id); - // 删除 - userGroupMapper.deleteById(id); - } - - private void validateUserGroupExists(Long id) { - if (userGroupMapper.selectById(id) == null) { - throw ServiceExceptionUtil.exception(USER_GROUP_NOT_EXISTS); - } - } - - @Override - public BpmUserGroupDO getUserGroup(Long id) { - return userGroupMapper.selectById(id); - } - - @Override - public List getUserGroupList(Collection ids) { - return userGroupMapper.selectBatchIds(ids); - } - - - @Override - public List getUserGroupListByStatus(Integer status) { - return userGroupMapper.selectListByStatus(status); - } - - @Override - public PageResult getUserGroupPage(BpmUserGroupPageReqVO pageReqVO) { - return userGroupMapper.selectPage(pageReqVO); - } - - @Override - public void validUserGroups(Set ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - // 获得用户组信息 - List userGroups = userGroupMapper.selectBatchIds(ids); - Map userGroupMap = CollectionUtils.convertMap(userGroups, BpmUserGroupDO::getId); - // 校验 - ids.forEach(id -> { - BpmUserGroupDO userGroup = userGroupMap.get(id); - if (userGroup == null) { - throw ServiceExceptionUtil.exception(USER_GROUP_NOT_EXISTS); - } - if (!CommonStatusEnum.ENABLE.getStatus().equals(userGroup.getStatus())) { - throw exception(USER_GROUP_IS_DISABLE, userGroup.getName()); - } - }); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmFormFieldRespDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmFormFieldRespDTO.java deleted file mode 100644 index 1606192ce7..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmFormFieldRespDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - * Bpm 表单的 Field 表单项 Response DTO - * 字段的定义,可见 https://github.com/JakHuang/form-generator/issues/46 文档 - * - * @author 芋道源码 - */ -@Data -public class BpmFormFieldRespDTO { - - /** - * 表单标题 - */ - private String label; - /** - * 表单字段的属性名,可自定义 - */ - @JsonProperty(value = "vModel") - private String vModel; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java deleted file mode 100644 index 3a36b0eeb0..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition.dto; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import lombok.Data; - -/** - * BPM 流程 MetaInfo Response DTO - * 主要用于 { Model#setMetaInfo(String)} 的存储 - * - * @author 芋道源码 - */ -@Data -public class BpmModelMetaInfoRespDTO { - - /** - * 流程描述 - */ - private String description; - /** - * 表单类型 - */ - private Integer formType; - /** - * 表单编号 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private Long formId; - /** - * 自定义表单的提交路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomCreatePath; - /** - * 自定义表单的查看路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomViewPath; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java deleted file mode 100644 index eb715edb42..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition.dto; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import lombok.Data; - -import jakarta.validation.constraints.AssertTrue; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; -import java.util.Objects; - -/** - * 流程定义创建 Request DTO - */ -@Data -public class BpmProcessDefinitionCreateReqDTO { - - // ========== 模型相关 ========== - - /** - * 流程模型的编号 - */ - @NotEmpty(message = "流程模型编号不能为空") - private String modelId; - /** - * 流程标识 - */ - @NotEmpty(message = "流程标识不能为空") - private String key; - /** - * 流程名称 - */ - @NotEmpty(message = "流程名称不能为空") - private String name; - /** - * 流程描述 - */ - private String description; - /** - * 流程分类 - * 参见 bpm_model_category 数据字典 - */ - @NotEmpty(message = "流程分类不能为空") - private String category; - /** - * BPMN XML - */ - @NotEmpty(message = "BPMN XML 不能为空") - private byte[] bpmnBytes; - - // ========== 表单相关 ========== - - /** - * 表单类型 - */ - @NotNull(message = "表单类型不能为空") - private Integer formType; - /** - * 动态表单编号 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private Long formId; - /** - * 表单的配置 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private String formConf; - /** - * 表单项的数组 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private List formFields; - /** - * 自定义表单的提交路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomCreatePath; - /** - * 自定义表单的查看路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomViewPath; - - @AssertTrue(message = "流程表单信息不全") - public boolean isNormalFormTypeValid() { - // 如果非业务表单,则直接通过 - if (!Objects.equals(formType, BpmModelFormTypeEnum.NORMAL.getType())) { - return true; - } - return formId != null && StrUtil.isNotEmpty(formConf) && CollUtil.isNotEmpty(formFields); - } - - @AssertTrue(message = "业务表单信息不全") - public boolean isNormalCustomTypeValid() { - // 如果非业务表单,则直接通过 - if (!Objects.equals(formType, BpmModelFormTypeEnum.CUSTOM.getType())) { - return true; - } - return StrUtil.isNotEmpty(formCustomCreatePath) && StrUtil.isNotEmpty(formCustomViewPath); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageService.java deleted file mode 100644 index 0de2664cb5..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageService.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message; - -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; - -import jakarta.validation.Valid; - -/** - * BPM 消息 Service 接口 - * - * TODO 芋艿:未来支持消息的可配置;不同的流程,在什么场景下,需要发送什么消息,消息的内容是什么; - * - * @author 芋道源码 - */ -public interface BpmMessageService { - - /** - * 发送流程实例被通过的消息 - * - * @param reqDTO 发送信息 - */ - void sendMessageWhenProcessInstanceApprove(@Valid BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO); - - /** - * 发送流程实例被不通过的消息 - * - * @param reqDTO 发送信息 - */ - void sendMessageWhenProcessInstanceReject(@Valid BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO); - - /** - * 发送任务被分配的消息 - * - * @param reqDTO 发送信息 - */ - void sendMessageWhenTaskAssigned(@Valid BpmMessageSendWhenTaskCreatedReqDTO reqDTO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java deleted file mode 100644 index 62f0500988..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message; - -import cn.iocoder.yudao.framework.web.config.WebProperties; -import cn.iocoder.yudao.module.bpm.convert.message.BpmMessageConvert; -import cn.iocoder.yudao.module.bpm.enums.message.BpmMessageEnum; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; -import cn.iocoder.yudao.module.system.api.sms.SmsSendApi; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -/** - * BPM 消息 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class BpmMessageServiceImpl implements BpmMessageService { - - @Resource - private SmsSendApi smsSendApi; - - @Resource - private WebProperties webProperties; - - @Override - public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), - BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams)); - } - - @Override - public void sendMessageWhenProcessInstanceReject(BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("reason", reqDTO.getReason()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), - BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams)); - } - - @Override - public void sendMessageWhenTaskAssigned(BpmMessageSendWhenTaskCreatedReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("taskName", reqDTO.getTaskName()); - templateParams.put("startUserNickname", reqDTO.getStartUserNickname()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getAssigneeUserId(), - BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams)); - } - - private String getProcessInstanceDetailUrl(String taskId) { - return webProperties.getAdminUi().getUrl() + "/bpm/process-instance/detail?id=" + taskId; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceApproveReqDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceApproveReqDTO.java deleted file mode 100644 index 9065ac255e..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceApproveReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message.dto; - -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * BPM 发送流程实例被通过 Request DTO - */ -@Data -public class BpmMessageSendWhenProcessInstanceApproveReqDTO { - - /** - * 流程实例的编号 - */ - @NotEmpty(message = "流程实例的编号不能为空") - private String processInstanceId; - /** - * 流程实例的名字 - */ - @NotEmpty(message = "流程实例的名字不能为空") - private String processInstanceName; - @NotNull(message = "发起人的用户编号") - private Long startUserId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceRejectReqDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceRejectReqDTO.java deleted file mode 100644 index 69b0dbe51d..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceRejectReqDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message.dto; - -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * BPM 发送流程实例被不通过 Request DTO - */ -@Data -public class BpmMessageSendWhenProcessInstanceRejectReqDTO { - - /** - * 流程实例的编号 - */ - @NotEmpty(message = "流程实例的编号不能为空") - private String processInstanceId; - /** - * 流程实例的名字 - */ - @NotEmpty(message = "流程实例的名字不能为空") - private String processInstanceName; - @NotNull(message = "发起人的用户编号") - private Long startUserId; - - /** - * 不通过理由 - */ - @NotEmpty(message = "不通过理由不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenTaskCreatedReqDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenTaskCreatedReqDTO.java deleted file mode 100644 index 0e09fc55be..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenTaskCreatedReqDTO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message.dto; - -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * BPM 发送任务被分配 Request DTO - */ -@Data -public class BpmMessageSendWhenTaskCreatedReqDTO { - - /** - * 流程实例的编号 - */ - @NotEmpty(message = "流程实例的编号不能为空") - private String processInstanceId; - /** - * 流程实例的名字 - */ - @NotEmpty(message = "流程实例的名字不能为空") - private String processInstanceName; - @NotNull(message = "发起人的用户编号") - private Long startUserId; - @NotEmpty(message = "发起人的昵称") - private String startUserNickname; - - /** - * 流程任务的编号 - */ - @NotEmpty(message = "流程任务的编号不能为空") - private String taskId; - /** - * 流程任务的名字 - */ - @NotEmpty(message = "流程任务的名字不能为空") - private String taskName; - - /** - * 审批人的用户编号 - */ - @NotNull(message = "审批人的用户编号不能为空") - private Long assigneeUserId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveService.java deleted file mode 100644 index 3089566598..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveService.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.oa; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; - -import jakarta.validation.Valid; - -/** - * 请假申请 Service 接口 - * - * @author jason - * @author 芋道源码 - */ -public interface BpmOALeaveService { - - /** - * 创建请假申请 - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createLeave(Long userId, @Valid BpmOALeaveCreateReqVO createReqVO); - - /** - * 更新请假申请的状态 - * - * @param id 编号 - * @param result 结果 - */ - void updateLeaveResult(Long id, Integer result); - - /** - * 获得请假申请 - * - * @param id 编号 - * @return 请假申请 - */ - BpmOALeaveDO getLeave(Long id); - - /** - * 获得请假申请分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页查询 - * @return 请假申请分页 - */ - PageResult getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveServiceImpl.java deleted file mode 100644 index 76fe216696..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveServiceImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.oa; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO; -import cn.iocoder.yudao.module.bpm.convert.oa.BpmOALeaveConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOALeaveMapper; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_LEAVE_NOT_EXISTS; - -/** - * OA 请假申请 Service 实现类 - * - * @author jason - * @author 芋道源码 - */ -@Service -@Validated -public class BpmOALeaveServiceImpl implements BpmOALeaveService { - - /** - * OA 请假对应的流程定义 KEY - */ - public static final String PROCESS_KEY = "oa_leave"; - - @Resource - private BpmOALeaveMapper leaveMapper; - - @Resource - private BpmProcessInstanceApi processInstanceApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createLeave(Long userId, BpmOALeaveCreateReqVO createReqVO) { - // 插入 OA 请假单 - long day = LocalDateTimeUtil.between(createReqVO.getStartTime(), createReqVO.getEndTime()).toDays(); - BpmOALeaveDO leave = BpmOALeaveConvert.INSTANCE.convert(createReqVO).setUserId(userId).setDay(day) - .setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); - leaveMapper.insert(leave); - - // 发起 BPM 流程 - Map processInstanceVariables = new HashMap<>(); - processInstanceVariables.put("day", day); - String processInstanceId = processInstanceApi.createProcessInstance(userId, - new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY) - .setVariables(processInstanceVariables).setBusinessKey(String.valueOf(leave.getId()))); - - // 将工作流的编号,更新到 OA 请假单中 - leaveMapper.updateById(new BpmOALeaveDO().setId(leave.getId()).setProcessInstanceId(processInstanceId)); - return leave.getId(); - } - - @Override - public void updateLeaveResult(Long id, Integer result) { - validateLeaveExists(id); - leaveMapper.updateById(new BpmOALeaveDO().setId(id).setResult(result)); - } - - private void validateLeaveExists(Long id) { - if (leaveMapper.selectById(id) == null) { - throw exception(OA_LEAVE_NOT_EXISTS); - } - } - - @Override - public BpmOALeaveDO getLeave(Long id) { - return leaveMapper.selectById(id); - } - - @Override - public PageResult getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO) { - return leaveMapper.selectPage(userId, pageReqVO); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/BpmOALeaveResultListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/BpmOALeaveResultListener.java deleted file mode 100644 index 0f8e9e5699..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/BpmOALeaveResultListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.oa.listener; - -import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEvent; -import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventListener; -import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveService; -import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveServiceImpl; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -/** - * OA 请假单的结果的监听器实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmOALeaveResultListener extends BpmProcessInstanceResultEventListener { - - @Resource - private BpmOALeaveService leaveService; - - @Override - protected String getProcessDefinitionKey() { - return BpmOALeaveServiceImpl.PROCESS_KEY; - } - - @Override - protected void onEvent(BpmProcessInstanceResultEvent event) { - leaveService.updateLeaveResult(Long.parseLong(event.getBusinessKey()), event.getResult()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java deleted file mode 100644 index 4bed16413b..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import org.flowable.engine.history.HistoricActivityInstance; - -import java.util.List; - -/** - * BPM 活动实例 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmActivityService { - - /** - * 获得指定流程实例的活动实例列表 - * - * @param processInstanceId 流程实例的编号 - * @return 活动实例列表 - */ - List getActivityListByProcessInstanceId(String processInstanceId); - - /** - * 获得执行编号对应的活动实例 - * - * @param executionId 执行编号 - * @return 活动实例 - */ - List getHistoricActivityListByExecutionId(String executionId); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java deleted file mode 100644 index 1ae9b1df0e..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import cn.iocoder.yudao.module.bpm.convert.task.BpmActivityConvert; -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.HistoryService; -import org.flowable.engine.history.HistoricActivityInstance; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - - -/** - * BPM 活动实例 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Slf4j -@Validated -public class BpmActivityServiceImpl implements BpmActivityService { - - @Resource - private HistoryService historyService; - - @Override - public List getActivityListByProcessInstanceId(String processInstanceId) { - List activityList = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId).list(); - return BpmActivityConvert.INSTANCE.convertList(activityList); - } - - @Override - public List getHistoricActivityListByExecutionId(String executionId) { - return historyService.createHistoricActivityInstanceQuery().executionId(executionId).list(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java deleted file mode 100644 index a0cc1c71b8..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java +++ /dev/null @@ -1,158 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*; -import org.flowable.engine.delegate.event.FlowableCancelledEvent; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.runtime.ProcessInstance; - -import jakarta.validation.Valid; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * 流程实例 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmProcessInstanceService { - - /** - * 获得流程实例 - * - * @param id 流程实例的编号 - * @return 流程实例 - */ - ProcessInstance getProcessInstance(String id); - - /** - * 获得流程实例列表 - * - * @param ids 流程实例的编号集合 - * @return 流程实例列表 - */ - List getProcessInstances(Set ids); - - /** - * 获得流程实例 Map - * - * @param ids 流程实例的编号集合 - * @return 流程实例列表 Map - */ - default Map getProcessInstanceMap(Set ids) { - return CollectionUtils.convertMap(getProcessInstances(ids), ProcessInstance::getProcessInstanceId); - } - - /** - * 获得流程实例的分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程实例的分页 - */ - PageResult getMyProcessInstancePage(Long userId, - @Valid BpmProcessInstanceMyPageReqVO pageReqVO); - - /** - * 创建流程实例(提供给前端) - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 实例的编号 - */ - String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqVO createReqVO); - - /** - * 创建流程实例(提供给内部) - * - * @param userId 用户编号 - * @param createReqDTO 创建信息 - * @return 实例的编号 - */ - String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO createReqDTO); - - /** - * 获得流程实例 VO 信息 - * - * @param id 流程实例的编号 - * @return 流程实例 - */ - BpmProcessInstanceRespVO getProcessInstanceVO(String id); - - /** - * 取消流程实例 - * - * @param userId 用户编号 - * @param cancelReqVO 取消信息 - */ - void cancelProcessInstance(Long userId, @Valid BpmProcessInstanceCancelReqVO cancelReqVO); - - /** - * 获得历史的流程实例 - * - * @param id 流程实例的编号 - * @return 历史的流程实例 - */ - HistoricProcessInstance getHistoricProcessInstance(String id); - - /** - * 获得历史的流程实例列表 - * - * @param ids 流程实例的编号集合 - * @return 历史的流程实例列表 - */ - List getHistoricProcessInstances(Set ids); - - /** - * 获得历史的流程实例 Map - * - * @param ids 流程实例的编号集合 - * @return 历史的流程实例列表 Map - */ - default Map getHistoricProcessInstanceMap(Set ids) { - return CollectionUtils.convertMap(getHistoricProcessInstances(ids), HistoricProcessInstance::getId); - } - - /** - * 创建 ProcessInstance 拓展记录 - * - * @param instance 流程任务 - */ - void createProcessInstanceExt(ProcessInstance instance); - - /** - * 更新 ProcessInstance 拓展记录为取消 - * - * @param event 流程取消事件 - */ - void updateProcessInstanceExtCancel(FlowableCancelledEvent event); - - /** - * 更新 ProcessInstance 拓展记录为完成 - * - * @param instance 流程任务 - */ - void updateProcessInstanceExtComplete(ProcessInstance instance); - - /** - * 更新 ProcessInstance 拓展记录为不通过 - * - * @param id 流程编号 - * @param reason 理由。例如说,审批不通过时,需要传递该值 - */ - void updateProcessInstanceExtReject(String id, String reason); - - // TODO @hai:改成 getProcessInstanceAssigneesByTaskDefinitionKey(String id, String taskDefinitionKey) - /** - * 获取流程实例中,取出指定流程任务提前指定的审批人 - * - * @param processInstanceId 流程实例的编号 - * @param taskDefinitionKey 流程任务定义的 key - * @return 审批人集合 - */ - List getAssigneeByProcessInstanceIdAndTaskDefinitionKey(String processInstanceId, String taskDefinitionKey); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java deleted file mode 100644 index 603c5bb071..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.number.NumberUtils; import cn.iocoder.yudao.framework.flowable.core.context.FlowableContextHolder; import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*; import cn.iocoder.yudao.module.bpm.convert.task.BpmProcessInstanceConvert; import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO; import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmProcessInstanceExtMapper; import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum; import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum; import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventPublisher; import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import lombok.extern.slf4j.Slf4j; import org.flowable.engine.HistoryService; import org.flowable.engine.RuntimeService; import org.flowable.engine.delegate.event.FlowableCancelledEvent; import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.runtime.ProcessInstance; import org.flowable.task.api.Task; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import jakarta.annotation.Resource; import jakarta.validation.Valid; import java.time.LocalDateTime; import java.util.*; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; /** * 流程实例 Service 实现类 *

* ProcessDefinition & ProcessInstance & Execution & Task 的关系: * 1. *

* HistoricProcessInstance & ProcessInstance 的关系: * 1. *

* 简单来说,前者 = 历史 + 运行中的流程实例,后者仅是运行中的流程实例 * * @author 芋道源码 */ @Service @Validated @Slf4j public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService { @Resource private RuntimeService runtimeService; @Resource private BpmProcessInstanceExtMapper processInstanceExtMapper; @Resource @Lazy // 解决循环依赖 private BpmTaskService taskService; @Resource private BpmProcessDefinitionService processDefinitionService; @Resource private HistoryService historyService; @Resource private AdminUserApi adminUserApi; @Resource private DeptApi deptApi; @Resource private BpmProcessInstanceResultEventPublisher processInstanceResultEventPublisher; @Resource private BpmMessageService messageService; @Override public ProcessInstance getProcessInstance(String id) { return runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult(); } @Override public List getProcessInstances(Set ids) { return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list(); } @Override public PageResult getMyProcessInstancePage(Long userId, BpmProcessInstanceMyPageReqVO pageReqVO) { // 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页 PageResult pageResult = processInstanceExtMapper.selectPage(userId, pageReqVO); if (CollUtil.isEmpty(pageResult.getList())) { return new PageResult<>(pageResult.getTotal()); } // 获得流程 Task Map List processInstanceIds = convertList(pageResult.getList(), BpmProcessInstanceExtDO::getProcessInstanceId); Map> taskMap = taskService.getTaskMapByProcessInstanceIds(processInstanceIds); // 转换返回 return BpmProcessInstanceConvert.INSTANCE.convertPage(pageResult, taskMap); } @Override @Transactional(rollbackFor = Exception.class) public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqVO createReqVO) { // 获得流程定义 ProcessDefinition definition = processDefinitionService.getProcessDefinition(createReqVO.getProcessDefinitionId()); // 发起流程 return createProcessInstance0(userId, definition, createReqVO.getVariables(), null, createReqVO.getAssignee()); } @Override public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO createReqDTO) { // 获得流程定义 ProcessDefinition definition = processDefinitionService.getActiveProcessDefinition(createReqDTO.getProcessDefinitionKey()); // 发起流程 return createProcessInstance0(userId, definition, createReqDTO.getVariables(), createReqDTO.getBusinessKey(), createReqDTO.getAssignee()); } @Override public BpmProcessInstanceRespVO getProcessInstanceVO(String id) { // 获得流程实例 HistoricProcessInstance processInstance = getHistoricProcessInstance(id); if (processInstance == null) { return null; } BpmProcessInstanceExtDO processInstanceExt = processInstanceExtMapper.selectByProcessInstanceId(id); Assert.notNull(processInstanceExt, "流程实例拓展({}) 不存在", id); // 获得流程定义 ProcessDefinition processDefinition = processDefinitionService .getProcessDefinition(processInstance.getProcessDefinitionId()); Assert.notNull(processDefinition, "流程定义({}) 不存在", processInstance.getProcessDefinitionId()); BpmProcessDefinitionExtDO processDefinitionExt = processDefinitionService.getProcessDefinitionExt( processInstance.getProcessDefinitionId()); Assert.notNull(processDefinitionExt, "流程定义拓展({}) 不存在", id); String bpmnXml = processDefinitionService.getProcessDefinitionBpmnXML(processInstance.getProcessDefinitionId()); // 获得 User AdminUserRespDTO startUser = adminUserApi.getUser(NumberUtils.parseLong(processInstance.getStartUserId())); DeptRespDTO dept = null; if (startUser != null) { dept = deptApi.getDept(startUser.getDeptId()); } // 拼接结果 return BpmProcessInstanceConvert.INSTANCE.convert2(processInstance, processInstanceExt, processDefinition, processDefinitionExt, bpmnXml, startUser, dept); } @Override public void cancelProcessInstance(Long userId, @Valid BpmProcessInstanceCancelReqVO cancelReqVO) { // 校验流程实例存在 ProcessInstance instance = getProcessInstance(cancelReqVO.getId()); if (instance == null) { throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS); } // 只能取消自己的 if (!Objects.equals(instance.getStartUserId(), String.valueOf(userId))) { throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF); } // 通过删除流程实例,实现流程实例的取消, // 删除流程实例,正则执行任务 ACT_RU_TASK. 任务会被删除。通过历史表查询 deleteProcessInstance(cancelReqVO.getId(), BpmProcessInstanceDeleteReasonEnum.CANCEL_TASK.format(cancelReqVO.getReason())); } /** * 获得历史的流程实例 * * @param id 流程实例的编号 * @return 历史的流程实例 */ @Override public HistoricProcessInstance getHistoricProcessInstance(String id) { return historyService.createHistoricProcessInstanceQuery().processInstanceId(id).singleResult(); } @Override public List getHistoricProcessInstances(Set ids) { return historyService.createHistoricProcessInstanceQuery().processInstanceIds(ids).list(); } @Override public void createProcessInstanceExt(ProcessInstance instance) { // 获得流程定义 ProcessDefinition definition = processDefinitionService.getProcessDefinition2(instance.getProcessDefinitionId()); // 插入 BpmProcessInstanceExtDO 对象 BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO() .setProcessInstanceId(instance.getId()) .setProcessDefinitionId(definition.getId()) .setName(instance.getProcessDefinitionName()) .setStartUserId(Long.valueOf(instance.getStartUserId())) .setCategory(definition.getCategory()) .setStatus(BpmProcessInstanceStatusEnum.RUNNING.getStatus()) .setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); processInstanceExtMapper.insert(instanceExtDO); } @Override public void updateProcessInstanceExtCancel(FlowableCancelledEvent event) { // 判断是否为 Reject 不通过。如果是,则不进行更新. // 因为,updateProcessInstanceExtReject 方法,已经进行更新了 if (BpmProcessInstanceDeleteReasonEnum.isRejectReason((String) event.getCause())) { return; } // 需要主动查询,因为 instance 只有 id 属性 // 另外,此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance HistoricProcessInstance processInstance = getHistoricProcessInstance(event.getProcessInstanceId()); // 更新拓展表 BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO() .setProcessInstanceId(event.getProcessInstanceId()) .setEndTime(LocalDateTime.now()) // 由于 ProcessInstance 里没有办法拿到 endTime,所以这里设置 .setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()) .setResult(BpmProcessInstanceResultEnum.CANCEL.getResult()); processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO); // 发送流程实例的状态事件 processInstanceResultEventPublisher.sendProcessInstanceResultEvent( BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance, instanceExtDO.getResult())); } @Override public void updateProcessInstanceExtComplete(ProcessInstance instance) { // 需要主动查询,因为 instance 只有 id 属性 // 另外,此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance HistoricProcessInstance processInstance = getHistoricProcessInstance(instance.getId()); // 更新拓展表 BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO() .setProcessInstanceId(instance.getProcessInstanceId()) .setEndTime(LocalDateTime.now()) // 由于 ProcessInstance 里没有办法拿到 endTime,所以这里设置 .setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()) .setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()); // 如果正常完全,说明审批通过 processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO); // 发送流程被通过的消息 messageService.sendMessageWhenProcessInstanceApprove(BpmProcessInstanceConvert.INSTANCE.convert2ApprovedReq(instance)); // 发送流程实例的状态事件 processInstanceResultEventPublisher.sendProcessInstanceResultEvent( BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance, instanceExtDO.getResult())); } @Override @Transactional(rollbackFor = Exception.class) public void updateProcessInstanceExtReject(String id, String reason) { // 需要主动查询,因为 instance 只有 id 属性 ProcessInstance processInstance = getProcessInstance(id); // 删除流程实例,以实现驳回任务时,取消整个审批流程 deleteProcessInstance(id, StrUtil.format(BpmProcessInstanceDeleteReasonEnum.REJECT_TASK.format(reason))); // 更新 status + result // 注意,不能和上面的逻辑更换位置。因为 deleteProcessInstance 会触发流程的取消,进而调用 updateProcessInstanceExtCancel 方法, // 设置 result 为 BpmProcessInstanceStatusEnum.CANCEL,显然和 result 不一定是一致的 BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO().setProcessInstanceId(id) .setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()) .setResult(BpmProcessInstanceResultEnum.REJECT.getResult()); processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO); // 发送流程被不通过的消息 messageService.sendMessageWhenProcessInstanceReject(BpmProcessInstanceConvert.INSTANCE.convert2RejectReq(processInstance, reason)); // 发送流程实例的状态事件 processInstanceResultEventPublisher.sendProcessInstanceResultEvent( BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance, instanceExtDO.getResult())); } private void deleteProcessInstance(String id, String reason) { runtimeService.deleteProcessInstance(id, reason); } private String createProcessInstance0(Long userId, ProcessDefinition definition, Map variables, String businessKey, Map> assignee) { // 校验流程定义 if (definition == null) { throw exception(PROCESS_DEFINITION_NOT_EXISTS); } if (definition.isSuspended()) { throw exception(PROCESS_DEFINITION_IS_SUSPENDED); } // 设置上下文信息 // TODO @hai:要不往 variables 存到一个全局固定 key 里,减少对上下文的依赖 FlowableContextHolder.setAssignee(assignee); // 创建流程实例 ProcessInstance instance = runtimeService.createProcessInstanceBuilder() .processDefinitionId(definition.getId()) .businessKey(businessKey) .name(definition.getName().trim()) .variables(variables) .start(); // 设置流程名字 runtimeService.setProcessInstanceName(instance.getId(), definition.getName()); // 补全流程实例的拓展表 processInstanceExtMapper.updateByProcessInstanceId(new BpmProcessInstanceExtDO().setProcessInstanceId(instance.getId()) .setFormVariables(variables).setAssignee(assignee)); return instance.getId(); } @Override public List getAssigneeByProcessInstanceIdAndTaskDefinitionKey(String processInstanceId, String taskDefinitionKey) { // 1. 先从上下文获取,首次提交数据库中查询不到 List result = FlowableContextHolder.getAssigneeByTaskDefinitionKey(taskDefinitionKey); if (CollUtil.isNotEmpty(result)) { return result; } // 2. 从数据库中获取 BpmProcessInstanceExtDO instance = processInstanceExtMapper.selectByProcessInstanceId(processInstanceId); if (instance == null) { throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS); } if (CollUtil.isNotEmpty(instance.getAssignee())) { return instance.getAssignee().get(taskDefinitionKey); } return Collections.emptyList(); } } \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java deleted file mode 100644 index 6c38371798..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java +++ /dev/null @@ -1,184 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; -import org.flowable.task.api.Task; - -import jakarta.validation.Valid; -import java.util.List; -import java.util.Map; - -/** - * 流程任务实例 Service 接口 - * - * @author jason - * @author 芋道源码 - */ -public interface BpmTaskService { - - /** - * 获得待办的流程任务分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程任务分页 - */ - PageResult getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageReqVO); - - /** - * 获得已办的流程任务分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程任务分页 - */ - PageResult getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageReqVO); - - /** - * 获得流程任务 Map - * - * @param processInstanceIds 流程实例的编号数组 - * @return 流程任务 Map - */ - default Map> getTaskMapByProcessInstanceIds(List processInstanceIds) { - return CollectionUtils.convertMultiMap(getTasksByProcessInstanceIds(processInstanceIds), - Task::getProcessInstanceId); - } - - /** - * 获得流程任务列表 - * - * @param processInstanceIds 流程实例的编号数组 - * @return 流程任务列表 - */ - List getTasksByProcessInstanceIds(List processInstanceIds); - - /** - * 获得指令流程实例的流程任务列表,包括所有状态的 - * - * @param processInstanceId 流程实例的编号 - * @return 流程任务列表 - */ - List getTaskListByProcessInstanceId(String processInstanceId); - - - /** - * 通过任务 ID 集合,获取任务扩展表信息集合 - * - * @param taskIdList 任务 ID 集合 - * @return 任务列表 - */ - List getTaskListByTaskIdList(List taskIdList); - - /** - * 通过任务 - * - * @param userId 用户编号 - * @param reqVO 通过请求 - */ - void approveTask(Long userId, @Valid BpmTaskApproveReqVO reqVO); - - /** - * 不通过任务 - * - * @param userId 用户编号 - * @param reqVO 不通过请求 - */ - void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO); - - /** - * 将流程任务分配给指定用户 - * - * @param userId 用户编号 - * @param reqVO 分配请求 - */ - void updateTaskAssignee(Long userId, BpmTaskUpdateAssigneeReqVO reqVO); - - /** - * 将流程任务分配给指定用户 - * - * @param id 流程任务编号 - * @param userId 用户编号 - */ - void updateTaskAssignee(String id, Long userId); - - /** - * 创建 Task 拓展记录 - * - * @param task 任务实体 - */ - void createTaskExt(Task task); - - /** - * 更新 Task 拓展记录为完成 - * - * @param task 任务实体 - */ - void updateTaskExtComplete(Task task); - - /** - * 更新 Task 拓展记录为已取消 - * - * @param taskId 任务的编号 - */ - void updateTaskExtCancel(String taskId); - - /** - * 更新 Task 拓展记录,并发送通知 - * - * @param task 任务实体 - */ - void updateTaskExtAssign(Task task); - - /** - * 获取当前任务的可回退的流程集合 - * - * @param taskId 当前的任务 ID - * @return 可以回退的节点列表 - */ - List getReturnTaskList(String taskId); - - /** - * 将任务回退到指定的 targetDefinitionKey 位置 - * - * @param userId 用户编号 - * @param reqVO 回退的任务key和当前所在的任务ID - */ - void returnTask(Long userId, BpmTaskReturnReqVO reqVO); - - - /** - * 将指定任务委派给其他人处理,等接收人处理后再回到原审批人手中审批 - * - * @param userId 用户编号 - * @param reqVO 被委派人和被委派的任务编号理由参数 - */ - void delegateTask(Long userId, BpmTaskDelegateReqVO reqVO); - - /** - * 任务加签 - * - * @param userId 被加签的用户和任务 ID,加签类型 - * @param reqVO 当前用户 ID - */ - void createSignTask(Long userId, BpmTaskAddSignReqVO reqVO); - - /** - * 任务减签名 - * - * @param userId 当前用户ID - * @param reqVO 被减签的任务 ID,理由 - */ - void deleteSignTask(Long userId, BpmTaskSubSignReqVO reqVO); - - /** - * 获取指定任务的子任务和审批人信息 - * - * @param parentId 指定任务ID - * @return 子任务列表 - */ - List getChildrenTaskList(String parentId); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java deleted file mode 100644 index a0f938e677..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java +++ /dev/null @@ -1,969 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmTaskExtMapper; -import cn.iocoder.yudao.module.bpm.enums.task.BpmCommentTypeEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskAddSignTypeEnum; -import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; -import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.FlowElement; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.HistoryService; -import org.flowable.engine.ManagementService; -import org.flowable.engine.RuntimeService; -import org.flowable.engine.TaskService; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.DelegationState; -import org.flowable.task.api.Task; -import org.flowable.task.api.TaskInfo; -import org.flowable.task.api.TaskQuery; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.api.history.HistoricTaskInstanceQuery; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; -import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.util.Assert; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * 流程任务实例 Service 实现类 - * - * @author 芋道源码 - * @author jason - */ -@Slf4j -@Service -public class BpmTaskServiceImpl implements BpmTaskService { - - @Resource - private TaskService taskService; - @Resource - private HistoryService historyService; - @Resource - private RuntimeService runtimeService; - - @Resource - private BpmProcessInstanceService processInstanceService; - @Resource - private BpmModelService bpmModelService; - @Resource - private BpmMessageService messageService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @Resource - private BpmTaskExtMapper taskExtMapper; - - @Resource - private ManagementService managementService; - - @Override - public PageResult getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) { - // 查询待办任务 - TaskQuery taskQuery = taskService.createTaskQuery().taskAssignee(String.valueOf(userId)) // 分配给自己 - .orderByTaskCreateTime().desc(); // 创建时间倒序 - if (StrUtil.isNotBlank(pageVO.getName())) { - taskQuery.taskNameLike("%" + pageVO.getName() + "%"); - } - if (ArrayUtil.get(pageVO.getCreateTime(), 0) != null) { - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0])); - } - if (ArrayUtil.get(pageVO.getCreateTime(), 1) != null) { - taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1])); - } - // 执行查询 - List tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - if (CollUtil.isEmpty(tasks)) { - return PageResult.empty(taskQuery.count()); - } - - // 获得 ProcessInstance Map - Map processInstanceMap = - processInstanceService.getProcessInstanceMap(convertSet(tasks, Task::getProcessInstanceId)); - // 获得 User Map - Map userMap = adminUserApi.getUserMap( - convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); - // 拼接结果 - return new PageResult<>(BpmTaskConvert.INSTANCE.convertList1(tasks, processInstanceMap, userMap), - taskQuery.count()); - } - - @Override - public PageResult getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageVO) { - // 查询已办任务 - HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery().finished() // 已完成 - .taskAssignee(String.valueOf(userId)) // 分配给自己 - .orderByHistoricTaskInstanceEndTime().desc(); // 审批时间倒序 - if (StrUtil.isNotBlank(pageVO.getName())) { - taskQuery.taskNameLike("%" + pageVO.getName() + "%"); - } - if (pageVO.getBeginCreateTime() != null) { - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getBeginCreateTime())); - } - if (pageVO.getEndCreateTime() != null) { - taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getEndCreateTime())); - } - // 执行查询 - List tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - if (CollUtil.isEmpty(tasks)) { - return PageResult.empty(taskQuery.count()); - } - - // 获得 TaskExtDO Map - List bpmTaskExtDOs = - taskExtMapper.selectListByTaskIds(convertSet(tasks, HistoricTaskInstance::getId)); - Map bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, BpmTaskExtDO::getTaskId); - // 获得 ProcessInstance Map - Map historicProcessInstanceMap = - processInstanceService.getHistoricProcessInstanceMap( - convertSet(tasks, HistoricTaskInstance::getProcessInstanceId)); - // 获得 User Map - Map userMap = adminUserApi.getUserMap( - convertSet(historicProcessInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); - // 拼接结果 - return new PageResult<>( - BpmTaskConvert.INSTANCE.convertList2(tasks, bpmTaskExtDOMap, historicProcessInstanceMap, userMap), - taskQuery.count()); - } - - @Override - public List getTasksByProcessInstanceIds(List processInstanceIds) { - if (CollUtil.isEmpty(processInstanceIds)) { - return Collections.emptyList(); - } - return taskService.createTaskQuery().processInstanceIdIn(processInstanceIds).list(); - } - - @Override - public List getTaskListByProcessInstanceId(String processInstanceId) { - // 获得任务列表 - List tasks = historyService.createHistoricTaskInstanceQuery() - .processInstanceId(processInstanceId) - .orderByHistoricTaskInstanceStartTime().desc() // 创建时间倒序 - .list(); - if (CollUtil.isEmpty(tasks)) { - return Collections.emptyList(); - } - - // 获得 TaskExtDO Map - List bpmTaskExtDOs = taskExtMapper.selectListByTaskIds(convertSet(tasks, HistoricTaskInstance::getId)); - Map bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, BpmTaskExtDO::getTaskId); - // 获得 ProcessInstance Map - HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(processInstanceId); - // 获得 User Map - Set userIds = convertSet(tasks, task -> NumberUtils.parseLong(task.getAssignee())); - userIds.add(NumberUtils.parseLong(processInstance.getStartUserId())); - Map userMap = adminUserApi.getUserMap(userIds); - // 获得 Dept Map - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - - // 拼接数据 - List result = BpmTaskConvert.INSTANCE.convertList3(tasks, bpmTaskExtDOMap, processInstance, userMap, deptMap); - return BpmTaskConvert.INSTANCE.convertChildrenList(result); - } - - @Override - public List getTaskListByTaskIdList(List taskIdList) { - return taskExtMapper.selectListByTaskIds(taskIdList); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void approveTask(Long userId, @Valid BpmTaskApproveReqVO reqVO) { - // 1.1 校验任务存在 - Task task = validateTask(userId, reqVO.getId()); - // 1.2 校验流程实例存在 - ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - if (instance == null) { - throw exception(PROCESS_INSTANCE_NOT_EXISTS); - } - - // 情况一:被委派的任务,不调用 complete 去完成任务 - if (DelegationState.PENDING.equals(task.getDelegationState())) { - approveDelegateTask(reqVO, task); - return; - } - - // 情况二:后加签的任务 - if (BpmTaskAddSignTypeEnum.AFTER.getType().equals(task.getScopeType())) { - // 后加签处理 - approveAfterSignTask(task, reqVO); - return; - } - - // 情况三:自己审批的任务,调用 complete 去完成任务 - // 完成任务,审批通过 - taskService.complete(task.getId(), instance.getProcessVariables()); - // 更新任务拓展表为通过 - taskExtMapper.updateByTaskId( - new BpmTaskExtDO().setTaskId(task.getId()).setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()) - .setReason(reqVO.getReason())); - // 处理加签任务 - handleParentTask(task); - } - - - /** - * 审批通过存在“后加签”的任务。 - *

- * 注意:该任务不能马上完成,需要一个中间状态(SIGN_AFTER),并激活剩余所有子任务(PROCESS)为可审批处理 - * - * @param task 当前任务 - * @param reqVO 前端请求参数 - */ - private void approveAfterSignTask(Task task, BpmTaskApproveReqVO reqVO) { - // 1. 有向后加签,则该任务状态临时设置为 ADD_SIGN_AFTER 状态 - taskExtMapper.updateByTaskId( - new BpmTaskExtDO().setTaskId(task.getId()).setResult(BpmProcessInstanceResultEnum.SIGN_AFTER.getResult()) - .setReason(reqVO.getReason()).setEndTime(LocalDateTime.now())); - - // 2. 激活子任务 - List childrenTaskIdList = getChildrenTaskIdList(task.getId()); - for (String childrenTaskId : childrenTaskIdList) { - taskService.resolveTask(childrenTaskId); - } - // 2.1 更新任务扩展表中子任务为进行中 - taskExtMapper.updateBatchByTaskIdList(childrenTaskIdList, - new BpmTaskExtDO().setResult(BpmProcessInstanceResultEnum.PROCESS.getResult())); - } - - /** - * 处理当前任务的父任务,主要处理“加签”的情况 - * - * @param task 当前任务 - */ - private void handleParentTask(Task task) { - String parentTaskId = task.getParentTaskId(); - if (StrUtil.isBlank(parentTaskId)) { - return; - } - // 1. 判断当前任务的父任务是否还有子任务 - Long childrenTaskCount = getChildrenTaskCount(parentTaskId); - if (childrenTaskCount > 0) { - return; - } - // 2. 获取父任务 - Task parentTask = validateTaskExist(parentTaskId); - - // 3. 处理加签情况 - String scopeType = parentTask.getScopeType(); - if(!validateSignType(scopeType)){ - return; - } - // 3.1 情况一:处理向前加签 - if (BpmTaskAddSignTypeEnum.BEFORE.getType().equals(scopeType)) { - // 3.1.1 如果是向前加签的任务,则调用 resolveTask 指派父任务,将 owner 重新赋值给父任务的 assignee,这样它就可以被审批 - taskService.resolveTask(parentTaskId); - // 3.1.2 更新任务拓展表为处理中 - taskExtMapper.updateByTaskId( - new BpmTaskExtDO().setTaskId(parentTask.getId()).setResult(BpmProcessInstanceResultEnum.PROCESS.getResult())); - } else if (BpmTaskAddSignTypeEnum.AFTER.getType().equals(scopeType)) { - // 3.2 情况二:处理向后加签 - handleParentTaskForAfterSign(parentTask); - } - - // 4. 子任务已处理完成,清空 scopeType 字段,修改 parentTask 信息,方便后续可以继续向前后向后加签 - // 再查询一次的原因是避免报错:Task was updated by another transaction concurrently - // 因为前面处理后可能会导致 parentTask rev 字段被修改,需要重新获取最新的 - parentTask = getTask(parentTaskId); - if (parentTask == null) { - // 为空的情况是:已经通过 handleAfterSign 方法将任务完成了,所以 ru_task 表会查不到数据 - return; - } - clearTaskScopeTypeAndSave(parentTask); - } - - - /** - * 处理后加签任务 - * - * @param parentTask 当前审批任务的父任务 - */ - // TODO @海:这个逻辑,怎么感觉可以是 parentTask 的 parent,再去调用 handleParentTask 方法;可以微信聊下; - private void handleParentTaskForAfterSign(Task parentTask) { - String parentTaskId = parentTask.getId(); - // 1. 更新 parentTask 的任务拓展表为通过,并调用 complete 完成自己 - BpmTaskExtDO currentTaskExt = taskExtMapper.selectByTaskId(parentTask.getId()); - BpmTaskExtDO currentTaskExtUpdateObj = new BpmTaskExtDO().setTaskId(parentTask.getId()) - .setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()); - if (currentTaskExt.getEndTime() == null) { - // 1.1 有这个判断是因为,以前没设置过结束时间,才去设置 - currentTaskExtUpdateObj.setEndTime(LocalDateTime.now()); - } - taskExtMapper.updateByTaskId(currentTaskExtUpdateObj); - // 1.2 完成自己(因为它已经没有子任务,所以也可以完成) - taskService.complete(parentTaskId); - - // 2. 如果有父级,递归查询上级任务是否都已经完成 - if (StrUtil.isEmpty(parentTask.getParentTaskId())) { - return; - } - // 2.1 判断整条链路的任务是否完成 - // 例如从 A 任务加签了一个 B 任务,B 任务又加签了一个 C 任务,C 任务加签了 D 任务 - // 此时,D 任务完成,要一直往上找到祖先任务 A调用 complete 方法完成 A 任务 - boolean allChildrenTaskFinish = true; - while (StrUtil.isNotBlank(parentTask.getParentTaskId())) { - parentTask = validateTaskExist(parentTask.getParentTaskId()); - BpmTaskExtDO parentTaskExt = taskExtMapper.selectByTaskId(parentTask.getId()); - if (parentTaskExt == null) { - break; - } - boolean currentTaskFinish = BpmProcessInstanceResultEnum.isEndResult(parentTaskExt.getResult()); - // 2.2 如果 allChildrenTaskFinish 已经被赋值为 false,则不会再赋值为 true,因为整个链路没有完成 - if (allChildrenTaskFinish) { - allChildrenTaskFinish = currentTaskFinish; - } - // 2.3 任务已完成则不处理 - if (currentTaskFinish) { - continue; - } - - // 3 处理非完成状态的任务 - // 3.1 判断当前任务的父任务是否还有子任务 - Long childrenTaskCount = getChildrenTaskCount(parentTaskExt.getTaskId()); - if (childrenTaskCount > 0) { - continue; - } - // 3.2 没有子任务,判断当前任务状态是否为 ADD_SIGN_BEFORE 待前加签任务完成 - if (BpmProcessInstanceResultEnum.SIGN_BEFORE.getResult().equals(parentTaskExt.getResult())) { - // 3.3 需要修改该任务状态为处理中 - taskService.resolveTask(parentTaskExt.getTaskId()); - parentTaskExt.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); - taskExtMapper.updateByTaskId(parentTaskExt); - } - // 3.4 清空 scopeType 字段,用于任务没有子任务时使用该方法,方便任务可以再次被不同的方式加签 - parentTask = validateTaskExist(parentTaskExt.getTaskId()); - clearTaskScopeTypeAndSave(parentTask); - } - - // 4. 完成最后的顶级祖先任务 - if (allChildrenTaskFinish) { - taskService.complete(parentTask.getId()); - } - } - - /** - * 清空 scopeType 字段,用于任务没有子任务时使用该方法,方便任务可以再次被不同的方式加签 - * - * @param task 需要被清空的任务 - */ - private void clearTaskScopeTypeAndSave(Task task) { - TaskEntityImpl taskImpl = (TaskEntityImpl) task; - taskImpl.setScopeType(null); - taskService.saveTask(task); - } - - /** - * 获取子任务个数 - * - * @param parentTaskId 父任务 ID - * @return 剩余子任务个数 - */ - private Long getChildrenTaskCount(String parentTaskId) { - String tableName = managementService.getTableName(TaskEntity.class); - String sql = "SELECT COUNT(1) from " + tableName + " WHERE PARENT_TASK_ID_=#{parentTaskId}"; - return taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).count(); - } - - /** - * 审批被委派的任务 - * - * @param reqVO 前端请求参数,包含当前任务ID,审批意见等 - * @param task 当前被审批的任务 - */ - private void approveDelegateTask(BpmTaskApproveReqVO reqVO, Task task) { - // 1. 添加审批意见 - AdminUserRespDTO currentUser = adminUserApi.getUser(WebFrameworkUtils.getLoginUserId()); - AdminUserRespDTO sourceApproveUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())); - Assert.notNull(sourceApproveUser, "委派任务找不到原审批人,需要检查数据"); - String comment = StrUtil.format("[{}]完成委派任务,任务重新回到[{}]手中,审批意见为:{}", currentUser.getNickname(), - sourceApproveUser.getNickname(), reqVO.getReason()); - taskService.addComment(reqVO.getId(), task.getProcessInstanceId(), - BpmCommentTypeEnum.DELEGATE.getType().toString(), comment); - - // 2.1 调用 resolveTask 完成任务。 - // 底层调用 TaskHelper.changeTaskAssignee(task, task.getOwner()):将 owner 设置为 assignee - taskService.resolveTask(task.getId()); - // 2.2 更新任务拓展表为【处理中】 - taskExtMapper.updateByTaskId( - new BpmTaskExtDO().setTaskId(task.getId()).setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()) - .setReason(reqVO.getReason())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO) { - Task task = validateTask(userId, reqVO.getId()); - // 校验流程实例存在 - ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - if (instance == null) { - throw exception(PROCESS_INSTANCE_NOT_EXISTS); - } - - // 更新流程实例为不通过 - processInstanceService.updateProcessInstanceExtReject(instance.getProcessInstanceId(), reqVO.getReason()); - - // 更新任务拓展表为不通过 - taskExtMapper.updateByTaskId( - new BpmTaskExtDO().setTaskId(task.getId()).setResult(BpmProcessInstanceResultEnum.REJECT.getResult()) - .setEndTime(LocalDateTime.now()).setReason(reqVO.getReason())); - } - - @Override - public void updateTaskAssignee(Long userId, BpmTaskUpdateAssigneeReqVO reqVO) { - // 校验任务存在 - Task task = validateTask(userId, reqVO.getId()); - // 更新负责人 - updateTaskAssignee(task.getId(), reqVO.getAssigneeUserId()); - } - - @Override - public void updateTaskAssignee(String id, Long userId) { - taskService.setAssignee(id, String.valueOf(userId)); - } - - /** - * 校验任务是否存在, 并且是否是分配给自己的任务 - * - * @param userId 用户 id - * @param taskId task id - */ - private Task validateTask(Long userId, String taskId) { - Task task = validateTaskExist(taskId); - if (!Objects.equals(userId, NumberUtils.parseLong(task.getAssignee()))) { - throw exception(TASK_OPERATE_FAIL_ASSIGN_NOT_SELF); - } - return task; - } - - @Override - public void createTaskExt(Task task) { - BpmTaskExtDO taskExtDO = BpmTaskConvert.INSTANCE.convert2TaskExt(task) - .setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); - // 向后加签生成的任务,状态不能为进行中,需要等前面父任务完成 - if (BpmTaskAddSignTypeEnum.AFTER_CHILDREN_TASK.getType().equals(task.getScopeType())) { - taskExtDO.setResult(BpmProcessInstanceResultEnum.WAIT_BEFORE_TASK.getResult()); - } - taskExtMapper.insert(taskExtDO); - } - - @Override - public void updateTaskExtComplete(Task task) { - BpmTaskExtDO taskExtDO = BpmTaskConvert.INSTANCE.convert2TaskExt(task) - .setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()) // 不设置也问题不大,因为 Complete 一般是审核通过,已经设置 - .setEndTime(LocalDateTime.now()); - taskExtMapper.updateByTaskId(taskExtDO); - } - - @Override - public void updateTaskExtCancel(String taskId) { - // 需要在事务提交后,才进行查询。不然查询不到历史的原因 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - - @Override - public void afterCommit() { - // 可能只是活动,不是任务,所以查询不到 - HistoricTaskInstance task = getHistoricTask(taskId); - if (task == null) { - return; - } - - // 如果任务拓展表已经是完成的状态,则跳过 - BpmTaskExtDO taskExt = taskExtMapper.selectByTaskId(taskId); - if (taskExt == null) { - log.error("[updateTaskExtCancel][taskId({}) 查找不到对应的记录,可能存在问题]", taskId); - return; - } - // 如果已经是最终的结果,则跳过 - if (BpmProcessInstanceResultEnum.isEndResult(taskExt.getResult())) { - log.error("[updateTaskExtCancel][taskId({}) 处于结果({}),无需进行更新]", taskId, taskExt.getResult()); - return; - } - - // 更新任务 - taskExtMapper.updateById(new BpmTaskExtDO().setId(taskExt.getId()).setResult(BpmProcessInstanceResultEnum.CANCEL.getResult()) - .setEndTime(LocalDateTime.now()).setReason(BpmProcessInstanceDeleteReasonEnum.translateReason(task.getDeleteReason()))); - } - - }); - } - - @Override - public void updateTaskExtAssign(Task task) { - BpmTaskExtDO taskExtDO = - new BpmTaskExtDO().setAssigneeUserId(NumberUtils.parseLong(task.getAssignee())).setTaskId(task.getId()); - taskExtMapper.updateByTaskId(taskExtDO); - // 发送通知。在事务提交时,批量执行操作,所以直接查询会无法查询到 ProcessInstance,所以这里是通过监听事务的提交来实现。 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - @Override - public void afterCommit() { - if (StrUtil.isNotEmpty(task.getAssignee())) { - ProcessInstance processInstance = - processInstanceService.getProcessInstance(task.getProcessInstanceId()); - AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())); - messageService.sendMessageWhenTaskAssigned( - BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task)); - } - } - }); - } - - private Task validateTaskExist(String id) { - Task task = getTask(id); - if (task == null) { - throw exception(TASK_NOT_EXISTS); - } - return task; - } - - private Task getTask(String id) { - return taskService.createTaskQuery().taskId(id).singleResult(); - } - - private HistoricTaskInstance getHistoricTask(String id) { - return historyService.createHistoricTaskInstanceQuery().taskId(id).singleResult(); - } - - @Override - public List getReturnTaskList(String taskId) { - // 1. 校验当前任务 task 存在 - Task task = validateTaskExist(taskId); - // 根据流程定义获取流程模型信息 - BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(task.getProcessDefinitionId()); - FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); - if (source == null) { - throw exception(TASK_NOT_EXISTS); - } - - // 2.1 查询该任务的前置任务节点的 key 集合 - List previousUserList = BpmnModelUtils.getPreviousUserTaskList(source, null, null); - if (CollUtil.isEmpty(previousUserList)) { - return Collections.emptyList(); - } - // 2.2 过滤:只有串行可到达的节点,才可以回退。类似非串行、子流程无法退回 - previousUserList.removeIf(userTask -> !BpmnModelUtils.isSequentialReachable(source, userTask, null)); - return BpmTaskConvert.INSTANCE.convertList(previousUserList); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void returnTask(Long userId, BpmTaskReturnReqVO reqVO) { - // 1.1 当前任务 task - Task task = validateTask(userId, reqVO.getId()); - if (task.isSuspended()) { - throw exception(TASK_IS_PENDING); - } - // 1.2 校验源头和目标节点的关系,并返回目标元素 - FlowElement targetElement = validateTargetTaskCanReturn(task.getTaskDefinitionKey(), reqVO.getTargetDefinitionKey(), task.getProcessDefinitionId()); - - // 2. 调用 flowable 框架的回退逻辑 - returnTask0(task, targetElement, reqVO); - - // 3. 更新任务扩展表 - taskExtMapper.updateByTaskId(new BpmTaskExtDO().setTaskId(task.getId()) - .setResult(BpmProcessInstanceResultEnum.BACK.getResult()) - .setEndTime(LocalDateTime.now()).setReason(reqVO.getReason())); - } - - /** - * 回退流程节点时,校验目标任务节点是否可回退 - * - * @param sourceKey 当前任务节点 Key - * @param targetKey 目标任务节点 key - * @param processDefinitionId 当前流程定义 ID - * @return 目标任务节点元素 - */ - private FlowElement validateTargetTaskCanReturn(String sourceKey, String targetKey, String processDefinitionId) { - // 1.1 获取流程模型信息 - BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(processDefinitionId); - // 1.3 获取当前任务节点元素 - FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, sourceKey); - // 1.3 获取跳转的节点元素 - FlowElement target = BpmnModelUtils.getFlowElementById(bpmnModel, targetKey); - if (target == null) { - throw exception(TASK_TARGET_NODE_NOT_EXISTS); - } - - // 2.2 只有串行可到达的节点,才可以回退。类似非串行、子流程无法退回 - if (!BpmnModelUtils.isSequentialReachable(source, target, null)) { - throw exception(TASK_RETURN_FAIL_SOURCE_TARGET_ERROR); - } - return target; - } - - /** - * 执行回退逻辑 - * - * @param currentTask 当前回退的任务 - * @param targetElement 需要回退到的目标任务 - * @param reqVO 前端参数封装 - */ - public void returnTask0(Task currentTask, FlowElement targetElement, BpmTaskReturnReqVO reqVO) { - // 1. 获得所有需要回撤的任务 taskDefinitionKey,用于稍后的 moveActivityIdsToSingleActivityId 回撤 - // 1.1 获取所有正常进行的任务节点 Key - List taskList = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).list(); - List runTaskKeyList = convertList(taskList, Task::getTaskDefinitionKey); - // 1.2 通过 targetElement 的出口连线,计算在 runTaskKeyList 有哪些 key 需要被撤回 - // 为什么不直接使用 runTaskKeyList 呢?因为可能存在多个审批分支,例如说:A -> B -> C 和 D -> F,而只要 C 撤回到 A,需要排除掉 F - List returnUserTaskList = BpmnModelUtils.iteratorFindChildUserTasks(targetElement, runTaskKeyList, null, null); - List returnTaskKeyList = convertList(returnUserTaskList, UserTask::getId); - - // 2. 给当前要被回退的 task 数组,设置回退意见 - taskList.forEach(task -> { - // 需要排除掉,不需要设置回退意见的任务 - if (!returnTaskKeyList.contains(task.getTaskDefinitionKey())) { - return; - } - taskService.addComment(task.getId(), currentTask.getProcessInstanceId(), - BpmCommentTypeEnum.BACK.getType().toString(), reqVO.getReason()); - }); - - // 3. 执行驳回 - runtimeService.createChangeActivityStateBuilder() - .processInstanceId(currentTask.getProcessInstanceId()) - .moveActivityIdsToSingleActivityId(returnTaskKeyList, // 当前要跳转的节点列表( 1 或多) - reqVO.getTargetDefinitionKey()) // targetKey 跳转到的节点(1) - .changeState(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delegateTask(Long userId, BpmTaskDelegateReqVO reqVO) { - // 1.1 校验任务 - Task task = validateTaskCanDelegate(userId, reqVO); - // 1.2 校验目标用户存在 - AdminUserRespDTO delegateUser = adminUserApi.getUser(reqVO.getDelegateUserId()); - if (delegateUser == null) { - throw exception(TASK_DELEGATE_FAIL_USER_NOT_EXISTS); - } - - // 2. 添加审批意见 - AdminUserRespDTO currentUser = adminUserApi.getUser(userId); - String comment = StrUtil.format("[{}]将任务委派给[{}],委派理由为:{}", currentUser.getNickname(), - delegateUser.getNickname(), reqVO.getReason()); - String taskId = reqVO.getId(); - taskService.addComment(taskId, task.getProcessInstanceId(), - BpmCommentTypeEnum.DELEGATE.getType().toString(), comment); - - // 3.1 设置任务所有人 (owner) 为原任务的处理人 (assignee) - taskService.setOwner(taskId, task.getAssignee()); - // 3.2 执行委派,将任务委派给 receiveId - taskService.delegateTask(taskId, reqVO.getDelegateUserId().toString()); - // 3.3 更新任务拓展表为【委派】 - taskExtMapper.updateByTaskId( - new BpmTaskExtDO().setTaskId(task.getId()).setResult(BpmProcessInstanceResultEnum.DELEGATE.getResult()) - .setReason(reqVO.getReason())); - } - - /** - * 校验任务委派参数 - * - * @param userId 用户编号 - * @param reqVO 任务编号,接收人ID - * @return 当前任务信息 - */ - private Task validateTaskCanDelegate(Long userId, BpmTaskDelegateReqVO reqVO) { - // 校验任务 - Task task = validateTask(userId, reqVO.getId()); - // 校验当前审批人和被委派人不是同一人 - if (task.getAssignee().equals(reqVO.getDelegateUserId().toString())) { - throw exception(TASK_DELEGATE_FAIL_USER_REPEAT); - } - return task; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void createSignTask(Long userId, BpmTaskAddSignReqVO reqVO) { - // 1. 获取和校验任务 - TaskEntityImpl taskEntity = validateAddSign(userId, reqVO); - List userList = adminUserApi.getUserList(reqVO.getUserIdList()); - if (CollUtil.isEmpty(userList)) { - throw exception(TASK_ADD_SIGN_USER_NOT_EXIST); - } - - // 2. 处理当前任务 - // 2.1 开启计数功能,主要用于为了让表 ACT_RU_TASK 中的 SUB_TASK_COUNT_ 字段记录下总共有多少子任务,后续可能有用 - taskEntity.setCountEnabled(true); - if (reqVO.getType().equals(BpmTaskAddSignTypeEnum.BEFORE.getType())) { - // 2.2 向前加签,设置 owner,置空 assign。等子任务都完成后,再调用 resolveTask 重新将 owner 设置为 assign - // 原因是:不能和向前加签的子任务一起审批,需要等前面的子任务都完成才能审批 - taskEntity.setOwner(taskEntity.getAssignee()); - taskEntity.setAssignee(null); - // 2.3 更新扩展表状态 - taskExtMapper.updateByTaskId( - new BpmTaskExtDO().setTaskId(taskEntity.getId()) - .setResult(BpmProcessInstanceResultEnum.SIGN_BEFORE.getResult()) - .setReason(reqVO.getReason())); - } - // 2.4 记录加签方式,完成任务时需要用到判断 - taskEntity.setScopeType(reqVO.getType()); - // 2.5 保存当前任务修改后的值 - taskService.saveTask(taskEntity); - - // 3. 创建加签任务 - createSignTask(convertList(reqVO.getUserIdList(), String::valueOf), taskEntity); - - // 4. 记录加签 comment,拼接结果为: [当前用户]向前加签/向后加签给了[多个用户],理由为:reason - AdminUserRespDTO currentUser = adminUserApi.getUser(userId); - String comment = StrUtil.format(BpmCommentTypeEnum.ADD_SIGN.getComment(), currentUser.getNickname(), - BpmTaskAddSignTypeEnum.formatDesc(reqVO.getType()), String.join(",", convertList(userList, AdminUserRespDTO::getNickname)), reqVO.getReason()); - taskService.addComment(reqVO.getId(), taskEntity.getProcessInstanceId(), - BpmCommentTypeEnum.ADD_SIGN.getType().toString(), comment); - } - - - /** - * 校验任务的加签是否一致 - *

- * 1. 如果存在“向前加签”的任务,则不能“向后加签” - * 2. 如果存在“向后加签”的任务,则不能“向前加签” - * - * @param userId 当前用户 ID - * @param reqVO 请求参数,包含任务 ID 和加签类型 - * @return 当前任务 - */ - private TaskEntityImpl validateAddSign(Long userId, BpmTaskAddSignReqVO reqVO) { - TaskEntityImpl taskEntity = (TaskEntityImpl) validateTask(userId, reqVO.getId()); - // 向前加签和向后加签不能同时存在 - if (StrUtil.isNotBlank(taskEntity.getScopeType()) - && ObjectUtil.notEqual(BpmTaskAddSignTypeEnum.AFTER_CHILDREN_TASK.getType(), taskEntity.getScopeType()) - && ObjectUtil.notEqual(taskEntity.getScopeType(), reqVO.getType())) { - throw exception(TASK_ADD_SIGN_TYPE_ERROR, - BpmTaskAddSignTypeEnum.formatDesc(taskEntity.getScopeType()), BpmTaskAddSignTypeEnum.formatDesc(reqVO.getType())); - } - // 同一个 key 的任务,审批人不重复 - List taskList = taskService.createTaskQuery().processInstanceId(taskEntity.getProcessInstanceId()) - .taskDefinitionKey(taskEntity.getTaskDefinitionKey()).list(); - List currentAssigneeList = convertList(taskList, task -> NumberUtils.parseLong(task.getAssignee())); - // 保留交集在 currentAssigneeList 中 - currentAssigneeList.retainAll(reqVO.getUserIdList()); - if (CollUtil.isNotEmpty(currentAssigneeList)) { - List userList = adminUserApi.getUserList(currentAssigneeList); - throw exception(TASK_ADD_SIGN_USER_REPEAT, String.join(",", convertList(userList, AdminUserRespDTO::getNickname))); - } - return taskEntity; - } - - /** - * 创建加签子任务 - * - * @param addSingUserIdList 被加签的用户 ID - * @param taskEntity 被加签的任务 - */ - private void createSignTask(List addSingUserIdList, TaskEntityImpl taskEntity) { - if (CollUtil.isEmpty(addSingUserIdList)) { - return; - } - // 创建加签人的新任务,全部基于 taskEntity 为父任务来创建 - for (String addSignId : addSingUserIdList) { - if (StrUtil.isBlank(addSignId)) { - continue; - } - createSignTask(taskEntity, addSignId); - } - } - - /** - * 创建加签子任务 - * - * @param parentTask 父任务 - * @param assignee 子任务的执行人 - */ - private void createSignTask(TaskEntityImpl parentTask, String assignee) { - // 1. 生成子任务 - TaskEntityImpl task = (TaskEntityImpl) taskService.newTask(IdUtil.fastSimpleUUID()); - task = BpmTaskConvert.INSTANCE.convert(task, parentTask); - if (BpmTaskAddSignTypeEnum.BEFORE.getType().equals(parentTask.getScopeType())) { - // 2.1 前加签,设置审批人 - task.setAssignee(assignee); - } else { - // 2.2.1 设置 owner 不设置 assignee 是因为不能同时审批,需要等父任务完成 - task.setOwner(assignee); - // 2.2.2 设置向后加签任务的 scopeType 为 afterChildrenTask,用于设置任务扩展表的状态 - task.setScopeType(BpmTaskAddSignTypeEnum.AFTER_CHILDREN_TASK.getType()); - } - // 2. 保存子任务 - taskService.saveTask(task); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSignTask(Long userId, BpmTaskSubSignReqVO reqVO) { - // 1.1 校验 task 可以被减签 - Task task = validateSubSign(reqVO.getId()); - // 1.2 校验取消人存在 - AdminUserRespDTO cancelUser = null; - if (StrUtil.isNotBlank(task.getAssignee())) { - cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getAssignee())); - } - if (cancelUser == null && StrUtil.isNotBlank(task.getOwner())) { - cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())); - } - Assert.notNull(cancelUser, "任务中没有所有者和审批人,数据错误"); - - // 2. 删除任务和对应子任务 - // 2.1 获取所有需要删除的任务 ID ,包含当前任务和所有子任务 - List allTaskIdList = getAllChildTaskIds(task.getId()); - // 2.2 删除任务和所有子任务 - taskService.deleteTasks(allTaskIdList); - // 2.3 修改扩展表状态为取消 - AdminUserRespDTO user = adminUserApi.getUser(userId); - taskExtMapper.updateBatchByTaskIdList(allTaskIdList, new BpmTaskExtDO().setResult(BpmProcessInstanceResultEnum.CANCEL.getResult()) - .setReason(StrUtil.format("由于{}操作[减签],任务被取消", user.getNickname()))); - - // 3. 记录日志到父任务中。先记录日志是因为,通过 handleParentTask 方法之后,任务可能被完成了,并且不存在了,会报异常,所以先记录 - String comment = StrUtil.format(BpmCommentTypeEnum.SUB_SIGN.getComment(), user.getNickname(), cancelUser.getNickname()); - taskService.addComment(task.getParentTaskId(), task.getProcessInstanceId(), - BpmCommentTypeEnum.SUB_SIGN.getType().toString(), comment); - - // 4. 处理当前任务的父任务 - handleParentTask(task); - } - - /** - * 校验任务是否能被减签 - * - * @param id 任务ID - * @return 任务信息 - */ - private Task validateSubSign(String id) { - Task task = validateTaskExist(id); - - // 必须有 scopeType - String scopeType = task.getScopeType(); - if (StrUtil.isEmpty(scopeType)) { - throw exception(TASK_SUB_SIGN_NO_PARENT); - } - // 并且值为 向前和向后加签 - if (!validateSignType(scopeType)) { - throw exception(TASK_SUB_SIGN_NO_PARENT); - } - return task; - } - - /** - * 判断当前类型是否为加签 - * @param scopeType 任务的 scopeType - * @return 当前 scopeType 为加签则返回 true - */ - private boolean validateSignType(String scopeType){ - return StrUtil.equalsAny(scopeType,BpmTaskAddSignTypeEnum.BEFORE.getType(),scopeType, BpmTaskAddSignTypeEnum.AFTER.getType()); - } - - /** - * 获取所有要被取消的删除的任务 ID 集合 - * - * @param parentTaskId 父级任务ID - * @return 所有任务ID - */ - public List getAllChildTaskIds(String parentTaskId) { - List allChildTaskIds = new ArrayList<>(); - // 1. 递归获取子级 - Stack stack = new Stack<>(); - // 1.1 将根任务ID入栈 - stack.push(parentTaskId); - //控制遍历的次数不超过 Byte.MAX_VALUE,避免脏数据造成死循环 - int count = 0; - // TODO @海:< 的前后空格,要注意哈; - while (!stack.isEmpty() && count childrenTaskIdList = getChildrenTaskIdList(taskId); - if (CollUtil.isNotEmpty(childrenTaskIdList)) { - for (String childTaskId : childrenTaskIdList) { - // 1.5 将子任务ID入栈,以便后续处理 - stack.push(childTaskId); - } - } - count++; - } - return allChildTaskIds; - } - - /** - * 获取指定父级任务的所有子任务 ID 集合 - * - * @param parentTaskId 父任务 ID - * @return 所有子任务的 ID 集合 - */ - private List getChildrenTaskIdList(String parentTaskId) { - return convertList(getChildrenTaskList0(parentTaskId), Task::getId); - } - - /** - * 获取指定父级任务的所有子任务 ID 集合 - * - * @param parentTaskId 父任务 ID - * @return 所有子任务的 ID 集合 - */ - private List getChildrenTaskList0(String parentTaskId) { - String tableName = managementService.getTableName(TaskEntity.class); - // taskService.createTaskQuery() 没有 parentId 参数,所以写 sql 查询 - String sql = "select ID_,OWNER_,ASSIGNEE_ from " + tableName + " where PARENT_TASK_ID_=#{parentTaskId}"; - return taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).list(); - } - - - @Override - public List getChildrenTaskList(String parentId) { - // 1. 只查询进行中的任务 后加签的任务,可能不存在 assignee,所以还需要查询 owner - List taskList = getChildrenTaskList0(parentId); - if (CollUtil.isEmpty(taskList)) { - return Collections.emptyList(); - } - List childrenTaskIdList = convertList(taskList, Task::getId); - - // 2.1 将 owner 和 assignee 统一到一个集合中 - List userIds = convertListByFlatMap(taskList, control -> - Stream.of(NumberUtils.parseLong(control.getAssignee()), NumberUtils.parseLong(control.getOwner())) - .filter(Objects::nonNull)); - // 2.2 组装数据 - Map userMap = adminUserApi.getUserMap(userIds); - List taskExtList = taskExtMapper.selectProcessListByTaskIds(childrenTaskIdList); - Map idTaskMap = convertMap(taskList, TaskInfo::getId); - return BpmTaskConvert.INSTANCE.convertList(taskExtList, userMap, idTaskMap); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/package-info.java deleted file mode 100644 index eaa615302a..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX2ScriptTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX2ScriptTest.java deleted file mode 100644 index f462780835..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX2ScriptTest.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskAssignLeaderX2ScriptTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskAssignLeaderX2Script script; - - @Mock - private AdminUserApi adminUserApi; - @Mock - private DeptApi deptApi; - @Mock - private BpmProcessInstanceService bpmProcessInstanceService; - - @Test - public void testCalculateTaskCandidateUsers_noDept() { - // 准备参数 - DelegateExecution execution = mockDelegateExecution(1L); - // mock 方法(startUser) - AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(startUser); - // mock 方法(getStartUserDept)没有部门 - when(deptApi.getDept(eq(10L))).thenReturn(null); - - // 调用 - Set result = script.calculateTaskCandidateUsers(execution); - // 断言 - assertEquals(0, result.size()); - } - - @Test - public void testCalculateTaskCandidateUsers_noParentDept() { - // 准备参数 - DelegateExecution execution = mockDelegateExecution(1L); - // mock 方法(startUser) - AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(startUser); - DeptRespDTO startUserDept = randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(100L) - .setLeaderUserId(20L)); - // mock 方法(getDept) - when(deptApi.getDept(eq(10L))).thenReturn(startUserDept); - when(deptApi.getDept(eq(100L))).thenReturn(null); - - // 调用 - Set result = script.calculateTaskCandidateUsers(execution); - // 断言 - assertEquals(asSet(20L), result); - } - - @Test - public void testCalculateTaskCandidateUsers_existParentDept() { - // 准备参数 - DelegateExecution execution = mockDelegateExecution(1L); - // mock 方法(startUser) - AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(startUser); - DeptRespDTO startUserDept = randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(100L) - .setLeaderUserId(20L)); - when(deptApi.getDept(eq(10L))).thenReturn(startUserDept); - // mock 方法(父 dept) - DeptRespDTO parentDept = randomPojo(DeptRespDTO.class, o -> o.setId(100L).setParentId(1000L) - .setLeaderUserId(200L)); - when(deptApi.getDept(eq(100L))).thenReturn(parentDept); - - // 调用 - Set result = script.calculateTaskCandidateUsers(execution); - // 断言 - assertEquals(asSet(200L), result); - } - - @SuppressWarnings("SameParameterValue") - private DelegateExecution mockDelegateExecution(Long startUserId) { - ExecutionEntityImpl execution = new ExecutionEntityImpl(); - execution.setProcessInstanceId(randomString()); - // mock 返回 startUserId - ExecutionEntityImpl processInstance = new ExecutionEntityImpl(); - processInstance.setStartUserId(String.valueOf(startUserId)); - when(bpmProcessInstanceService.getProcessInstance(eq(execution.getProcessInstanceId()))) - .thenReturn(processInstance); - return execution; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java deleted file mode 100644 index fbc069d8aa..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormUpdateReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmFormMapper; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmFormFieldRespDTO; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.FORM_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link BpmFormServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(BpmFormServiceImpl.class) -public class BpmFormServiceTest extends BaseDbUnitTest { - - @Resource - private BpmFormServiceImpl formService; - - @Resource - private BpmFormMapper formMapper; - - @Test - public void testCreateForm_success() { - // 准备参数 - BpmFormCreateReqVO reqVO = randomPojo(BpmFormCreateReqVO.class, o -> { - o.setConf("{}"); - o.setFields(randomFields()); - }); - - // 调用 - Long formId = formService.createForm(reqVO); - // 断言 - assertNotNull(formId); - // 校验记录的属性是否正确 - BpmFormDO form = formMapper.selectById(formId); - assertPojoEquals(reqVO, form); - } - - @Test - public void testUpdateForm_success() { - // mock 数据 - BpmFormDO dbForm = randomPojo(BpmFormDO.class, o -> { - o.setConf("{}"); - o.setFields(randomFields()); - }); - formMapper.insert(dbForm);// @Sql: 先插入出一条存在的数据 - // 准备参数 - BpmFormUpdateReqVO reqVO = randomPojo(BpmFormUpdateReqVO.class, o -> { - o.setId(dbForm.getId()); // 设置更新的 ID - o.setConf("{'yudao': 'yuanma'}"); - o.setFields(randomFields()); - }); - - // 调用 - formService.updateForm(reqVO); - // 校验是否更新正确 - BpmFormDO form = formMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, form); - } - - @Test - public void testUpdateForm_notExists() { - // 准备参数 - BpmFormUpdateReqVO reqVO = randomPojo(BpmFormUpdateReqVO.class, o -> { - o.setConf("{'yudao': 'yuanma'}"); - o.setFields(randomFields()); - }); - - // 调用, 并断言异常 - assertServiceException(() -> formService.updateForm(reqVO), FORM_NOT_EXISTS); - } - - @Test - public void testDeleteForm_success() { - // mock 数据 - BpmFormDO dbForm = randomPojo(BpmFormDO.class); - formMapper.insert(dbForm);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbForm.getId(); - - // 调用 - formService.deleteForm(id); - // 校验数据不存在了 - assertNull(formMapper.selectById(id)); - } - - @Test - public void testDeleteForm_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> formService.deleteForm(id), FORM_NOT_EXISTS); - } - - @Test - public void testGetFormPage() { - // mock 数据 - BpmFormDO dbForm = randomPojo(BpmFormDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - }); - formMapper.insert(dbForm); - // 测试 name 不匹配 - formMapper.insert(cloneIgnoreId(dbForm, o -> o.setName("源码"))); - // 准备参数 - BpmFormPageReqVO reqVO = new BpmFormPageReqVO(); - reqVO.setName("芋道"); - - // 调用 - PageResult pageResult = formService.getFormPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbForm, pageResult.getList().get(0)); - } - - private List randomFields() { - int size = RandomUtil.randomInt(1, 3); - return Stream.iterate(0, i -> i).limit(size) - .map(i -> JsonUtils.toJsonString(randomPojo(BpmFormFieldRespDTO.class))) - .collect(Collectors.toList()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImplTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImplTest.java deleted file mode 100644 index 2ca2ff914c..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImplTest.java +++ /dev/null @@ -1,227 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl.BpmTaskAssignStartUserScript; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.dict.DictDataApi; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.permission.RoleApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Collections.singleton; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link BpmTaskAssignRuleService} 的单元测试 - * - * @author 芋道源码 - */ -@Import({BpmTaskAssignRuleServiceImpl.class, BpmTaskAssignStartUserScript.class}) // Import 引入 BpmTaskAssignStartUserScript 目的是保证不报错 -public class BpmTaskAssignRuleServiceImplTest extends BaseDbUnitTest { - - @Resource - private BpmTaskAssignRuleServiceImpl bpmTaskRuleService; - - @MockBean - private BpmUserGroupService userGroupService; - @MockBean - private DeptApi deptApi; - @MockBean - private AdminUserApi adminUserApi; - @MockBean - private PermissionApi permissionApi; - @MockBean - private RoleApi roleApi; - @MockBean - private PostApi postApi; - @MockBean - private DictDataApi dictDataApi; - - @Test - public void testCalculateTaskCandidateUsers_Role() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) - .setType(BpmTaskAssignRuleTypeEnum.ROLE.getType()); - // mock 方法 - when(permissionApi.getUserRoleIdListByRoleIds(eq(rule.getOptions()))) - .thenReturn(asSet(11L, 22L)); - mockGetUserMap(asSet(11L, 22L)); - - // 调用 - Set results = bpmTaskRuleService.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - - @Test - public void testCalculateTaskCandidateUsers_DeptMember() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) - .setType(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType()); - // mock 方法 - List users = CollectionUtils.convertList(asSet(11L, 22L), - id -> new AdminUserRespDTO().setId(id)); - when(adminUserApi.getUserListByDeptIds(eq(rule.getOptions()))).thenReturn(users); - mockGetUserMap(asSet(11L, 22L)); - - // 调用 - Set results = bpmTaskRuleService.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - - @Test - public void testCalculateTaskCandidateUsers_DeptLeader() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) - .setType(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType()); - // mock 方法 - DeptRespDTO dept1 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(11L)); - DeptRespDTO dept2 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(22L)); - when(deptApi.getDeptList(eq(rule.getOptions()))).thenReturn(Arrays.asList(dept1, dept2)); - mockGetUserMap(asSet(11L, 22L)); - - // 调用 - Set results = bpmTaskRuleService.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - - @Test - public void testCalculateTaskCandidateUsers_Post() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) - .setType(BpmTaskAssignRuleTypeEnum.POST.getType()); - // mock 方法 - List users = CollectionUtils.convertList(asSet(11L, 22L), - id -> new AdminUserRespDTO().setId(id)); - when(adminUserApi.getUserListByPostIds(eq(rule.getOptions()))).thenReturn(users); - mockGetUserMap(asSet(11L, 22L)); - - // 调用 - Set results = bpmTaskRuleService.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - - @Test - public void testCalculateTaskCandidateUsers_User() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) - .setType(BpmTaskAssignRuleTypeEnum.USER.getType()); - // mock 方法 - mockGetUserMap(asSet(1L, 2L)); - - // 调用 - Set results = bpmTaskRuleService.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(1L, 2L), results); - } - - @Test - public void testCalculateTaskCandidateUsers_UserGroup() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) - .setType(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType()); - // mock 方法 - BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(11L, 12L))); - BpmUserGroupDO userGroup2 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(21L, 22L))); - when(userGroupService.getUserGroupList(eq(rule.getOptions()))).thenReturn(Arrays.asList(userGroup1, userGroup2)); - mockGetUserMap(asSet(11L, 12L, 21L, 22L)); - - // 调用 - Set results = bpmTaskRuleService.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(11L, 12L, 21L, 22L), results); - } - - @Test - public void testCalculateTaskCandidateUsers_Script() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(20L, 21L)) - .setType(BpmTaskAssignRuleTypeEnum.SCRIPT.getType()); - // mock 方法 - BpmTaskAssignScript script1 = new BpmTaskAssignScript() { - - @Override - public Set calculateTaskCandidateUsers(DelegateExecution task) { - return singleton(11L); - } - - @Override - public BpmTaskRuleScriptEnum getEnum() { - return BpmTaskRuleScriptEnum.LEADER_X1; - } - }; - BpmTaskAssignScript script2 = new BpmTaskAssignScript() { - - @Override - public Set calculateTaskCandidateUsers(DelegateExecution task) { - return singleton(22L); - } - - @Override - public BpmTaskRuleScriptEnum getEnum() { - return BpmTaskRuleScriptEnum.LEADER_X2; - } - }; - bpmTaskRuleService.setScripts(Arrays.asList(script1, script2)); - mockGetUserMap(asSet(11L, 22L)); - - // 调用 - Set results = bpmTaskRuleService.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - - @Test - public void testRemoveDisableUsers() { - // 准备参数. 1L 可以找到;2L 是禁用的;3L 找不到 - Set assigneeUserIds = asSet(1L, 2L, 3L); - // mock 方法 - AdminUserRespDTO user1 = randomPojo(AdminUserRespDTO.class, o -> o.setId(1L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - AdminUserRespDTO user2 = randomPojo(AdminUserRespDTO.class, o -> o.setId(2L) - .setStatus(CommonStatusEnum.DISABLE.getStatus())); - Map userMap = MapUtil.builder(user1.getId(), user1) - .put(user2.getId(), user2).build(); - when(adminUserApi.getUserMap(eq(assigneeUserIds))).thenReturn(userMap); - - // 调用 - bpmTaskRuleService.removeDisableUsers(assigneeUserIds); - // 断言 - assertEquals(asSet(1L), assigneeUserIds); - } - - private void mockGetUserMap(Set assigneeUserIds) { - Map userMap = CollectionUtils.convertMap(assigneeUserIds, id -> id, - id -> new AdminUserRespDTO().setId(id).setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(adminUserApi.getUserMap(eq(assigneeUserIds))).thenReturn(userMap); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java deleted file mode 100644 index 9aca274768..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java +++ /dev/null @@ -1,131 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.framework.test.core.util.AssertUtils; -import cn.iocoder.yudao.framework.test.core.util.RandomUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmUserGroupMapper; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_NOT_EXISTS; - -/** - * {@link BpmUserGroupServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(BpmUserGroupServiceImpl.class) -public class BpmUserGroupServiceTest extends BaseDbUnitTest { - - @Resource - private BpmUserGroupServiceImpl userGroupService; - - @Resource - private BpmUserGroupMapper userGroupMapper; - - @Test - public void testCreateUserGroup_success() { - // 准备参数 - BpmUserGroupCreateReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupCreateReqVO.class); - - // 调用 - Long userGroupId = userGroupService.createUserGroup(reqVO); - // 断言 - Assertions.assertNotNull(userGroupId); - // 校验记录的属性是否正确 - BpmUserGroupDO userGroup = userGroupMapper.selectById(userGroupId); - AssertUtils.assertPojoEquals(reqVO, userGroup); - } - - @Test - public void testUpdateUserGroup_success() { - // mock 数据 - BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class); - userGroupMapper.insert(dbUserGroup);// @Sql: 先插入出一条存在的数据 - // 准备参数 - BpmUserGroupUpdateReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupUpdateReqVO.class, o -> { - o.setId(dbUserGroup.getId()); // 设置更新的 ID - }); - - // 调用 - userGroupService.updateUserGroup(reqVO); - // 校验是否更新正确 - BpmUserGroupDO userGroup = userGroupMapper.selectById(reqVO.getId()); // 获取最新的 - AssertUtils.assertPojoEquals(reqVO, userGroup); - } - - @Test - public void testUpdateUserGroup_notExists() { - // 准备参数 - BpmUserGroupUpdateReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupUpdateReqVO.class); - - // 调用, 并断言异常 - AssertUtils.assertServiceException(() -> userGroupService.updateUserGroup(reqVO), USER_GROUP_NOT_EXISTS); - } - - @Test - public void testDeleteUserGroup_success() { - // mock 数据 - BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class); - userGroupMapper.insert(dbUserGroup);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbUserGroup.getId(); - - // 调用 - userGroupService.deleteUserGroup(id); - // 校验数据不存在了 - Assertions.assertNull(userGroupMapper.selectById(id)); - } - - @Test - public void testDeleteUserGroup_notExists() { - // 准备参数 - Long id = RandomUtils.randomLongId(); - - // 调用, 并断言异常 - AssertUtils.assertServiceException(() -> userGroupService.deleteUserGroup(id), USER_GROUP_NOT_EXISTS); - } - - @Test - public void testGetUserGroupPage() { - // mock 数据 - BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2021, 11, 11)); - }); - userGroupMapper.insert(dbUserGroup); - // 测试 name 不匹配 - userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setName("芋道"))); - // 测试 status 不匹配 - userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setCreateTime(buildTime(2021, 12, 12)))); - // 准备参数 - BpmUserGroupPageReqVO reqVO = new BpmUserGroupPageReqVO(); - reqVO.setName("源码"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 11, 10),buildTime(2021, 11, 12)})); - - // 调用 - PageResult pageResult = userGroupService.getUserGroupPage(reqVO); - // 断言 - Assertions.assertEquals(1, pageResult.getTotal()); - Assertions.assertEquals(1, pageResult.getList().size()); - AssertUtils.assertPojoEquals(dbUserGroup, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 1bbe0f530c..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,44 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/logback.xml b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff0..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index 6e42d3cfc6..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,2 +0,0 @@ -DELETE FROM "bpm_form"; -DELETE FROM "bpm_user_group"; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 20a939b761..0000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE IF NOT EXISTS "bpm_user_group" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "description" varchar(255) NOT NULL, - "status" tinyint NOT NULL, - "member_user_ids" varchar(255) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '用户组'; - -CREATE TABLE IF NOT EXISTS "bpm_form" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "status" tinyint NOT NULL, - "fields" varchar(255) NOT NULL, - "conf" varchar(255) NOT NULL, - "remark" varchar(255), - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '动态表单'; diff --git a/yudao-module-crm/pom.xml b/yudao-module-crm/pom.xml deleted file mode 100644 index 2a7b748c38..0000000000 --- a/yudao-module-crm/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - cn.iocoder.boot - yudao - ${revision} - - - yudao-module-crm-api - yudao-module-crm-biz - - 4.0.0 - yudao-module-crm - pom - - ${project.artifactId} - - - crm 包下,客户关系管理(Customer Relationship Management)。 - 例如说:客户、联系人、商机、合同、回款等等 - - - diff --git a/yudao-module-crm/yudao-module-crm-api/pom.xml b/yudao-module-crm/yudao-module-crm-api/pom.xml deleted file mode 100644 index 94e1296264..0000000000 --- a/yudao-module-crm/yudao-module-crm-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-crm - ${revision} - - 4.0.0 - yudao-module-crm-api - jar - - ${project.artifactId} - - crm 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java deleted file mode 100644 index c38bde7f5b..0000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * crm API 包,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.crm.api; diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java deleted file mode 100644 index 76a4d872cc..0000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums; - -/** - * CRM 字典类型的枚举类 - * - * @author 芋道源码 - */ -public interface DictTypeConstants { - - String CRM_CUSTOMER_INDUSTRY = "crm_customer_industry"; // CRM 客户所属行业 - String CRM_CUSTOMER_LEVEL = "crm_customer_level"; // CRM 客户等级 - String CRM_CUSTOMER_SOURCE = "crm_customer_source"; // CRM 客户来源 - String CRM_AUDIT_STATUS = "crm_audit_status"; // CRM 审批状态 - String CRM_PRODUCT_UNIT = "crm_product_unit"; // CRM 产品单位 - String CRM_PRODUCT_STATUS = "crm_product_status"; // CRM 产品状态 - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java deleted file mode 100644 index a7494dc8d4..0000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * CRM 错误码枚举类 - *

- * crm 系统,使用 1-020-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 合同管理 1-020-000-000 ========== - ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在"); - - // ========== 线索管理 1-020-001-000 ========== - ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); - - // ========== 商机管理 1-020-002-000 ========== - ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); - - // TODO @lilleo:商机状态、商机类型,都单独错误码段 - - - // ========== 联系人管理 1-020-003-000 ========== - ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); - ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode( 1_020_003_001, "联系人商机关联不存在"); - - // ========== 回款 1-020-004-000 ========== - ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在"); - - // ========== 合同管理 1-020-005-000 ========== - ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_020_005_000, "回款计划不存在"); - - // ========== 客户管理 1_020_006_000 ========== - ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_006_000, "客户不存在"); - ErrorCode CUSTOMER_OWNER_EXISTS = new ErrorCode(1_020_006_001, "客户【{}】已存在所属负责人"); - ErrorCode CUSTOMER_LOCKED = new ErrorCode(1_020_006_002, "客户【{}】状态已锁定"); - ErrorCode CUSTOMER_ALREADY_DEAL = new ErrorCode(1_020_006_003, "客户已交易"); - ErrorCode CUSTOMER_IN_POOL = new ErrorCode(1_020_006_004, "客户【{}】放入公海失败,原因:已经是公海客户"); - ErrorCode CUSTOMER_LOCKED_PUT_POOL_FAIL = new ErrorCode(1_020_006_005, "客户【{}】放入公海失败,原因:客户已锁定"); - ErrorCode CUSTOMER_UPDATE_OWNER_USER_FAIL = new ErrorCode(1_020_006_006, "更新客户【{}】负责人失败, 原因:系统异常"); - - // ========== 权限管理 1_020_007_000 ========== - ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在"); - ErrorCode CRM_PERMISSION_DENIED = new ErrorCode(1_020_007_001, "{}操作失败,原因:没有权限"); - ErrorCode CRM_PERMISSION_MODEL_NOT_EXISTS = new ErrorCode(1_020_007_002, "{}不存在"); - ErrorCode CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS = new ErrorCode(1_020_007_003, "{}操作失败,原因:转移对象已经是该负责人"); - ErrorCode CRM_PERMISSION_DELETE_FAIL = new ErrorCode(1_020_007_004, "删除数据权限失败,原因:批量删除权限的时候,只能属于同一个 bizId 下"); - ErrorCode CRM_PERMISSION_DELETE_FAIL_EXIST_OWNER = new ErrorCode(1_020_007_005, "删除数据权限失败,原因:存在负责人"); - ErrorCode CRM_PERMISSION_DELETE_DENIED = new ErrorCode(1_020_007_006, "删除数据权限失败,原因:没有权限"); - ErrorCode CRM_PERMISSION_DELETE_SELF_PERMISSION_FAIL_EXIST_OWNER = new ErrorCode(1_020_007_007, "删除数据权限失败,原因:不能删除负责人"); - - // ========== 产品 1_020_008_000 ========== - ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_020_008_000, "产品不存在"); - ErrorCode PRODUCT_NO_EXISTS = new ErrorCode(1_020_008_001, "产品编号已存在"); - - // ========== 产品分类 1_020_009_000 ========== - ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_020_009_000, "产品分类不存在"); - ErrorCode PRODUCT_CATEGORY_EXISTS = new ErrorCode(1_020_009_001, "产品分类已存在"); - ErrorCode PRODUCT_CATEGORY_USED = new ErrorCode(1_020_009_002, "产品分类已关联产品"); - ErrorCode PRODUCT_CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1_020_009_003, "父分类不存在"); - ErrorCode PRODUCT_CATEGORY_PARENT_NOT_FIRST_LEVEL = new ErrorCode(1_020_009_004, "父分类不能是二级分类"); - ErrorCode product_CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_020_009_005, "存在子分类,无法删除"); - - // ========== 商机状态类型 1_020_010_000 ========== - ErrorCode BUSINESS_STATUS_TYPE_NOT_EXISTS = new ErrorCode(1_020_010_000, "商机状态类型不存在"); - ErrorCode BUSINESS_STATUS_TYPE_NAME_EXISTS = new ErrorCode(1_020_010_001, "商机状态类型名称已存在"); - - // ========== 商机状态 1_020_011_000 ========== - ErrorCode BUSINESS_STATUS_NOT_EXISTS = new ErrorCode(1_020_011_000, "商机状态不存在"); - - // ========== 客户公海规则设置 1_020_012_000 ========== - ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_012_000, "客户限制配置不存在"); - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java deleted file mode 100644 index 67709e95b6..0000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * CRM 的审批状态 - * - * @author 赤焰 - */ -@RequiredArgsConstructor -@Getter -public enum CrmAuditStatusEnum implements IntArrayValuable { - - DRAFT(0, "未提交"), - PROCESS(10, "审批中"), - APPROVE(20, "审核通过"), - REJECT(30, "审核不通过"), - CANCEL(40, "已取消"); - - private final Integer status; - private final String name; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmAuditStatusEnum::getStatus).toArray(); - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java deleted file mode 100644 index 0a441d229f..0000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.common; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * CRM 业务类型枚举 - * - * @author HUIHUI - */ -@RequiredArgsConstructor -@Getter -public enum CrmBizTypeEnum implements IntArrayValuable { - - CRM_LEADS(1, "线索"), - CRM_CUSTOMER(2, "客户"), - CRM_CONTACT(3, "联系人"), - CRM_BUSINESS(4, "商机"), - CRM_CONTRACT(5, "合同"), - CRM_PRODUCT(6, "产品") - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 名称 - */ - private final String name; - - public static String getNameByType(Integer type) { - CrmBizTypeEnum typeEnum = CollUtil.findOne(CollUtil.newArrayList(CrmBizTypeEnum.values()), - item -> ObjUtil.equal(item.type, type)); - return typeEnum == null ? null : typeEnum.getName(); - } - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmSceneEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmSceneEnum.java deleted file mode 100644 index a8d892a90a..0000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmSceneEnum.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.common; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -// TODO @puhui999:这个枚举,要不改成 CrmSceneTypeEnum -/** - * CRM 列表检索场景 - * - * @author HUIHUI - */ -@Getter -@AllArgsConstructor -public enum CrmSceneEnum implements IntArrayValuable { - - OWNER(1, "我负责的"), - FOLLOW(2, "我关注的"), - // TODO @puhui999:还有一个我参与的 - SUBORDINATE(3, "下属负责的"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneEnum::getType).toArray(); - - /** - * 场景类型 - */ - private final Integer type; - /** - * 场景名称 - */ - private final String name; - - public static boolean isOwner(Integer type) { - return ObjUtil.equal(OWNER.getType(), type); - } - - public static boolean isFollow(Integer type) { - return ObjUtil.equal(FOLLOW.getType(), type); - } - - public static boolean isSubordinate(Integer type) { - return ObjUtil.equal(SUBORDINATE.getType(), type); - } - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java deleted file mode 100644 index aa06b05ebc..0000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.customer; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 客户等级 - * - * @author Wanwan - */ -@Getter -@AllArgsConstructor -public enum CrmCustomerLevelEnum implements IntArrayValuable { - - IMPORTANT(1, "A(重点客户)"), - GENERAL(2, "B(普通客户)"), - LOW_PRIORITY(3, "C(非优先客户)"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLevelEnum::getLevel).toArray(); - - /** - * 状态 - */ - private final Integer level; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLimitConfigTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLimitConfigTypeEnum.java deleted file mode 100644 index 6300dee0ee..0000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLimitConfigTypeEnum.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.customer; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 客户限制配置规则类型 - * - * @author Wanwan - */ -@Getter -@AllArgsConstructor -public enum CrmCustomerLimitConfigTypeEnum implements IntArrayValuable { - - /** - * 拥有客户数限制 - */ - CUSTOMER_QUANTITY_LIMIT(1, "拥有客户数限制"), - /** - * 锁定客户数限制 - */ - CUSTOMER_LOCK_LIMIT(2, "锁定客户数限制"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLimitConfigTypeEnum::getCode).toArray(); - - /** - * 状态 - */ - private final Integer code; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/permission/CrmPermissionLevelEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/permission/CrmPermissionLevelEnum.java deleted file mode 100644 index 56b0366aa5..0000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/permission/CrmPermissionLevelEnum.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.permission; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 数据权限级别枚举 - * - * @author HUIHUI - */ -@Getter -@AllArgsConstructor -public enum CrmPermissionLevelEnum implements IntArrayValuable { - - OWNER(1, "负责人"), - READ(2, "读"), - WRITE(3, "写"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmPermissionLevelEnum::getLevel).toArray(); - - /** - * 级别 - */ - private final Integer level; - /** - * 级别名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static boolean isOwner(Integer level) { - return ObjUtil.equal(OWNER.level, level); - } - - public static boolean isRead(Integer level) { - return ObjUtil.equal(READ.level, level); - } - - public static boolean isWrite(Integer level) { - return ObjUtil.equal(WRITE.level, level); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/product/CrmProductStatusEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/product/CrmProductStatusEnum.java deleted file mode 100644 index e82d5b5b80..0000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/product/CrmProductStatusEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.product; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 商品状态 - * - * @author ZanGe丶 - * @since 2023-11-30 21:53 - */ -@Getter -@AllArgsConstructor -public enum CrmProductStatusEnum implements IntArrayValuable { - - DISABLE(0, "下架"), - ENABLE(1, "上架"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmProductStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/pom.xml b/yudao-module-crm/yudao-module-crm-biz/pom.xml deleted file mode 100644 index 15bbc932de..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-crm - ${revision} - - 4.0.0 - yudao-module-crm-biz - - ${project.artifactId} - - crm 包下,客户关系管理(Customer Relationship Management)。 - 例如说:客户、联系人、商机、合同、回款等等 - - - - - cn.iocoder.boot - yudao-module-system-api - ${revision} - - - cn.iocoder.boot - yudao-module-crm-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-ip - - - - - cn.iocoder.boot - yudao-spring-boot-starter-web - - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-excel - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java deleted file mode 100644 index 5c4e2493e8..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * crm API 实现类,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.crm.api; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.http deleted file mode 100644 index 55adb4bd53..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.http +++ /dev/null @@ -1,32 +0,0 @@ -### 请求 /transfer -PUT {{baseUrl}}/crm/business/transfer -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "id": 1, - "ownerUserId": 2, - "transferType": 2, - "permissionType": 2 -} - -### 请求 /update -PUT {{baseUrl}}/crm/business/update -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "id": 1, - "name": "2", - "statusTypeId": 2, - "statusId": 2, - "customerId": 1 -} - -### 请求 /get -GET {{baseUrl}}/crm/business/get?id=1024 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java deleted file mode 100644 index 1194403789..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java +++ /dev/null @@ -1,174 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusTypeService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 商机") -@RestController -@RequestMapping("/crm/business") -@Validated -public class CrmBusinessController { - - @Resource - private CrmBusinessService businessService; - - @Resource - private CrmCustomerService customerService; - - @Resource - private CrmBusinessStatusTypeService businessStatusTypeService; - - @Resource - private CrmBusinessStatusService businessStatusService; - - @PostMapping("/create") - @Operation(summary = "创建商机") - @PreAuthorize("@ss.hasPermission('crm:business:create')") - public CommonResult createBusiness(@Valid @RequestBody CrmBusinessCreateReqVO createReqVO) { - return success(businessService.createBusiness(createReqVO, getLoginUserId())); - } - - @PutMapping("/update") - @Operation(summary = "更新商机") - @PreAuthorize("@ss.hasPermission('crm:business:update')") - public CommonResult updateBusiness(@Valid @RequestBody CrmBusinessUpdateReqVO updateReqVO) { - businessService.updateBusiness(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商机") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:business:delete')") - public CommonResult deleteBusiness(@RequestParam("id") Long id) { - businessService.deleteBusiness(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得商机") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult getBusiness(@RequestParam("id") Long id) { - CrmBusinessDO business = businessService.getBusiness(id); - return success(CrmBusinessConvert.INSTANCE.convert(business)); - } - - @GetMapping("/page") - @Operation(summary = "获得商机分页") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) { - PageResult pageResult = businessService.getBusinessPage(pageVO, getLoginUserId()); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - // 处理客户名称回显 - // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈; - Set customerIds = pageResult.getList().stream() - .map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet()); - List customerList = customerService.getCustomerList(customerIds); - // 处理商机状态类型名称回显 - Set statusTypeIds = pageResult.getList().stream() - .map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet()); - CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO(); - queryStatusTypeVO.setIdList(statusTypeIds); - List statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO); - // 处理商机状态名称回显 - Set statusIds = pageResult.getList().stream() - .map(CrmBusinessDO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet()); - CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO(); - queryVO.setIdList(statusIds); - List statusList = businessStatusService.selectList(queryVO); - return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList)); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得商机分页,基于指定客户") - public CommonResult> getBusinessPageByCustomer(@Valid CrmContractPageReqVO pageReqVO) { - Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = businessService.getBusinessPageByCustomer(pageReqVO); - // 处理客户名称回显 - // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈; - Set customerIds = pageResult.getList().stream() - .map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet()); - List customerList = customerService.getCustomerList(customerIds); - // 处理商机状态类型名称回显 - Set statusTypeIds = pageResult.getList().stream() - .map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet()); - CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO(); - queryStatusTypeVO.setIdList(statusTypeIds); - List statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO); - // 处理商机状态名称回显 - Set statusIds = pageResult.getList().stream() - .map(CrmBusinessDO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet()); - CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO(); - queryVO.setIdList(statusIds); - List statusList = businessStatusService.selectList(queryVO); - return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList)); - } - - @GetMapping("/pool-page") - @Operation(summary = "获得商机公海分页") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult> getBusinessPoolPage(@Valid CrmBusinessPageReqVO pageVO) { - // TODO puhui999: 等数据权限完善后再实现 - return null; - } - - @GetMapping("/export-excel") - @Operation(summary = "导出商机 Excel") - @PreAuthorize("@ss.hasPermission('crm:business:export')") - @OperateLog(type = EXPORT) - public void exportBusinessExcel(@Valid CrmBusinessPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - PageResult pageResult = businessService.getBusinessPage(exportReqVO, getLoginUserId()); - // 导出 Excel - ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class, - CrmBusinessConvert.INSTANCE.convertList02(pageResult.getList())); - } - - @PutMapping("/transfer") - @Operation(summary = "商机转移") - @PreAuthorize("@ss.hasPermission('crm:business:update')") - public CommonResult transfer(@Valid @RequestBody CrmBusinessTransferReqVO reqVO) { - businessService.transferBusiness(reqVO, getLoginUserId()); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusTypeController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusTypeController.java deleted file mode 100644 index cd4a60e819..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusTypeController.java +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO; -import cn.iocoder.yudao.module.crm.convert.businessstatus.CrmBusinessStatusConvert; -import cn.iocoder.yudao.module.crm.convert.businessstatustype.CrmBusinessStatusTypeConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusTypeService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.Collection; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; - -@Tag(name = "管理后台 - 商机状态类型") -@RestController -@RequestMapping("/crm/business-status-type") -@Validated -public class CrmBusinessStatusTypeController { - - @Resource - private CrmBusinessStatusTypeService businessStatusTypeService; - - @Resource - private CrmBusinessStatusService businessStatusService; - - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建商机状态类型") - @PreAuthorize("@ss.hasPermission('crm:business-status-type:create')") - public CommonResult createBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeSaveReqVO createReqVO) { - return success(businessStatusTypeService.createBusinessStatusType(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新商机状态类型") - @PreAuthorize("@ss.hasPermission('crm:business-status-type:update')") - public CommonResult updateBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeSaveReqVO updateReqVO) { - businessStatusTypeService.updateBusinessStatusType(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商机状态类型") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:business-status-type:delete')") - public CommonResult deleteBusinessStatusType(@RequestParam("id") Long id) { - businessStatusTypeService.deleteBusinessStatusType(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得商机状态类型") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") - public CommonResult getBusinessStatusType(@RequestParam("id") Long id) { - CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeService.getBusinessStatusType(id); - // 处理状态回显 - // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈; - CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO(); - queryVO.setTypeId(id); - List statusList = businessStatusService.selectList(queryVO); - return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType, statusList)); - } - - @GetMapping("/page") - @Operation(summary = "获得商机状态类型分页") - @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") - public CommonResult> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageReqVO) { - PageResult pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO); - // 处理部门回显 - // TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈; - Set deptIds = pageResult.getList().stream() - .map(CrmBusinessStatusTypeDO::getDeptIds) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .collect(Collectors.toSet()); - List deptList = deptApi.getDeptList(deptIds); - return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult, deptList)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出商机状态类型 Excel") - @PreAuthorize("@ss.hasPermission('crm:business-status-type:export')") - @OperateLog(type = EXPORT) - public void exportBusinessStatusTypeExcel(@Valid CrmBusinessStatusTypePageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "商机状态类型.xls", "数据", CrmBusinessStatusTypeRespVO.class, - BeanUtils.toBean(list, CrmBusinessStatusTypeRespVO.class)); - } - - @GetMapping("/get-simple-list") - @Operation(summary = "获得商机状态类型列表") - @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") - public CommonResult> getBusinessStatusTypeList() { - CrmBusinessStatusTypeQueryVO queryVO = new CrmBusinessStatusTypeQueryVO(); - queryVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - List list = businessStatusTypeService.selectList(queryVO); - return success(BeanUtils.toBean(list, CrmBusinessStatusTypeRespVO.class)); - } - - // TODO @ljlleo 这个接口,是不是可以和 getBusinessStatusTypeList 合并成一个? - @GetMapping("/get-status-list") - @Operation(summary = "获得商机状态列表") - @PreAuthorize("@ss.hasPermission('crm:business-status:query')") - public CommonResult> getBusinessStatusListByTypeId(@RequestParam("typeId") Long typeId) { - CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO(); - queryVO.setTypeId(typeId); - List list = businessStatusService.selectList(queryVO); - return success(CrmBusinessStatusConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessBaseVO.java deleted file mode 100644 index db0a342a66..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessBaseVO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.math.BigDecimal; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 商机 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class CrmBusinessBaseVO { - - @Schema(description = "商机名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "商机名称不能为空") - private String name; - - @Schema(description = "商机状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714") - @NotNull(message = "商机状态类型不能为空") - private Long statusTypeId; - - @Schema(description = "商机状态编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") - @NotNull(message = "商机状态不能为空") - private Long statusId; - - @Schema(description = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactNextTime; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10299") - @NotNull(message = "客户不能为空") - private Long customerId; - - @Schema(description = "预计成交日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime dealTime; - - @Schema(description = "商机金额", example = "12371") - private Integer price; - - // TODO @ljileo:折扣使用 Integer 类型,存储时,默认 * 100;展示的时候,前端需要 / 100;避免精度丢失问题 - @Schema(description = "整单折扣") - private Integer discountPercent; - - @Schema(description = "产品总金额", example = "12025") - private BigDecimal productPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessCreateReqVO.java deleted file mode 100644 index 1f01e76ebe..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessCreateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商机创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO { - - // TODO @ljileo:新建的时候,应该可以传递添加的产品; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessExcelVO.java deleted file mode 100644 index a11949ecd7..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessExcelVO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Set; - -/** - * 商机 Excel VO - * - * @author ljlleo - */ -@Data -public class CrmBusinessExcelVO { - - @ExcelProperty("主键") - private Long id; - - @ExcelProperty("商机名称") - private String name; - - @ExcelProperty("商机状态类型编号") - private Long statusTypeId; - - @ExcelProperty("商机状态编号") - private Long statusId; - - @ExcelProperty("下次联系时间") - private LocalDateTime contactNextTime; - - @ExcelProperty("客户编号") - private Long customerId; - - @ExcelProperty("预计成交日期") - private LocalDateTime dealTime; - - @ExcelProperty("商机金额") - private BigDecimal price; - - @ExcelProperty("整单折扣") - private BigDecimal discountPercent; - - @ExcelProperty("产品总金额") - private BigDecimal productPrice; - - @ExcelProperty("备注") - private String remark; - - @ExcelProperty("负责人的用户编号") - private Long ownerUserId; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @ExcelProperty("只读权限的用户编号数组") - private Set roUserIds; - - @ExcelProperty("读写权限的用户编号数组") - private Set rwUserIds; - - @ExcelProperty("1赢单2输单3无效") - private Integer endStatus; - - @ExcelProperty("结束时的备注") - private String endRemark; - - @ExcelProperty("最后跟进时间") - private LocalDateTime contactLastTime; - - @ExcelProperty("跟进状态") - private Integer followUpStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java deleted file mode 100644 index c756b79cb1..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商机分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmBusinessPageReqVO extends PageParam { - - @Schema(description = "商机名称", example = "李四") - private String name; - - @Schema(description = "客户编号", example = "10795") - private Long customerId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java deleted file mode 100644 index 53c8f45dac..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商机 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmBusinessRespVO extends CrmBusinessBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String customerName; - - @Schema(description = "状态类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "进行中") - private String statusTypeName; - - @Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "跟进中") - private String statusName; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessTransferReqVO.java deleted file mode 100644 index c76c4873fb..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessTransferReqVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商机转移 Request VO") -@Data -public class CrmBusinessTransferReqVO { - - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "联系人编号不能为空") - private Long id; - - /** - * 新负责人的用户编号 - */ - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessUpdateReqVO.java deleted file mode 100644 index 94b82fa5aa..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessUpdateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商机更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") - @NotNull(message = "主键不能为空") - private Long id; - - // TODO @ljileo:修改的时候,应该可以传递添加的产品; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusPageReqVO.java deleted file mode 100644 index b91a954e08..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusPageReqVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商机状态分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmBusinessStatusPageReqVO extends PageParam { - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusQueryVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusQueryVO.java deleted file mode 100644 index fbf4d06e1a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusQueryVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.util.Collection; - -@Schema(description = "管理后台 - 商机状态 Query VO") -@Data -@ToString(callSuper = true) -public class CrmBusinessStatusQueryVO { - - @Schema(description = "主键集合") - private Collection idList; - - @Schema(description = "状态类型编号") - private Long typeId; -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusRespVO.java deleted file mode 100644 index 405a832a53..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商机状态 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmBusinessStatusRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "23899") - @ExcelProperty("主键") - private Long id; - - @Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7139") - @ExcelProperty("状态类型编号") - private Long typeId; - - @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @ExcelProperty("状态名") - private String name; - - @Schema(description = "赢单率") - @ExcelProperty("赢单率") - private String percent; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("排序") - private Integer sort; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusSaveReqVO.java deleted file mode 100644 index c5ecf52d69..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusSaveReqVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商机状态新增/修改 Request VO") -@Data -public class CrmBusinessStatusSaveReqVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "23899") - private Long id; - - @Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7139") - @NotNull(message = "状态类型编号不能为空") - private Long typeId; - - @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotEmpty(message = "状态名不能为空") - private String name; - - // TODO @lilleo:percent 应该是 Integer; - @Schema(description = "赢单率") - private String percent; - - // TODO @lilleo:这个是不是不用前端新增和修改的时候传递,交给顺序计算出来,存储起来就好了; - @Schema(description = "排序") - private Integer sort; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypePageReqVO.java deleted file mode 100644 index 03b113cc7d..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypePageReqVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商机状态类型分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmBusinessStatusTypePageReqVO extends PageParam { - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeQueryVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeQueryVO.java deleted file mode 100644 index 9c78f1afc0..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeQueryVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.util.Collection; - -@Schema(description = "管理后台 - 商机状态类型 Query VO") -@Data -@ToString(callSuper = true) -public class CrmBusinessStatusTypeQueryVO { - - @Schema(description = "主键集合") - private Collection idList; - - @Schema(description = "状态") - private Integer status; -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeRespVO.java deleted file mode 100644 index 9d13d5dc37..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeRespVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type; - -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 商机状态类型 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmBusinessStatusTypeRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934") - @ExcelProperty("主键") - private Long id; - - @Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("状态类型名") - private String name; - - @Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("使用的部门编号") - private List deptIds; - @Schema(description = "使用的部门名称", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("使用的部门名称") - private List deptNames; - - @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建人") - private String creator; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - // TODO @ljlleo 字段后缀改成 statuses,保持和 deptIds 风格一致;CrmBusinessStatusDO 改成 VO 哈;一般不使用 do 直接返回 - @Schema(description = "状态集合", requiredMode = Schema.RequiredMode.REQUIRED) - private List statusList; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeSaveReqVO.java deleted file mode 100644 index 096b42e1f5..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/type/CrmBusinessStatusTypeSaveReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type; - -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; -import com.google.common.collect.Lists; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import java.util.List; - -@Schema(description = "管理后台 - 商机状态类型新增/修改 Request VO") -@Data -public class CrmBusinessStatusTypeSaveReqVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934") - private Long id; - - @Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotEmpty(message = "状态类型名不能为空") - private String name; - - @Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED) - private List deptIds = Lists.newArrayList(); - - // TODO @ljlleo VO 里面,我们不使用默认值哈。这里 Lists.newArrayList() 看看怎么去掉。上面 deptIds 也是类似噢 - @Schema(description = "商机状态集合", requiredMode = Schema.RequiredMode.REQUIRED) - private List statusList = Lists.newArrayList(); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java deleted file mode 100644 index 759e46d131..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; -import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.module.crm.service.clue.CrmClueService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; - -@Tag(name = "管理后台 - 线索") -@RestController -@RequestMapping("/crm/clue") -@Validated -public class CrmClueController { - - @Resource - private CrmClueService clueService; - - @PostMapping("/create") - @Operation(summary = "创建线索") - @PreAuthorize("@ss.hasPermission('crm:clue:create')") - public CommonResult createClue(@Valid @RequestBody CrmClueCreateReqVO createReqVO) { - return success(clueService.createClue(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新线索") - @PreAuthorize("@ss.hasPermission('crm:clue:update')") - public CommonResult updateClue(@Valid @RequestBody CrmClueUpdateReqVO updateReqVO) { - clueService.updateClue(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除线索") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:clue:delete')") - public CommonResult deleteClue(@RequestParam("id") Long id) { - clueService.deleteClue(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得线索") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:clue:query')") - public CommonResult getClue(@RequestParam("id") Long id) { - CrmClueDO clue = clueService.getClue(id); - return success(CrmClueConvert.INSTANCE.convert(clue)); - } - - @GetMapping("/page") - @Operation(summary = "获得线索分页") - @PreAuthorize("@ss.hasPermission('crm:clue:query')") - public CommonResult> getCluePage(@Valid CrmCluePageReqVO pageVO) { - PageResult pageResult = clueService.getCluePage(pageVO); - return success(CrmClueConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出线索 Excel") - @PreAuthorize("@ss.hasPermission('crm:clue:export')") - @OperateLog(type = EXPORT) - public void exportClueExcel(@Valid CrmClueExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = clueService.getClueList(exportReqVO); - // 导出 Excel - List datas = CrmClueConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "线索.xls", "数据", CrmClueExcelVO.class, datas); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java deleted file mode 100644 index b7ff0ef3ec..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 线索 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class CrmClueBaseVO { - - @Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx") - @NotEmpty(message = "线索名称不能为空") - private String name; - - @Schema(description = "客户 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520") - @NotNull(message = "客户不能为空") - private Long customerId; - - @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactNextTime; - - @Schema(description = "电话", example = "18000000000") - @Telephone - private String telephone; - - @Schema(description = "手机号", example = "18000000000") - @Mobile - private String mobile; - - @Schema(description = "地址", example = "北京市海淀区") - private String address; - - @Schema(description = "最后跟进时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactLastTime; - - @Schema(description = "备注", example = "随便") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java deleted file mode 100644 index a23837499e..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.*; - -@Schema(description = "管理后台 - 线索创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmClueCreateReqVO extends CrmClueBaseVO { - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java deleted file mode 100644 index d6457bd560..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; - -import com.alibaba.excel.annotation.ExcelProperty; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -/** - * 线索 Excel VO - * - * @author Wanwan - */ -@Data -public class CrmClueExcelVO { - - @ExcelProperty("编号") - private Long id; - - @ExcelProperty(value = "转化状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean transformStatus; - - @ExcelProperty(value = "跟进状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean followUpStatus; - - @ExcelProperty("线索名称") - private String name; - - // TODO 这里需要导出成客户名称 - @ExcelProperty("客户id") - private Long customerId; - - @ExcelProperty("下次联系时间") - private LocalDateTime contactNextTime; - - @ExcelProperty("电话") - private String telephone; - - @ExcelProperty("手机号") - private String mobile; - - @ExcelProperty("地址") - private String address; - - @ExcelProperty("负责人的用户编号") - private Long ownerUserId; - - @ExcelProperty("最后跟进时间") - private LocalDateTime contactLastTime; - - @ExcelProperty("备注") - private String remark; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExportReqVO.java deleted file mode 100644 index fe061b3650..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExportReqVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import java.time.LocalDateTime; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 线索 Excel 导出 Request VO,参数和 CrmCluePageReqVO 是一致的") -@Data -public class CrmClueExportReqVO { - - @Schema(description = "转化状态", example = "true") - private Boolean transformStatus; - - @Schema(description = "跟进状态", example = "true") - private Boolean followUpStatus; - - @Schema(description = "线索名称", example = "线索xxx") - private String name; - - @Schema(description = "客户id", example = "520") - private Long customerId; - - @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] contactNextTime; - - @Schema(description = "电话", example = "18000000000") - private String telephone; - - @Schema(description = "手机号", example = "18000000000") - private String mobile; - - @Schema(description = "地址", example = "北京市海淀区") - private String address; - - @Schema(description = "负责人的用户编号", example = "27199") - private Long ownerUserId; - - @Schema(description = "最后跟进时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] contactLastTime; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java deleted file mode 100644 index 4d28ebc739..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 线索分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCluePageReqVO extends PageParam { - - @Schema(description = "线索名称", example = "线索xxx") - private String name; - - @Schema(description = "电话", example = "18000000000") - private String telephone; - - @Schema(description = "手机号", example = "18000000000") - private String mobile; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java deleted file mode 100644 index 327e6a00bf..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 线索 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmClueRespVO extends CrmClueBaseVO { - - @Schema(description = "编号,主键自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "转化状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean transformStatus; - - @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean followUpStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java deleted file mode 100644 index 996c381304..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 线索更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmClueUpdateReqVO extends CrmClueBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java deleted file mode 100644 index df55ef4133..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java +++ /dev/null @@ -1,163 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.NumberUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; -import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.google.common.collect.Lists; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - CRM 联系人") -@RestController -@RequestMapping("/crm/contact") -@Validated -@Slf4j -public class CrmContactController { - - @Resource - private CrmContactService contactService; - @Resource - private CrmCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建联系人") - @PreAuthorize("@ss.hasPermission('crm:contact:create')") - public CommonResult createContact(@Valid @RequestBody CrmContactCreateReqVO createReqVO) { - return success(contactService.createContact(createReqVO, getLoginUserId())); - } - - @PutMapping("/update") - @Operation(summary = "更新联系人") - @PreAuthorize("@ss.hasPermission('crm:contact:update')") - public CommonResult updateContact(@Valid @RequestBody CrmContactUpdateReqVO updateReqVO) { - contactService.updateContact(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除联系人") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:contact:delete')") - public CommonResult deleteContact(@RequestParam("id") Long id) { - contactService.deleteContact(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得联系人") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:contact:query')") - public CommonResult getContact(@RequestParam("id") Long id) { - CrmContactDO contact = contactService.getContact(id); - if (contact == null) { - throw exception(ErrorCodeConstants.CONTACT_NOT_EXISTS); - } - // 1. 获取用户名 - Map userMap = adminUserApi.getUserMap(CollUtil.removeNull(Lists.newArrayList( - NumberUtil.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - // 2. 获取客户信息 - List customerList = customerService.getCustomerList(Collections.singletonList(contact.getCustomerId())); - // 3. 直属上级 - List parentContactList = contactService.getContactList(Collections.singletonList(contact.getParentId())); - return success(ContactConvert.INSTANCE.convert(contact, userMap, customerList, parentContactList)); - } - - @GetMapping("/simple-all-list") - @Operation(summary = "获得联系人列表") - @PreAuthorize("@ss.hasPermission('crm:contact:query')") - public CommonResult> getSimpleContactList() { - List list = contactService.getContactList(); - return success(ContactConvert.INSTANCE.convertAllList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得联系人分页") - @PreAuthorize("@ss.hasPermission('crm:contact:query')") - public CommonResult> getContactPage(@Valid CrmContactPageReqVO pageVO) { - PageResult pageResult = contactService.getContactPage(pageVO); - return success(convertDetailContactPage(pageResult)); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得联系人分页,基于指定客户") - public CommonResult> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) { - Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = contactService.getContactPageByCustomer(pageVO); - return success(convertDetailContactPage(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出联系人 Excel") - @PreAuthorize("@ss.hasPermission('crm:contact:export')") - @OperateLog(type = EXPORT) - public void exportContactExcel(@Valid CrmContactPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - exportReqVO.setPageNo(PageParam.PAGE_SIZE_NONE); - PageResult pageResult = contactService.getContactPage(exportReqVO); - ExcelUtils.write(response, "联系人.xls", "数据", CrmContactRespVO.class, - convertDetailContactPage(pageResult).getList()); - } - - /** - * 转换成详细的联系人分页,即读取关联信息 - * - * @param pageResult 联系人分页 - * @return 详细的联系人分页 - */ - private PageResult convertDetailContactPage(PageResult pageResult) { - List contactList = pageResult.getList(); - if (CollUtil.isEmpty(contactList)) { - return PageResult.empty(pageResult.getTotal()); - } - // 1. 获取客户列表 - List crmCustomerDOList = customerService.getCustomerList( - convertSet(contactList, CrmContactDO::getCustomerId)); - // 2. 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - // 3. 直属上级 - List parentContactList = contactService.getContactList( - convertSet(contactList, CrmContactDO::getParentId)); - return ContactConvert.INSTANCE.convertPage(pageResult, userMap, crmCustomerDOList, parentContactList); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBaseVO.java deleted file mode 100644 index eb984884dd..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBaseVO.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.Email; -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -// TODO zyna:要不按照新的,干掉这个 basevo,都放子类里 -/** - * CRM 联系人 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -@ExcelIgnoreUnannotated -public class CrmContactBaseVO { - - @ExcelProperty(value = "姓名",order = 1) - @Schema(description = "姓名", example = "芋艿") - @NotNull(message = "姓名不能为空") - private String name; - - @Schema(description = "客户编号", example = "10795") - private Long customerId; - - @ExcelProperty(value = "性别", converter = DictConvert.class, order = 3) - @DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_SEX) - @Schema(description = "性别") - private Integer sex; - - @Schema(description = "职位") - @ExcelProperty(value = "职位", order = 3) - private String post; - - @Schema(description = "是否关键决策人") - @ExcelProperty(value = "是否关键决策人", converter = DictConvert.class, order = 3) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean master; - - @Schema(description = "直属上级", example = "23457") - private Long parentId; - - @Schema(description = "手机号",example = "1387171766") - @Mobile - @ExcelProperty(value = "手机号",order = 4) - private String mobile; - - @Schema(description = "座机",example = "021-0029922") - @Telephone - @ExcelProperty(value = "座机",order = 4) - private String telephone; - - @ExcelProperty(value = "QQ",order = 4) - @Schema(description = "QQ",example = "197272662") - private Long qq; - - @ExcelProperty(value = "微信",order = 4) - @Schema(description = "微信",example = "zzz3883") - private String wechat; - - @Schema(description = "电子邮箱",example = "1111@22.com") - @Email - @ExcelProperty(value = "邮箱",order = 4) - private String email; - - @ExcelProperty(value = "地址",order = 5) - @Schema(description = "地址") - private String address; - - @Schema(description = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) - @ExcelProperty(value = "下次联系时间",order = 6) - private LocalDateTime nextTime; - - @Schema(description = "备注", example = "你说的对") - @ExcelProperty(value = "备注",order = 6) - private String remark; - - @Schema(description = "最后跟进时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ExcelProperty(value = "最后跟进时间",order = 6) - private LocalDateTime lastTime; - - @Schema(description = "负责人用户编号", example = "14334") - @NotNull(message = "负责人不能为空") - private Long ownerUserId; - - @Schema(description = "地区编号", example = "20158") - private Integer areaId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactCreateReqVO.java deleted file mode 100644 index 33f2db8521..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 联系人创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmContactCreateReqVO extends CrmContactBaseVO { - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactPageReqVO.java deleted file mode 100644 index 1adfc341d9..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 联系人分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmContactPageReqVO extends PageParam { - - @Schema(description = "姓名", example = "芋艿") - private String name; - - @Schema(description = "客户编号", example = "10795") - private Long customerId; - - @Schema(description = "手机号", example = "13898273941") - private String mobile; - - @Schema(description = "电话", example = "021-383773") - private String telephone; - - @Schema(description = "电子邮箱", example = "111@22.com") - private String email; - - @Schema(description = "QQ", example = "3882872") - private Long qq; - - @Schema(description = "微信", example = "zzZ98373") - private String wechat; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactRespVO.java deleted file mode 100644 index e52f4d0c1a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactRespVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 联系人 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@ExcelIgnoreUnannotated -public class CrmContactRespVO extends CrmContactBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167") - private Long id; - - @Schema(description = "创建时间") - @ExcelProperty(value = "创建时间", order = 8) - private LocalDateTime createTime; - - @Schema(description = "更新时间") - @ExcelProperty(value = "更新时间", order = 8) - private LocalDateTime updateTime; - - @Schema(description = "创建人", example = "25682") - private String creator; - - @Schema(description = "创建人名字", example = "test") - @ExcelProperty(value = "创建人", order = 8) - private String creatorName; - - @ExcelProperty(value = "客户名称",order = 2) - @Schema(description = "客户名字", example = "test") - private String customerName; - - @Schema(description = "负责人", example = "test") - @ExcelProperty(value = "负责人", order = 7) - private String ownerUserName; - - @Schema(description = "直属上级名", example = "芋头") - @ExcelProperty(value = "直属上级", order = 4) - private String parentName; - - @Schema(description = "地区名", example = "上海上海市浦东新区") - @ExcelProperty(value = "地区", order = 5) - private String areaName; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactSimpleRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactSimpleRespVO.java deleted file mode 100644 index 4ebf44a30e..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactSimpleRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 联系人的精简 Response VO") -@Data -@ToString(callSuper = true) -public class CrmContactSimpleRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167") - private Long id; - - @Schema(description = "姓名", example = "芋艿") - private String name; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java deleted file mode 100644 index c65b205c8b..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 联系人转移 Request VO") -@Data -public class CrmContactTransferReqVO { - - @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "联系人编号不能为空") - private Long id; - - /** - * 新负责人的用户编号 - */ - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactUpdateReqVO.java deleted file mode 100644 index 0f705d5cbb..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 联系人更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmContactUpdateReqVO extends CrmContactBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167") - @NotNull(message = "主键不能为空") - private Long id; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/CrmContactBusinessLinkController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/CrmContactBusinessLinkController.java deleted file mode 100644 index cc9ae8cd1b..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/CrmContactBusinessLinkController.java +++ /dev/null @@ -1,115 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contactbusinesslink.CrmContactBusinessLinkService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; - -@Tag(name = "管理后台 - CRM 联系人商机关联") -@RestController -@RequestMapping("/crm/contact-business-link") -@Validated -public class CrmContactBusinessLinkController { - - @Resource - private CrmContactBusinessLinkService contactBusinessLinkService; - @Resource - private CrmBusinessService crmBusinessService; - - // TODO @zyna:createContactBusinessLink 和 createContactBusinessLinkBatch 是不是合并成一个接口?contactId、List - @PostMapping("/create") - @Operation(summary = "创建联系人商机关联") - @PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')") - public CommonResult createContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO createReqVO) { - return success(contactBusinessLinkService.createContactBusinessLink(createReqVO)); - } - - @PostMapping("/create-batch") - @Operation(summary = "创建联系人商机关联") - @PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')") - @Transactional(rollbackFor = Exception.class) - public CommonResult createContactBusinessLinkBatch( - @Valid @RequestBody List createReqVO) { - createReqVO.stream().forEach(item -> { - CrmBusinessDO crmBusinessDO = crmBusinessService.getBusiness(item.getBusinessId()); - if(crmBusinessDO == null){ - throw exception(BUSINESS_NOT_EXISTS); - } - }); - contactBusinessLinkService.createContactBusinessLinkBatch(createReqVO); - return success(true); - } - - // TODO @zyna:这个接口是不是可以删除掉了哈?应该不存在更新。 - @PutMapping("/update") - @Operation(summary = "更新联系人商机关联") - @PreAuthorize("@ss.hasPermission('crm:contact-business-link:update')") - public CommonResult updateContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO updateReqVO) { - contactBusinessLinkService.updateContactBusinessLink(updateReqVO); - return success(true); - } - - // TODO @zyna:删除,是不是传递 ids? - @DeleteMapping("/delete-batch") - @Operation(summary = "批量删除联系人商机关联") - @PreAuthorize("@ss.hasPermission('crm:contact-business-link:delete')") - public CommonResult deleteContactBusinessLinkBatch(@Valid @RequestBody List deleteList) { - contactBusinessLinkService.deleteContactBusinessLink(deleteList); - return success(true); - } - - // TODO @zyna:这个接口是不是可以删除掉了哈?应该不存在单个读取; - @GetMapping("/get") - @Operation(summary = "获得联系人商机关联") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')") - public CommonResult getContactBusinessLink(@RequestParam("id") Long id) { - CrmContactBusinessLinkDO contactBusinessLink = contactBusinessLinkService.getContactBusinessLink(id); - return success(BeanUtils.toBean(contactBusinessLink, CrmContactBusinessLinkRespVO.class)); - } - - // TODO @zyna:这个可以转化下,使用客户编号去查询,就是使用 CrmBusinessController 的 getBusinessPageByCustomer 接口;目的是:复用 - @GetMapping("/page-by-contact") - @Operation(summary = "获得联系人商机关联") - @PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')") - public CommonResult> getContactBusinessLinkByContact( - @Valid CrmContactBusinessLinkPageReqVO pageReqVO) { - PageResult contactBusinessLink = contactBusinessLinkService.getContactBusinessLinkPageByContact(pageReqVO); - return success(contactBusinessLink); - } - - // TODO @zyna:这个优化下,搞到 CrmBusinessController 里去,加一个 CrmBusinessController 的 getBusinessPageByContact 接口;目的是: - @GetMapping("/page") - @Operation(summary = "获得联系人商机关联分页") - @PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')") - public CommonResult> getContactBusinessLinkPage( - @Valid CrmContactBusinessLinkPageReqVO pageReqVO) { - PageResult pageResult = contactBusinessLinkService.getContactBusinessLinkPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, CrmContactBusinessLinkRespVO.class)); - } - - // TODO @zyna:最终梳理完后,应该就 2 个接口,要不直接合并到 CrmContactController 中,不作为独立模块,就关联、接触关联。其实和 user 设置它有哪些岗位、部门是类似的。 - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkPageReqVO.java deleted file mode 100644 index c8e98c15a7..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 联系人商机关联分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmContactBusinessLinkPageReqVO extends PageParam { - - @Schema(description = "联系人编号", example = "20878") - private Long contactId; - - @Schema(description = "商机编号", example = "7638") - private Long businessId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkRespVO.java deleted file mode 100644 index 17aadf667e..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo; - -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 联系人商机关联 Response VO") -@Data -public class CrmContactBusinessLinkRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220") - @ExcelProperty("主键") - private Long id; - - @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878") - private Long contactId; - - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638") - private Long businessId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkSaveReqVO.java deleted file mode 100644 index 6f867c5115..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkSaveReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 联系人商机关联新增/修改 Request VO") -@Data -public class CrmContactBusinessLinkSaveReqVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220") - private Long id; - - @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878") - @NotNull(message="联系人不能为空") - private Long contactId; - - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638") - @NotNull(message="商机不能为空") - private Long businessId; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java deleted file mode 100644 index b1581bc624..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; -import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - CRM 合同") -@RestController -@RequestMapping("/crm/contract") -@Validated -public class CrmContractController { - - @Resource - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建合同") - @PreAuthorize("@ss.hasPermission('crm:contract:create')") - public CommonResult createContract(@Valid @RequestBody CrmContractCreateReqVO createReqVO) { - return success(contractService.createContract(createReqVO, getLoginUserId())); - } - - @PutMapping("/update") - @Operation(summary = "更新合同") - @PreAuthorize("@ss.hasPermission('crm:contract:update')") - public CommonResult updateContract(@Valid @RequestBody CrmContractUpdateReqVO updateReqVO) { - contractService.updateContract(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除合同") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:contract:delete')") - public CommonResult deleteContract(@RequestParam("id") Long id) { - contractService.deleteContract(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得合同") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult getContract(@RequestParam("id") Long id) { - CrmContractDO contract = contractService.getContract(id); - return success(ContractConvert.INSTANCE.convert(contract)); - } - - @GetMapping("/page") - @Operation(summary = "获得合同分页") - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult> getContractPage(@Valid CrmContractPageReqVO pageVO) { - PageResult pageResult = contractService.getContractPage(pageVO); - return success(convertDetailContractPage(pageResult)); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得联系人分页,基于指定客户") - public CommonResult> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) { - Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = contractService.getContractPageByCustomer(pageVO); - return success(convertDetailContractPage(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出合同 Excel") - @PreAuthorize("@ss.hasPermission('crm:contract:export')") - @OperateLog(type = EXPORT) - public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - PageResult pageResult = contractService.getContractPage(exportReqVO); - // 导出 Excel - ExcelUtils.write(response, "合同.xls", "数据", CrmContractExcelVO.class, - ContractConvert.INSTANCE.convertList02(pageResult.getList())); - } - - /** - * 转换成详细的合同分页,即读取关联信息 - * - * @param pageResult 合同分页 - * @return 详细的合同分页 - */ - private PageResult convertDetailContractPage(PageResult pageResult) { - List contactList = pageResult.getList(); - if (CollUtil.isEmpty(contactList)) { - return PageResult.empty(pageResult.getTotal()); - } - // 1. 获取客户列表 - List customerList = customerService.getCustomerList( - convertSet(contactList, CrmContractDO::getCustomerId)); - // 2. 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - return ContractConvert.INSTANCE.convertPage(pageResult, userMap, customerList); - } - - @PutMapping("/transfer") - @Operation(summary = "合同转移") - @PreAuthorize("@ss.hasPermission('crm:contract:update')") - public CommonResult transfer(@Valid @RequestBody CrmContractTransferReqVO reqVO) { - contractService.transferContract(reqVO, getLoginUserId()); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractRespVO.java deleted file mode 100644 index cfe746bcb1..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractRespVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 合同 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ContractRespVO extends CrmContractBaseVO { - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "创建人", example = "25682") - private String creator; - - @Schema(description = "创建人名字", example = "test") - private String creatorName; - - @Schema(description = "客户名字", example = "test") - private String customerName; - - @Schema(description = "负责人", example = "test") - private String ownerUserName; - - @Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer auditStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractBaseVO.java deleted file mode 100644 index a7a8c5d8ce..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractBaseVO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 合同 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class CrmContractBaseVO { - - // TODO @dhb52:类似 no 字段的 example 要写xia 哈; - - @Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotNull(message = "合同名称不能为空") - private String name; - - // TODO @dhb52:这个必须传递 - @Schema(description = "客户编号", example = "18336") - private Long customerId; - - @Schema(description = "商机编号", example = "10864") - private Long businessId; - - @Schema(description = "工作流编号", example = "1043") - private Long processInstanceId; - - // TODO @dhb52:这个必须传递 - @Schema(description = "下单日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime orderDate; - - // TODO @dhb52:这个必须传递 - @Schema(description = "负责人的用户编号", example = "17144") - private Long ownerUserId; - - // TODO @芋艿:未来应该支持自动生成; - // TODO @dhb52:这个必须传递; - @Schema(description = "合同编号") - private String no; - - @Schema(description = "开始时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "合同金额", example = "5617") - private Integer price; - - @Schema(description = "整单折扣") - private Integer discountPercent; - - @Schema(description = "产品总金额", example = "19510") - private Integer productPrice; - - @Schema(description = "联系人编号", example = "18546") - private Long contactId; - - @Schema(description = "公司签约人", example = "14036") - private Long signUserId; - - @Schema(description = "最后跟进时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactLastTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - // TODO @dhb52:增加一个 status 字段:具体有哪些值,你来枚举下;主要页面上有个【草稿】【提交审核】的流程,可以看看。然后要对接工作流,这块也可以看看,不确定的地方问我。 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractCreateReqVO.java deleted file mode 100644 index 17196473a0..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 合同创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmContractCreateReqVO extends CrmContractBaseVO { - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractExcelVO.java deleted file mode 100644 index 72f9f3cfaf..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractExcelVO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; - -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * CRM 合同 Excel VO - * - * @author dhb52 - */ -@Data -public class CrmContractExcelVO { - - @ExcelProperty("合同编号") - private Long id; - - @ExcelProperty("合同名称") - private String name; - - @ExcelProperty("客户编号") - private Long customerId; - - @ExcelProperty("商机编号") - private Long businessId; - - @ExcelProperty("工作流编号") - private Long processInstanceId; - - @ExcelProperty("下单日期") - private LocalDateTime orderDate; - - @ExcelProperty("负责人的用户编号") - private Long ownerUserId; - - @ExcelProperty("合同编号") - private String no; - - @ExcelProperty("开始时间") - private LocalDateTime startTime; - - @ExcelProperty("结束时间") - private LocalDateTime endTime; - - @ExcelProperty("合同金额") - private Integer price; - - @ExcelProperty("整单折扣") - private Integer discountPercent; - - @ExcelProperty("产品总金额") - private Integer productPrice; - - @ExcelProperty("联系人编号") - private Long contactId; - - @ExcelProperty("公司签约人") - private Long signUserId; - - @ExcelProperty("最后跟进时间") - private LocalDateTime contactLastTime; - - @ExcelProperty("备注") - private String remark; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractPageReqVO.java deleted file mode 100644 index e2f286a997..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 合同分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmContractPageReqVO extends PageParam { - - @Schema(description = "合同编号", example = "XYZ008") - private String no; - - @Schema(description = "合同名称", example = "王五") - private String name; - - @Schema(description = "客户编号", example = "18336") - private Long customerId; - - @Schema(description = "商机编号", example = "10864") - private Long businessId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractTransferReqVO.java deleted file mode 100644 index 88227c560a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractTransferReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 合同转移 Request VO") -@Data -public class CrmContractTransferReqVO { - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "联系人编号不能为空") - private Long id; - - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(value = CrmPermissionLevelEnum.class) - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractUpdateReqVO.java deleted file mode 100644 index f0c0e9959a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 合同更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmContractUpdateReqVO extends CrmContractBaseVO { - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "合同编号不能为空") - private Long id; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.http deleted file mode 100644 index f6ecb473bc..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.http +++ /dev/null @@ -1,6 +0,0 @@ -### 请求 /update -GET {{baseUrl}}/crm/customer/page?pageNo=1&pageSize=10&name="张三" -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java deleted file mode 100644 index f06e26e4a3..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java +++ /dev/null @@ -1,186 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; -import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.mapstruct.ap.internal.util.Collections; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - CRM 客户") -@RestController -@RequestMapping("/crm/customer") -@Validated -public class CrmCustomerController { - - @Resource - private CrmCustomerService customerService; - - @Resource - private DeptApi deptApi; - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建客户") - @PreAuthorize("@ss.hasPermission('crm:customer:create')") - public CommonResult createCustomer(@Valid @RequestBody CrmCustomerCreateReqVO createReqVO) { - return success(customerService.createCustomer(createReqVO, getLoginUserId())); - } - - @PutMapping("/update") - @Operation(summary = "更新客户") - @PreAuthorize("@ss.hasPermission('crm:customer:update')") - public CommonResult updateCustomer(@Valid @RequestBody CrmCustomerUpdateReqVO updateReqVO) { - customerService.updateCustomer(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除客户") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:customer:delete')") - public CommonResult deleteCustomer(@RequestParam("id") Long id) { - customerService.deleteCustomer(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得客户") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult getCustomer(@RequestParam("id") Long id) { - // 1. 获取客户 - CrmCustomerDO customer = customerService.getCustomer(id); - if (customer == null) { - return success(null); - } - // 2. 拼接数据 - Map userMap = adminUserApi.getUserMap( - Collections.asSet(Long.valueOf(customer.getCreator()), customer.getOwnerUserId())); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - return success(CrmCustomerConvert.INSTANCE.convert(customer, userMap, deptMap)); - } - - @GetMapping("/page") - @Operation(summary = "获得客户分页") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { - // 1. 查询客户分页 - PageResult pageResult = customerService.getCustomerPage(pageVO, getLoginUserId()); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 2. 拼接数据 - Map userMap = adminUserApi.getUserMap( - convertSetByFlatMap(pageResult.getList(), user -> Stream.of(Long.parseLong(user.getCreator()), user.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出客户 Excel") - @PreAuthorize("@ss.hasPermission('crm:customer:export')") - @OperateLog(type = EXPORT) - public void exportCustomerExcel(@Valid CrmCustomerPageReqVO pageVO, - HttpServletResponse response) throws IOException { - pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页 - List list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList(); - // 导出 Excel - List datas = CrmCustomerConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerExcelVO.class, datas); - } - - @PutMapping("/transfer") - @Operation(summary = "客户转移") - @PreAuthorize("@ss.hasPermission('crm:customer:update')") - public CommonResult transfer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) { - customerService.transferCustomer(reqVO, getLoginUserId()); - return success(true); - } - - // TODO @Joey:单独建一个属于自己业务的 ReqVO;因为前端如果模拟请求,是不是可以更新其它字段了; - @PutMapping("/lock") - @Operation(summary = "锁定/解锁客户") - @PreAuthorize("@ss.hasPermission('crm:customer:update')") - public CommonResult lockCustomer(@Valid @RequestBody CrmCustomerUpdateReqVO updateReqVO) { - customerService.lockCustomer(updateReqVO); - return success(true); - } - - // ==================== 公海相关操作 ==================== - - @PutMapping("/put-pool") - @Operation(summary = "数据放入公海") - @Parameter(name = "id", description = "客户编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:customer:update')") - public CommonResult putCustomerPool(@RequestParam("id") Long id) { - customerService.putCustomerPool(id); - return success(true); - } - - @PutMapping("/receive") - @Operation(summary = "领取公海客户") - @Parameter(name = "ids", description = "编号数组", required = true, example = "1,2,3") - @PreAuthorize("@ss.hasPermission('crm:customer:receive')") - public CommonResult receiveCustomer(@RequestParam(value = "ids") List ids) { - customerService.receiveCustomer(ids, getLoginUserId()); - return success(true); - } - - @PutMapping("/distribute") - @Operation(summary = "分配公海给对应负责人") - @Parameters({ - @Parameter(name = "ids", description = "客户编号数组", required = true, example = "1,2,3"), - @Parameter(name = "ownerUserId", description = "分配的负责人编号", required = true, example = "12345") - }) - @PreAuthorize("@ss.hasPermission('crm:customer:distribute')") - public CommonResult distributeCustomer(@RequestParam(value = "ids") List ids, - @RequestParam(value = "ownerUserId") Long ownerUserId) { - // 领取公海数据 - customerService.receiveCustomer(ids, ownerUserId); - return success(true); - } - - // TODO 芋艿:这个接口要调整下 - @GetMapping("/query-all-list") - @Operation(summary = "查询客户列表") - @PreAuthorize("@ss.hasPermission('crm:customer:all')") - public CommonResult> queryAll() { - List crmCustomerDOList = customerService.getCustomerList(); - List data = CrmCustomerConvert.INSTANCE.convertQueryAll(crmCustomerDOList); - return success(data); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java deleted file mode 100644 index ec86c99d58..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; - -@Tag(name = "管理后台 - CRM 客户限制配置") -@RestController -@RequestMapping("/crm/customer-limit-config") -@Validated -public class CrmCustomerLimitConfigController { - - @Resource - private CrmCustomerLimitConfigService customerLimitConfigService; - - @Resource - private DeptApi deptApi; - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建客户限制配置") - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:create')") - public CommonResult createCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigCreateReqVO createReqVO) { - return success(customerLimitConfigService.createCustomerLimitConfig(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新客户限制配置") - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:update')") - public CommonResult updateCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigUpdateReqVO updateReqVO) { - customerLimitConfigService.updateCustomerLimitConfig(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除客户限制配置") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:delete')") - public CommonResult deleteCustomerLimitConfig(@RequestParam("id") Long id) { - customerLimitConfigService.deleteCustomerLimitConfig(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得客户限制配置") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:query')") - public CommonResult getCustomerLimitConfig(@RequestParam("id") Long id) { - CrmCustomerLimitConfigDO customerLimitConfig = customerLimitConfigService.getCustomerLimitConfig(id); - // 拼接数据 - Map userMap = adminUserApi.getUserMap(customerLimitConfig.getUserIds()); - Map deptMap = deptApi.getDeptMap(customerLimitConfig.getDeptIds()); - return success(CrmCustomerLimitConfigConvert.INSTANCE.convert(customerLimitConfig, userMap, deptMap)); - } - - @GetMapping("/page") - @Operation(summary = "获得客户限制配置分页") - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:query')") - public CommonResult> getCustomerLimitConfigPage(@Valid CrmCustomerLimitConfigPageReqVO pageVO) { - PageResult pageResult = customerLimitConfigService.getCustomerLimitConfigPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - // 拼接数据 - Map userMap = adminUserApi.getUserMap( - convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getUserIds, Collection::stream)); - Map deptMap = deptApi.getDeptMap( - convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getDeptIds, Collection::stream)); - return success(CrmCustomerLimitConfigConvert.INSTANCE.convertPage(pageResult, userMap, deptMap)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerPoolConfigController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerPoolConfigController.java deleted file mode 100644 index a6da45b7d0..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerPoolConfigController.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 客户公海配置") -@RestController -@RequestMapping("/crm/customer-pool-config") -@Validated -public class CrmCustomerPoolConfigController { - - @Resource - private CrmCustomerPoolConfigService customerPoolConfigService; - - @GetMapping("/get") - @Operation(summary = "获取客户公海规则设置") - @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:query')") - public CommonResult getCustomerPoolConfig() { - CrmCustomerPoolConfigDO customerPoolConfig = customerPoolConfigService.getCustomerPoolConfig(); - return success(CrmCustomerConvert.INSTANCE.convert(customerPoolConfig)); - } - - @PutMapping("/save") - @Operation(summary = "更新客户公海规则设置") - @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:update')") - public CommonResult saveCustomerPoolConfig(@Valid @RequestBody CrmCustomerPoolConfigSaveReqVO updateReqVO) { - customerPoolConfigService.saveCustomerPoolConfig(updateReqVO); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java deleted file mode 100644 index 3d03ba8075..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.Email; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.Size; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 客户 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class CrmCustomerBaseVO { - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - @NotEmpty(message = "客户名称不能为空") - private String name; - - @Schema(description = "所属行业", example = "1") - private Integer industryId; - - @Schema(description = "客户等级", example = "2") - @InEnum(CrmCustomerLevelEnum.class) - private Integer level; - - @Schema(description = "客户来源", example = "3") - private Integer source; - - @Schema(description = "手机", example = "18000000000") - @Mobile - private String mobile; - - @Schema(description = "电话", example = "18000000000") - @Telephone - private String telephone; - - @Schema(description = "网址", example = "https://www.baidu.com") - private String website; - - @Schema(description = "QQ", example = "123456789") - @Size(max = 20, message = "QQ长度不能超过 20 个字符") - private String qq; - - @Schema(description = "wechat", example = "123456789") - @Size(max = 255, message = "微信长度不能超过 255 个字符") - private String wechat; - - @Schema(description = "email", example = "123456789@qq.com") - @Email(message = "邮箱格式不正确") - @Size(max = 255, message = "邮箱长度不能超过 255 个字符") - private String email; - - @Schema(description = "客户描述", example = "任意文字") - @Size(max = 4096, message = "客户描述长度不能超过 4096 个字符") - private String description; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "地区编号", example = "20158") - private Integer areaId; - - @Schema(description = "详细地址", example = "北京市海淀区") - private String detailAddress; - - @Schema(description = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactNextTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java deleted file mode 100644 index a81c2095d5..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 客户创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerCreateReqVO extends CrmCustomerBaseVO { - - @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @NotNull(message = "负责人不能为空") - private Long ownerUserId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java deleted file mode 100644 index d49f569b3e..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -// TODO 芋艿:导出最后做,等基本确认的差不多之后; -/** - * CRM 客户 Excel VO - * - * @author Wanwan - */ -@Data -public class CrmCustomerExcelVO { - - @ExcelProperty("编号") - private Long id; - - @ExcelProperty("客户名称") - private String name; - - @ExcelProperty(value = "跟进状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean followUpStatus; - - @ExcelProperty(value = "锁定状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean lockStatus; - - @ExcelProperty(value = "成交状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean dealStatus; - - @ExcelProperty(value = "所属行业", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY) - private Integer industryId; - - @ExcelProperty(value = "客户等级", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL) - private Integer level; - - @ExcelProperty(value = "客户来源", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE) - private Integer source; - - @ExcelProperty("手机") - private String mobile; - - @ExcelProperty("电话") - private String telephone; - - @ExcelProperty("网址") - private String website; - - @ExcelProperty("QQ") - private String qq; - - @ExcelProperty("wechat") - private String wechat; - - @ExcelProperty("email") - private String email; - - @ExcelProperty("客户描述") - private String description; - - @ExcelProperty("备注") - private String remark; - - @ExcelProperty("负责人的用户编号") - private Long ownerUserId; - - @ExcelProperty("地区编号") - private Integer areaId; - - @ExcelProperty("详细地址") - private String detailAddress; - - @ExcelProperty("最后跟进时间") - private LocalDateTime contactLastTime; - - @ExcelProperty("下次联系时间") - private LocalDateTime contactNextTime; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java deleted file mode 100644 index 59d6ae3605..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; - -import cn.iocoder.yudao.module.crm.framework.vo.CrmBasePageReqVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 客户分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerPageReqVO extends CrmBasePageReqVO { - - @Schema(description = "客户名称", example = "赵六") - private String name; - - @Schema(description = "手机", example = "18000000000") - private String mobile; - - @Schema(description = "所属行业", example = "1") - private Integer industryId; - - @Schema(description = "客户等级", example = "1") - private Integer level; - - @Schema(description = "客户来源", example = "1") - private Integer source; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerQueryAllRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerQueryAllRespVO.java deleted file mode 100644 index a66b8d8107..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerQueryAllRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -// TODO 芋艿:这块要统一下; -@Schema(description = "管理后台 - CRM 全部客户 Response VO") -@Data -public class CrmCustomerQueryAllRespVO{ - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long id; - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private String name; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java deleted file mode 100644 index 2cbd85dd37..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 客户 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerRespVO extends CrmCustomerBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long id; - - @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean followUpStatus; - - @Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean lockStatus; - - @Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean dealStatus; - - @Schema(description = "负责人的用户编号", example = "25682") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - private String ownerUserName; - @Schema(description = "负责人部门") - private String ownerUserDeptName; - - @Schema(description = "地区名称", example = "北京市") - private String areaName; - - @Schema(description = "最后跟进时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactLastTime; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime updateTime; - - @Schema(description = "创建人") - private String creator; - @Schema(description = "创建人名字") - private String creatorName; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerTransferReqVO.java deleted file mode 100644 index c425520a91..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerTransferReqVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; - -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 客户转移 Request VO") -@Data -public class CrmCustomerTransferReqVO { - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "联系人编号不能为空") - private Long id; - - /** - * 新负责人的用户编号 - */ - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java deleted file mode 100644 index 615666a73a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 客户更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerUpdateReqVO extends CrmCustomerBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigBaseVO.java deleted file mode 100644 index 07c74f7d21..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigBaseVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; -import java.util.List; - -/** - * 客户限制配置 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class CrmCustomerLimitConfigBaseVO { - - @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "规则类型不能为空") - private Integer type; - - @Schema(description = "规则适用人群") - private List userIds; - - @Schema(description = "规则适用部门") - private List deptIds; - - @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") - @NotNull(message = "数量上限不能为空") - private Integer maxCount; - - @Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)") - private Boolean dealCountEnabled; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigCreateReqVO.java deleted file mode 100644 index 7aa372901e..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 客户限制配置创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerLimitConfigCreateReqVO extends CrmCustomerLimitConfigBaseVO { - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigPageReqVO.java deleted file mode 100644 index 37ce110097..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 客户限制配置分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerLimitConfigPageReqVO extends PageParam { - - @Schema(description = "规则类型", example = "1") - private Integer type; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java deleted file mode 100644 index 010d0fc100..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; - -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 客户限制配置 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerLimitConfigRespVO extends CrmCustomerLimitConfigBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930") - private Long id; - - @Schema(description = "规则适用人群名称") - private List users; - - @Schema(description = "规则适用部门名称") - private List depts; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigUpdateReqVO.java deleted file mode 100644 index f3ce86f358..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 客户限制配置更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerLimitConfigUpdateReqVO extends CrmCustomerLimitConfigBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigBaseVO.java deleted file mode 100644 index 5df7973bef..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigBaseVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 客户公海配置 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class CrmCustomerPoolConfigBaseVO { - - @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否启用客户公海不能为空") - private Boolean enabled; - - @Schema(description = "未跟进放入公海天数", example = "2") - private Integer contactExpireDays; - - @Schema(description = "未成交放入公海天数", example = "2") - private Integer dealExpireDays; - - @Schema(description = "是否开启提前提醒", example = "true") - private Boolean notifyEnabled; - - @Schema(description = "提前提醒天数", example = "2") - private Integer notifyDays; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigRespVO.java deleted file mode 100644 index dc48d6da7a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigRespVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 客户公海规则 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerPoolConfigRespVO extends CrmCustomerPoolConfigBaseVO { - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java deleted file mode 100644 index fa72f5f746..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; - -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.ObjectUtil; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.AssertTrue; -import java.util.Objects; - -@Schema(description = "管理后台 - CRM 客户公海配置的保存 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerPoolConfigSaveReqVO extends CrmCustomerPoolConfigBaseVO { - - // TODO @wanwan:AssertTrue 必须 is 开头哈;注意需要 json 忽略下,避免被序列化; - @AssertTrue(message = "客户公海规则设置不正确") - // TODO @wanwan:这个方法,是不是拆成 2 个,一个校验 contactExpireDays、一个校验 dealExpireDays; - public boolean poolEnableValid() { - if (!BooleanUtil.isTrue(getEnabled())) { - return true; - } - return ObjectUtil.isAllNotEmpty(getContactExpireDays(), getDealExpireDays()); - } - - @AssertTrue(message = "客户公海规则设置不正确") - // TODO @wanwan:这个方法,是不是改成 isNotifyDaysValid() 更好点?本质校验的是 notifyDays 是否为空 - public boolean notifyEnableValid() { - if (!BooleanUtil.isTrue(getNotifyEnabled())) { - return true; - } - return Objects.nonNull(getNotifyDays()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.http deleted file mode 100644 index 1ef2bc1a1d..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.http +++ /dev/null @@ -1,32 +0,0 @@ -### 请求 /add -POST {{baseUrl}}/crm/permission/create -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "userId": 1, - "bizType": 2, - "bizId": 2, - "level": 1 -} - -### 请求 /update -PUT {{baseUrl}}/crm/permission/update -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "userId": 1, - "bizType": 2, - "bizId": 2, - "level": 1, - "id": 1 -} - -### 请求 /delete -DELETE {{baseUrl}}/crm/permission/delete?bizType=2&bizId=1&id=1 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java deleted file mode 100644 index 32d4a1ab76..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.permission.CrmPermissionConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - CRM 数据权限") -@RestController -@RequestMapping("/crm/permission") -@Validated -public class CrmPermissionController { - - @Resource - private CrmPermissionService permissionService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - @Resource - private PostApi postApi; - - @PostMapping("/create") - @Operation(summary = "创建数据权限") - @PreAuthorize("@ss.hasPermission('crm:permission:create')") - @CrmPermission(bizTypeValue = "#reqVO.bizType", bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER) - public CommonResult addPermission(@Valid @RequestBody CrmPermissionCreateReqVO reqVO) { - permissionService.createPermission(CrmPermissionConvert.INSTANCE.convert(reqVO)); - return success(true); - } - - @PutMapping("/update") - @Operation(summary = "编辑数据权限") - @PreAuthorize("@ss.hasPermission('crm:permission:update')") - @CrmPermission(bizTypeValue = "#updateReqVO.bizType", bizId = "#updateReqVO.bizId" - , level = CrmPermissionLevelEnum.OWNER) - public CommonResult updatePermission(@Valid @RequestBody CrmPermissionUpdateReqVO updateReqVO) { - permissionService.updatePermission(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除数据权限") - @Parameter(name = "ids", description = "数据权限编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:permission:delete')") - public CommonResult deletePermission(@RequestParam("ids") Collection ids) { - permissionService.deletePermissionBatch(ids, getLoginUserId()); - return success(true); - } - - @DeleteMapping("/delete-self") - @Operation(summary = "删除自己的数据权限") - @Parameter(name = "id", description = "数据权限编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:permission:delete')") - public CommonResult deleteSelfPermission(@RequestParam("id") Long id) { - permissionService.deleteSelfPermission(id, getLoginUserId()); - return success(true); - } - - @GetMapping("/list") - @Operation(summary = "获得数据权限列表") - @Parameters({ - @Parameter(name = "bizType", description = "CRM 类型", required = true, example = "2"), - @Parameter(name = "bizId", description = "CRM 类型数据编号", required = true, example = "1024") - }) - @PreAuthorize("@ss.hasPermission('crm:permission:query')") - public CommonResult> getPermissionList(@RequestParam("bizType") Integer bizType, - @RequestParam("bizId") Long bizId) { - List permission = permissionService.getPermissionListByBiz(bizType, bizId); - if (CollUtil.isEmpty(permission)) { - return success(Collections.emptyList()); - } - - // 拼接数据 - List userList = adminUserApi.getUserList(convertSet(permission, CrmPermissionDO::getUserId)); - Map deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId)); - Set postIds = CollectionUtils.convertSetByFlatMap(userList, AdminUserRespDTO::getPostIds, Collection::stream); - Map postMap = postApi.getPostMap(postIds); - return success(CrmPermissionConvert.INSTANCE.convert(permission, userList, deptMap, postMap)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionBaseVO.java deleted file mode 100644 index 796b3cd469..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionBaseVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 数据权限 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class CrmPermissionBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "CRM 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmBizTypeEnum.class) - @NotNull(message = "CRM 类型不能为空") - private Integer bizType; - - @Schema(description = "CRM 类型数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "CRM 类型数据编号不能为空") - private Long bizId; - - @Schema(description = "权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmPermissionLevelEnum.class) - @NotNull(message = "权限级别不能为空") - private Integer level; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionCreateReqVO.java deleted file mode 100644 index 99793389ba..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 数据权限创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmPermissionCreateReqVO extends CrmPermissionBaseVO { - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionRespVO.java deleted file mode 100644 index 10f1ce1985..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Set; - -@Schema(description = "管理后台 - CRM 数据权限 Response VO") -@Data -public class CrmPermissionRespVO extends CrmPermissionBaseVO { - - @Schema(description = "数据权限编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String nickname; - - @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "研发部") - private String deptName; - - @Schema(description = "岗位名称数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[BOOS,经理]") - private Set postNames; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-01-01 00:00:00") - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionUpdateReqVO.java deleted file mode 100644 index 26c94728a5..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionUpdateReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - CRM 数据权限更新 Request VO") -@Data -public class CrmPermissionUpdateReqVO { - - @Schema(description = "数据权限编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,2]") - @NotNull(message = "数据权限编号列表不能为空") - private List ids; - - @Schema(description = "Crm 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmBizTypeEnum.class) - @NotNull(message = "Crm 类型不能为空") - private Integer bizType; - - @Schema(description = "Crm 类型数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "Crm 类型数据编号不能为空") - private Long bizId; - - @Schema(description = "权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmPermissionLevelEnum.class) - @NotNull(message = "权限级别不能为空") - private Integer level; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductCategoryController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductCategoryController.java deleted file mode 100644 index 2c840d5952..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductCategoryController.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryRespVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.service.product.CrmProductCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 产品分类") -@RestController -@RequestMapping("/crm/product-category") -@Validated -public class CrmProductCategoryController { - - @Resource - private CrmProductCategoryService productCategoryService; - - @PostMapping("/create") - @Operation(summary = "创建产品分类") - @PreAuthorize("@ss.hasPermission('crm:product-category:create')") - public CommonResult createProductCategory(@Valid @RequestBody CrmProductCategoryCreateReqVO createReqVO) { - return success(productCategoryService.createProductCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新产品分类") - @PreAuthorize("@ss.hasPermission('crm:product-category:update')") - public CommonResult updateProductCategory(@Valid @RequestBody CrmProductCategoryCreateReqVO updateReqVO) { - productCategoryService.updateProductCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除产品分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:product-category:delete')") - public CommonResult deleteProductCategory(@RequestParam("id") Long id) { - productCategoryService.deleteProductCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得产品分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:product-category:query')") - public CommonResult getProductCategory(@RequestParam("id") Long id) { - CrmProductCategoryDO category = productCategoryService.getProductCategory(id); - return success(BeanUtils.toBean(category, CrmProductCategoryRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得产品分类列表") - @PreAuthorize("@ss.hasPermission('crm:product-category:query')") - public CommonResult> getProductCategoryList(@Valid CrmProductCategoryListReqVO listReqVO) { - List list = productCategoryService.getProductCategoryList(listReqVO); - return success(BeanUtils.toBean(list, CrmProductCategoryRespVO.class)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java deleted file mode 100644 index 2ce156ebd9..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO; -import cn.iocoder.yudao.module.crm.convert.product.CrmProductConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import cn.iocoder.yudao.module.crm.service.product.CrmProductCategoryService; -import cn.iocoder.yudao.module.crm.service.product.CrmProductService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; - -@Tag(name = "管理后台 - CRM 产品") -@RestController -@RequestMapping("/crm/product") -@Validated -public class CrmProductController { - - @Resource - private CrmProductService productService; - @Resource - private CrmProductCategoryService productCategoryService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建产品") - @PreAuthorize("@ss.hasPermission('crm:product:create')") - public CommonResult createProduct(@Valid @RequestBody CrmProductSaveReqVO createReqVO) { - return success(productService.createProduct(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新产品") - @PreAuthorize("@ss.hasPermission('crm:product:update')") - public CommonResult updateProduct(@Valid @RequestBody CrmProductSaveReqVO updateReqVO) { - productService.updateProduct(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除产品") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:product:delete')") - public CommonResult deleteProduct(@RequestParam("id") Long id) { - productService.deleteProduct(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得产品") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:product:query')") - public CommonResult getProduct(@RequestParam("id") Long id) { - CrmProductDO product = productService.getProduct(id); - if (product == null) { - return success(null); - } - Map userMap = adminUserApi.getUserMap( - SetUtils.asSet( Long.valueOf(product.getCreator()), product.getOwnerUserId())); - CrmProductCategoryDO category = productCategoryService.getProductCategory(product.getCategoryId()); - return success(CrmProductConvert.INSTANCE.convert(product, userMap, category)); - } - - @GetMapping("/page") - @Operation(summary = "获得产品分页") - @PreAuthorize("@ss.hasPermission('crm:product:query')") - public CommonResult> getProductPage(@Valid CrmProductPageReqVO pageVO) { - PageResult pageResult = productService.getProductPage(pageVO); - return success(new PageResult<>(getProductDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品 Excel") - @PreAuthorize("@ss.hasPermission('crm:product:export')") - @OperateLog(type = EXPORT) - public void exportProductExcel(@Valid CrmProductPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = productService.getProductPage(exportReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "产品.xls", "数据", CrmProductRespVO.class, - getProductDetailList(list)); - } - - private List getProductDetailList(List list) { - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - Map userMap = adminUserApi.getUserMap( - convertSetByFlatMap(list, user -> Stream.of(Long.valueOf(user.getCreator()), user.getOwnerUserId()))); - List productCategoryList = productCategoryService.getProductCategoryList( - convertSet(list, CrmProductDO::getCategoryId)); - return CrmProductConvert.INSTANCE.convertList(list, userMap, productCategoryList); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java deleted file mode 100644 index 6772612f43..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 产品分类创建/更新 Request VO") -@Data -public class CrmProductCategoryCreateReqVO{ - - @Schema(description = "分类编号", example = "23902") - private Long id; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - @NotNull(message = "分类名称不能为空") - private String name; - - @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4680") - @NotNull(message = "父级编号不能为空") - private Long parentId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryListReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryListReqVO.java deleted file mode 100644 index 6144c95c4d..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryListReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category; - -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 产品分类列表 Request VO") -@Data -public class CrmProductCategoryListReqVO { - - @ExcelProperty("名称") - private String name; - - @ExcelProperty("父级 id") - private Long parentId; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryRespVO.java deleted file mode 100644 index 4cea8e464f..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 产品分类 Response VO") -@Data -public class CrmProductCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23902") - private Long id; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private String name; - - @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4680") - private Long parentId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductPageReqVO.java deleted file mode 100644 index 39b1090f87..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 产品分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmProductPageReqVO extends PageParam { - - @Schema(description = "产品名称", example = "李四") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductRespVO.java deleted file mode 100644 index ceca3e5a03..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductRespVO.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 产品 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmProductRespVO { - - @Schema(description = "产品编号", example = "20529") - @ExcelProperty("产品编号") - private Long id; - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "好产品") - @ExcelProperty("产品名称") - private String name; - - @Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "12306") - @ExcelProperty("产品编码") - private String no; - - @Schema(description = "单位", example = "2") - @ExcelProperty(value = "单位", converter = DictConvert.class) - @DictFormat(DictTypeConstants.CRM_PRODUCT_UNIT) - private Integer unit; - - @Schema(description = "价格, 单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - @ExcelProperty("价格,单位:分") - private Long price; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "上架") - @ExcelProperty(value = "单位", converter = DictConvert.class) - @DictFormat(DictTypeConstants.CRM_PRODUCT_STATUS) - private Integer status; - - @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Long categoryId; - @Schema(description = "产品分类名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "衣服") - @ExcelProperty("产品分类") - private String categoryName; - - @Schema(description = "产品描述", example = "你说的对") - @ExcelProperty("产品描述") - private String description; - - @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926") - private Long ownerUserId; - @Schema(description = "负责人的用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @ExcelProperty("负责人") - private String ownerUserName; - - @Schema(description = "创建人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String creator; - @Schema(description = "创建人名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @ExcelProperty("创建人") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java deleted file mode 100644 index c6c3919e99..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 产品创建/修改 Request VO") -@Data -public class CrmProductSaveReqVO { - - @Schema(description = "产品编号", example = "20529") - private Long id; - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "好产品") - @NotNull(message = "产品名称不能为空") - private String name; - - @Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "12306") - @NotNull(message = "产品编码不能为空") - private String no; - - @Schema(description = "单位", example = "2") - private Integer unit; - - @Schema(description = "价格, 单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - @NotNull(message = "价格不能为空") - private Long price; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "上架") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "产品分类编号不能为空") - private Long categoryId; - - @Schema(description = "产品描述", example = "你说的对") - private String description; - - @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926") - @NotNull(message = "负责人的用户编号不能为空") - private Long ownerUserId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java deleted file mode 100644 index 45ea6f0200..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivableConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; - -@Tag(name = "管理后台 - CRM 回款") -@RestController -@RequestMapping("/crm/receivable") -@Validated -public class CrmReceivableController { - - @Resource - private CrmReceivableService receivableService; - @Resource - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建回款") - @PreAuthorize("@ss.hasPermission('crm:receivable:create')") - public CommonResult createReceivable(@Valid @RequestBody CrmReceivableCreateReqVO createReqVO) { - return success(receivableService.createReceivable(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新回款") - @PreAuthorize("@ss.hasPermission('crm:receivable:update')") - public CommonResult updateReceivable(@Valid @RequestBody CrmReceivableUpdateReqVO updateReqVO) { - receivableService.updateReceivable(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除回款") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:receivable:delete')") - public CommonResult deleteReceivable(@RequestParam("id") Long id) { - receivableService.deleteReceivable(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得回款") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:receivable:query')") - public CommonResult getReceivable(@RequestParam("id") Long id) { - CrmReceivableDO receivable = receivableService.getReceivable(id); - return success(CrmReceivableConvert.INSTANCE.convert(receivable)); - } - - @GetMapping("/page") - @Operation(summary = "获得回款分页") - @PreAuthorize("@ss.hasPermission('crm:receivable:query')") - public CommonResult> getReceivablePage(@Valid CrmReceivablePageReqVO pageReqVO) { - PageResult pageResult = receivableService.getReceivablePage(pageReqVO); - return success(convertDetailReceivablePage(pageResult)); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得回款分页,基于指定客户") - public CommonResult> getReceivablePageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) { - Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = receivableService.getReceivablePageByCustomer(pageReqVO); - return success(convertDetailReceivablePage(pageResult)); - } - - // TODO 芋艿:后面在优化导出 - @GetMapping("/export-excel") - @Operation(summary = "导出回款 Excel") - @PreAuthorize("@ss.hasPermission('crm:receivable:export')") - @OperateLog(type = EXPORT) - public void exportReceivableExcel(@Valid CrmReceivablePageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - PageResult pageResult = receivableService.getReceivablePage(exportReqVO); - // 导出 Excel - ExcelUtils.write(response, "回款.xls", "数据", CrmReceivableRespVO.class, - convertDetailReceivablePage(pageResult).getList()); - } - - /** - * 转换成详细的回款分页,即读取关联信息 - * - * @param pageResult 回款分页 - * @return 详细的回款分页 - */ - private PageResult convertDetailReceivablePage(PageResult pageResult) { - List receivableList = pageResult.getList(); - if (CollUtil.isEmpty(receivableList)) { - return PageResult.empty(pageResult.getTotal()); - } - // 1. 获取客户列表 - List customerList = customerService.getCustomerList( - convertSet(receivableList, CrmReceivableDO::getCustomerId)); - // 2. 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(receivableList, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - // 3. 获得合同列表 - List contractList = contractService.getContractList( - convertSet(receivableList, CrmReceivableDO::getContractId)); - return CrmReceivableConvert.INSTANCE.convertPage(pageResult, userMap, customerList, contractList); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java deleted file mode 100644 index fe569a0876..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java +++ /dev/null @@ -1,151 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivablePlanConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivablePlanService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; - -@Tag(name = "管理后台 - CRM 回款计划") -@RestController -@RequestMapping("/crm/receivable-plan") -@Validated -public class CrmReceivablePlanController { - - @Resource - private CrmReceivablePlanService receivablePlanService; - @Resource - private CrmReceivableService receivableService; - @Resource - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建回款计划") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:create')") - public CommonResult createReceivablePlan(@Valid @RequestBody CrmReceivablePlanCreateReqVO createReqVO) { - return success(receivablePlanService.createReceivablePlan(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新回款计划") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:update')") - public CommonResult updateReceivablePlan(@Valid @RequestBody CrmReceivablePlanUpdateReqVO updateReqVO) { - receivablePlanService.updateReceivablePlan(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除回款计划") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:delete')") - public CommonResult deleteReceivablePlan(@RequestParam("id") Long id) { - receivablePlanService.deleteReceivablePlan(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得回款计划") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult getReceivablePlan(@RequestParam("id") Long id) { - CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(id); - return success(CrmReceivablePlanConvert.INSTANCE.convert(receivablePlan)); - } - - @GetMapping("/page") - @Operation(summary = "获得回款计划分页") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult> getReceivablePlanPage(@Valid CrmReceivablePlanPageReqVO pageReqVO) { - PageResult pageResult = receivablePlanService.getReceivablePlanPage(pageReqVO); - return success(convertDetailReceivablePlanPage(pageResult)); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得回款计划分页,基于指定客户") - public CommonResult> getReceivablePlanPageByCustomer(@Valid CrmReceivablePlanPageReqVO pageReqVO) { - Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = receivablePlanService.getReceivablePlanPageByCustomer(pageReqVO); - return success(convertDetailReceivablePlanPage(pageResult)); - } - - // TODO 芋艿:后面在优化导出 - @GetMapping("/export-excel") - @Operation(summary = "导出回款计划 Excel") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:export')") - @OperateLog(type = EXPORT) - public void exportReceivablePlanExcel(@Valid CrmReceivablePlanPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - PageResult pageResult = receivablePlanService.getReceivablePlanPage(exportReqVO); - // 导出 Excel - ExcelUtils.write(response, "回款计划.xls", "数据", CrmReceivablePlanRespVO.class, - convertDetailReceivablePlanPage(pageResult).getList()); - } - - /** - * 转换成详细的回款计划分页,即读取关联信息 - * - * @param pageResult 回款计划分页 - * @return 详细的回款计划分页 - */ - private PageResult convertDetailReceivablePlanPage(PageResult pageResult) { - List receivablePlanList = pageResult.getList(); - if (CollUtil.isEmpty(receivablePlanList)) { - return PageResult.empty(pageResult.getTotal()); - } - // 1. 获取客户列表 - List customerList = customerService.getCustomerList( - convertSet(receivablePlanList, CrmReceivablePlanDO::getCustomerId)); - // 2. 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(receivablePlanList, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - // 3. 获得合同列表 - List contractList = contractService.getContractList( - convertSet(receivablePlanList, CrmReceivablePlanDO::getContractId)); - // 4. 获得还款列表 - List receivableList = receivableService.getReceivableList( - convertSet(receivablePlanList, CrmReceivablePlanDO::getReceivableId)); - return CrmReceivablePlanConvert.INSTANCE.convertPage(pageResult, userMap, customerList, contractList, receivableList); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanBaseVO.java deleted file mode 100644 index 70272b8e8e..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanBaseVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 回款计划 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class CrmReceivablePlanBaseVO { - - @Schema(description = "期数", example = "1") - private Integer period; - - @Schema(description = "回款计划编号", example = "19852") - private Long receivableId; - - @Schema(description = "计划回款金额", example = "29675") - private Integer price; - - @Schema(description = "计划回款日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime returnTime; - - @Schema(description = "提前几天提醒") - private Integer remindDays; - - @Schema(description = "提醒日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime remindTime; - - @Schema(description = "客户名称", example = "18026") - private Long customerId; - - @Schema(description = "合同编号", example = "3473") - private Long contractId; - - // TODO @liuhongfeng:负责人编号 - @Schema(description = "负责人编号", example = "17828") - private Long ownerUserId; - - @Schema(description = "显示顺序") - private Integer sort; - - @Schema(description = "备注", example = "备注") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanCreateReqVO.java deleted file mode 100644 index 193a44bf4c..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "管理后台 - CRM 回款计划创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivablePlanCreateReqVO extends CrmReceivablePlanBaseVO { - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java deleted file mode 100644 index b9249c2f2b..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 回款计划分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivablePlanPageReqVO extends PageParam { - - @Schema(description = "客户编号", example = "18026") - private Long customerId; - - // TODO @芋艿:这个搜的应该是合同编号 no - @Schema(description = "合同名称", example = "3473") - private Long contractId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java deleted file mode 100644 index d5e9de187a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 回款计划 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivablePlanRespVO extends CrmReceivablePlanBaseVO { - - @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") - private String customerName; - - @Schema(description = "合同编号", example = "Q110") - private String contractNo; - - @Schema(description = "负责人", example = "test") - private String ownerUserName; - - @Schema(description = "创建人", example = "25682") - private String creator; - - @Schema(description = "创建人名字", example = "test") - private String creatorName; - - @Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Boolean finishStatus; - - @Schema(description = "回款方式", example = "1") // 来自 Receivable 的 returnType 字段 - private Integer returnType; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanUpdateReqVO.java deleted file mode 100644 index 2e83a1cbb2..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanUpdateReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import jakarta.validation.constraints.*; - -@Schema(description = "管理后台 - CRM 回款计划更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivablePlanUpdateReqVO extends CrmReceivablePlanBaseVO { - - @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153") - @NotNull(message = "ID不能为空") - private Long id; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableBaseVO.java deleted file mode 100644 index c32bc9ad52..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableBaseVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 回款 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class CrmReceivableBaseVO { - - @Schema(description = "回款编号",requiredMode = Schema.RequiredMode.REQUIRED, example = "31177") - private String no; - - // TODO @liuhongfeng:回款计划编号 - @Schema(description = "回款计划", example = "31177") - private Long planId; - - // TODO @liuhongfeng:客户编号 - @Schema(description = "客户名称", example = "4963") - private Long customerId; - - // TODO @liuhongfeng:客户编号 - @Schema(description = "合同名称", example = "30305") - private Long contractId; - - // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的 - @Schema(description = "审批状态", example = "1") - @InEnum(CrmAuditStatusEnum.class) - private Integer checkStatus; - - @Schema(description = "回款日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime returnTime; - - @Schema(description = "回款方式", example = "2") - private Integer returnType; - - @Schema(description = "回款金额,单位:分", example = "31859") - private Integer price; - - // TODO @liuhongfeng:负责人编号 - @Schema(description = "负责人", example = "22202") - private Long ownerUserId; - - @Schema(description = "显示顺序") - private Integer sort; - - @Schema(description = "备注", example = "备注") - private String remark; - - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableCreateReqVO.java deleted file mode 100644 index 4471b780a8..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "管理后台 - CRM 回款创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivableCreateReqVO extends CrmReceivableBaseVO { - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java deleted file mode 100644 index 9d0d4eb212..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 回款分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivablePageReqVO extends PageParam { - - @Schema(description = "回款编号") - private String no; - - @Schema(description = "回款计划编号", example = "31177") - private Long planId; - - @Schema(description = "客户编号", example = "4963") - private Long customerId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java deleted file mode 100644 index 7c536bd512..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -// TODO 芋艿:导出的 VO,可以考虑使用 @Excel 注解,实现导出功能 -@Schema(description = "管理后台 - CRM 回款 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivableRespVO extends CrmReceivableBaseVO { - - @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") - private String customerName; - - @Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer auditStatus; - - @Schema(description = "合同编号", example = "Q110") - private String contractNo; - - @Schema(description = "负责人", example = "test") - private String ownerUserName; - - @Schema(description = "创建人", example = "25682") - private String creator; - - @Schema(description = "创建人名字", example = "test") - private String creatorName; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableUpdateReqVO.java deleted file mode 100644 index 0f63978c81..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableUpdateReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import jakarta.validation.constraints.*; - -@Schema(description = "管理后台 - CRM 回款更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivableUpdateReqVO extends CrmReceivableBaseVO { - - @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") - @NotNull(message = "ID不能为空") - private Long id; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java deleted file mode 100644 index 78d85635c2..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.crm.controller.app; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java deleted file mode 100644 index 8354b3176f..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.crm.controller; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java deleted file mode 100644 index affb57b558..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商机 Convert - * - * @author ljlleo - */ -@Mapper -public interface CrmBusinessConvert { - - CrmBusinessConvert INSTANCE = Mappers.getMapper(CrmBusinessConvert.class); - - CrmBusinessDO convert(CrmBusinessCreateReqVO bean); - - CrmBusinessDO convert(CrmBusinessUpdateReqVO bean); - - CrmBusinessRespVO convert(CrmBusinessDO bean); - List convert(List bean); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - - @Mappings({ - @Mapping(target = "bizId", source = "reqVO.id"), - @Mapping(target = "newOwnerUserId", source = "reqVO.id") - }) - CrmPermissionTransferReqBO convert(CrmBusinessTransferReqVO reqVO, Long userId); - - default PageResult convertPage(PageResult page, List customerList, - List statusTypeList, List statusList) { - PageResult result = convertPage(page); - // 拼接关联字段 - Map customerMap = convertMap(customerList, CrmCustomerDO::getId, CrmCustomerDO::getName); - Map statusTypeMap = convertMap(statusTypeList, CrmBusinessStatusTypeDO::getId, CrmBusinessStatusTypeDO::getName); - Map statusMap = convertMap(statusList, CrmBusinessStatusDO::getId, CrmBusinessStatusDO::getName); - result.getList().forEach(type -> type - .setCustomerName(customerMap.get(type.getCustomerId())) - .setStatusTypeName(statusTypeMap.get(type.getStatusTypeId())) - .setStatusName(statusMap.get(type.getStatusId()))); - return result; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java deleted file mode 100644 index db49e5a6d2..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.businessstatus; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 商机状态 Convert - * - * @author ljlleo - */ -@Mapper -public interface CrmBusinessStatusConvert { - - CrmBusinessStatusConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusConvert.class); - - CrmBusinessStatusDO convert(CrmBusinessStatusSaveReqVO bean); - - CrmBusinessStatusRespVO convert(CrmBusinessStatusDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java deleted file mode 100644 index ae7e361223..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.businessstatustype; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商机状态类型 Convert - * - * @author ljlleo - */ -@Mapper -public interface CrmBusinessStatusTypeConvert { - - CrmBusinessStatusTypeConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusTypeConvert.class); - - CrmBusinessStatusTypeDO convert(CrmBusinessStatusTypeSaveReqVO bean); - - CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, List deptList) { - PageResult pageResult = convertPage(page); - // 拼接关联字段 - Map deptMap = convertMap(deptList, DeptRespDTO::getId, DeptRespDTO::getName); - pageResult.getList().forEach(type -> type.setDeptNames(convertList(type.getDeptIds(), deptMap::get))); - return pageResult; - } - - default CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean, List statusList) { - // TODO @ljlleo 可以链式赋值,简化成一行; - CrmBusinessStatusTypeRespVO result = convert(bean); - result.setStatusList(statusList); - return result; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java deleted file mode 100644 index 76ea428c78..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.clue; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; - -/** - * 线索 Convert - * - * @author Wanwan - */ -@Mapper -public interface CrmClueConvert { - - CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class); - - CrmClueDO convert(CrmClueCreateReqVO bean); - - CrmClueDO convert(CrmClueUpdateReqVO bean); - - CrmClueRespVO convert(CrmClueDO bean); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java deleted file mode 100644 index 636835be75..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.contact; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -// TODO 芋艿:convert 后面在梳理下,略微有点乱 -/** - * CRM 联系人 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ContactConvert { - - ContactConvert INSTANCE = Mappers.getMapper(ContactConvert.class); - - CrmContactDO convert(CrmContactCreateReqVO bean); - - CrmContactDO convert(CrmContactUpdateReqVO bean); - - CrmContactRespVO convert(CrmContactDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult pageResult, Map userMap, - List customerList, List parentContactList) { - List list = converList(pageResult.getList(), userMap, customerList, parentContactList); - return convertPage(pageResult).setList(list); - } - - List convertAllList(List list); - - @Mappings({ - @Mapping(target = "bizId", source = "reqVO.id"), - @Mapping(target = "newOwnerUserId", source = "reqVO.id") - }) - CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId); - - /** - * 转换详情信息 - * - * @param contactDO 联系人 - * @param userMap 用户列表 - * @param crmCustomerDOList 客户 - * @return ContactRespVO - */ - default CrmContactRespVO convert(CrmContactDO contactDO, Map userMap, List crmCustomerDOList, - List contactList) { - CrmContactRespVO contactVO = convert(contactDO); - setUserInfo(contactVO, userMap); - Map ustomerMap = crmCustomerDOList.stream().collect(Collectors.toMap(CrmCustomerDO::getId, v -> v)); - Map contactMap = contactList.stream().collect(Collectors.toMap(CrmContactDO::getId, v -> v)); - findAndThen(ustomerMap, contactDO.getCustomerId(), customer -> contactVO.setCustomerName(customer.getName())); - findAndThen(contactMap, contactDO.getParentId(), contact -> contactVO.setParentName(contact.getName())); - return contactVO; - } - - default List converList(List contactList, Map userMap, - List customerList, List parentContactList) { - List result = convertList(contactList); - Map parentContactMap = convertMap(parentContactList, CrmContactDO::getId); - Map customerMap = convertMap(customerList, CrmCustomerDO::getId); - result.forEach(item -> { - setUserInfo(item, userMap); - findAndThen(customerMap, item.getCustomerId(), customer -> { // TODO @zyna:这里的 { 可以去掉 - item.setCustomerName(customer.getName()); - }); - findAndThen(parentContactMap, item.getParentId(), contactDO -> { // TODO @zyna:这里的 { 可以去掉 - item.setParentName(contactDO.getName()); - }); - }); - return result; - } - - /** - * 设置用户信息 - * - * @param contactRespVO 联系人Response VO - * @param userMap 用户信息 map - */ - static void setUserInfo(CrmContactRespVO contactRespVO, Map userMap) { - contactRespVO.setAreaName(AreaUtils.format(contactRespVO.getAreaId())); - findAndThen(userMap, contactRespVO.getOwnerUserId(), user -> { - contactRespVO.setOwnerUserName(user == null ? "" : user.getNickname()); - }); - findAndThen(userMap, Long.parseLong(contactRespVO.getCreator()), user -> contactRespVO.setCreatorName(user.getNickname())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contactbusinessslink/CrmContactBusinessLinkConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contactbusinessslink/CrmContactBusinessLinkConvert.java deleted file mode 100644 index dfb71bad56..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contactbusinessslink/CrmContactBusinessLinkConvert.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.contactbusinessslink; - -import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -// TODO @zyna:使用 BeanUtils 慢慢替代现有的 mapstruct 哈 -@Mapper -public interface CrmContactBusinessLinkConvert { - CrmContactBusinessLinkConvert INSTANCE = Mappers.getMapper(CrmContactBusinessLinkConvert.class); - CrmContactBusinessLinkDO convert(CrmContactBusinessLinkSaveReqVO bean); - List convert(List bean); -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java deleted file mode 100644 index 2041ba5deb..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.contract; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 合同 Convert - * - * @author dhb52 - */ -@Mapper -public interface ContractConvert { - - ContractConvert INSTANCE = Mappers.getMapper(ContractConvert.class); - - CrmContractDO convert(CrmContractCreateReqVO bean); - - CrmContractDO convert(CrmContractUpdateReqVO bean); - - ContractRespVO convert(CrmContractDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - - @Mappings({ - @Mapping(target = "bizId", source = "reqVO.id"), - @Mapping(target = "newOwnerUserId", source = "reqVO.id") - }) - CrmPermissionTransferReqBO convert(CrmContractTransferReqVO reqVO, Long userId); - - default PageResult convertPage(PageResult pageResult, Map userMap, - List customerList) { - return new PageResult<>(converList(pageResult.getList(), userMap, customerList), pageResult.getTotal()); - } - - default List converList(List contractList, Map userMap, - List customerList) { - List result = convertList(contractList); - Map customerMap = convertMap(customerList, CrmCustomerDO::getId); - result.forEach(item -> { - setUserInfo(item, userMap); - findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName())); - }); - return result; - } - - static void setUserInfo(ContractRespVO contract, Map userMap) { - findAndThen(userMap, contract.getOwnerUserId(), user -> contract.setOwnerUserName(user.getNickname())); - findAndThen(userMap, Long.parseLong(contract.getCreator()), user -> contract.setCreatorName(user.getNickname())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java deleted file mode 100644 index fcf643f660..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 客户 Convert - * - * @author Wanwan - */ -@Mapper -public interface CrmCustomerConvert { - - CrmCustomerConvert INSTANCE = Mappers.getMapper(CrmCustomerConvert.class); - - CrmCustomerDO convert(CrmCustomerCreateReqVO bean); - - CrmCustomerDO convert(CrmCustomerUpdateReqVO bean); - - CrmCustomerRespVO convert(CrmCustomerDO bean); - - /** - * 设置用户信息 - * - * @param customer CRM 客户 Response VO - * @param userMap 用户信息 map - * @param deptMap 用户部门信息 map - */ - static void setUserInfo(CrmCustomerRespVO customer, Map userMap, Map deptMap) { - customer.setAreaName(AreaUtils.format(customer.getAreaId())); - findAndThen(userMap, customer.getOwnerUserId(), user -> { - customer.setOwnerUserName(user.getNickname()); - findAndThen(deptMap, user.getDeptId(), dept -> customer.setOwnerUserDeptName(dept.getName())); - }); - findAndThen(userMap, Long.parseLong(customer.getCreator()), user -> customer.setCreatorName(user.getNickname())); - } - - List convertList02(List list); - - @Mappings({ - @Mapping(target = "bizId", source = "reqVO.id"), - @Mapping(target = "newOwnerUserId", source = "reqVO.id") - }) - CrmPermissionTransferReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId); - - PageResult convertPage(PageResult page); - - default CrmCustomerRespVO convert(CrmCustomerDO customer, Map userMap, - Map deptMap) { - CrmCustomerRespVO customerResp = convert(customer); - setUserInfo(customerResp, userMap, deptMap); - return customerResp; - } - - default PageResult convertPage(PageResult pageResult, Map userMap, - Map deptMap) { - PageResult result = convertPage(pageResult); - result.getList().forEach(item -> setUserInfo(item, userMap, deptMap)); - return result; - } - - CrmCustomerPoolConfigRespVO convert(CrmCustomerPoolConfigDO customerPoolConfig); - - CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO); - - List convertQueryAll(List crmCustomerDO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerLimitConfigConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerLimitConfigConvert.java deleted file mode 100644 index 13a59a1ec5..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerLimitConfigConvert.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 客户限制配置 Convert - * - * @author Wanwan - */ -@Mapper -public interface CrmCustomerLimitConfigConvert { - - CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class); - - CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigCreateReqVO bean); - - CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigUpdateReqVO bean); - - CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult pageResult, - Map userMap, Map deptMap) { - PageResult result = convertPage(pageResult); - result.getList().forEach(respVo -> fillNameField(userMap, deptMap, respVo)); - return result; - } - - default CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO customerLimitConfig, - Map userMap, Map deptMap) { - CrmCustomerLimitConfigRespVO respVo = convert(customerLimitConfig); - fillNameField(userMap, deptMap, respVo); - return respVo; - } - - /** - * 填充名称字段 - * - * @param userMap 用户映射 - * @param deptMap 部门映射 - * @param respVo 响应实体 - */ - static void fillNameField(Map userMap, Map deptMap, CrmCustomerLimitConfigRespVO respVo) { - respVo.setUsers(CollectionUtils.convertList(respVo.getUserIds(), userMap::get)); - respVo.setDepts(CollectionUtils.convertList(respVo.getDeptIds(), deptMap::get)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java deleted file mode 100644 index 6fbc525080..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.crm.convert; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java deleted file mode 100644 index 0f3c77e5f3..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.permission; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionUpdateReqBO; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.google.common.collect.Multimaps; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * Crm 数据权限 Convert - * - * @author HUIHUI - */ -@Mapper -public interface CrmPermissionConvert { - - CrmPermissionConvert INSTANCE = Mappers.getMapper(CrmPermissionConvert.class); - - CrmPermissionDO convert(CrmPermissionCreateReqBO createBO); - - CrmPermissionDO convert(CrmPermissionUpdateReqBO updateBO); - - CrmPermissionCreateReqBO convert(CrmPermissionCreateReqVO reqVO); - - CrmPermissionUpdateReqBO convert(CrmPermissionUpdateReqVO updateReqVO); - - List convert(List permission); - - default List convert(List permission, List userList, - Map deptMap, Map postMap) { - Map userMap = CollectionUtils.convertMap(userList, AdminUserRespDTO::getId); - return CollectionUtils.convertList(convert(permission), item -> { - findAndThen(userMap, item.getUserId(), user -> { - item.setNickname(user.getNickname()); - findAndThen(deptMap, user.getDeptId(), deptRespDTO -> { - item.setDeptName(deptRespDTO.getName()); - }); - List postRespList = MapUtils.getList(Multimaps.forMap(postMap), user.getPostIds()); - item.setPostNames(CollectionUtils.convertSet(postRespList, PostRespDTO::getName)); - }); - return item; - }); - } - - default List convertList(CrmPermissionUpdateReqVO updateReqVO) { - return CollectionUtils.convertList(updateReqVO.getIds(), - id -> new CrmPermissionDO().setId(id).setLevel(updateReqVO.getLevel())); - } - - List convertList(List list); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/product/CrmProductConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/product/CrmProductConvert.java deleted file mode 100644 index 2165a208fe..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/product/CrmProductConvert.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.product; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductRespVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 产品 Convert - * - * @author ZanGe丶 - */ -@Mapper -public interface CrmProductConvert { - - CrmProductConvert INSTANCE = Mappers.getMapper(CrmProductConvert.class); - - default List convertList(List list, - Map userMap, - List categoryList) { - Map categoryMap = convertMap(categoryList, CrmProductCategoryDO::getId); - return CollectionUtils.convertList(list, - product -> convert(product, userMap, categoryMap.get(product.getCategoryId()))); - } - - default CrmProductRespVO convert(CrmProductDO product, - Map userMap, CrmProductCategoryDO category) { - CrmProductRespVO productVO = BeanUtils.toBean(product, CrmProductRespVO.class); - Optional.ofNullable(category).ifPresent(c -> productVO.setCategoryName(c.getName())); - MapUtils.findAndThen(userMap, productVO.getOwnerUserId(), user -> productVO.setOwnerUserName(user.getNickname())); - MapUtils.findAndThen(userMap, Long.valueOf(productVO.getCreator()), user -> productVO.setCreatorName(user.getNickname())); - return productVO; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivableConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivableConvert.java deleted file mode 100644 index 27502103d2..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivableConvert.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 回款 Convert - * - * @author 赤焰 - */ -@Mapper -public interface CrmReceivableConvert { - - CrmReceivableConvert INSTANCE = Mappers.getMapper(CrmReceivableConvert.class); - - CrmReceivableDO convert(CrmReceivableCreateReqVO bean); - - CrmReceivableDO convert(CrmReceivableUpdateReqVO bean); - - CrmReceivableRespVO convert(CrmReceivableDO bean); - - List convertList(List list); - - default PageResult convertPage(PageResult pageResult, Map userMap, - List customerList, List contractList) { - return new PageResult<>(converList(pageResult.getList(), userMap, customerList, contractList), pageResult.getTotal()); - } - - default List converList(List receivableList, Map userMap, - List customerList, List contractList) { - List result = convertList(receivableList); - Map customerMap = convertMap(customerList, CrmCustomerDO::getId); - Map contractMap = convertMap(contractList, CrmContractDO::getId); - result.forEach(item -> { - setUserInfo(item, userMap); - findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName())); - findAndThen(contractMap, item.getContractId(), contract -> item.setContractNo(contract.getNo())); - }); - return result; - } - - static void setUserInfo(CrmReceivableRespVO receivable, Map userMap) { - findAndThen(userMap, receivable.getOwnerUserId(), user -> receivable.setOwnerUserName(user.getNickname())); - findAndThen(userMap, Long.parseLong(receivable.getCreator()), user -> receivable.setCreatorName(user.getNickname())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivablePlanConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivablePlanConvert.java deleted file mode 100644 index a89140d07c..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivablePlanConvert.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 回款计划 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface CrmReceivablePlanConvert { - - CrmReceivablePlanConvert INSTANCE = Mappers.getMapper(CrmReceivablePlanConvert.class); - - CrmReceivablePlanDO convert(CrmReceivablePlanCreateReqVO bean); - - CrmReceivablePlanDO convert(CrmReceivablePlanUpdateReqVO bean); - - CrmReceivablePlanRespVO convert(CrmReceivablePlanDO bean); - - List convertList(List list); - - default PageResult convertPage(PageResult pageResult, Map userMap, - List customerList, List contractList, - List receivableList) { - return new PageResult<>(converList(pageResult.getList(), userMap, customerList, contractList, receivableList), pageResult.getTotal()); - } - - default List converList(List receivablePlanList, Map userMap, - List customerList, List contractList, - List receivableList) { - List result = convertList(receivablePlanList); - Map customerMap = convertMap(customerList, CrmCustomerDO::getId); - Map contractMap = convertMap(contractList, CrmContractDO::getId); - Map receivableMap = convertMap(receivableList, CrmReceivableDO::getId); - result.forEach(item -> { - setUserInfo(item, userMap); - findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName())); - findAndThen(contractMap, item.getContractId(), contract -> item.setContractNo(contract.getNo())); - findAndThen(receivableMap, item.getReceivableId(), receivable -> item.setReturnType(receivable.getReturnType())); - }); - return result; - } - - static void setUserInfo(CrmReceivablePlanRespVO receivablePlan, Map userMap) { - findAndThen(userMap, receivablePlan.getOwnerUserId(), user -> receivablePlan.setOwnerUserName(user.getNickname())); - findAndThen(userMap, Long.parseLong(receivablePlan.getCreator()), user -> receivablePlan.setCreatorName(user.getNickname())); - } - -} diff --git "a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" "b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" deleted file mode 100644 index 8153487b72..0000000000 --- "a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java deleted file mode 100644 index 2bc1daa41b..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.business; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 商机 DO - * - * @author ljlleo - */ -@TableName("crm_business") -@KeySequence("crm_business_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 商机名称 - */ - private String name; - /** - * 商机状态类型编号 - * - * 关联 {@link CrmBusinessStatusTypeDO#getId()} - */ - private Long statusTypeId; - /** - * 商机状态编号 - * - * 关联 {@link CrmBusinessStatusDO#getId()} - */ - private Long statusId; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - /** - * 客户编号 - * - * TODO @ljileo:这个字段,后续要写下关联的实体哈 - */ - private Long customerId; - /** - * 预计成交日期 - */ - private LocalDateTime dealTime; - /** - * 商机金额 - * - */ - private Integer price; - /** - * 整单折扣 - * - */ - private Integer discountPercent; - /** - * 产品总金额,单位:分 - */ - private Integer productPrice; - /** - * 备注 - */ - private String remark; - /** - * 1赢单2输单3无效 - * - * TODO @lijie:搞个枚举; - */ - private Integer endStatus; - /** - * 结束时的备注 - */ - private String endRemark; - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 跟进状态 - * - * TODO @lijie:目前就是 Boolean;是否跟进 - */ - private Integer followUpStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java deleted file mode 100644 index f83d0fb278..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.business; - -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商机状态 DO - * - * @author ljlleo - */ -@TableName("crm_business_status") -@KeySequence("crm_business_status_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessStatusDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 状态类型编号 - * - * 关联 {@link CrmBusinessStatusTypeDO#getId()} - */ - private Long typeId; - /** - * 状态名 - */ - private String name; - /** - * 赢单率 - * - * TODO 这里是不是改成 Integer 存储,百分比 * 100 ; - */ - private String percent; - /** - * 排序 - */ - private Integer sort; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java deleted file mode 100644 index d0d2f11f21..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.business; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.List; - -/** - * 商机状态类型 DO - * - * @author ljlleo - */ -@TableName(value = "crm_business_status_type", autoResultMap = true) -@KeySequence("crm_business_status_type_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessStatusTypeDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 状态类型名 - */ - private String name; - /** - * 使用的部门编号 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List deptIds; - /** - * 开启状态 - * - * TODO 改成 Integer,关联 CommonStatus - */ - private Boolean status; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/package-info.java deleted file mode 100644 index df6e44536f..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 商机(销售机会) - */ -package cn.iocoder.yudao.module.crm.dal.dataobject.business; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java deleted file mode 100644 index 592301b446..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.clue; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -// TODO 芋艿:字段的顺序,需要整理下; -/** - * 线索 DO - * - * @author Wanwan - */ -@TableName("crm_clue") -@KeySequence("crm_clue_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmClueDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - /** - * 转化状态 - */ - private Boolean transformStatus; - /** - * 跟进状态 - */ - private Boolean followUpStatus; - /** - * 线索名称 - */ - private String name; - /** - * 客户 id - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - /** - * 电话 - */ - private String telephone; - /** - * 手机号 - */ - private String mobile; - /** - * 地址 - */ - private String address; - /** - * 最后跟进时间 TODO 添加跟进记录时更新该值 - */ - private LocalDateTime contactLastTime; - /** - * 备注 - */ - private String remark; - - // TODO 芋艿:客户级别; - // TODO 芋艿:线索来源; - // TODO 芋艿:客户行业; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java deleted file mode 100644 index 929b9b6fe2..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 线索 - */ -package cn.iocoder.yudao.module.crm.dal.dataobject.clue; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactDO.java deleted file mode 100644 index 75d6bd565a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactDO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contact; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * CRM 联系人 DO - * - * @author 芋道源码 - */ -@TableName("crm_contact") -@KeySequence("crm_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContactDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 下次联系时间 - */ - private LocalDateTime nextTime; - /** - * 手机号 - */ - private String mobile; - /** - * 电话 - */ - private String telephone; - /** - * 电子邮箱 - */ - private String email; - /** - * 客户编号 - */ - private Long customerId; - /** - * 地址 - */ - private String address; - /** - * 备注 - */ - private String remark; - /** - * 最后跟进时间 - */ - private LocalDateTime lastTime; - /** - * 直属上级 - * - * 关联 {@link CrmContactDO#id} - */ - private Long parentId; - /** - * 姓名 - */ - private String name; - /** - * 职位 - */ - private String post; - /** - * QQ - */ - private Long qq; - /** - * 微信 - */ - private String wechat; - /** - * 性别 - * - * 枚举 {@link cn.iocoder.yudao.module.system.enums.common.SexEnum} - */ - private Integer sex; - /** - * 是否关键决策人 - */ - private Boolean master; - /** - * 负责人用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - - /** - * 所在地 - * - * 关联 {@link cn.iocoder.yudao.framework.ip.core.Area#getId()} 字段 - */ - private Integer areaId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java deleted file mode 100644 index dfe0898e30..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 联系人 - */ -package cn.iocoder.yudao.module.crm.dal.dataobject.contact; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contactbusinesslink/CrmContactBusinessLinkDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contactbusinesslink/CrmContactBusinessLinkDO.java deleted file mode 100644 index ad6c898d7a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contactbusinesslink/CrmContactBusinessLinkDO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -// TODO @zyna:可以放到 contact 包下 -/** - * CRM 联系人商机关联 DO - * - * @author 芋道源码 - */ -@TableName("crm_contact_business_link") -@KeySequence("crm_contact_business_link_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContactBusinessLinkDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 联系人编号 - * - * 关联 {@link CrmContactDO#getId()} 字段 - */ - private Long contactId; - /** - * 商机编号 - * - * 关联 {@link CrmBusinessDO#getId()} 字段 - */ - private Long businessId; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java deleted file mode 100644 index bdaff72712..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contract; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -// TODO 芋艿:实体的梳理 -/** - * CRM 合同 DO - * - * @author dhb52 - */ -@TableName("crm_contract") -@KeySequence("crm_contract_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContractDO extends BaseDO { - - /** - * 合同编号 - */ - @TableId - private Long id; - /** - * 合同名称 - */ - private String name; - /** - * 客户编号 - */ - private Long customerId; - /** - * 商机编号 - */ - private Long businessId; - /** - * 工作流编号 - */ - private Long processInstanceId; - /** - * 下单日期 - */ - private LocalDateTime orderDate; - /** - * 合同编号 - */ - private String no; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 合同金额 - */ - private Integer price; - /** - * 整单折扣 - */ - private Integer discountPercent; - /** - * 产品总金额 - */ - private Integer productPrice; - /** - * 联系人编号 - */ - private Long contactId; - /** - * 公司签约人 - */ - private Long signUserId; - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 备注 - */ - private String remark; - - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - - /** - * 审批状态 - * - * 枚举 {@link CrmAuditStatusEnum} - */ - private Integer auditStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/package-info.java deleted file mode 100644 index a981b5dfc5..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 合同 - */ -package cn.iocoder.yudao.module.crm.dal.dataobject.contract; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java deleted file mode 100644 index c5826b7c39..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java +++ /dev/null @@ -1,123 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.customer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -// TODO 芋艿:调整下字段 - -/** - * 客户 DO - * - * @author Wanwan - */ -@TableName(value = "crm_customer") -@KeySequence("crm_customer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmCustomerDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 客户名称 - */ - private String name; - /** - * 跟进状态 - */ - private Boolean followUpStatus; - /** - * 锁定状态 - */ - private Boolean lockStatus; - /** - * 成交状态 - */ - private Boolean dealStatus; - /** - * 所属行业 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_INDUSTRY} - */ - private Integer industryId; - /** - * 客户等级 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_LEVEL} - */ - private Integer level; - /** - * 客户来源 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_SOURCE} - */ - private Integer source; - /** - * 手机 - */ - private String mobile; - /** - * 电话 - */ - private String telephone; - /** - * 网址 - */ - private String website; - /** - * QQ - */ - private String qq; - /** - * wechat - */ - private String wechat; - /** - * email - */ - private String email; - /** - * 客户描述 - */ - private String description; - /** - * 备注 - */ - private String remark; - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - /** - * 地区编号 - */ - private Integer areaId; - /** - * 详细地址 - */ - private String detailAddress; - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerLimitConfigDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerLimitConfigDO.java deleted file mode 100644 index df3d3be6ff..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerLimitConfigDO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.customer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.List; - -/** - * 客户限制配置 DO - * - * @author Wanwan - */ -@TableName(value = "crm_customer_limit_config", autoResultMap = true) -@KeySequence("crm_customer_limit_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmCustomerLimitConfigDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 规则类型 - *

- * 枚举 {@link CrmCustomerLimitConfigTypeEnum} - */ - private Integer type; - /** - * 规则适用人群 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List userIds; - /** - * 规则适用部门 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List deptIds; - /** - * 数量上限 - */ - private Integer maxCount; - /** - * 成交客户是否占有拥有客户数 - * - * 当且仅当 {@link #type} 为 1 时,进行使用 - */ - private Boolean dealCountEnabled; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerPoolConfigDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerPoolConfigDO.java deleted file mode 100644 index 76f20dc3b2..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerPoolConfigDO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.customer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.*; -import lombok.*; - -/** - * 客户公海配置 DO - * - * @author Wanwan - */ -@TableName(value = "crm_customer_pool_config") -@KeySequence("crm_customer_pool_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmCustomerPoolConfigDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 是否启用客户公海 - */ - private Boolean enabled; - /** - * 未跟进放入公海天数 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Integer contactExpireDays; - /** - * 未成交放入公海天数 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Integer dealExpireDays; - /** - * 是否开启提前提醒 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Boolean notifyEnabled; - /** - * 提前提醒天数 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Integer notifyDays; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java deleted file mode 100644 index 59e47a5a80..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.permission; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * CRM 数据权限 DO - * - * @author HUIHUI - */ -@TableName("crm_permission") -@KeySequence("crm_permission_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmPermissionDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 数据类型 - * - * 枚举 {@link CrmBizTypeEnum} - */ - private Integer bizType; - /** - * 数据编号 - * - * 关联 {@link CrmBizTypeEnum} 对应模块 DO 的 id 字段 - */ - private Long bizId; - - /** - * 用户编号 - * - * 关联 AdminUser 的 id 字段 - */ - private Long userId; - - /** - * 权限级别 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - private Integer level; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductCategoryDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductCategoryDO.java deleted file mode 100644 index e0f4d6245a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductCategoryDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 产品分类 DO - * - * @author ZanGe丶 - */ -@TableName("crm_product_category") -@KeySequence("crm_product_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmProductCategoryDO extends BaseDO { - - /** - * 父分类编号 - 根分类 - */ - public static final Long PARENT_ID_NULL = 0L; - /** - * 限定分类层级 - */ - public static final int CATEGORY_LEVEL = 2; - - /** - * 分类编号 - */ - @TableId - private Long id; - /** - * 分类名称 - */ - private String name; - /** - * 父级编号 - * - * 关联 {@link CrmProductCategoryDO#getId()} - */ - private Long parentId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductDO.java deleted file mode 100644 index a4ac3d3d71..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductDO.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.enums.product.CrmProductStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * CRM 产品 DO - * - * @author ZanGe丶 - */ -@TableName("crm_product") -@KeySequence("crm_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmProductDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 产品名称 - */ - private String name; - /** - * 产品编码 - */ - private String no; - /** - * 单位 - * - * 字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_PRODUCT_UNIT} - */ - private Integer unit; - /** - * 价格,单位:分 - */ - private Long price; - /** - * 状态 - * - * 关联 {@link CrmProductStatusEnum} - */ - private Integer status; - /** - * 产品分类 ID - * - * 关联 {@link CrmProductCategoryDO#getId()} 字段 - */ - private Long categoryId; - /** - * 产品描述 - */ - private String description; - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java deleted file mode 100644 index 4c7282d736..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 产品表 - */ -package cn.iocoder.yudao.module.crm.dal.dataobject.product; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java deleted file mode 100644 index 842fc96b4f..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 回款 DO - * - * @author 赤焰 - */ -@TableName("crm_receivable") -@KeySequence("crm_receivable_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmReceivableDO extends BaseDO { - - /** - * ID - */ - @TableId - private Long id; - /** - * 回款编号 - */ - private String no; - // TODO @liuhongfeng:“对应实体”,参考别的模块,关联 {@link TableField.MetaInfo#getJdbcType()} - /** - * 回款计划 - * - * TODO @liuhongfeng:这个字段什么时候更新,也可以写下 - * - * 对应实体 {@link CrmReceivablePlanDO} - */ - private Long planId; - /** - * 客户 ID - * - * 对应实体 {@link cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO} - */ - private Long customerId; - /** - * 合同 ID - * - * 对应实体 {@link CrmContractDO} - */ - private Long contractId; - /** - * 工作流编号 - * - * TODO @liuhongfeng:这个字段,后续要写下关联的实体哈 - */ - private Long processInstanceId; - /** - * 回款日期 - */ - private LocalDateTime returnTime; - // TODO @liuhongfeng:少个枚举 - /** - * 回款方式 - */ - private Integer returnType; - /** - * 回款金额 - */ - private Integer price; - // TODO @liuhongfeng:少关联实体; - /** - * 负责人 - */ - private Long ownerUserId; - /** - * 显示顺序 - */ - private Integer sort; - /** - * 审核状态 - * - * 枚举 {@link cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum} - */ - private Integer auditStatus; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java deleted file mode 100644 index 78658e609a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 回款计划 DO - * - * @author 芋道源码 - */ -@TableName("crm_receivable_plan") -@KeySequence("crm_receivable_plan_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmReceivablePlanDO extends BaseDO { - - /** - * ID - */ - @TableId - private Long id; - /** - * 期数 - */ - private Integer period; - /** - * 回款ID - * - * TODO @liuhongfeng:少关联实体; - */ - private Long receivableId; - /** - * 完成状态 - */ - private Boolean finishStatus; - /** - * 计划回款金额,单位:分 - */ - private Integer price; - /** - * 计划回款日期 - */ - private LocalDateTime returnTime; - /** - * 提前几天提醒 - */ - private Integer remindDays; - /** - * 提醒日期 - */ - private LocalDateTime remindTime; - /** - * 客户 ID - * - * TODO @liuhongfeng:少关联实体; - */ - private Long customerId; - /** - * 合同 ID - * - * TODO @liuhongfeng:少关联实体; - */ - private Long contractId; - /** - * 负责人 ID - * - * TODO @liuhongfeng:少关联实体; - */ - private Long ownerUserId; - /** - * 显示顺序 - */ - private Integer sort; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/package-info.java deleted file mode 100644 index f27442cdf6..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 回款 - */ -package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java deleted file mode 100644 index 0f3964bf72..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; - -/** - * 商机 Mapper - * - * @author ljlleo - */ -@Mapper -public interface CrmBusinessMapper extends BaseMapperX { - - default PageResult selectPage(CrmBusinessPageReqVO reqVO, Collection ids) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .in(CrmBusinessDO::getId, ids) - .likeIfPresent(CrmBusinessDO::getName, reqVO.getName()) - .orderByDesc(CrmBusinessDO::getId)); - } - - default PageResult selectPageByCustomer(CrmContractPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(CrmBusinessDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 - .likeIfPresent(CrmBusinessDO::getName, reqVO.getName()) - .orderByDesc(CrmBusinessDO::getId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java deleted file mode 100644 index be847ab9d7..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 商机状态 Mapper - * - * @author ljlleo - */ -@Mapper -public interface CrmBusinessStatusMapper extends BaseMapperX { - - default PageResult selectPage(CrmBusinessStatusPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .orderByDesc(CrmBusinessStatusDO::getId)); - } - - default List selectList(CrmBusinessStatusQueryVO queryVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(CrmBusinessStatusDO::getTypeId, queryVO.getTypeId()) - .inIfPresent(CrmBusinessStatusDO::getId, queryVO.getIdList()) - .orderByDesc(CrmBusinessStatusDO::getId)); - } - - default int delete(Long typeId) { - return delete(CrmBusinessStatusDO::getTypeId, typeId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java deleted file mode 100644 index af10bf8c72..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 商机状态类型 Mapper - * - * @author ljlleo - */ -@Mapper -public interface CrmBusinessStatusTypeMapper extends BaseMapperX { - - default PageResult selectPage(CrmBusinessStatusTypePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .orderByDesc(CrmBusinessStatusTypeDO::getId)); - } - - default List selectList(CrmBusinessStatusTypeQueryVO queryVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(CrmBusinessStatusTypeDO::getStatus, queryVO.getStatus()) - .inIfPresent(CrmBusinessStatusTypeDO::getId, queryVO.getIdList())); - } -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/package-info.java deleted file mode 100644 index 72863e1f46..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 商机(销售机会) - */ -package cn.iocoder.yudao.module.crm.dal.mysql.business; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java deleted file mode 100644 index 8f9fea6c39..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.clue; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 线索 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmClueMapper extends BaseMapperX { - - default PageResult selectPage(CrmCluePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(CrmClueDO::getName, reqVO.getName()) - .likeIfPresent(CrmClueDO::getTelephone, reqVO.getTelephone()) - .likeIfPresent(CrmClueDO::getMobile, reqVO.getMobile()) - .orderByDesc(CrmClueDO::getId)); - } - - default List selectList(CrmClueExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(CrmClueDO::getTransformStatus, reqVO.getTransformStatus()) - .eqIfPresent(CrmClueDO::getFollowUpStatus, reqVO.getFollowUpStatus()) - .likeIfPresent(CrmClueDO::getName, reqVO.getName()) - .eqIfPresent(CrmClueDO::getCustomerId, reqVO.getCustomerId()) - .betweenIfPresent(CrmClueDO::getContactNextTime, reqVO.getContactNextTime()) - .likeIfPresent(CrmClueDO::getTelephone, reqVO.getTelephone()) - .likeIfPresent(CrmClueDO::getMobile, reqVO.getMobile()) - .likeIfPresent(CrmClueDO::getAddress, reqVO.getAddress()) - .betweenIfPresent(CrmClueDO::getContactLastTime, reqVO.getContactLastTime()) - .betweenIfPresent(CrmClueDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(CrmClueDO::getId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java deleted file mode 100644 index f9978e8687..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 线索 - */ -package cn.iocoder.yudao.module.crm.dal.mysql.clue; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java deleted file mode 100644 index 4c8f82f1a7..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contact; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * CRM 联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CrmContactMapper extends BaseMapperX { - - // TODO @puhui999:数据权限 - default PageResult selectPage(CrmContactPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmContactDO::getMobile, reqVO.getMobile()) - .eqIfPresent(CrmContactDO::getTelephone, reqVO.getTelephone()) - .eqIfPresent(CrmContactDO::getEmail, reqVO.getEmail()) - .eqIfPresent(CrmContactDO::getCustomerId, reqVO.getCustomerId()) - .likeIfPresent(CrmContactDO::getName, reqVO.getName()) - .eqIfPresent(CrmContactDO::getQq, reqVO.getQq()) - .eqIfPresent(CrmContactDO::getWechat, reqVO.getWechat()) - .orderByDesc(CrmContactDO::getId)); - } - - default PageResult selectPageByCustomer(CrmContactPageReqVO pageVO) { - return selectPage(pageVO, new LambdaQueryWrapperX() - .eq(CrmContactDO::getCustomerId, pageVO.getCustomerId()) // 必须传递 - .likeIfPresent(CrmContactDO::getName, pageVO.getName()) - .eqIfPresent(CrmContactDO::getMobile, pageVO.getMobile()) - .eqIfPresent(CrmContactDO::getTelephone, pageVO.getTelephone()) - .eqIfPresent(CrmContactDO::getEmail, pageVO.getEmail()) - .eqIfPresent(CrmContactDO::getQq, pageVO.getQq()) - .eqIfPresent(CrmContactDO::getWechat, pageVO.getWechat()) - .orderByDesc(CrmContactDO::getId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/package-info.java deleted file mode 100644 index 6cb7d4be27..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 联系人 - */ -package cn.iocoder.yudao.module.crm.dal.mysql.contact; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contactbusinesslink/CrmContactBusinessLinkMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contactbusinesslink/CrmContactBusinessLinkMapper.java deleted file mode 100644 index 1692def86d..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contactbusinesslink/CrmContactBusinessLinkMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * CRM 联系人商机关联 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CrmContactBusinessLinkMapper extends BaseMapperX { - - default PageResult selectPage(CrmContactBusinessLinkPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmContactBusinessLinkDO::getContactId, reqVO.getContactId()) - .eqIfPresent(CrmContactBusinessLinkDO::getBusinessId, reqVO.getBusinessId()) - .betweenIfPresent(CrmContactBusinessLinkDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(CrmContactBusinessLinkDO::getId)); - } // TODO @zyna:方法和方法之间要有空行 - default PageResult selectPageByContact(CrmContactBusinessLinkPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmContactBusinessLinkDO::getContactId, reqVO.getContactId()) - .orderByDesc(CrmContactBusinessLinkDO::getId)); - } -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java deleted file mode 100644 index a229121629..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contract; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * CRM 合同 Mapper - * - * @author dhb52 - */ -@Mapper -public interface CrmContractMapper extends BaseMapperX { - - default PageResult selectPage(CrmContractPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(CrmContractDO::getNo, reqVO.getNo()) - .likeIfPresent(CrmContractDO::getName, reqVO.getName()) - .eqIfPresent(CrmContractDO::getCustomerId, reqVO.getCustomerId()) - .eqIfPresent(CrmContractDO::getBusinessId, reqVO.getBusinessId()) - .orderByDesc(CrmContractDO::getId)); - } - - default PageResult selectPageByCustomer(CrmContractPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(CrmContractDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 - .likeIfPresent(CrmContractDO::getNo, reqVO.getNo()) - .likeIfPresent(CrmContractDO::getName, reqVO.getName()) - .eqIfPresent(CrmContractDO::getBusinessId, reqVO.getBusinessId()) - .orderByDesc(CrmContractDO::getId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java deleted file mode 100644 index f5fb31b61c..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 客户限制配置 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmCustomerLimitConfigMapper extends BaseMapperX { - - default PageResult selectPage(CrmCustomerLimitConfigPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmCustomerLimitConfigDO::getType, reqVO.getType()) - .orderByDesc(CrmCustomerLimitConfigDO::getId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java deleted file mode 100644 index 0ce9d9f032..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmQueryPageUtils; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 客户 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmCustomerMapper extends BaseMapperX { - - default int updateOwnerUserIdById(Long id, Long ownerUserId) { - return update(new LambdaUpdateWrapper() - .eq(CrmCustomerDO::getId, id) - .set(CrmCustomerDO::getOwnerUserId, ownerUserId)); - } - - /** - * 获取客户分页 - * - * @param pageReqVO 请求 - * @param userId 用户编号 - * @param subordinateIds 下属用户编号 - * @param isAdmin 是否为管理 - * @return 客户分页数据 - */ - default PageResult selectPage(CrmCustomerPageReqVO pageReqVO, Long userId, Collection subordinateIds, Boolean isAdmin) { - IPage mpPage = MyBatisUtils.buildPage(pageReqVO); - MPJLambdaWrapperX mpjLambdaWrapperX = new MPJLambdaWrapperX<>(); - // 构建数据权限连表条件 - CrmQueryPageUtils.builderQuery(mpjLambdaWrapperX, pageReqVO, userId, - CrmBizTypeEnum.CRM_CUSTOMER.getType(), CrmCustomerDO::getId, subordinateIds, isAdmin); - mpjLambdaWrapperX.selectAll(CrmCustomerDO.class) - .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile()) - .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) - .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel()) - .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource()); - // 特殊:不分页,直接查询全部 - // TODO @puhui999:下面这个,封装一个方法;从 56 到 61 这里哈; - if (PageParam.PAGE_SIZE_NONE.equals(pageReqVO.getPageNo())) { - List list = selectJoinList(CrmCustomerDO.class, mpjLambdaWrapperX); - return new PageResult<>(list, (long) list.size()); - } - mpPage = selectJoinPage(mpPage, CrmCustomerDO.class, mpjLambdaWrapperX); - return new PageResult<>(mpPage.getRecords(), mpPage.getTotal()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerPoolConfigMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerPoolConfigMapper.java deleted file mode 100644 index 1461ff6dd8..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerPoolConfigMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.customer; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 客户公海配置 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmCustomerPoolConfigMapper extends BaseMapperX { -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java deleted file mode 100644 index 3493185027..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.permission; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * crm 数据权限 mapper - * - * @author HUIHUI - */ -@Mapper -public interface CrmPermissionMapper extends BaseMapperX { - - default CrmPermissionDO selectByBizTypeAndBizIdByUserId(Integer bizType, Long bizId, Long userId) { - return selectOne(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId) - .eq(CrmPermissionDO::getUserId, userId)); - } - - default List selectByBizTypeAndBizId(Integer bizType, Long bizId) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId)); - } - - default List selectListByBizTypeAndUserId(Integer bizType, Long userId) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getUserId, userId)); - } - - default List selectListByBizTypeAndBizIdAndLevel(Integer bizType, Long bizId, Integer level) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId) - .eq(CrmPermissionDO::getLevel, level)); - } - - default CrmPermissionDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getId, id).eq(CrmPermissionDO::getUserId, userId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java deleted file mode 100644 index ff0e16b905..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.permission; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductCategoryMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductCategoryMapper.java deleted file mode 100644 index 3cced73562..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductCategoryMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.product; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * CRM 产品分类 Mapper - * - * @author ZanGe丶 - */ -@Mapper -public interface CrmProductCategoryMapper extends BaseMapperX { - - default List selectList(CrmProductCategoryListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(CrmProductCategoryDO::getName, reqVO.getName()) - .eqIfPresent(CrmProductCategoryDO::getParentId, reqVO.getParentId()) - .orderByDesc(CrmProductCategoryDO::getId)); - } - - default CrmProductCategoryDO selectByParentIdAndName(Long parentId, String name) { - return selectOne(CrmProductCategoryDO::getParentId, parentId, CrmProductCategoryDO::getName, name); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(CrmProductCategoryDO::getParentId, parentId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductMapper.java deleted file mode 100644 index 5b15e1d12a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductMapper.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * CRM 产品 Mapper - * - * @author ZanGe丶 - */ -@Mapper -public interface CrmProductMapper extends BaseMapperX { - - default PageResult selectPage(CrmProductPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(CrmProductDO::getName, reqVO.getName()) - .eqIfPresent(CrmProductDO::getStatus, reqVO.getStatus()) - .orderByDesc(CrmProductDO::getId)); - } - - default CrmProductDO selectByNo(String no) { - return selectOne(CrmProductDO::getNo, no); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java deleted file mode 100644 index 9da1300228..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 回款 Mapper - * - * @author 赤焰 - */ -@Mapper -public interface CrmReceivableMapper extends BaseMapperX { - - default PageResult selectPage(CrmReceivablePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) - .eqIfPresent(CrmReceivableDO::getPlanId, reqVO.getPlanId()) - .eqIfPresent(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) - .orderByDesc(CrmReceivableDO::getId)); - } - - default PageResult selectPageByCustomer(CrmReceivablePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 - .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) - .eqIfPresent(CrmReceivableDO::getPlanId, reqVO.getPlanId()) - .orderByDesc(CrmReceivableDO::getId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java deleted file mode 100644 index 52d16f0e1b..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 回款计划 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CrmReceivablePlanMapper extends BaseMapperX { - - default PageResult selectPage(CrmReceivablePlanPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) - .eqIfPresent(CrmReceivablePlanDO::getContractId, reqVO.getContractId()) - .orderByDesc(CrmReceivablePlanDO::getId)); - } - - default PageResult selectPageByCustomer(CrmReceivablePlanPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(CrmReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 - .eqIfPresent(CrmReceivablePlanDO::getContractId, reqVO.getContractId()) - .orderByDesc(CrmReceivablePlanDO::getId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/annotations/CrmPermission.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/annotations/CrmPermission.java deleted file mode 100644 index 410637829c..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/annotations/CrmPermission.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.core.annotations; - -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.METHOD; - -/** - * CRM 数据操作权限校验 AOP 注解 - * - * @author HUIHUI - */ -@Target({METHOD, ANNOTATION_TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface CrmPermission { - - /** - * CRM 类型 - */ - CrmBizTypeEnum[] bizType() default {}; - - /** - * CRM 类型扩展,通过 Spring EL 表达式获取到 {@link #bizType()} - * - * 目的:用于 CrmPermissionController 团队权限校验 - */ - String bizTypeValue() default ""; - - /** - * 数据编号,通过 Spring EL 表达式获取 - * TODO 数据权限完成后去除 default "" - */ - String bizId() default ""; - - /** - * 操作所需权限级别 - */ - CrmPermissionLevelEnum level(); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java deleted file mode 100644 index 40a05872f2..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.core.aop; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_DENIED; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_MODEL_NOT_EXISTS; - -/** - * Crm 数据权限校验 AOP 切面 - * - * @author HUIHUI - */ -@Component -@Aspect -@Slf4j -public class CrmPermissionAspect { - - @Resource - private CrmPermissionService crmPermissionService; - - @Before("@annotation(crmPermission)") - public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) { - // TODO 芋艿:临时,方便大家调试 - //if (true) { - // return; - //} - // 获取相关属性值 - Map expressionValues = parseExpressions(joinPoint, crmPermission); - Integer bizType = StrUtil.isEmpty(crmPermission.bizTypeValue()) ? - crmPermission.bizType()[0].getType() : (Integer) expressionValues.get(crmPermission.bizTypeValue()); // 模块类型 - Long bizId = (Long) expressionValues.get(crmPermission.bizId()); // 模块数据编号 - Integer permissionLevel = crmPermission.level().getLevel(); // 需要的权限级别 - - // TODO 如果是超级管理员则直接通过 - //if (superAdmin){ - // return; - //} - - // 1. 获取数据权限 - List bizPermissions = crmPermissionService.getPermissionListByBiz(bizType, bizId); - if (CollUtil.isEmpty(bizPermissions)) { // 数据权限不存存那么数据也不存在 - throw exception(CRM_PERMISSION_MODEL_NOT_EXISTS, CrmBizTypeEnum.getNameByType(bizType)); - } - // 2.1 情况一:如果自己是负责人,则默认有所有权限 - CrmPermissionDO userPermission = CollUtil.findOne(bizPermissions, permission -> ObjUtil.equal(permission.getUserId(), getUserId())); - if (userPermission != null) { - if (CrmPermissionLevelEnum.isOwner(userPermission.getLevel())) { - return; - } - // 2.2 情况二:校验自己是否有读权限 - if (CrmPermissionLevelEnum.isRead(permissionLevel)) { - if (CrmPermissionLevelEnum.isRead(userPermission.getLevel()) // 校验当前用户是否有读权限 - || CrmPermissionLevelEnum.isWrite(userPermission.getLevel())) { // 校验当前用户是否有写权限 - return; - } - } - // 2.3 情况三:校验自己是否有写权限 - if (CrmPermissionLevelEnum.isWrite(permissionLevel)) { - if (CrmPermissionLevelEnum.isWrite(userPermission.getLevel())) { // 校验当前用户是否有写权限 - return; - } - } - } - // 2.4 没有权限! - // 打个 info 日志,方便后续排查问题、审计 - log.info("[doBefore][userId({}) 要求权限({}) 实际权限({}) 数据校验错误]", - getUserId(), permissionLevel, toJsonString(userPermission)); - throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType)); - } - - /** - * 获得用户编号 - * - * @return 用户编号 - */ - private static Long getUserId() { - return WebFrameworkUtils.getLoginUserId(); - } - - private static Map parseExpressions(JoinPoint joinPoint, CrmPermission crmPermission) { - // 1. 需要解析的表达式 - List expressionStrings = new ArrayList<>(2); - expressionStrings.add(crmPermission.bizId()); - if (StrUtil.isNotEmpty(crmPermission.bizTypeValue())) { // 为空则表示 bizType 有值 - expressionStrings.add(crmPermission.bizTypeValue()); - } - // 2. 执行解析 - return SpringExpressionUtils.parseExpressions(joinPoint, expressionStrings); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/package-info.java deleted file mode 100644 index 4a3e657225..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.core; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java deleted file mode 100644 index 281e36c453..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 crm 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.crm.framework; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/vo/CrmBasePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/vo/CrmBasePageReqVO.java deleted file mode 100644 index 14070fa197..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/vo/CrmBasePageReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Schema(description = "管理后台 - CRM 分页 Base Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -public class CrmBasePageReqVO extends PageParam { - - /** - * 场景类型,为 null 时则表示全部 - */ - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneEnum.class) - private Integer sceneType; - - @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean pool; // null 则表示为不是公海数据 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java deleted file mode 100644 index 2ea5f9f417..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * crm 包下,客户关系管理(Customer Relationship Management)。 - * 例如说:客户、联系人、商机、合同、回款等等 - * - * 1. Controller URL:以 /crm/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 crm_ 开头,方便在数据库中区分 - * - * 注意,由于 Crm 模块下,容易和其它模块重名,所以类名都加载 Crm 的前缀~ - */ -package cn.iocoder.yudao.module.crm; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java deleted file mode 100644 index 82839ec24d..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java +++ /dev/null @@ -1,91 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 商机 Service 接口 - * - * @author ljlleo - */ -public interface CrmBusinessService { - - /** - * 创建商机 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createBusiness(@Valid CrmBusinessCreateReqVO createReqVO, Long userId); - - /** - * 更新商机 - * - * @param updateReqVO 更新信息 - */ - void updateBusiness(@Valid CrmBusinessUpdateReqVO updateReqVO); - - /** - * 删除商机 - * - * @param id 编号 - */ - void deleteBusiness(Long id); - - /** - * 获得商机 - * - * @param id 编号 - * @return 商机 - */ - CrmBusinessDO getBusiness(Long id); - - /** - * 获得商机列表 - * - * @param ids 编号 - * @return 商机列表 - */ - List getBusinessList(Collection ids); - - /** - * 获得商机分页 - * - * 数据权限:基于 {@link CrmBusinessDO} - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 商机分页 - */ - PageResult getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId); - - /** - * 获得商机分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 联系人分页 - */ - PageResult getBusinessPageByCustomer(CrmContractPageReqVO pageReqVO); - - /** - * 商机转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java deleted file mode 100644 index 54946d052e..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; - -/** - * 商机 Service 实现类 - * - * @author ljlleo - */ -@Service -@Validated -public class CrmBusinessServiceImpl implements CrmBusinessService { - - @Resource - private CrmBusinessMapper businessMapper; - - @Resource - private CrmPermissionService crmPermissionService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createBusiness(CrmBusinessCreateReqVO createReqVO, Long userId) { - // 插入 - CrmBusinessDO business = CrmBusinessConvert.INSTANCE.convert(createReqVO); - businessMapper.insert(business); - - // 创建数据权限 - crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) - .setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 - - // 返回 - return business.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#updateReqVO.id", - level = CrmPermissionLevelEnum.WRITE) - public void updateBusiness(CrmBusinessUpdateReqVO updateReqVO) { - // 校验存在 - validateBusinessExists(updateReqVO.getId()); - // 更新 - CrmBusinessDO updateObj = CrmBusinessConvert.INSTANCE.convert(updateReqVO); - businessMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, level = CrmPermissionLevelEnum.WRITE) - public void deleteBusiness(Long id) { - // 校验存在 - validateBusinessExists(id); - // 删除 - businessMapper.deleteById(id); - } - - private CrmBusinessDO validateBusinessExists(Long id) { - CrmBusinessDO crmBusiness = businessMapper.selectById(id); - if (crmBusiness == null) { - throw exception(BUSINESS_NOT_EXISTS); - } - return crmBusiness; - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS,bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmBusinessDO getBusiness(Long id) { - return businessMapper.selectById(id); - } - - @Override - public List getBusinessList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return businessMapper.selectBatchIds(ids); - } - - @Override - public PageResult getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId) { - // 1. 获取当前用户能看的分页数据 - // TODO @puhui999:如果业务的数据量比较大,in 太多可能有性能问题噢;看看是不是搞成 join 连表了;可以微信讨论下; - List permissions = crmPermissionService.getPermissionListByBizTypeAndUserId( - CrmBizTypeEnum.CRM_BUSINESS.getType(), userId); - Set ids = convertSet(permissions, CrmPermissionDO::getBizId); - if (CollUtil.isEmpty(ids)) { // 没得说明没有什么给他看的 - return PageResult.empty(); - } - - // 2. 获取商机分页数据 - return businessMapper.selectPage(pageReqVO, ids); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getBusinessPageByCustomer(CrmContractPageReqVO pageReqVO) { - return businessMapper.selectPageByCustomer(pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) { - // 1 校验商机是否存在 - validateBusinessExists(reqVO.getId()); - - // 2. 数据权限转移 - crmPermissionService.transferPermission( - CrmBusinessConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType())); - - // 3. TODO 记录转移日志 - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java deleted file mode 100644 index ffad53556b..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * 商机状态 Service 接口 - * - * @author ljlleo - */ -public interface CrmBusinessStatusService { - - /** - * 创建商机状态 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBusinessStatus(@Valid CrmBusinessStatusSaveReqVO createReqVO); - - /** - * 更新商机状态 - * - * @param updateReqVO 更新信息 - */ - void updateBusinessStatus(@Valid CrmBusinessStatusSaveReqVO updateReqVO); - - /** - * 删除商机状态 - * - * @param id 编号 - */ - void deleteBusinessStatus(Long id); - - /** - * 获得商机状态 - * - * @param id 编号 - * @return 商机状态 - */ - CrmBusinessStatusDO getBusinessStatus(Long id); - - /** - * 获得商机状态分页 - * - * @param pageReqVO 分页查询 - * @return 商机状态分页 - */ - PageResult getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO); - - // TODO @ljlleo 常用的 ids 之类的查询,可以封装单独的方法,不用走类似 QueryVO,用起来更方便。 - // TODO @ljlleo 方法名用 getBusinessStatusList - /** - * 获得商机状态分页 - * - * @param queryVO 查询参数 - * @return 商机状态分页 - */ - List selectList(CrmBusinessStatusQueryVO queryVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java deleted file mode 100644 index fa6ad3d03a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_NOT_EXISTS; - -/** - * 商机状态 Service 实现类 - * - * @author ljlleo - */ -@Service -@Validated -public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { - - @Resource - private CrmBusinessStatusMapper businessStatusMapper; - - @Override - public Long createBusinessStatus(CrmBusinessStatusSaveReqVO createReqVO) { - // 插入 - CrmBusinessStatusDO businessStatus = BeanUtils.toBean(createReqVO, CrmBusinessStatusDO.class); - businessStatusMapper.insert(businessStatus); - // 返回 - return businessStatus.getId(); - } - - @Override - public void updateBusinessStatus(CrmBusinessStatusSaveReqVO updateReqVO) { - // 校验存在 - validateBusinessStatusExists(updateReqVO.getId()); - // 更新 - CrmBusinessStatusDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusDO.class); - businessStatusMapper.updateById(updateObj); - } - - @Override - public void deleteBusinessStatus(Long id) { - // 校验存在 - validateBusinessStatusExists(id); - // TODO @ljlleo 这里可以考虑,如果有商机在使用,不允许删除 - // 删除 - businessStatusMapper.deleteById(id); - } - - private void validateBusinessStatusExists(Long id) { - if (businessStatusMapper.selectById(id) == null) { - throw exception(BUSINESS_STATUS_NOT_EXISTS); - } - } - - @Override - public CrmBusinessStatusDO getBusinessStatus(Long id) { - return businessStatusMapper.selectById(id); - } - - @Override - public PageResult getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO) { - return businessStatusMapper.selectPage(pageReqVO); - } - - @Override - public List selectList(CrmBusinessStatusQueryVO queryVO) { - return businessStatusMapper.selectList(queryVO); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeService.java deleted file mode 100644 index 39dc3128c5..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeService.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * 商机状态类型 Service 接口 - * - * @author ljlleo - */ -public interface CrmBusinessStatusTypeService { - - /** - * 创建商机状态类型 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBusinessStatusType(@Valid CrmBusinessStatusTypeSaveReqVO createReqVO); - - /** - * 更新商机状态类型 - * - * @param updateReqVO 更新信息 - */ - void updateBusinessStatusType(@Valid CrmBusinessStatusTypeSaveReqVO updateReqVO); - - /** - * 删除商机状态类型 - * - * @param id 编号 - */ - void deleteBusinessStatusType(Long id); - - /** - * 获得商机状态类型 - * - * @param id 编号 - * @return 商机状态类型 - */ - CrmBusinessStatusTypeDO getBusinessStatusType(Long id); - - /** - * 获得商机状态类型分页 - * - * @param pageReqVO 分页查询 - * @return 商机状态类型分页 - */ - PageResult getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO); - - // TODO @ljlleo 常用的 ids 之类的查询,可以封装单独的方法,不用走类似 QueryVO,用起来更方便。 - /** - * 获得商机状态类型列表 - * - * @param queryVO 查询参数 - * @return 商机状态类型列表 - */ - List selectList(CrmBusinessStatusTypeQueryVO queryVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeServiceImpl.java deleted file mode 100644 index 501780abde..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeServiceImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NAME_EXISTS; - -/** - * 商机状态类型 Service 实现类 - * - * @author ljlleo - */ -@Service -@Validated -public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeService { - - @Resource - private CrmBusinessStatusTypeMapper businessStatusTypeMapper; - - @Resource - private CrmBusinessStatusMapper businessStatusMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createBusinessStatusType(CrmBusinessStatusTypeSaveReqVO createReqVO) { - //检验名称是否存在 - validateBusinessStatusTypeExists(createReqVO.getName(), null); - // 插入类型 - CrmBusinessStatusTypeDO businessStatusType = BeanUtils.toBean(createReqVO, CrmBusinessStatusTypeDO.class); - businessStatusTypeMapper.insert(businessStatusType); - // 插入状态 - if (CollUtil.isNotEmpty(createReqVO.getStatusList())) { - createReqVO.getStatusList().forEach(status -> status.setTypeId(businessStatusType.getId())); - businessStatusMapper.insertBatch(BeanUtils.toBean(createReqVO.getStatusList(), CrmBusinessStatusDO.class)); - } - return businessStatusType.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateBusinessStatusType(CrmBusinessStatusTypeSaveReqVO updateReqVO) { - // 校验存在 - validateBusinessStatusTypeExists(updateReqVO.getId()); - // 校验名称是否存在 - validateBusinessStatusTypeExists(updateReqVO.getName(), updateReqVO.getId()); - // 更新类型 - CrmBusinessStatusTypeDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusTypeDO.class); - businessStatusTypeMapper.updateById(updateObj); - // 更新状态(删除 + 更新) - // TODO @ljlleo 可以参考 DeliveryExpressTemplateServiceImpl 的 updateExpressTemplateFree 方法;主要没变化的,还是不删除了哈。 - businessStatusMapper.delete(updateReqVO.getId()); - updateReqVO.getStatusList().forEach(status -> status.setTypeId(updateReqVO.getId())); - businessStatusMapper.insertBatch(BeanUtils.toBean(updateReqVO.getStatusList(), CrmBusinessStatusDO.class)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteBusinessStatusType(Long id) { - // TODO 待添加被引用校验 - //... - - // 校验存在 - validateBusinessStatusTypeExists(id); - // 删除类型 - businessStatusTypeMapper.deleteById(id); - // 删除状态 - businessStatusMapper.delete(id); - } - - private void validateBusinessStatusTypeExists(Long id) { - if (businessStatusTypeMapper.selectById(id) == null) { - throw exception(BUSINESS_STATUS_TYPE_NOT_EXISTS); - } - } - - // TODO @ljlleo 这个方法,这个参考 validateDeptNameUnique 实现。 - private void validateBusinessStatusTypeExists(String name, Long id) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapperX<>(); - if(null != id) { - wrapper.ne(CrmBusinessStatusTypeDO::getId, id); - } - long cnt = businessStatusTypeMapper.selectCount(wrapper.eq(CrmBusinessStatusTypeDO::getName, name)); - if (cnt > 0) { - throw exception(BUSINESS_STATUS_TYPE_NAME_EXISTS); - } - } - - @Override - public CrmBusinessStatusTypeDO getBusinessStatusType(Long id) { - return businessStatusTypeMapper.selectById(id); - } - - @Override - public PageResult getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO) { - return businessStatusTypeMapper.selectPage(pageReqVO); - } - - @Override - public List selectList(CrmBusinessStatusTypeQueryVO queryVO) { - return businessStatusTypeMapper.selectList(queryVO); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/package-info.java deleted file mode 100644 index 8995e12421..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 商机(销售机会) - */ -package cn.iocoder.yudao.module.crm.service.business; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java deleted file mode 100644 index 26ba0b4081..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.clue; - -import java.util.*; -import jakarta.validation.*; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -/** - * 线索 Service 接口 - * - * @author Wanwan - */ -public interface CrmClueService { - - /** - * 创建线索 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createClue(@Valid CrmClueCreateReqVO createReqVO); - - /** - * 更新线索 - * - * @param updateReqVO 更新信息 - */ - void updateClue(@Valid CrmClueUpdateReqVO updateReqVO); - - /** - * 删除线索 - * - * @param id 编号 - */ - void deleteClue(Long id); - - /** - * 获得线索 - * - * @param id 编号 - * @return 线索 - */ - CrmClueDO getClue(Long id); - - /** - * 获得线索列表 - * - * @param ids 编号 - * @return 线索列表 - */ - List getClueList(Collection ids); - - /** - * 获得线索分页 - * - * @param pageReqVO 分页查询 - * @return 线索分页 - */ - PageResult getCluePage(CrmCluePageReqVO pageReqVO); - - /** - * 获得线索列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 线索列表 - */ - List getClueList(CrmClueExportReqVO exportReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java deleted file mode 100644 index 37efb98a51..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.clue; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; - -/** - * 线索 Service 实现类 - * - * @author Wanwan - */ -@Service -@Validated -public class CrmClueServiceImpl implements CrmClueService { - - @Resource - private CrmClueMapper clueMapper; - @Resource - private CrmCustomerService customerService; - - @Override - public Long createClue(CrmClueCreateReqVO createReqVO) { - // 校验客户是否存在 - customerService.validateCustomer(createReqVO.getCustomerId()); - // 插入 - CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO); - clueMapper.insert(clue); - // 返回 - return clue.getId(); - } - - @Override - public void updateClue(CrmClueUpdateReqVO updateReqVO) { - // 校验存在 - validateClueExists(updateReqVO.getId()); - // 校验客户是否存在 - customerService.validateCustomer(updateReqVO.getCustomerId()); - - // 更新 - CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO); - clueMapper.updateById(updateObj); - } - - @Override - public void deleteClue(Long id) { - // 校验存在 - validateClueExists(id); - // 删除 - clueMapper.deleteById(id); - } - - private void validateClueExists(Long id) { - if (clueMapper.selectById(id) == null) { - throw exception(CLUE_NOT_EXISTS); - } - } - - @Override - public CrmClueDO getClue(Long id) { - return clueMapper.selectById(id); - } - - @Override - public List getClueList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return clueMapper.selectBatchIds(ids); - } - - @Override - public PageResult getCluePage(CrmCluePageReqVO pageReqVO) { - return clueMapper.selectPage(pageReqVO); - } - - @Override - public List getClueList(CrmClueExportReqVO exportReqVO) { - return clueMapper.selectList(exportReqVO); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/package-info.java deleted file mode 100644 index 5cb8b6ec7a..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 线索 - */ -package cn.iocoder.yudao.module.crm.service.clue; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java deleted file mode 100644 index 85aec14cc4..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contact; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * CRM 联系人 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmContactService { - - /** - * 创建联系人 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createContact(@Valid CrmContactCreateReqVO createReqVO, Long userId); - - /** - * 更新联系人 - * - * @param updateReqVO 更新信息 - */ - void updateContact(@Valid CrmContactUpdateReqVO updateReqVO); - - /** - * 删除联系人 - * - * @param id 编号 - */ - void deleteContact(Long id); - - /** - * 获得联系人 - * - * @param id 编号 - * @return 联系人 - */ - CrmContactDO getContact(Long id); - - /** - * 获得联系人列表 - * - * @param ids 编号 - * @return 联系人列表 - */ - List getContactList(Collection ids); - - /** - * 获得联系人分页 - * - * 数据权限:基于 {@link CrmContactDO} - * - * @param pageReqVO 分页查询 - * @return 联系人分页 - */ - PageResult getContactPage(CrmContactPageReqVO pageReqVO); - - /** - * 获得联系人分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 联系人分页 - */ - PageResult getContactPageByCustomer(CrmContactPageReqVO pageReqVO); - - /** - * 获取所有联系人列表 - * - * @return 所有联系人列表 - */ - List getContactList(); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java deleted file mode 100644 index d4c4fe9c28..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contact; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBaseVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper; -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; - -/** - * CRM 联系人 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmContactServiceImpl implements CrmContactService { - - @Resource - private CrmContactMapper contactMapper; - - @Resource - private CrmCustomerService customerService; - @Resource - private CrmPermissionService crmPermissionService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createContact(CrmContactCreateReqVO createReqVO, Long userId) { - // 1.1 校验 - validateRelationDataExists(createReqVO); - // 1.2 插入 - CrmContactDO contact = ContactConvert.INSTANCE.convert(createReqVO); - contactMapper.insert(contact); - - // 2. 创建数据权限 - crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId) - .setBizType(CrmBizTypeEnum.CRM_CONTACT.getType()).setBizId(contact.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - return contact.getId(); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateContact(CrmContactUpdateReqVO updateReqVO) { - // 1. 校验存在 - validateContactExists(updateReqVO.getId()); - validateRelationDataExists(updateReqVO); - // 2. 更新 - CrmContactDO updateObj = ContactConvert.INSTANCE.convert(updateReqVO); - contactMapper.updateById(updateObj); - } - - /** - * 校验关联的数据都存在 - * - * @param saveReqVO 新增/修改请求 VO - */ - private void validateRelationDataExists(CrmContactBaseVO saveReqVO){ - // 1. 校验客户 - if (saveReqVO.getCustomerId() != null && customerService.getCustomer(saveReqVO.getCustomerId()) == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - // 2. 校验负责人 - if (saveReqVO.getOwnerUserId() != null && adminUserApi.getUser(saveReqVO.getOwnerUserId()) == null) { - throw exception(USER_NOT_EXISTS); - } - // 3. 直属上级 - if (saveReqVO.getParentId() != null && contactMapper.selectById(saveReqVO.getParentId()) == null) { - throw exception(CONTACT_NOT_EXISTS); - } - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void deleteContact(Long id) { - // 校验存在 - validateContactExists(id); - // 删除 - contactMapper.deleteById(id); - } - - private void validateContactExists(Long id) { - if (contactMapper.selectById(id) == null) { - throw exception(CONTACT_NOT_EXISTS); - } - } - - // TODO 芋艿:是否要做数据权限的校验??? - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmContactDO getContact(Long id) { - return contactMapper.selectById(id); - } - - @Override - public List getContactList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return contactMapper.selectBatchIds(ids); - } - - @Override - public PageResult getContactPage(CrmContactPageReqVO pageReqVO) { - // TODO puhui999:后面要改成,基于数据权限的查询 - return contactMapper.selectPage(pageReqVO); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getContactPageByCustomer(CrmContactPageReqVO pageReqVO) { - return contactMapper.selectPageByCustomer(pageReqVO); - } - - @Override - public List getContactList() { - return contactMapper.selectList(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contactbusinesslink/CrmContactBusinessLinkService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contactbusinesslink/CrmContactBusinessLinkService.java deleted file mode 100644 index c265c43559..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contactbusinesslink/CrmContactBusinessLinkService.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contactbusinesslink; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * CRM 联系人商机关联 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmContactBusinessLinkService { - - /** - * 创建联系人商机关联 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createContactBusinessLink(@Valid CrmContactBusinessLinkSaveReqVO createReqVO); - - /** - * 创建联系人商机关联 - * - * @param createReqVO 创建信息 - */ - void createContactBusinessLinkBatch(@Valid List createReqVO); - - /** - * 更新联系人商机关联 - * - * @param updateReqVO 更新信息 - */ - void updateContactBusinessLink(@Valid CrmContactBusinessLinkSaveReqVO updateReqVO); - - /** - * 删除联系人商机关联 - * - * @param createReqVO 删除列表 - */ - void deleteContactBusinessLink(@Valid List createReqVO); - - /** - * 获得联系人商机关联 - * - * @param id 编号 - * @return 联系人商机关联 - */ - CrmContactBusinessLinkDO getContactBusinessLink(Long id); - - /** - * 获得联系人商机关联分页 - * - * @param pageReqVO 编号 - * @return 联系人商机关联 - */ - PageResult getContactBusinessLinkPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO); - - /** - * 获得联系人商机关联分页 - * - * @param pageReqVO 分页查询 - * @return 联系人商机关联分页 - */ - PageResult getContactBusinessLinkPage(CrmContactBusinessLinkPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contactbusinesslink/CrmContactBusinessLinkServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contactbusinesslink/CrmContactBusinessLinkServiceImpl.java deleted file mode 100644 index d8ef6a511b..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contactbusinesslink/CrmContactBusinessLinkServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contactbusinesslink; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO; -import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; -import cn.iocoder.yudao.module.crm.convert.contactbusinessslink.CrmContactBusinessLinkConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessLinkMapper; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_BUSINESS_LINK_NOT_EXISTS; - -// TODO @puhui999:数据权限的校验;每个操作; -/** - * 联系人商机关联 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmContactBusinessLinkServiceImpl implements CrmContactBusinessLinkService { - - @Resource - private CrmContactBusinessLinkMapper contactBusinessLinkMapper; - @Resource - private CrmBusinessService crmBusinessService; - - @Override - public Long createContactBusinessLink(CrmContactBusinessLinkSaveReqVO createReqVO) { - CrmContactBusinessLinkDO contactBusinessLink = BeanUtils.toBean(createReqVO, CrmContactBusinessLinkDO.class); - contactBusinessLinkMapper.insert(contactBusinessLink); - return contactBusinessLink.getId(); - } - - @Override - public void createContactBusinessLinkBatch(List createReqVOList) { - // 插入 - // TODO @zyna:如果已经关联过,不用重复插入; - // TODO @zyna:contact 和 business 存在校验,挪到这里,Controller 不用 @Transactional 注解,添加到这里哈。尽量业务都在 Service; - List saveDoList = CrmContactBusinessLinkConvert.INSTANCE.convert(createReqVOList); - contactBusinessLinkMapper.insertBatch(saveDoList); - } - - @Override - public void updateContactBusinessLink(CrmContactBusinessLinkSaveReqVO updateReqVO) { - // 校验存在 - validateContactBusinessLinkExists(updateReqVO.getId()); - // 更新 - CrmContactBusinessLinkDO updateObj = BeanUtils.toBean(updateReqVO, CrmContactBusinessLinkDO.class); - contactBusinessLinkMapper.updateById(updateObj); - } - - @Override - public void deleteContactBusinessLink(List createReqVO) { - // 删除 - createReqVO.forEach(item -> { - contactBusinessLinkMapper.delete(new LambdaQueryWrapperX() - .eq(CrmContactBusinessLinkDO::getBusinessId,item.getBusinessId()) - .eq(CrmContactBusinessLinkDO::getContactId,item.getContactId()) - .eq(CrmContactBusinessLinkDO::getDeleted,0)); - }); - } - - private void validateContactBusinessLinkExists(Long id) { - if (contactBusinessLinkMapper.selectById(id) == null) { - throw exception(CONTACT_BUSINESS_LINK_NOT_EXISTS); - } - } - - @Override - public CrmContactBusinessLinkDO getContactBusinessLink(Long id) { - return contactBusinessLinkMapper.selectById(id); - } - - @Override - public PageResult getContactBusinessLinkPageByContact(CrmContactBusinessLinkPageReqVO pageReqVO) { - CrmContactBusinessLinkPageReqVO crmContactBusinessLinkPageReqVO = new CrmContactBusinessLinkPageReqVO(); - crmContactBusinessLinkPageReqVO.setContactId(pageReqVO.getContactId()); - PageResult businessLinkDOS = contactBusinessLinkMapper.selectPageByContact(crmContactBusinessLinkPageReqVO); - List businessDOS = crmBusinessService.getBusinessList(CollectionUtils.convertList(businessLinkDOS.getList(), - CrmContactBusinessLinkDO::getBusinessId)); - PageResult pageResult = new PageResult(); - pageResult.setList(CrmBusinessConvert.INSTANCE.convert(businessDOS)); - pageResult.setTotal(businessLinkDOS.getTotal()); - return pageResult; - - } - - @Override - public PageResult getContactBusinessLinkPage(CrmContactBusinessLinkPageReqVO pageReqVO) { - return contactBusinessLinkMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java deleted file mode 100644 index e9162b1cac..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * CRM 合同 Service 接口 - * - * @author dhb52 - */ -public interface CrmContractService { - - /** - * 创建合同 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createContract(@Valid CrmContractCreateReqVO createReqVO, Long userId); - - /** - * 更新合同 - * - * @param updateReqVO 更新信息 - */ - void updateContract(@Valid CrmContractUpdateReqVO updateReqVO); - - /** - * 删除合同 - * - * @param id 编号 - */ - void deleteContract(Long id); - - /** - * 获得合同 - * - * @param id 编号 - * @return 合同 - */ - CrmContractDO getContract(Long id); - - /** - * 获得合同列表 - * - * @param ids 编号 - * @return 合同列表 - */ - List getContractList(Collection ids); - - /** - * 获得合同分页 - * - * 数据权限:基于 {@link CrmContractDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 合同分页 - */ - PageResult getContractPage(CrmContractPageReqVO pageReqVO); - - /** - * 获得合同分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 联系人分页 - */ - PageResult getContractPageByCustomer(CrmContractPageReqVO pageReqVO); - - /** - * 合同转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferContract(CrmContractTransferReqVO reqVO, Long userId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java deleted file mode 100644 index 731711a3a5..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; -import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; - -/** - * CRM 合同 Service 实现类 - * - * @author dhb52 - */ -@Service -@Validated -public class CrmContractServiceImpl implements CrmContractService { - - @Resource - private CrmContractMapper contractMapper; - - @Resource - private CrmPermissionService crmPermissionService; - - @Override - public Long createContract(CrmContractCreateReqVO createReqVO, Long userId) { - // 插入 - CrmContractDO contract = ContractConvert.INSTANCE.convert(createReqVO); - contractMapper.insert(contract); - - // 创建数据权限 - crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId) - .setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType()).setBizId(contract.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - return contract.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, level = CrmPermissionLevelEnum.WRITE) - public void updateContract(CrmContractUpdateReqVO updateReqVO) { - // 校验存在 - validateContractExists(updateReqVO.getId()); - // 更新 - CrmContractDO updateObj = ContractConvert.INSTANCE.convert(updateReqVO); - contractMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void deleteContract(Long id) { - // 校验存在 - validateContractExists(id); - // 删除 - contractMapper.deleteById(id); - } - - private CrmContractDO validateContractExists(Long id) { - CrmContractDO contract = contractMapper.selectById(id); - if (contract == null) { - throw exception(CONTRACT_NOT_EXISTS); - } - return contract; - } - - // TODO 芋艿:是否要做数据权限的校验??? - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmContractDO getContract(Long id) { - return contractMapper.selectById(id); - } - - @Override - public List getContractList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return contractMapper.selectBatchIds(ids); - } - - @Override - public PageResult getContractPage(CrmContractPageReqVO pageReqVO) { - return contractMapper.selectPage(pageReqVO); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getContractPageByCustomer(CrmContractPageReqVO pageReqVO) { - return contractMapper.selectPageByCustomer(pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void transferContract(CrmContractTransferReqVO reqVO, Long userId) { - // 1 校验合同是否存在 - validateContractExists(reqVO.getId()); - - // 2. 数据权限转移 - crmPermissionService.transferPermission( - ContractConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType())); - - // 3. TODO 记录转移日志 - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java deleted file mode 100644 index 96090cdfc1..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; - -import jakarta.validation.Valid; - -/** - * 客户限制配置 Service 接口 - * - * @author Wanwan - */ -public interface CrmCustomerLimitConfigService { - - /** - * 创建客户限制配置 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCustomerLimitConfig(@Valid CrmCustomerLimitConfigCreateReqVO createReqVO); - - /** - * 更新客户限制配置 - * - * @param updateReqVO 更新信息 - */ - void updateCustomerLimitConfig(@Valid CrmCustomerLimitConfigUpdateReqVO updateReqVO); - - /** - * 删除客户限制配置 - * - * @param id 编号 - */ - void deleteCustomerLimitConfig(Long id); - - /** - * 获得客户限制配置 - * - * @param id 编号 - * @return 客户限制配置 - */ - CrmCustomerLimitConfigDO getCustomerLimitConfig(Long id); - - /** - * 获得客户限制配置分页 - * - * @param pageReqVO 分页查询 - * @return 客户限制配置分页 - */ - PageResult getCustomerLimitConfigPage(CrmCustomerLimitConfigPageReqVO pageReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java deleted file mode 100644 index 4528eafada..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -import java.util.Collection; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS; - -/** - * 客户限制配置 Service 实现类 - * - * @author Wanwan - */ -@Service -@Validated -public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfigService { - - @Resource - private CrmCustomerLimitConfigMapper customerLimitConfigMapper; - @Resource - private DeptApi deptApi; - @Resource - private AdminUserApi adminUserApi; - - @Override - public Long createCustomerLimitConfig(CrmCustomerLimitConfigCreateReqVO createReqVO) { - validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds()); - // 插入 - CrmCustomerLimitConfigDO customerLimitConfig = CrmCustomerLimitConfigConvert.INSTANCE.convert(createReqVO); - customerLimitConfigMapper.insert(customerLimitConfig); - // 返回 - return customerLimitConfig.getId(); - } - - @Override - public void updateCustomerLimitConfig(CrmCustomerLimitConfigUpdateReqVO updateReqVO) { - // 校验存在 - validateCustomerLimitConfigExists(updateReqVO.getId()); - validateUserAndDept(updateReqVO.getUserIds(), updateReqVO.getDeptIds()); - // 更新 - CrmCustomerLimitConfigDO updateObj = CrmCustomerLimitConfigConvert.INSTANCE.convert(updateReqVO); - customerLimitConfigMapper.updateById(updateObj); - } - - @Override - public void deleteCustomerLimitConfig(Long id) { - // 校验存在 - validateCustomerLimitConfigExists(id); - // 删除 - customerLimitConfigMapper.deleteById(id); - } - - @Override - public CrmCustomerLimitConfigDO getCustomerLimitConfig(Long id) { - return customerLimitConfigMapper.selectById(id); - } - - @Override - public PageResult getCustomerLimitConfigPage(CrmCustomerLimitConfigPageReqVO pageReqVO) { - return customerLimitConfigMapper.selectPage(pageReqVO); - } - - private void validateCustomerLimitConfigExists(Long id) { - if (customerLimitConfigMapper.selectById(id) == null) { - throw exception(CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); - } - } - - /** - * 校验入参的用户和部门 - * - * @param userIds 用户 ids - * @param deptIds 部门 ids - */ - private void validateUserAndDept(Collection userIds, Collection deptIds) { - deptApi.validateDeptList(deptIds); - adminUserApi.validateUserList(userIds); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigService.java deleted file mode 100644 index 30eb6f581e..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigService.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; - -import jakarta.validation.Valid; - -/** - * 客户公海配置 Service 接口 - * - * @author Wanwan - */ -public interface CrmCustomerPoolConfigService { - - /** - * 获得客户公海配置 - * - * @return 客户公海配置 - */ - CrmCustomerPoolConfigDO getCustomerPoolConfig(); - - /** - * 保存客户公海配置 - * - * @param saveReqVO 更新信息 - */ - void saveCustomerPoolConfig(@Valid CrmCustomerPoolConfigSaveReqVO saveReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java deleted file mode 100644 index 069bb9ab6e..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerPoolConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Objects; - -/** - * 客户公海配置 Service 实现类 - * - * @author Wanwan - */ -@Service -@Validated -public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigService { - @Resource - private CrmCustomerPoolConfigMapper customerPoolConfigMapper; - - /** - * 获得客户公海配置 - * - * @return 客户公海配置 - */ - @Override - public CrmCustomerPoolConfigDO getCustomerPoolConfig() { - return customerPoolConfigMapper.selectOne(new LambdaQueryWrapperX().last("LIMIT 1")); - } - - /** - * 保存客户公海配置 - * - * @param saveReqVO 更新信息 - */ - @Override - public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) { - // 存在,则进行更新 - CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig(); - if (Objects.nonNull(dbConfig)) { - customerPoolConfigMapper.updateById(CrmCustomerConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId())); - return; - } - // 不存在,则进行插入 - customerPoolConfigMapper.insert(CrmCustomerConvert.INSTANCE.convert(saveReqVO)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java deleted file mode 100644 index bf22413d4d..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 客户 Service 接口 - * - * @author Wanwan - */ -public interface CrmCustomerService { - - /** - * 创建客户 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createCustomer(@Valid CrmCustomerCreateReqVO createReqVO, Long userId); - - /** - * 更新客户 - * - * @param updateReqVO 更新信息 - */ - void updateCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO); - - /** - * 删除客户 - * - * @param id 编号 - */ - void deleteCustomer(Long id); - - /** - * 获得客户 - * - * @param id 编号 - * @return 客户 - */ - CrmCustomerDO getCustomer(Long id); - - /** - * 获得客户列表 - * - * @param ids 客户编号数组 - * @return 客户列表 - * @author ljlleo - */ - List getCustomerList(Collection ids); - - /** - * 获得客户分页 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 客户分页 - */ - PageResult getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId); - - /** - * 校验客户是否存在 - * - * @param customerId 客户 id - * @return 客户 - */ - CrmCustomerDO validateCustomer(Long customerId); - - /** - * 客户转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId); - - /** - * 锁定/解锁客户 - * - * @param updateReqVO 更新信息 - */ - void lockCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO); - - // ==================== 公海相关操作 ==================== - - /** - * 客户放入公海 - * - * @param id 客户编号 - */ - void putCustomerPool(Long id); - - /** - * 领取公海客户 - * - * @param ids 要领取的客户编号数组 - * @param ownerUserId 负责人 - */ - void receiveCustomer(List ids, Long ownerUserId); - - /** - * 获取客户列表 - * - * @return 客户列表 - * @author zyna - */ - List getCustomerList(); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java deleted file mode 100644 index e3723c281c..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ /dev/null @@ -1,242 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; - -/** - * 客户 Service 实现类 - * - * @author Wanwan - */ -@Service -@Validated -public class CrmCustomerServiceImpl implements CrmCustomerService { - - @Resource - private CrmCustomerMapper customerMapper; - - @Resource - private CrmPermissionService crmPermissionService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createCustomer(CrmCustomerCreateReqVO createReqVO, Long userId) { - // 插入 - CrmCustomerDO customer = CrmCustomerConvert.INSTANCE.convert(createReqVO); - customerMapper.insert(customer); - - // 创建数据权限 - crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) - .setBizId(customer.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 - return customer.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateCustomer(CrmCustomerUpdateReqVO updateReqVO) { - // 校验存在 - validateCustomerExists(updateReqVO.getId()); - - // 更新 - CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(updateReqVO); - customerMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteCustomer(Long id) { - // 校验存在 - validateCustomerExists(id); - - // 删除 - customerMapper.deleteById(id); - } - - private void validateCustomerExists(Long id) { - if (customerMapper.selectById(id) == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmCustomerDO getCustomer(Long id) { - return customerMapper.selectById(id); - } - - @Override - public List getCustomerList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return customerMapper.selectBatchIds(ids); - } - - @Override - public PageResult getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId) { - boolean admin = false; // TODO 如果是管理员 - return customerMapper.selectPage(pageReqVO, userId, adminUserApi.getSubordinateIds(userId), admin); - } - - /** - * 校验客户是否存在 - * - * @param customerId 客户 id - * @return 客户 - */ - @Override - public CrmCustomerDO validateCustomer(Long customerId) { - CrmCustomerDO customer = getCustomer(customerId); - if (Objects.isNull(customer)) { - throw exception(CUSTOMER_NOT_EXISTS); - } - return customer; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) { - // 1. 校验客户是否存在 - validateCustomer(reqVO.getId()); - - // 2. 数据权限转移 - crmPermissionService.transferPermission( - CrmCustomerConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType())); - - // 3. TODO 记录转移日志 - } - - @Override - public void lockCustomer(CrmCustomerUpdateReqVO updateReqVO) { - // 校验存在 - validateCustomerExists(updateReqVO.getId()); - // TODO @Joey:可以校验下,如果已经对应的锁定状态,报个业务异常;原因是:后续这个业务会记录操作日志,会记录多了; - // TODO @芋艿:业务完善,增加锁定上限; - - // 更新 - CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(updateReqVO); - customerMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void putCustomerPool(Long id) { - // 1. 校验存在 - CrmCustomerDO customer = customerMapper.selectById(id); - if (customer == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - // 1.2. 校验是否为公海数据 - validateCustomerOwnerExists(customer, true); - // 1.3. 校验客户是否锁定 - validateCustomerIsLocked(customer, true); - - // 2. 设置负责人为 NULL - int updateOwnerUserIncr = customerMapper.updateOwnerUserIdById(customer.getId(), null); - if (updateOwnerUserIncr == 0) { - throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL); - } - // 3. 删除负责人数据权限 - crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(), - CrmPermissionLevelEnum.OWNER.getLevel()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void receiveCustomer(List ids, Long ownerUserId) { - // 1.1 校验存在 - List customers = customerMapper.selectBatchIds(ids); - if (customers.size() != ids.size()) { - throw exception(CUSTOMER_NOT_EXISTS); - } - // 1.2. 校验负责人是否存在 - adminUserApi.validateUserList(singletonList(ownerUserId)); - // 1.3. 校验状态 - customers.forEach(customer -> { - // 校验是否已有负责人 - validateCustomerOwnerExists(customer, false); - // 校验是否锁定 - validateCustomerIsLocked(customer, false); - // 校验成交状态 - validateCustomerDeal(customer); - }); - - // 2. 领取公海数据 - List updateCustomers = new ArrayList<>(); - List createPermissions = new ArrayList<>(); - customers.forEach(customer -> { - // 2.1. 设置负责人 - updateCustomers.add(new CrmCustomerDO().setId(customer.getId()).setOwnerUserId(ownerUserId)); - // 2.2. 创建负责人数据权限 - createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) - .setBizId(customer.getId()).setUserId(ownerUserId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - }); - - // 3.1 更新客户负责人 - customerMapper.updateBatch(updateCustomers); - // 3.2 创建负责人数据权限 - crmPermissionService.createPermissionBatch(createPermissions); - } - - private void validateCustomerOwnerExists(CrmCustomerDO customer, Boolean pool) { - if (customer == null) { // 防御一下 - throw exception(CUSTOMER_NOT_EXISTS); - } - // 校验是否为公海数据 - if (pool && customer.getOwnerUserId() == null) { - throw exception(CUSTOMER_IN_POOL, customer.getName()); - } - // 负责人已存在 - if (customer.getOwnerUserId() != null) { - throw exception(CUSTOMER_OWNER_EXISTS, customer.getName()); - } - } - - private void validateCustomerIsLocked(CrmCustomerDO customer, Boolean pool) { - if (customer.getLockStatus()) { - throw exception(pool ? CUSTOMER_LOCKED_PUT_POOL_FAIL : CUSTOMER_LOCKED, customer.getName()); - } - } - - private void validateCustomerDeal(CrmCustomerDO customer) { - if (customer.getDealStatus()) { - throw exception(CUSTOMER_ALREADY_DEAL); - } - } - - @Override - public List getCustomerList() { - return customerMapper.selectList(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java deleted file mode 100644 index 75fb95fda6..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission; - - -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * crm 数据权限 Service 接口 - * - * @author HUIHUI - */ -public interface CrmPermissionService { - - /** - * 创建数据权限 - * - * @param createReqBO 创建信息 - * @return 编号 - */ - Long createPermission(@Valid CrmPermissionCreateReqBO createReqBO); - - /** - * 创建数据权限 - * - * @param createReqBOs 创建信息 - */ - void createPermissionBatch(@Valid List createReqBOs); - - /** - * 更新数据权限 - * - * @param updateReqVO 更新信息 - */ - void updatePermission(CrmPermissionUpdateReqVO updateReqVO); - - /** - * 数据权限转移 - * - * @param crmPermissionTransferReqBO 数据权限转移请求 - */ - void transferPermission(@Valid CrmPermissionTransferReqBO crmPermissionTransferReqBO); - - /** - * 删除数据权限 - * - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() - * @param level 数据权限级别,关联 {@link CrmPermissionLevelEnum} - */ - void deletePermission(Integer bizType, Long bizId, Integer level); - - /** - * 批量删除数据权限 - * - * @param ids 权限编号 - * @param userId 用户编号 - */ - void deletePermissionBatch(Collection ids, Long userId); - - /** - * 删除指定用户数据权限 - * - * @param id 权限编号 - * @param userId 用户编号 - */ - void deleteSelfPermission(Long id, Long userId); - - /** - * 获取数据权限列表,通过 数据类型 x 某个数据 - * - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() - * @return Crm 数据权限列表 - */ - List getPermissionListByBiz(Integer bizType, Long bizId); - - /** - * 获取用户参与的模块数据列表 - * - * @param bizType 模块类型 - * @param userId 用户编号 - * @return 模块数据列表 - */ - List getPermissionListByBizTypeAndUserId(Integer bizType, Long userId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java deleted file mode 100644 index 8ca6b9cdd5..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java +++ /dev/null @@ -1,186 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.permission.CrmPermissionConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.dal.mysql.permission.CrmPermissionMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum.isOwner; - -/** - * CRM 数据权限 Service 接口实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class CrmPermissionServiceImpl implements CrmPermissionService { - - @Resource - private CrmPermissionMapper crmPermissionMapper; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createPermission(CrmPermissionCreateReqBO createReqBO) { - // TODO @puhui999:排重 - // 1. 校验用户是否存在 - adminUserApi.validateUserList(Collections.singletonList(createReqBO.getUserId())); - - // 2. 创建 - CrmPermissionDO permission = CrmPermissionConvert.INSTANCE.convert(createReqBO); - crmPermissionMapper.insert(permission); - return permission.getId(); - } - - @Override - public void createPermissionBatch(List createReqBOs) { - // TODO @puhui999:排重 - // 1. 校验用户是否存在 - adminUserApi.validateUserList(convertSet(createReqBOs, CrmPermissionCreateReqBO::getUserId)); - - // 2. 创建 - List permissions = CrmPermissionConvert.INSTANCE.convertList(createReqBOs); - crmPermissionMapper.insertBatch(permissions); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePermission(CrmPermissionUpdateReqVO updateReqVO) { - // TODO @puhui999:排重 - // 1. 校验存在 - validateCrmPermissionExists(updateReqVO.getIds()); - // 2. 更新 - List updateDO = CrmPermissionConvert.INSTANCE.convertList(updateReqVO); - crmPermissionMapper.updateBatch(updateDO); - } - - private void validateCrmPermissionExists(Collection ids) { - List permissionList = crmPermissionMapper.selectBatchIds(ids); - if (ObjUtil.notEqual(permissionList.size(), ids.size())) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void transferPermission(CrmPermissionTransferReqBO transferReqBO) { - // 1. 校验数据权限:是否是负责人,只有负责人才可以转移 - CrmPermissionDO oldPermission = crmPermissionMapper.selectByBizTypeAndBizIdByUserId( - transferReqBO.getBizType(), transferReqBO.getBizId(), transferReqBO.getUserId()); - String bizTypeName = CrmBizTypeEnum.getNameByType(transferReqBO.getBizType()); - // TODO 校验是否为超级管理员 || 1 - if (oldPermission == null || !isOwner(oldPermission.getLevel())) { - throw exception(CRM_PERMISSION_DENIED, bizTypeName); - } - // 1.1 校验转移对象是否已经是该负责人 - if (ObjUtil.equal(transferReqBO.getNewOwnerUserId(), oldPermission.getUserId())) { - throw exception(CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS, bizTypeName); - } - // 1.2 校验新负责人是否存在 - adminUserApi.validateUserList(Collections.singletonList(transferReqBO.getNewOwnerUserId())); - - // 2. 修改新负责人的权限 - List permissions = crmPermissionMapper.selectByBizTypeAndBizId( - transferReqBO.getBizType(), transferReqBO.getBizId()); // 获得所有数据权限 - CrmPermissionDO permission = CollUtil.findOne(permissions, - item -> ObjUtil.equal(item.getUserId(), transferReqBO.getNewOwnerUserId())); - if (permission == null) { - crmPermissionMapper.insert(new CrmPermissionDO().setBizType(transferReqBO.getBizType()) - .setBizId(transferReqBO.getBizId()).setUserId(transferReqBO.getNewOwnerUserId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - } else { - crmPermissionMapper.updateById(new CrmPermissionDO().setId(permission.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - } - - // 3. 修改老负责人的权限 - if (transferReqBO.getOldOwnerPermissionLevel() != null) { - crmPermissionMapper.updateById(new CrmPermissionDO().setId(oldPermission.getId()) - .setLevel(transferReqBO.getOldOwnerPermissionLevel())); - } else { - crmPermissionMapper.deleteById(oldPermission.getId()); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deletePermission(Integer bizType, Long bizId, Integer level) { - List permissions = crmPermissionMapper.selectListByBizTypeAndBizIdAndLevel( - bizType, bizId, level); - // 校验存在 - if (CollUtil.isEmpty(permissions)) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - - // 删除数据权限 - crmPermissionMapper.deleteBatchIds(convertSet(permissions, CrmPermissionDO::getId)); - } - - @Override - public void deletePermissionBatch(Collection ids, Long userId) { - List permissions = crmPermissionMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(permissions)) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - // 校验:数据权限的模块数据编号是一致的不可能存在两个 - if (convertSet(permissions, CrmPermissionDO::getBizId).size() > 1) { - throw exception(CRM_PERMISSION_DELETE_FAIL); - } - // 校验操作人是否为负责人 - CrmPermissionDO permission = crmPermissionMapper.selectByIdAndUserId(permissions.get(0).getBizId(), userId); - if (!CrmPermissionLevelEnum.isOwner(permission.getLevel())) { - throw exception(CRM_PERMISSION_DELETE_DENIED); - } - - // 删除数据权限 - crmPermissionMapper.deleteBatchIds(ids); - } - - @Override - public void deleteSelfPermission(Long id, Long userId) { - // 校验数据存在且是自己 - CrmPermissionDO permission = crmPermissionMapper.selectByIdAndUserId(id, userId); - if (permission == null) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - // 校验是否是负责人 - if (CrmPermissionLevelEnum.isOwner(permission.getLevel())) { - throw exception(CRM_PERMISSION_DELETE_SELF_PERMISSION_FAIL_EXIST_OWNER); - } - - // 删除 - crmPermissionMapper.deleteById(id); - } - - @Override - public List getPermissionListByBiz(Integer bizType, Long bizId) { - return crmPermissionMapper.selectByBizTypeAndBizId(bizType, bizId); - } - - @Override - public List getPermissionListByBizTypeAndUserId(Integer bizType, Long userId) { - return crmPermissionMapper.selectListByBizTypeAndUserId(bizType, userId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateReqBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateReqBO.java deleted file mode 100644 index f4b4bb3647..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateReqBO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission.bo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * crm 数据权限 Create Req BO - * - * @author HUIHUI - */ -@Data -public class CrmPermissionCreateReqBO { - - /** - * 当前登录用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - - /** - * Crm 类型 - */ - @NotNull(message = "Crm 类型不能为空") - @InEnum(CrmBizTypeEnum.class) - private Integer bizType; - /** - * 数据编号 - */ - @NotNull(message = "Crm 数据编号不能为空") - private Long bizId; - - /** - * 权限级别 - */ - @NotNull(message = "权限级别不能为空") - @InEnum(CrmPermissionLevelEnum.class) - private Integer level; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionTransferReqBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionTransferReqBO.java deleted file mode 100644 index 0e5933c0c7..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionTransferReqBO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission.bo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 数据权限转移 Request BO - * - * @author HUIHUI - */ -@Data -public class CrmPermissionTransferReqBO { - - /** - * 当前登录用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - - /** - * CRM 类型 - */ - @NotNull(message = "Crm 类型不能为空") - @InEnum(CrmBizTypeEnum.class) - private Integer bizType; - /** - * 数据编号 - */ - @NotNull(message = "CRM 数据编号不能为空") - private Long bizId; - - /** - * 新负责人的用户编号 - */ - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateReqBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateReqBO.java deleted file mode 100644 index 0ac4741013..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateReqBO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission.bo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * crm 数据权限 Update Req BO - * - * @author HUIHUI - */ -@Data -public class CrmPermissionUpdateReqBO { - - /** - * 数据权限编号 - */ - @NotNull(message = "数据权限编号不能为空") - private Long id; - - /** - * 当前登录用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - - /** - * 权限级别 - */ - @NotNull(message = "权限级别不能为空") - @InEnum(CrmPermissionLevelEnum.class) - private Integer level; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryService.java deleted file mode 100644 index 56974da114..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryService.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.product; - -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * CRM 产品分类 Service 接口 - * - * @author ZanGe丶 - */ -public interface CrmProductCategoryService { - - /** - * 创建产品分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProductCategory(@Valid CrmProductCategoryCreateReqVO createReqVO); - - /** - * 更新产品分类 - * - * @param updateReqVO 更新信息 - */ - void updateProductCategory(@Valid CrmProductCategoryCreateReqVO updateReqVO); - - /** - * 删除产品分类 - * - * @param id 编号 - */ - void deleteProductCategory(Long id); - - /** - * 获得产品分类 - * - * @param id 编号 - * @return 产品分类 - */ - CrmProductCategoryDO getProductCategory(Long id); - - /** - * 获得产品分类列表 - * - * @param listReqVO 列表请求 - * @return 产品分类列表 - */ - List getProductCategoryList(CrmProductCategoryListReqVO listReqVO); - - /** - * 获得产品分类列表 - * - * @param ids 编号数组 - * @return 产品分类列表 - */ - List getProductCategoryList(Collection ids); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java deleted file mode 100644 index 388f6133b4..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.product; - -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.dal.mysql.product.CrmProductCategoryMapper; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO.PARENT_ID_NULL; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; - -/** - * CRM 产品分类 Service 实现类 - * - * @author ZanGe丶 - */ -@Service -@Validated -public class CrmProductCategoryServiceImpl implements CrmProductCategoryService { - - @Resource(name = "crmProductCategoryMapper") - private CrmProductCategoryMapper productCategoryMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖问题 - private CrmProductService crmProductService; - - @Override - public Long createProductCategory(CrmProductCategoryCreateReqVO createReqVO) { - // 1.1 校验父分类存在 - validateParentProductCategory(createReqVO.getParentId()); - // 1.2 分类名称是否存在 - validateProductNameExists(null, createReqVO.getParentId(), createReqVO.getName()); - // 2. 插入 - CrmProductCategoryDO category = BeanUtils.toBean(createReqVO, CrmProductCategoryDO.class); - productCategoryMapper.insert(category); - return category.getId(); - } - - @Override - public void updateProductCategory(CrmProductCategoryCreateReqVO updateReqVO) { - // 1.1 校验存在 - validateProductCategoryExists(updateReqVO.getId()); - // 1.2 校验父分类存在 - validateParentProductCategory(updateReqVO.getParentId()); - // 1.3 分类名称是否存在 - validateProductNameExists(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); - // 2. 更新 - CrmProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductCategoryDO.class); - productCategoryMapper.updateById(updateObj); - } - - private void validateProductCategoryExists(Long id) { - if (productCategoryMapper.selectById(id) == null) { - throw exception(PRODUCT_CATEGORY_NOT_EXISTS); - } - } - - private void validateParentProductCategory(Long id) { - // 如果是根分类,无需验证 - if (Objects.equals(id, PARENT_ID_NULL)) { - return; - } - // 父分类不存在 - CrmProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(PRODUCT_CATEGORY_PARENT_NOT_EXISTS); - } - // 父分类不能是二级分类 - if (!Objects.equals(category.getParentId(), PARENT_ID_NULL)) { - throw exception(PRODUCT_CATEGORY_PARENT_NOT_FIRST_LEVEL); - } - } - - private void validateProductNameExists(Long id, Long parentId, String name) { - CrmProductCategoryDO category = productCategoryMapper.selectByParentIdAndName(parentId, name); - if (category == null - || category.getId().equals(id)) { - return; - } - throw exception(PRODUCT_CATEGORY_EXISTS); - } - - @Override - public void deleteProductCategory(Long id) { - // TODO zange:参考 mall: ProductCategoryServiceImpl 补充下必要的参数校验; - // 校验存在 - validateProductCategoryExists(id); - // 校验是否还有子分类 - if (productCategoryMapper.selectCountByParentId(id) > 0) { - throw exception(product_CATEGORY_EXISTS_CHILDREN); - } - // 校验是否被产品使用 - if (crmProductService.getProductByCategoryId(id) !=null) { - throw exception(PRODUCT_CATEGORY_USED); - } - // 删除 - productCategoryMapper.deleteById(id); - } - - @Override - public CrmProductCategoryDO getProductCategory(Long id) { - return productCategoryMapper.selectById(id); - } - - @Override - public List getProductCategoryList(CrmProductCategoryListReqVO listReqVO) { - return productCategoryMapper.selectList(listReqVO); - } - - @Override - public List getProductCategoryList(Collection ids) { - return productCategoryMapper.selectBatchIds(ids); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductService.java deleted file mode 100644 index 524df8ddbe..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductService.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * CRM 产品 Service 接口 - * - * @author ZanGe丶 - */ -public interface CrmProductService { - - /** - * 创建产品 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProduct(@Valid CrmProductSaveReqVO createReqVO); - - /** - * 更新产品 - * - * @param updateReqVO 更新信息 - */ - void updateProduct(@Valid CrmProductSaveReqVO updateReqVO); - - /** - * 删除产品 - * - * @param id 编号 - */ - void deleteProduct(Long id); - - /** - * 获得产品 - * - * @param id 编号 - * @return 产品 - */ - CrmProductDO getProduct(Long id); - - /** - * 获得产品列表 - * - * @param ids 编号 - * @return 产品列表 - */ - List getProductList(Collection ids); - - /** - * 获得产品分页 - * - * @param pageReqVO 分页查询 - * @return 产品分页 - */ - PageResult getProductPage(CrmProductPageReqVO pageReqVO); - - /** - * 获得产品 - * - * @param categoryId 分类编号 - * @return 产品 - */ - CrmProductDO getProductByCategoryId(Long categoryId); -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java deleted file mode 100644 index ba7b8ac836..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.product; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import cn.iocoder.yudao.module.crm.dal.mysql.product.CrmProductMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; - -// TODO 芋艿:数据权限 -/** - * CRM 产品 Service 实现类 - * - * @author ZanGe丶 - */ -@Service -@Validated -public class CrmProductServiceImpl implements CrmProductService { - - @Resource(name = "crmProductMapper") - private CrmProductMapper productMapper; - - @Resource - private CrmProductCategoryService productCategoryService; - @Resource - private CrmPermissionService permissionService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - public Long createProduct(CrmProductSaveReqVO createReqVO) { - // 校验产品 - adminUserApi.validateUserList(Collections.singleton(createReqVO.getOwnerUserId())); - validateProductNoDuplicate(null, createReqVO.getNo()); - validateProductCategoryExists(createReqVO.getCategoryId()); - - // 插入产品 - CrmProductDO product = BeanUtils.toBean(createReqVO, CrmProductDO.class); - productMapper.insert(product); - - // 插入数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(product.getOwnerUserId()) - .setBizType(CrmBizTypeEnum.CRM_PRODUCT.getType()).setBizId(product.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - return product.getId(); - } - - @Override - public void updateProduct(CrmProductSaveReqVO updateReqVO) { - // 校验产品 - updateReqVO.setOwnerUserId(null); // 不修改负责人 - validateProductExists(updateReqVO.getId()); - validateProductNoDuplicate(updateReqVO.getId(), updateReqVO.getNo()); - validateProductCategoryExists(updateReqVO.getCategoryId()); - - // 更新产品 - CrmProductDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductDO.class); - productMapper.updateById(updateObj); - } - - private void validateProductExists(Long id) { - CrmProductDO product = productMapper.selectById(id); - if (product == null) { - throw exception(PRODUCT_NOT_EXISTS); - } - } - - private void validateProductNoDuplicate(Long id, String no) { - CrmProductDO product = productMapper.selectByNo(no); - if (product == null - || product.getId().equals(id)) { - return; - } - throw exception(PRODUCT_NO_EXISTS); - } - - private void validateProductCategoryExists(Long categoryId) { - CrmProductCategoryDO category = productCategoryService.getProductCategory(categoryId); - if (category == null) { - throw exception(PRODUCT_CATEGORY_NOT_EXISTS); - } - } - - @Override - public void deleteProduct(Long id) { - // 校验存在 - validateProductExists(id); - // 删除 - productMapper.deleteById(id); - } - - @Override - public CrmProductDO getProduct(Long id) { - return productMapper.selectById(id); - } - - @Override - public List getProductList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return productMapper.selectBatchIds(ids); - } - - @Override - public PageResult getProductPage(CrmProductPageReqVO pageReqVO) { - return productMapper.selectPage(pageReqVO); - } - - @Override - public CrmProductDO getProductByCategoryId(Long categoryId) { - return productMapper.selectOne(new LambdaQueryWrapper().eq(CrmProductDO::getCategoryId, categoryId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/package-info.java deleted file mode 100644 index cae179aeaa..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 产品表 - */ -package cn.iocoder.yudao.module.crm.service.product; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java deleted file mode 100644 index ba8a62d049..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java +++ /dev/null @@ -1,79 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * CRM 回款计划 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmReceivablePlanService { - - /** - * 创建回款计划 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createReceivablePlan(@Valid CrmReceivablePlanCreateReqVO createReqVO); - - /** - * 更新回款计划 - * - * @param updateReqVO 更新信息 - */ - void updateReceivablePlan(@Valid CrmReceivablePlanUpdateReqVO updateReqVO); - - /** - * 删除回款计划 - * - * @param id 编号 - */ - void deleteReceivablePlan(Long id); - - /** - * 获得回款计划 - * - * @param id 编号 - * @return 回款计划 - */ - CrmReceivablePlanDO getReceivablePlan(Long id); - - /** - * 获得回款计划列表 - * - * @param ids 编号 - * @return 回款计划列表 - */ - List getReceivablePlanList(Collection ids); - - /** - * 获得回款计划分页 - * - * 数据权限:基于 {@link CrmReceivablePlanDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 回款计划分页 - */ - PageResult getReceivablePlanPage(CrmReceivablePlanPageReqVO pageReqVO); - - /** - * 获得回款计划分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 回款计划分页 - */ - PageResult getReceivablePlanPageByCustomer(CrmReceivablePlanPageReqVO pageReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java deleted file mode 100644 index 7fe0556901..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java +++ /dev/null @@ -1,128 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivablePlanConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivablePlanMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; - -// TODO @liuhongfeng:参考 CrmReceivableServiceImpl 写的 todo 哈; -// TODO @puhui999:数据权限 -/** - * 回款计划 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { - - @Resource - private CrmReceivablePlanMapper receivablePlanMapper; - - @Resource - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - - @Override - public Long createReceivablePlan(CrmReceivablePlanCreateReqVO createReqVO) { - // 插入 - CrmReceivablePlanDO receivablePlan = CrmReceivablePlanConvert.INSTANCE.convert(createReqVO); - receivablePlan.setFinishStatus(false); - - checkReceivablePlan(receivablePlan); - - receivablePlanMapper.insert(receivablePlan); - // 返回 - return receivablePlan.getId(); - } - - private void checkReceivablePlan(CrmReceivablePlanDO receivablePlan) { - - if(ObjectUtil.isNull(receivablePlan.getContractId())){ - throw exception(CONTRACT_NOT_EXISTS); - } - - CrmContractDO contract = contractService.getContract(receivablePlan.getContractId()); - if(ObjectUtil.isNull(contract)){ - throw exception(CONTRACT_NOT_EXISTS); - } - - CrmCustomerDO customer = customerService.getCustomer(receivablePlan.getCustomerId()); - if(ObjectUtil.isNull(customer)){ - throw exception(CUSTOMER_NOT_EXISTS); - } - - } - - @Override - public void updateReceivablePlan(CrmReceivablePlanUpdateReqVO updateReqVO) { - // 校验存在 - validateReceivablePlanExists(updateReqVO.getId()); - - // 更新 - CrmReceivablePlanDO updateObj = CrmReceivablePlanConvert.INSTANCE.convert(updateReqVO); - receivablePlanMapper.updateById(updateObj); - } - - @Override - public void deleteReceivablePlan(Long id) { - // 校验存在 - validateReceivablePlanExists(id); - // 删除 - receivablePlanMapper.deleteById(id); - } - - private void validateReceivablePlanExists(Long id) { - if (receivablePlanMapper.selectById(id) == null) { - throw exception(RECEIVABLE_PLAN_NOT_EXISTS); - } - } - - @Override - public CrmReceivablePlanDO getReceivablePlan(Long id) { - return receivablePlanMapper.selectById(id); - } - - @Override - public List getReceivablePlanList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return receivablePlanMapper.selectBatchIds(ids); - } - - @Override - public PageResult getReceivablePlanPage(CrmReceivablePlanPageReqVO pageReqVO) { - return receivablePlanMapper.selectPage(pageReqVO); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getReceivablePlanPageByCustomer(CrmReceivablePlanPageReqVO pageReqVO) { - return receivablePlanMapper.selectPageByCustomer(pageReqVO); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java deleted file mode 100644 index bf9e5571b1..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java +++ /dev/null @@ -1,79 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * CRM 回款 Service 接口 - * - * @author 赤焰 - */ -public interface CrmReceivableService { - - /** - * 创建回款 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createReceivable(@Valid CrmReceivableCreateReqVO createReqVO); - - /** - * 更新回款 - * - * @param updateReqVO 更新信息 - */ - void updateReceivable(@Valid CrmReceivableUpdateReqVO updateReqVO); - - /** - * 删除回款 - * - * @param id 编号 - */ - void deleteReceivable(Long id); - - /** - * 获得回款 - * - * @param id 编号 - * @return 回款 - */ - CrmReceivableDO getReceivable(Long id); - - /** - * 获得回款列表 - * - * @param ids 编号 - * @return 回款列表 - */ - List getReceivableList(Collection ids); - - /** - * 获得回款分页 - * - * 数据权限:基于 {@link CrmReceivableDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 回款分页 - */ - PageResult getReceivablePage(CrmReceivablePageReqVO pageReqVO); - - /** - * 获得回款分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 回款分页 - */ - PageResult getReceivablePageByCustomer(CrmReceivablePageReqVO pageReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java deleted file mode 100644 index ac3b71e08c..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivableConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; - -/** - * CRM 回款 Service 实现类 - * - * @author 赤焰 - */ -@Service -@Validated -public class CrmReceivableServiceImpl implements CrmReceivableService { - - @Resource - private CrmReceivableMapper receivableMapper; - - @Resource - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - @Resource - private CrmReceivablePlanService receivablePlanService; - - // TODO @liuhongfeng:创建还款后,是不是什么时候,要更新 plan? - @Override - public Long createReceivable(CrmReceivableCreateReqVO createReqVO) { - // 插入 - CrmReceivableDO receivable = CrmReceivableConvert.INSTANCE.convert(createReqVO); - if (ObjectUtil.isNull(receivable.getAuditStatus())) { - receivable.setAuditStatus(CommonStatusEnum.ENABLE.getStatus()); - } - receivable.setAuditStatus(CrmAuditStatusEnum.DRAFT.getStatus()); - - // TODO @liuhongfeng:一般来说,逻辑的写法,是要先检查,后操作 db;所以,你这个 check 应该放到 CrmReceivableDO receivable 之前; - // 校验 - checkReceivable(receivable); - - receivableMapper.insert(receivable); - return receivable.getId(); - } - - // TODO @liuhongfeng:这里的括号要注意排版; - private void checkReceivable(CrmReceivableDO receivable) { - // TODO @liuhongfeng:这个放在参数校验合适 - if(ObjectUtil.isNull(receivable.getContractId())){ - throw exception(CONTRACT_NOT_EXISTS); - } - - CrmContractDO contract = contractService.getContract(receivable.getContractId()); - if(ObjectUtil.isNull(contract)){ - throw exception(CONTRACT_NOT_EXISTS); - } - - CrmCustomerDO customer = customerService.getCustomer(receivable.getCustomerId()); - if(ObjectUtil.isNull(customer)){ - throw exception(CUSTOMER_NOT_EXISTS); - } - - CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(receivable.getPlanId()); - if(ObjectUtil.isNull(receivablePlan)){ - throw exception(RECEIVABLE_PLAN_NOT_EXISTS); - } - - } - - @Override - public void updateReceivable(CrmReceivableUpdateReqVO updateReqVO) { - // 校验存在 - validateReceivableExists(updateReqVO.getId()); - - // 更新 - CrmReceivableDO updateObj = CrmReceivableConvert.INSTANCE.convert(updateReqVO); - receivableMapper.updateById(updateObj); - } - - @Override - public void deleteReceivable(Long id) { - // 校验存在 - validateReceivableExists(id); - // 删除 - receivableMapper.deleteById(id); - } - - private void validateReceivableExists(Long id) { - if (receivableMapper.selectById(id) == null) { - throw exception(RECEIVABLE_NOT_EXISTS); - } - } - - // TODO @芋艿:数据权限 - @Override - public CrmReceivableDO getReceivable(Long id) { - return receivableMapper.selectById(id); - } - - @Override - public List getReceivableList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return receivableMapper.selectBatchIds(ids); - } - - // TODO @芋艿:数据权限 - @Override - public PageResult getReceivablePage(CrmReceivablePageReqVO pageReqVO) { - return receivableMapper.selectPage(pageReqVO); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getReceivablePageByCustomer(CrmReceivablePageReqVO pageReqVO) { - return receivableMapper.selectPageByCustomer(pageReqVO); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/package-info.java deleted file mode 100644 index 4004b301d0..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 回款 - */ -package cn.iocoder.yudao.module.crm.service.receivable; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmQueryPageUtils.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmQueryPageUtils.java deleted file mode 100644 index 5830a24a34..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmQueryPageUtils.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.crm.util; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneEnum; -import cn.iocoder.yudao.module.crm.framework.vo.CrmBasePageReqVO; -import com.baomidou.mybatisplus.core.toolkit.support.SFunction; -import com.github.yulichang.wrapper.MPJLambdaWrapper; - -import jakarta.annotation.Nullable; -import java.util.Collection; - -/** - * CRM 分页查询工具类 - * - * @author HUIHUI - */ -public class CrmQueryPageUtils { - - // TODO @puhui999:是不是弱化 CrmBasePageReqVO,把 sceneType 作为参数传入。默认其实 pool 不一定要传递的 - /** - * 构造 CRM 数据类型数据分页查询条件 - * - * @param queryMapper 连表查询对象 - * @param reqVO 查询条件 - * @param userId 用户编号 - * @param bizType 数据类型 {@link CrmBizTypeEnum} - * @param bizId 数据编号 - * @param subordinateIds 下属用户编号,可为空 - */ - public static , V extends CrmBasePageReqVO, S> void builderQuery( - T queryMapper, V reqVO, Long userId, - Integer bizType, SFunction bizId, - @Nullable Collection subordinateIds, // TODO @puhui999:subordinateIds 可以优化成 subordinateUserIds - Boolean isAdmin) { - // TODO @puhui999:是不是特殊处理,让这个 util 有状态,这样 isAdmin 直接从这里读取;subordinateIds 也是;这样,可以简化参数; - // 1. 构建数据权限连表条件 - if (ObjUtil.notEqual(isAdmin, Boolean.TRUE)) { // 管理员不需要数据权限 - queryMapper.innerJoin(CrmPermissionDO.class, on -> - on.eq(CrmPermissionDO::getBizType, bizType).eq(CrmPermissionDO::getBizId, bizId) - .eq(CrmPermissionDO::getUserId, userId)); - } - // 2. 拼接公海的查询条件 - if (ObjUtil.equal(reqVO.getPool(), Boolean.TRUE)) { // 情况一:公海 - queryMapper.isNull("owner_user_id"); - } else { // 情况二:不是公海 - queryMapper.isNotNull("owner_user_id"); - } - // 3. 拼接场景的查询条件 - // TODO @puhui999::1 处的数据权限,应该和 3 处的场景是结合的? - // null 时:一种处理 - // 1:一种条件; - // 2:一种条件; - // 3:一种条件; - if (CrmSceneEnum.isOwner(reqVO.getSceneType())) { // 场景一:我负责的数据 - queryMapper.eq("owner_user_id", userId); - } - // TODO puhui999: 这里有一个疑问:如果下属负责的数据权限中没有自己的话还能看吗?回复:不能 - if (CrmSceneEnum.isSubordinate(reqVO.getSceneType()) && CollUtil.isNotEmpty(subordinateIds)) { // 场景三:下属负责的数据 - queryMapper.in("owner_user_id", subordinateIds); - } - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/BusinessStatusTypeServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/BusinessStatusTypeServiceImplTest.java deleted file mode 100644 index 3c039f6447..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/BusinessStatusTypeServiceImplTest.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -// TODO 芋艿:后续再 review -/** - * {@link CrmBusinessStatusTypeServiceImpl} 的单元测试类 - * - * @author ljlleo - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(CrmBusinessStatusTypeServiceImpl.class) -public class BusinessStatusTypeServiceImplTest extends BaseDbUnitTest { - - @Resource - private CrmBusinessStatusTypeServiceImpl businessStatusTypeService; - - @Resource - private CrmBusinessStatusTypeMapper businessStatusTypeMapper; - - @Test - public void testCreateBusinessStatusType_success() { - // 准备参数 - CrmBusinessStatusTypeSaveReqVO createReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class).setId(null); - - // 调用 - Long businessStatusTypeId = businessStatusTypeService.createBusinessStatusType(createReqVO); - // 断言 - assertNotNull(businessStatusTypeId); - // 校验记录的属性是否正确 - CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(businessStatusTypeId); - assertPojoEquals(createReqVO, businessStatusType, "id"); - } - - @Test - public void testUpdateBusinessStatusType_success() { - // mock 数据 - CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class); - businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据 - // 准备参数 - CrmBusinessStatusTypeSaveReqVO updateReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class, o -> { - o.setId(dbBusinessStatusType.getId()); // 设置更新的 ID - }); - - // 调用 - businessStatusTypeService.updateBusinessStatusType(updateReqVO); - // 校验是否更新正确 - CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, businessStatusType); - } - - @Test - public void testUpdateBusinessStatusType_notExists() { - // 准备参数 - CrmBusinessStatusTypeSaveReqVO updateReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> businessStatusTypeService.updateBusinessStatusType(updateReqVO), BUSINESS_STATUS_TYPE_NOT_EXISTS); - } - - @Test - public void testDeleteBusinessStatusType_success() { - // mock 数据 - CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class); - businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbBusinessStatusType.getId(); - - // 调用 - businessStatusTypeService.deleteBusinessStatusType(id); - // 校验数据不存在了 - assertNull(businessStatusTypeMapper.selectById(id)); - } - - @Test - public void testDeleteBusinessStatusType_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> businessStatusTypeService.deleteBusinessStatusType(id), BUSINESS_STATUS_TYPE_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetBusinessStatusTypePage() { - // mock 数据 - CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class, o -> { // 等会查询到 - }); - businessStatusTypeMapper.insert(dbBusinessStatusType); - // 准备参数 - CrmBusinessStatusTypePageReqVO reqVO = new CrmBusinessStatusTypePageReqVO(); - - // 调用 - PageResult pageResult = businessStatusTypeService.getBusinessStatusTypePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbBusinessStatusType, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java deleted file mode 100644 index 6072b72e62..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java +++ /dev/null @@ -1,183 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; - -/** - * {@link CrmBusinessServiceImpl} 的单元测试类 - * - * @author ljlleo - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(CrmBusinessServiceImpl.class) -public class CrmBusinessServiceImplTest extends BaseDbUnitTest { - - @Resource - private CrmBusinessServiceImpl businessService; - - @Resource - private CrmBusinessMapper businessMapper; - - @Test - public void testCreateBusiness_success() { - // 准备参数 - CrmBusinessCreateReqVO reqVO = randomPojo(CrmBusinessCreateReqVO.class); - - // 调用 - Long businessId = businessService.createBusiness(reqVO, getLoginUserId()); - // 断言 - assertNotNull(businessId); - // 校验记录的属性是否正确 - CrmBusinessDO business = businessMapper.selectById(businessId); - assertPojoEquals(reqVO, business); - } - - @Test - public void testUpdateBusiness_success() { - // mock 数据 - CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class); - businessMapper.insert(dbBusiness);// @Sql: 先插入出一条存在的数据 - // 准备参数 - CrmBusinessUpdateReqVO reqVO = randomPojo(CrmBusinessUpdateReqVO.class, o -> { - o.setId(dbBusiness.getId()); // 设置更新的 ID - }); - - // 调用 - businessService.updateBusiness(reqVO); - // 校验是否更新正确 - CrmBusinessDO business = businessMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, business); - } - - @Test - public void testUpdateBusiness_notExists() { - // 准备参数 - CrmBusinessUpdateReqVO reqVO = randomPojo(CrmBusinessUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> businessService.updateBusiness(reqVO), BUSINESS_NOT_EXISTS); - } - - @Test - public void testDeleteBusiness_success() { - // mock 数据 - CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class); - businessMapper.insert(dbBusiness);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbBusiness.getId(); - - // 调用 - businessService.deleteBusiness(id); - // 校验数据不存在了 - assertNull(businessMapper.selectById(id)); - } - - @Test - public void testDeleteBusiness_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> businessService.deleteBusiness(id), BUSINESS_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetBusinessPage() { - // mock 数据 - CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class, o -> { // 等会查询到 - o.setName(null); - o.setStatusTypeId(null); - o.setStatusId(null); - o.setContactNextTime(null); - o.setCustomerId(null); - o.setDealTime(null); - o.setPrice(null); - o.setDiscountPercent(null); - o.setProductPrice(null); - o.setRemark(null); - o.setCreateTime(null); - o.setEndStatus(null); - o.setEndRemark(null); - o.setContactLastTime(null); - o.setFollowUpStatus(null); - }); - businessMapper.insert(dbBusiness); - // 测试 name 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setName(null))); - // 测试 statusTypeId 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusTypeId(null))); - // 测试 statusId 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusId(null))); - // 测试 contactNextTime 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactNextTime(null))); - // 测试 customerId 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCustomerId(null))); - // 测试 dealTime 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDealTime(null))); - // 测试 price 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setPrice(null))); - // 测试 discountPercent 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDiscountPercent(null))); - // 测试 productPrice 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setProductPrice(null))); - // 测试 remark 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRemark(null))); - // 测试 createTime 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCreateTime(null))); - // 测试 endStatus 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndStatus(null))); - // 测试 endRemark 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndRemark(null))); - // 测试 contactLastTime 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactLastTime(null))); - // 测试 followUpStatus 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setFollowUpStatus(null))); - //// 准备参数 - //CrmBusinessPageReqVO reqVO = new CrmBusinessPageReqVO(); - //reqVO.setName(null); - //reqVO.setStatusTypeId(null); - //reqVO.setStatusId(null); - //reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - //reqVO.setCustomerId(null); - //reqVO.setDealTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - //reqVO.setPrice(null); - //reqVO.setDiscountPercent(null); - //reqVO.setProductPrice(null); - //reqVO.setRemark(null); - //reqVO.setOwnerUserId(null); - //reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - //reqVO.setRoUserIds(null); - //reqVO.setRwUserIds(null); - //reqVO.setEndStatus(null); - //reqVO.setEndRemark(null); - //reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - //reqVO.setFollowUpStatus(null); - // - //// 调用 - //PageResult pageResult = businessService.getBusinessPage(reqVO); - //// 断言 - //assertEquals(1, pageResult.getTotal()); - //assertEquals(1, pageResult.getList().size()); - //assertPojoEquals(dbBusiness, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java deleted file mode 100644 index 3bb7dee639..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java +++ /dev/null @@ -1,215 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.clue; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -// TODO 芋艿:单测后续补; -/** - * {@link CrmClueServiceImpl} 的单元测试类 - * - * @author Wanwan - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(CrmClueServiceImpl.class) -public class CrmClueServiceImplTest extends BaseDbUnitTest { - - @Resource - private CrmClueServiceImpl clueService; - - @Resource - private CrmClueMapper clueMapper; - - @Test - public void testCreateClue_success() { - // 准备参数 - CrmClueCreateReqVO reqVO = randomPojo(CrmClueCreateReqVO.class); - - // 调用 - Long clueId = clueService.createClue(reqVO); - // 断言 - assertNotNull(clueId); - // 校验记录的属性是否正确 - CrmClueDO clue = clueMapper.selectById(clueId); - assertPojoEquals(reqVO, clue); - } - - @Test - public void testUpdateClue_success() { - // mock 数据 - CrmClueDO dbClue = randomPojo(CrmClueDO.class); - clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据 - // 准备参数 - CrmClueUpdateReqVO reqVO = randomPojo(CrmClueUpdateReqVO.class, o -> { - o.setId(dbClue.getId()); // 设置更新的 ID - }); - - // 调用 - clueService.updateClue(reqVO); - // 校验是否更新正确 - CrmClueDO clue = clueMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, clue); - } - - @Test - public void testUpdateClue_notExists() { - // 准备参数 - CrmClueUpdateReqVO reqVO = randomPojo(CrmClueUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> clueService.updateClue(reqVO), CLUE_NOT_EXISTS); - } - - @Test - public void testDeleteClue_success() { - // mock 数据 - CrmClueDO dbClue = randomPojo(CrmClueDO.class); - clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbClue.getId(); - - // 调用 - clueService.deleteClue(id); - // 校验数据不存在了 - assertNull(clueMapper.selectById(id)); - } - - @Test - public void testDeleteClue_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> clueService.deleteClue(id), CLUE_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetCluePage() { - // mock 数据 - CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到 - o.setTransformStatus(null); - o.setFollowUpStatus(null); - o.setName(null); - o.setCustomerId(null); - o.setContactNextTime(null); - o.setTelephone(null); - o.setMobile(null); - o.setAddress(null); - o.setContactLastTime(null); - o.setCreateTime(null); - }); - clueMapper.insert(dbClue); - // 测试 transformStatus 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null))); - // 测试 followUpStatus 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null))); - // 测试 name 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null))); - // 测试 customerId 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null))); - // 测试 contactNextTime 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null))); - // 测试 telephone 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null))); - // 测试 mobile 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null))); - // 测试 address 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null))); - // 测试 contactLastTime 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null))); - // 测试 createTime 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null))); - // 准备参数 - CrmCluePageReqVO reqVO = new CrmCluePageReqVO(); - reqVO.setName(null); - reqVO.setTelephone(null); - reqVO.setMobile(null); - - // 调用 - PageResult pageResult = clueService.getCluePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbClue, pageResult.getList().get(0)); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetClueList() { - // mock 数据 - CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到 - o.setTransformStatus(null); - o.setFollowUpStatus(null); - o.setName(null); - o.setCustomerId(null); - o.setContactNextTime(null); - o.setTelephone(null); - o.setMobile(null); - o.setAddress(null); - o.setContactLastTime(null); - o.setCreateTime(null); - }); - clueMapper.insert(dbClue); - // 测试 transformStatus 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null))); - // 测试 followUpStatus 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null))); - // 测试 name 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null))); - // 测试 customerId 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null))); - // 测试 contactNextTime 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null))); - // 测试 telephone 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null))); - // 测试 mobile 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null))); - // 测试 address 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null))); - // 测试 contactLastTime 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null))); - // 测试 createTime 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null))); - // 准备参数 - CrmClueExportReqVO reqVO = new CrmClueExportReqVO(); - reqVO.setTransformStatus(null); - reqVO.setFollowUpStatus(null); - reqVO.setName(null); - reqVO.setCustomerId(null); - reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setTelephone(null); - reqVO.setMobile(null); - reqVO.setAddress(null); - reqVO.setOwnerUserId(null); - reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - List list = clueService.getClueList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbClue, list.get(0)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java deleted file mode 100644 index 35825df191..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link CrmContractServiceImpl} 的单元测试类 - * - * @author dhb52 - */ -@Import(CrmContractServiceImpl.class) -public class ContractServiceImplTest extends BaseDbUnitTest { - - @Resource - private CrmContractServiceImpl contractService; - - @Resource - private CrmContractMapper contractMapper; - - @Test - public void testCreateContract_success() { - // 准备参数 - CrmContractCreateReqVO reqVO = randomPojo(CrmContractCreateReqVO.class); - - // 调用 - Long contractId = contractService.createContract(reqVO, getLoginUserId()); - // 断言 - assertNotNull(contractId); - // 校验记录的属性是否正确 - CrmContractDO contract = contractMapper.selectById(contractId); - assertPojoEquals(reqVO, contract); - } - - @Test - public void testUpdateContract_success() { - // mock 数据 - CrmContractDO dbContract = randomPojo(CrmContractDO.class); - contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据 - // 准备参数 - CrmContractUpdateReqVO reqVO = randomPojo(CrmContractUpdateReqVO.class, o -> { - o.setId(dbContract.getId()); // 设置更新的 ID - }); - - // 调用 - contractService.updateContract(reqVO); - // 校验是否更新正确 - CrmContractDO contract = contractMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, contract); - } - - @Test - public void testUpdateContract_notExists() { - // 准备参数 - CrmContractUpdateReqVO reqVO = randomPojo(CrmContractUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> contractService.updateContract(reqVO), CONTRACT_NOT_EXISTS); - } - - @Test - public void testDeleteContract_success() { - // mock 数据 - CrmContractDO dbContract = randomPojo(CrmContractDO.class); - contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbContract.getId(); - - // 调用 - contractService.deleteContract(id); - // 校验数据不存在了 - assertNull(contractMapper.selectById(id)); - } - - @Test - public void testDeleteContract_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> contractService.deleteContract(id), CONTRACT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetContractPage() { - // mock 数据 - CrmContractDO dbContract = randomPojo(CrmContractDO.class, o -> { // 等会查询到 - o.setName(null); - o.setCustomerId(null); - o.setBusinessId(null); - o.setOrderDate(null); - o.setNo(null); - o.setDiscountPercent(null); - o.setProductPrice(null); - }); - contractMapper.insert(dbContract); - // 测试 name 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setName(null))); - // 测试 customerId 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setCustomerId(null))); - // 测试 no 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setNo(null))); - // 准备参数 - CrmContractPageReqVO reqVO = new CrmContractPageReqVO(); - reqVO.setName(null); - reqVO.setCustomerId(null); - reqVO.setBusinessId(null); - reqVO.setNo(null); - - // 调用 - PageResult pageResult = contractService.getContractPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbContract, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java deleted file mode 100644 index 1d926e6707..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java +++ /dev/null @@ -1,177 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -// TODO 芋艿:单测后续补 - -/** - * {@link CrmCustomerServiceImpl} 的单元测试类 - * - * @author Wanwan - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(CrmCustomerServiceImpl.class) -public class CrmCustomerServiceImplTest extends BaseDbUnitTest { - - @Resource - private CrmCustomerServiceImpl customerService; - - @Resource - private CrmCustomerMapper customerMapper; - @MockBean - private CrmPermissionService permissionService; - - @Test - public void testCreateCustomer_success() { - // 准备参数 - CrmCustomerCreateReqVO reqVO = randomPojo(CrmCustomerCreateReqVO.class); - - // 调用 - Long customerId = customerService.createCustomer(reqVO, getLoginUserId()); - // 断言 - assertNotNull(customerId); - // 校验记录的属性是否正确 - CrmCustomerDO customer = customerMapper.selectById(customerId); - assertPojoEquals(reqVO, customer); - } - - @Test - public void testUpdateCustomer_success() { - // mock 数据 - CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class); - customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据 - // 准备参数 - CrmCustomerUpdateReqVO reqVO = randomPojo(CrmCustomerUpdateReqVO.class, o -> { - o.setId(dbCustomer.getId()); // 设置更新的 ID - }); - - // 调用 - customerService.updateCustomer(reqVO); - // 校验是否更新正确 - CrmCustomerDO customer = customerMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, customer); - } - - @Test - public void testUpdateCustomer_notExists() { - // 准备参数 - CrmCustomerUpdateReqVO reqVO = randomPojo(CrmCustomerUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> customerService.updateCustomer(reqVO), CUSTOMER_NOT_EXISTS); - } - - @Test - public void testDeleteCustomer_success() { - // mock 数据 - CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class); - customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCustomer.getId(); - - // 调用 - customerService.deleteCustomer(id); - // 校验数据不存在了 - assertNull(customerMapper.selectById(id)); - } - - @Test - public void testDeleteCustomer_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> customerService.deleteCustomer(id), CUSTOMER_NOT_EXISTS); - } - - @Test - public void testGetCustomerPage() { - // mock 数据 - CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class, o -> { // 等会查询到 - o.setName("张三"); - o.setMobile("13888888888"); - o.setTelephone("13888888888"); - o.setWebsite("https://yudao.com"); - }); - //customerMapper.insert(dbCustomer); - // 测试 name 不匹配 - //customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setName(""))); - // 测试 mobile 不匹配 - //customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setMobile(null))); - // 测试 telephone 不匹配 - //customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setTelephone(null))); - // 测试 website 不匹配 - //customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null))); - // 准备参数 - CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); - reqVO.setName("张三"); - reqVO.setMobile("13888888888"); - //reqVO.setTelephone(null); - //reqVO.setWebsite(null); - - // 调用 - PageResult pageResult = customerService.getCustomerPage(reqVO, 1L); - // 断言 - //assertEquals(1, pageResult.getTotal()); - //assertEquals(1, pageResult.getList().size()); - //assertPojoEquals(dbCustomer, pageResult.getList().get(0)); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetCustomerList() { - // mock 数据 - CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class, o -> { // 等会查询到 - o.setName(null); - o.setMobile(null); - o.setTelephone(null); - o.setWebsite(null); - }); - customerMapper.insert(dbCustomer); - // 测试 name 不匹配 - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setName(null))); - // 测试 mobile 不匹配 - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setMobile(null))); - // 测试 telephone 不匹配 - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setTelephone(null))); - // 测试 website 不匹配 - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null))); - // 准备参数 - CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); - reqVO.setName("张三"); - reqVO.setMobile("13888888888"); - reqVO.setPageSize(PAGE_SIZE_NONE); - //reqVO.setTelephone(null); - //reqVO.setWebsite(null); - - // 调用 - PageResult pageResult = customerService.getCustomerPage(reqVO, 1L); - // 断言 - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbCustomer, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImplTest.java deleted file mode 100644 index 41ef4a44e3..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImplTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customerlimitconfig; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigServiceImpl; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -// TODO 芋艿:单测后面搞 -/** - * {@link CrmCustomerLimitConfigServiceImpl} 的单元测试类 - * - * @author Wanwan - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(CrmCustomerLimitConfigServiceImpl.class) -public class CrmCustomerLimitConfigServiceImplTest extends BaseDbUnitTest { - - @Resource - private CrmCustomerLimitConfigServiceImpl customerLimitConfigService; - - @Resource - private CrmCustomerLimitConfigMapper customerLimitConfigMapper; - - @Test - public void testCreateCustomerLimitConfig_success() { - // 准备参数 - CrmCustomerLimitConfigCreateReqVO reqVO = randomPojo(CrmCustomerLimitConfigCreateReqVO.class); - - // 调用 - Long customerLimitConfigId = customerLimitConfigService.createCustomerLimitConfig(reqVO); - // 断言 - assertNotNull(customerLimitConfigId); - // 校验记录的属性是否正确 - CrmCustomerLimitConfigDO customerLimitConfig = customerLimitConfigMapper.selectById(customerLimitConfigId); - assertPojoEquals(reqVO, customerLimitConfig); - } - - @Test - public void testUpdateCustomerLimitConfig_success() { - // mock 数据 - CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class); - customerLimitConfigMapper.insert(dbCustomerLimitConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - CrmCustomerLimitConfigUpdateReqVO reqVO = randomPojo(CrmCustomerLimitConfigUpdateReqVO.class, o -> { - o.setId(dbCustomerLimitConfig.getId()); // 设置更新的 ID - }); - - // 调用 - customerLimitConfigService.updateCustomerLimitConfig(reqVO); - // 校验是否更新正确 - CrmCustomerLimitConfigDO customerLimitConfig = customerLimitConfigMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, customerLimitConfig); - } - - @Test - public void testUpdateCustomerLimitConfig_notExists() { - // 准备参数 - CrmCustomerLimitConfigUpdateReqVO reqVO = randomPojo(CrmCustomerLimitConfigUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> customerLimitConfigService.updateCustomerLimitConfig(reqVO), CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); - } - - @Test - public void testDeleteCustomerLimitConfig_success() { - // mock 数据 - CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class); - customerLimitConfigMapper.insert(dbCustomerLimitConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCustomerLimitConfig.getId(); - - // 调用 - customerLimitConfigService.deleteCustomerLimitConfig(id); - // 校验数据不存在了 - assertNull(customerLimitConfigMapper.selectById(id)); - } - - @Test - public void testDeleteCustomerLimitConfig_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> customerLimitConfigService.deleteCustomerLimitConfig(id), CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetCustomerLimitConfigPage() { - // mock 数据 - CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class, o -> { // 等会查询到 - }); - customerLimitConfigMapper.insert(dbCustomerLimitConfig); - // 准备参数 - CrmCustomerLimitConfigPageReqVO reqVO = new CrmCustomerLimitConfigPageReqVO(); - - // 调用 - PageResult pageResult = customerLimitConfigService.getCustomerLimitConfigPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbCustomerLimitConfig, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivablePlanServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivablePlanServiceImplTest.java deleted file mode 100644 index 7fa8986b0c..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivablePlanServiceImplTest.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivablePlanMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_PLAN_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -// TODO 芋艿:后续,需要补充测试用例 -/** - * {@link CrmReceivablePlanServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(CrmReceivablePlanServiceImpl.class) -public class CrmCrmReceivablePlanServiceImplTest extends BaseDbUnitTest { - - @Resource - private CrmReceivablePlanServiceImpl receivablePlanService; - - @Resource - private CrmReceivablePlanMapper crmReceivablePlanMapper; - - @Test - public void testCreateReceivablePlan_success() { - // 准备参数 - CrmReceivablePlanCreateReqVO reqVO = randomPojo(CrmReceivablePlanCreateReqVO.class); - - // 调用 - Long receivablePlanId = receivablePlanService.createReceivablePlan(reqVO); - // 断言 - assertNotNull(receivablePlanId); - // 校验记录的属性是否正确 - CrmReceivablePlanDO receivablePlan = crmReceivablePlanMapper.selectById(receivablePlanId); - assertPojoEquals(reqVO, receivablePlan); - } - - @Test - public void testUpdateReceivablePlan_success() { - // mock 数据 - CrmReceivablePlanDO dbReceivablePlan = randomPojo(CrmReceivablePlanDO.class); - crmReceivablePlanMapper.insert(dbReceivablePlan);// @Sql: 先插入出一条存在的数据 - // 准备参数 - CrmReceivablePlanUpdateReqVO reqVO = randomPojo(CrmReceivablePlanUpdateReqVO.class, o -> { - o.setId(dbReceivablePlan.getId()); // 设置更新的 ID - }); - - // 调用 - receivablePlanService.updateReceivablePlan(reqVO); - // 校验是否更新正确 - CrmReceivablePlanDO receivablePlan = crmReceivablePlanMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, receivablePlan); - } - - @Test - public void testUpdateReceivablePlan_notExists() { - // 准备参数 - CrmReceivablePlanUpdateReqVO reqVO = randomPojo(CrmReceivablePlanUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> receivablePlanService.updateReceivablePlan(reqVO), RECEIVABLE_PLAN_NOT_EXISTS); - } - - @Test - public void testDeleteReceivablePlan_success() { - // mock 数据 - CrmReceivablePlanDO dbReceivablePlan = randomPojo(CrmReceivablePlanDO.class); - crmReceivablePlanMapper.insert(dbReceivablePlan);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbReceivablePlan.getId(); - - // 调用 - receivablePlanService.deleteReceivablePlan(id); - // 校验数据不存在了 - assertNull(crmReceivablePlanMapper.selectById(id)); - } - - @Test - public void testDeleteReceivablePlan_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> receivablePlanService.deleteReceivablePlan(id), RECEIVABLE_PLAN_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetReceivablePlanPage() { - // mock 数据 - CrmReceivablePlanDO dbReceivablePlan = randomPojo(CrmReceivablePlanDO.class, o -> { // 等会查询到 - o.setPeriod(null); - o.setReturnTime(null); - o.setRemindDays(null); - o.setRemindTime(null); - o.setCustomerId(null); - o.setContractId(null); - o.setOwnerUserId(null); - o.setRemark(null); - o.setCreateTime(null); - }); - crmReceivablePlanMapper.insert(dbReceivablePlan); - // 测试 customerId 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCustomerId(null))); - // 测试 contractId 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setContractId(null))); - // 准备参数 - CrmReceivablePlanPageReqVO reqVO = new CrmReceivablePlanPageReqVO(); - reqVO.setCustomerId(null); - reqVO.setContractId(null); - - // 调用 - PageResult pageResult = receivablePlanService.getReceivablePlanPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbReceivablePlan, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java deleted file mode 100644 index 93ac0c99bd..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java +++ /dev/null @@ -1,143 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -// TODO 芋艿:等实现完,在校验下; -/** - * {@link CrmReceivableServiceImpl} 的单元测试类 - * - * @author 赤焰 - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(CrmReceivableServiceImpl.class) -public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest { - - @Resource - private CrmReceivableServiceImpl receivableService; - - @Resource - private CrmReceivableMapper crmReceivableMapper; - - @Test - public void testCreateReceivable_success() { - // 准备参数 - CrmReceivableCreateReqVO reqVO = randomPojo(CrmReceivableCreateReqVO.class); - - // 调用 - Long receivableId = receivableService.createReceivable(reqVO); - // 断言 - assertNotNull(receivableId); - // 校验记录的属性是否正确 - CrmReceivableDO receivable = crmReceivableMapper.selectById(receivableId); - assertPojoEquals(reqVO, receivable); - } - - @Test - public void testUpdateReceivable_success() { - // mock 数据 - CrmReceivableDO dbReceivable = randomPojo(CrmReceivableDO.class); - crmReceivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据 - // 准备参数 - CrmReceivableUpdateReqVO reqVO = randomPojo(CrmReceivableUpdateReqVO.class, o -> { - o.setId(dbReceivable.getId()); // 设置更新的 ID - }); - - // 调用 - receivableService.updateReceivable(reqVO); - // 校验是否更新正确 - CrmReceivableDO receivable = crmReceivableMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, receivable); - } - - @Test - public void testUpdateReceivable_notExists() { - // 准备参数 - CrmReceivableUpdateReqVO reqVO = randomPojo(CrmReceivableUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> receivableService.updateReceivable(reqVO), RECEIVABLE_NOT_EXISTS); - } - - @Test - public void testDeleteReceivable_success() { - // mock 数据 - CrmReceivableDO dbReceivable = randomPojo(CrmReceivableDO.class); - crmReceivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbReceivable.getId(); - - // 调用 - receivableService.deleteReceivable(id); - // 校验数据不存在了 - assertNull(crmReceivableMapper.selectById(id)); - } - - @Test - public void testDeleteReceivable_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> receivableService.deleteReceivable(id), RECEIVABLE_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetReceivablePage() { - // mock 数据 - CrmReceivableDO dbReceivable = randomPojo(CrmReceivableDO.class, o -> { // 等会查询到 - o.setNo(null); - o.setPlanId(null); - o.setCustomerId(null); - o.setContractId(null); - o.setProcessInstanceId(null); - o.setReturnTime(null); - o.setReturnType(null); - o.setPrice(null); - o.setOwnerUserId(null); - o.setSort(null); - o.setAuditStatus(null); - o.setRemark(null); - o.setCreateTime(null); - }); - crmReceivableMapper.insert(dbReceivable); - // 测试 no 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null))); - // 测试 planId 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null))); - // 测试 customerId 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null))); - // 准备参数 - CrmReceivablePageReqVO reqVO = new CrmReceivablePageReqVO(); - reqVO.setNo(null); - reqVO.setPlanId(null); - reqVO.setCustomerId(null); - - // 调用 - PageResult pageResult = receivableService.getReceivablePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbReceivable, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 0f28838da5..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,51 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml deleted file mode 100644 index 1d071e4799..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index 138780eed9..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,11 +0,0 @@ -DELETE FROM "crm_contract"; - -DELETE FROM "crm_clue"; - -DELETE FROM "crm_receivable"; - -DELETE FROM "crm_receivable_plan"; - -DELETE FROM "crm_customer"; - -DELETE FROM "crm_customer_limit_config"; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 9528f3dde3..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,162 +0,0 @@ -CREATE TABLE IF NOT EXISTS "crm_contract" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "customer_id" bigint, - "business_id" bigint, - "process_instance_id" bigint, - "order_date" varchar, - "owner_user_id" bigint, - "no" varchar, - "start_time" varchar, - "end_time" varchar, - "price" int, - "discount_percent" int, - "product_price" int, - "ro_user_ids" varchar, - "rw_user_ids" varchar, - "contact_id" bigint, - "sign_user_id" bigint, - "contact_last_time" varchar, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '合同表'; - -CREATE TABLE IF NOT EXISTS "crm_clue" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "transform_status" bit NOT NULL, - "follow_up_status" bit NOT NULL, - "name" varchar NOT NULL, - "customer_id" bigint NOT NULL, - "contact_next_time" varchar, - "telephone" varchar, - "mobile" varchar, - "address" varchar, - "owner_user_id" bigint, - "contact_last_time" varchar, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '线索表'; - -CREATE TABLE IF NOT EXISTS "crm_receivable" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "no" varchar, - "plan_id" bigint, - "customer_id" bigint, - "contract_id" bigint, - "check_status" int, - "process_instance_id" bigint, - "return_time" varchar, - "return_type" varchar, - "price" varchar, - "owner_user_id" bigint, - "batch_id" bigint, - "sort" int, - "data_scope" int, - "data_scope_dept_ids" varchar, - "status" int NOT NULL, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '回款'; - -CREATE TABLE IF NOT EXISTS "crm_receivable_plan" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "index_no" bigint, - "receivable_id" bigint, - "status" int NOT NULL, - "check_status" varchar, - "process_instance_id" bigint, - "price" varchar, - "return_time" varchar, - "remind_days" bigint, - "remind_time" varchar, - "customer_id" bigint, - "contract_id" bigint, - "owner_user_id" bigint, - "sort" int, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '回款计划'; - -CREATE TABLE IF NOT EXISTS "crm_customer" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(255), - "follow_up_status" int NOT NULL, - "lock_status" int NOT NULL, - "deal_status" int NOT NULL, - "industry_id" int, - "level" int, - "source" int, - "mobile" varchar(255), - "telephone" varchar(255), - "website" varchar(255), - "qq" varchar(255), - "wechat" varchar(255), - "email" varchar(255), - "description" varchar(255), - "remark" varchar(255), - "owner_user_id" bigint, - "area_id" int, - "detail_address" varchar(255), - "contact_last_time" datetime, - "contact_next_time" datetime, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '客户表'; - -CREATE TABLE IF NOT EXISTS "crm_customer_limit_config" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "type" int NOT NULL, - "user_ids" varchar, - "dept_ids" varchar, - "max_count" int NOT NULL, - "deal_count_enabled" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '客户限制配置表'; - -CREATE TABLE IF NOT EXISTS "crm_permission" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "biz_id" bigint NOT NULL, - "biz_type" int NOT NULL, - "user_id" bigint NOT NULL, - "level" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '客户限制配置表'; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/pom.xml b/yudao-module-infra/yudao-module-infra-biz/pom.xml index 4c6cd401bb..50b99a487f 100644 --- a/yudao-module-infra/yudao-module-infra-biz/pom.xml +++ b/yudao-module-infra/yudao-module-infra-biz/pom.xml @@ -80,13 +80,6 @@ yudao-spring-boot-starter-mq - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/DefaultDatabaseQueryTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/DefaultDatabaseQueryTest.java deleted file mode 100644 index a6de8d9eed..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/DefaultDatabaseQueryTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.infra.service; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.generator.query.DefaultQuery; -import com.baomidou.mybatisplus.generator.config.DataSourceConfig; -import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder; -import com.baomidou.mybatisplus.generator.config.po.TableInfo; - -import java.util.List; - -public class DefaultDatabaseQueryTest { - - public static void main(String[] args) { -// DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder("jdbc:oracle:thin:@127.0.0.1:1521:xe", -// "root", "123456").build(); - DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder("jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro", - "root", "123456").build(); -// StrategyConfig strategyConfig = new StrategyConfig.Builder().build(); - - ConfigBuilder builder = new ConfigBuilder(null, dataSourceConfig, null, null, null, null); - - DefaultQuery query = new DefaultQuery(builder); - - long time = System.currentTimeMillis(); - List tableInfos = query.queryTables(); - for (TableInfo tableInfo : tableInfos) { - if (StrUtil.startWithAny(tableInfo.getName().toLowerCase(), "act_", "flw_", "qrtz_")) { - continue; - } - System.out.println(String.format("CREATE SEQUENCE %s_seq MINVALUE 1;", tableInfo.getName())); -// System.out.println(String.format("DELETE FROM %s WHERE deleted = '1';", tableInfo.getName())); - } - System.out.println(tableInfos.size()); - System.out.println(System.currentTimeMillis() - time); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImplTest.java deleted file mode 100644 index 0dac3483ae..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImplTest.java +++ /dev/null @@ -1,556 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.codegen; - -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.CodegenCreateListReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.CodegenUpdateReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.column.CodegenColumnSaveReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table.CodegenTablePageReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table.DatabaseTableRespVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; -import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenColumnMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenTableMapper; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenFrontTypeEnum; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum; -import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties; -import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder; -import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine; -import cn.iocoder.yudao.module.infra.service.db.DatabaseTableService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.baomidou.mybatisplus.generator.config.po.TableField; -import com.baomidou.mybatisplus.generator.config.po.TableInfo; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * {@link CodegenServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(CodegenServiceImpl.class) -public class CodegenServiceImplTest extends BaseDbUnitTest { - - @Resource - private CodegenServiceImpl codegenService; - - @Resource - private CodegenTableMapper codegenTableMapper; - @Resource - private CodegenColumnMapper codegenColumnMapper; - - @MockBean - private DatabaseTableService databaseTableService; - - @MockBean - private AdminUserApi userApi; - - @MockBean - private CodegenBuilder codegenBuilder; - @MockBean - private CodegenEngine codegenEngine; - - @MockBean - private CodegenProperties codegenProperties; - - @Test - public void testCreateCodegenList() { - // 准备参数 - Long userId = randomLongId(); - CodegenCreateListReqVO reqVO = randomPojo(CodegenCreateListReqVO.class, - o -> o.setDataSourceConfigId(1L).setTableNames(Collections.singletonList("t_yunai"))); - // mock 方法(TableInfo) - TableInfo tableInfo = mock(TableInfo.class); - when(databaseTableService.getTable(eq(1L), eq("t_yunai"))) - .thenReturn(tableInfo); - when(tableInfo.getComment()).thenReturn("芋艿"); - // mock 方法(TableInfo fields) - TableField field01 = mock(TableField.class); - when(field01.getComment()).thenReturn("主键"); - TableField field02 = mock(TableField.class); - when(field02.getComment()).thenReturn("名字"); - List fields = Arrays.asList(field01, field02); - when(tableInfo.getFields()).thenReturn(fields); - // mock 方法(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class); - when(codegenBuilder.buildTable(same(tableInfo))).thenReturn(table); - // mock 方法(AdminUserRespDTO) - AdminUserRespDTO user = randomPojo(AdminUserRespDTO.class, o -> o.setNickname("芋头")); - when(userApi.getUser(eq(userId))).thenReturn(user); - // mock 方法(CodegenColumnDO) - List columns = randomPojoList(CodegenColumnDO.class); - when(codegenBuilder.buildColumns(eq(table.getId()), same(fields))) - .thenReturn(columns); - // mock 方法(CodegenProperties) - when(codegenProperties.getFrontType()).thenReturn(CodegenFrontTypeEnum.VUE3.getType()); - - // 调用 - List result = codegenService.createCodegenList(userId, reqVO); - // 断言 - assertEquals(1, result.size()); - // 断言(CodegenTableDO) - CodegenTableDO dbTable = codegenTableMapper.selectList().get(0); - assertPojoEquals(table, dbTable); - assertEquals(1L, dbTable.getDataSourceConfigId()); - assertEquals(CodegenSceneEnum.ADMIN.getScene(), dbTable.getScene()); - assertEquals(CodegenFrontTypeEnum.VUE3.getType(), dbTable.getFrontType()); - assertEquals("芋头", dbTable.getAuthor()); - // 断言(CodegenColumnDO) - List dbColumns = codegenColumnMapper.selectList(); - assertEquals(columns.size(), dbColumns.size()); - assertTrue(dbColumns.get(0).getPrimaryKey()); - for (int i = 0; i < dbColumns.size(); i++) { - assertPojoEquals(columns.get(i), dbColumns.get(i)); - } - } - - @Test - public void testValidateTableInfo() { - // 情况一 - assertServiceException(() -> codegenService.validateTableInfo(null), - CODEGEN_IMPORT_TABLE_NULL); - // 情况二 - TableInfo tableInfo = mock(TableInfo.class); - assertServiceException(() -> codegenService.validateTableInfo(tableInfo), - CODEGEN_TABLE_INFO_TABLE_COMMENT_IS_NULL); - // 情况三 - when(tableInfo.getComment()).thenReturn("芋艿"); - assertServiceException(() -> codegenService.validateTableInfo(tableInfo), - CODEGEN_IMPORT_COLUMNS_NULL); - // 情况四 - TableField field = mock(TableField.class); - when(field.getName()).thenReturn("name"); - when(tableInfo.getFields()).thenReturn(Collections.singletonList(field)); - assertServiceException(() -> codegenService.validateTableInfo(tableInfo), - CODEGEN_TABLE_INFO_COLUMN_COMMENT_IS_NULL, field.getName()); - } - - @Test - public void testUpdateCodegen_notExists() { - // 准备参数 - CodegenUpdateReqVO updateReqVO = randomPojo(CodegenUpdateReqVO.class); - // mock 方法 - - // 调用,并断言 - assertServiceException(() -> codegenService.updateCodegen(updateReqVO), - CODEGEN_TABLE_NOT_EXISTS); - } - - @Test - public void testUpdateCodegen_sub_masterNotExists() { - // mock 数据 - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(table); - // 准备参数 - CodegenUpdateReqVO updateReqVO = randomPojo(CodegenUpdateReqVO.class, - o -> o.getTable().setId(table.getId()) - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType())); - - // 调用,并断言 - assertServiceException(() -> codegenService.updateCodegen(updateReqVO), - CODEGEN_MASTER_TABLE_NOT_EXISTS, updateReqVO.getTable().getMasterTableId()); - } - - @Test - public void testUpdateCodegen_sub_columnNotExists() { - // mock 数据 - CodegenTableDO subTable = randomPojo(CodegenTableDO.class, - o -> o.setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(subTable); - // mock 数据(master) - CodegenTableDO masterTable = randomPojo(CodegenTableDO.class, - o -> o.setTemplateType(CodegenTemplateTypeEnum.MASTER_ERP.getType()) - .setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(masterTable); - // 准备参数 - CodegenUpdateReqVO updateReqVO = randomPojo(CodegenUpdateReqVO.class, - o -> o.getTable().setId(subTable.getId()) - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setMasterTableId(masterTable.getId())); - - // 调用,并断言 - assertServiceException(() -> codegenService.updateCodegen(updateReqVO), - CODEGEN_SUB_COLUMN_NOT_EXISTS, updateReqVO.getTable().getSubJoinColumnId()); - } - - @Test - public void testUpdateCodegen_success() { - // mock 数据 - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setTemplateType(CodegenTemplateTypeEnum.ONE.getType()) - .setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(table); - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column01); - CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column02); - // 准备参数 - CodegenUpdateReqVO updateReqVO = randomPojo(CodegenUpdateReqVO.class, - o -> o.getTable().setId(table.getId()) - .setTemplateType(CodegenTemplateTypeEnum.ONE.getType()) - .setScene(CodegenSceneEnum.ADMIN.getScene())); - CodegenColumnSaveReqVO columnVO01 = randomPojo(CodegenColumnSaveReqVO.class, - o -> o.setId(column01.getId()).setTableId(table.getId())); - CodegenColumnSaveReqVO columnVO02 = randomPojo(CodegenColumnSaveReqVO.class, - o -> o.setId(column02.getId()).setTableId(table.getId())); - updateReqVO.setColumns(Arrays.asList(columnVO01, columnVO02)); - - // 调用 - codegenService.updateCodegen(updateReqVO); - // 断言 - CodegenTableDO dbTable = codegenTableMapper.selectById(table.getId()); - assertPojoEquals(updateReqVO.getTable(), dbTable); - List dbColumns = codegenColumnMapper.selectList(); - assertEquals(2, dbColumns.size()); - assertPojoEquals(columnVO01, dbColumns.get(0)); - assertPojoEquals(columnVO02, dbColumns.get(1)); - } - - @Test - public void testSyncCodegenFromDB() { - // mock 数据(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class, o -> o.setTableName("t_yunai") - .setDataSourceConfigId(1L).setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(table); - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId()) - .setColumnName("id")); - codegenColumnMapper.insert(column01); - CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId()) - .setColumnName("name")); - codegenColumnMapper.insert(column02); - // 准备参数 - Long tableId = table.getId(); - // mock 方法(TableInfo) - TableInfo tableInfo = mock(TableInfo.class); - when(databaseTableService.getTable(eq(1L), eq("t_yunai"))) - .thenReturn(tableInfo); - when(tableInfo.getComment()).thenReturn("芋艿"); - // mock 方法(TableInfo fields) - TableField field01 = mock(TableField.class); - when(field01.getComment()).thenReturn("主键"); - TableField field03 = mock(TableField.class); - when(field03.getComment()).thenReturn("分类"); - List fields = Arrays.asList(field01, field03); - when(tableInfo.getFields()).thenReturn(fields); - when(databaseTableService.getTable(eq(1L), eq("t_yunai"))) - .thenReturn(tableInfo); - // mock 方法(CodegenTableDO) - List newColumns = randomPojoList(CodegenColumnDO.class); - when(codegenBuilder.buildColumns(eq(table.getId()), argThat(tableFields -> { - assertEquals(2, tableFields.size()); - assertSame(tableInfo.getFields(), tableFields); - return true; - }))).thenReturn(newColumns); - - // 调用 - codegenService.syncCodegenFromDB(tableId); - // 断言 - List dbColumns = codegenColumnMapper.selectList(); - assertEquals(newColumns.size(), dbColumns.size()); - assertPojoEquals(newColumns.get(0), dbColumns.get(0)); - assertPojoEquals(newColumns.get(1), dbColumns.get(1)); - } - - @Test - public void testDeleteCodegen_notExists() { - assertServiceException(() -> codegenService.deleteCodegen(randomLongId()), - CODEGEN_TABLE_NOT_EXISTS); - } - - @Test - public void testDeleteCodegen_success() { - // mock 数据 - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(table); - CodegenColumnDO column = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column); - // 准备参数 - Long tableId = table.getId(); - - // 调用 - codegenService.deleteCodegen(tableId); - // 断言 - assertNull(codegenTableMapper.selectById(tableId)); - assertEquals(0, codegenColumnMapper.selectList().size()); - } - - @Test - public void testGetCodegenTableList() { - // mock 数据 - CodegenTableDO table01 = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(table01); - CodegenTableDO table02 = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(table02); - // 准备参数 - Long dataSourceConfigId = table01.getDataSourceConfigId(); - - // 调用 - List result = codegenService.getCodegenTableList(dataSourceConfigId); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(table01, result.get(0)); - } - - @Test - public void testGetCodegenTablePage() { - // mock 数据 - CodegenTableDO tableDO = randomPojo(CodegenTableDO.class, o -> { - o.setTableName("t_yunai"); - o.setTableComment("芋艿"); - o.setClassName("SystemYunai"); - o.setCreateTime(buildTime(2021, 3, 10)); - }).setScene(CodegenSceneEnum.ADMIN.getScene()); - codegenTableMapper.insert(tableDO); - // 测试 tableName 不匹配 - codegenTableMapper.insert(cloneIgnoreId(tableDO, o -> o.setTableName(randomString()))); - // 测试 tableComment 不匹配 - codegenTableMapper.insert(cloneIgnoreId(tableDO, o -> o.setTableComment(randomString()))); - // 测试 className 不匹配 - codegenTableMapper.insert(cloneIgnoreId(tableDO, o -> o.setClassName(randomString()))); - // 测试 createTime 不匹配 - codegenTableMapper.insert(cloneIgnoreId(tableDO, logDO -> logDO.setCreateTime(buildTime(2021, 4, 10)))); - // 准备参数 - CodegenTablePageReqVO reqVO = new CodegenTablePageReqVO(); - reqVO.setTableName("yunai"); - reqVO.setTableComment("芋"); - reqVO.setClassName("Yunai"); - reqVO.setCreateTime(buildBetweenTime(2021, 3, 1, 2021, 3, 31)); - - // 调用 - PageResult pageResult = codegenService.getCodegenTablePage(reqVO); - // 断言,只查到了一条符合条件的 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(tableDO, pageResult.getList().get(0)); - } - - @Test - public void testGetCodegenTable() { - // mock 数据 - CodegenTableDO tableDO = randomPojo(CodegenTableDO.class, o -> o.setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(tableDO); - // 准备参数 - Long id = tableDO.getId(); - - // 调用 - CodegenTableDO result = codegenService.getCodegenTable(id); - // 断言 - assertPojoEquals(tableDO, result); - } - - @Test - public void testGetCodegenColumnListByTableId() { - // mock 数据 - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class); - codegenColumnMapper.insert(column01); - CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class); - codegenColumnMapper.insert(column02); - // 准备参数 - Long tableId = column01.getTableId(); - - // 调用 - List result = codegenService.getCodegenColumnListByTableId(tableId); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(column01, result.get(0)); - } - - @Test - public void testGenerationCodes_tableNotExists() { - assertServiceException(() -> codegenService.generationCodes(randomLongId()), - CODEGEN_TABLE_NOT_EXISTS); - } - - @Test - public void testGenerationCodes_columnNotExists() { - // mock 数据(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType())); - codegenTableMapper.insert(table); - // 准备参数 - Long tableId = table.getId(); - - // 调用,并断言 - assertServiceException(() -> codegenService.generationCodes(tableId), - CODEGEN_COLUMN_NOT_EXISTS); - } - - @Test - public void testGenerationCodes_sub_tableNotExists() { - // mock 数据(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType())); - codegenTableMapper.insert(table); - // mock 数据(CodegenColumnDO) - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column01); - // 准备参数 - Long tableId = table.getId(); - - // 调用,并断言 - assertServiceException(() -> codegenService.generationCodes(tableId), - CODEGEN_MASTER_GENERATION_FAIL_NO_SUB_TABLE); - } - - @Test - public void testGenerationCodes_sub_columnNotExists() { - // mock 数据(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType())); - codegenTableMapper.insert(table); - // mock 数据(CodegenColumnDO) - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column01); - // mock 数据(sub CodegenTableDO) - CodegenTableDO subTable = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setMasterTableId(table.getId())); - codegenTableMapper.insert(subTable); - // 准备参数 - Long tableId = table.getId(); - - // 调用,并断言 - assertServiceException(() -> codegenService.generationCodes(tableId), - CODEGEN_SUB_COLUMN_NOT_EXISTS, subTable.getId()); - } - - @Test - public void testGenerationCodes_one_success() { - // mock 数据(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.ONE.getType())); - codegenTableMapper.insert(table); - // mock 数据(CodegenColumnDO) - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column01); - CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column02); - // mock 执行生成 - Map codes = MapUtil.of(randomString(), randomString()); - when(codegenEngine.execute(eq(table), argThat(columns -> { - assertEquals(2, columns.size()); - assertEquals(column01, columns.get(0)); - assertEquals(column02, columns.get(1)); - return true; - }), isNull(), isNull())).thenReturn(codes); - // 准备参数 - Long tableId = table.getId(); - - // 调用 - Map result = codegenService.generationCodes(tableId); - // 断言 - assertSame(codes, result); - } - - @Test - public void testGenerationCodes_master_success() { - // mock 数据(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType())); - codegenTableMapper.insert(table); - // mock 数据(CodegenColumnDO) - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column01); - CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column02); - // mock 数据(sub CodegenTableDO) - CodegenTableDO subTable = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setMasterTableId(table.getId()) - .setSubJoinColumnId(1024L)); - codegenTableMapper.insert(subTable); - // mock 数据(sub CodegenColumnDO) - CodegenColumnDO subColumn01 = randomPojo(CodegenColumnDO.class, o -> o.setId(1024L).setTableId(subTable.getId())); - codegenColumnMapper.insert(subColumn01); - // mock 执行生成 - Map codes = MapUtil.of(randomString(), randomString()); - when(codegenEngine.execute(eq(table), argThat(columns -> { - assertEquals(2, columns.size()); - assertEquals(column01, columns.get(0)); - assertEquals(column02, columns.get(1)); - return true; - }), argThat(tables -> { - assertEquals(1, tables.size()); - assertPojoEquals(subTable, tables.get(0)); - return true; - }), argThat(columns -> { - assertEquals(1, columns.size()); - assertPojoEquals(subColumn01, columns.size()); - return true; - }))).thenReturn(codes); - // 准备参数 - Long tableId = table.getId(); - - // 调用 - Map result = codegenService.generationCodes(tableId); - // 断言 - assertSame(codes, result); - } - - @Test - public void testGetDatabaseTableList() { - // 准备参数 - Long dataSourceConfigId = randomLongId(); - String name = randomString(); - String comment = randomString(); - // mock 方法 - TableInfo tableInfo01 = mock(TableInfo.class); - when(tableInfo01.getName()).thenReturn("t_yunai"); - when(tableInfo01.getComment()).thenReturn("芋艿"); - TableInfo tableInfo02 = mock(TableInfo.class); - when(tableInfo02.getName()).thenReturn("t_yunai_02"); - when(tableInfo02.getComment()).thenReturn("芋艿_02"); - when(databaseTableService.getTableList(eq(dataSourceConfigId), eq(name), eq(comment))) - .thenReturn(ListUtil.toList(tableInfo01, tableInfo02)); - // mock 数据 - CodegenTableDO tableDO = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTableName("t_yunai_02") - .setDataSourceConfigId(dataSourceConfigId)); - codegenTableMapper.insert(tableDO); - - // 调用 - List result = codegenService.getDatabaseTableList(dataSourceConfigId, name, comment); - // 断言 - assertEquals(1, result.size()); - assertEquals("t_yunai", result.get(0).getName()); - assertEquals("芋艿", result.get(0).getComment()); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilderTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilderTest.java deleted file mode 100644 index 01a55be195..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilderTest.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.codegen.inner; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; -import com.baomidou.mybatisplus.generator.config.po.TableField; -import com.baomidou.mybatisplus.generator.config.po.TableInfo; -import com.baomidou.mybatisplus.generator.config.rules.IColumnType; -import org.apache.ibatis.type.JdbcType; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; - -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class CodegenBuilderTest extends BaseMockitoUnitTest { - - @InjectMocks - private CodegenBuilder codegenBuilder; - - @Test - public void testBuildTable() { - // 准备参数 - TableInfo tableInfo = mock(TableInfo.class); - // mock 方法 - when(tableInfo.getName()).thenReturn("system_user"); - when(tableInfo.getComment()).thenReturn("用户"); - - // 调用 - CodegenTableDO table = codegenBuilder.buildTable(tableInfo); - // 断言 - assertEquals("system_user", table.getTableName()); - assertEquals("用户", table.getTableComment()); - assertEquals("system", table.getModuleName()); - assertEquals("user", table.getBusinessName()); - assertEquals("User", table.getClassName()); - assertEquals("用户", table.getClassComment()); - } - - @Test - public void testBuildColumns() { - // 准备参数 - Long tableId = randomLongId(); - TableField tableField = mock(TableField.class); - List tableFields = Collections.singletonList(tableField); - // mock 方法 - TableField.MetaInfo metaInfo = mock(TableField.MetaInfo.class); - when(tableField.getMetaInfo()).thenReturn(metaInfo); - when(metaInfo.getJdbcType()).thenReturn(JdbcType.BIGINT); - when(tableField.getComment()).thenReturn("编号"); - when(tableField.isKeyFlag()).thenReturn(true); - when(tableField.isKeyIdentityFlag()).thenReturn(true); - IColumnType columnType = mock(IColumnType.class); - when(tableField.getColumnType()).thenReturn(columnType); - when(columnType.getType()).thenReturn("Long"); - when(tableField.getName()).thenReturn("id2"); - when(tableField.getPropertyName()).thenReturn("id"); - - // 调用 - List columns = codegenBuilder.buildColumns(tableId, tableFields); - // 断言 - assertEquals(1, columns.size()); - CodegenColumnDO column = columns.get(0); - assertEquals(tableId, column.getTableId()); - assertEquals("id2", column.getColumnName()); - assertEquals("BIGINT", column.getDataType()); - assertEquals("编号", column.getColumnComment()); - assertFalse(column.getNullable()); - assertTrue(column.getPrimaryKey()); - assertTrue(column.getAutoIncrement()); - assertEquals(1, column.getOrdinalPosition()); - assertEquals("Long", column.getJavaType()); - assertEquals("id", column.getJavaField()); - assertNull(column.getDictType()); - assertNotNull(column.getExample()); - assertFalse(column.getCreateOperation()); - assertTrue(column.getUpdateOperation()); - assertFalse(column.getListOperation()); - assertEquals("=", column.getListOperationCondition()); - assertTrue(column.getListOperationResult()); - assertEquals("input", column.getHtmlType()); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java deleted file mode 100644 index 5176af1c7f..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.codegen.inner; - -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.io.resource.ResourceUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.core.util.ZipUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; -import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties; -import org.junit.jupiter.api.BeforeEach; -import org.mockito.InjectMocks; -import org.mockito.Spy; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * {@link CodegenEngine} 的单元测试抽象基类 - * - * @author 芋道源码 - */ -public abstract class CodegenEngineAbstractTest extends BaseMockitoUnitTest { - - /** - * 测试文件资源目录 - */ - private String resourcesPath = ""; - - @InjectMocks - protected CodegenEngine codegenEngine; - - @Spy - protected CodegenProperties codegenProperties = new CodegenProperties() - .setBasePackage("cn.iocoder.yudao"); - - @BeforeEach - public void setUp() { - codegenEngine.initGlobalBindingMap(); - // 获取测试文件 resources 路径 - String absolutePath = FileUtil.getAbsolutePath("application-unit-test.yaml"); - // 系统不一样生成的文件也有差异,那就各自生成各自的 - resourcesPath = absolutePath.split("/target")[0] + "/src/test/resources/codegen/"; - } - - protected static CodegenTableDO getTable(String name) { - String content = ResourceUtil.readUtf8Str("codegen/table/" + name + ".json"); - return JsonUtils.parseObject(content, "table", CodegenTableDO.class); - } - - protected static List getColumnList(String name) { - String content = ResourceUtil.readUtf8Str("codegen/table/" + name + ".json"); - List list = JsonUtils.parseArray(content, "columns", CodegenColumnDO.class); - list.forEach(column -> { - if (column.getNullable() == null) { - column.setNullable(false); - } - if (column.getCreateOperation() == null) { - column.setCreateOperation(false); - } - if (column.getUpdateOperation() == null) { - column.setUpdateOperation(false); - } - if (column.getListOperation() == null) { - column.setListOperation(false); - } - if (column.getListOperationResult() == null) { - column.setListOperationResult(false); - } - }); - return list; - } - - @SuppressWarnings("rawtypes") - protected static void assertResult(Map result, String path) { - String assertContent = ResourceUtil.readUtf8Str("codegen/" + path + "/assert.json"); - List asserts = JsonUtils.parseArray(assertContent, HashMap.class); - assertEquals(asserts.size(), result.size()); - // 校验每个文件 - asserts.forEach(assertMap -> { - String contentPath = (String) assertMap.get("contentPath"); - String filePath = (String) assertMap.get("filePath"); - String content = ResourceUtil.readUtf8Str("codegen/" + path + "/" + contentPath); - assertEquals(content, result.get(filePath), filePath + ":不匹配"); - }); - } - - // ==================== 调试专用 ==================== - - /** - * 【调试使用】将生成的代码,写入到文件 - * - * @param result 生成的代码 - * @param path 写入文件的路径 - */ - protected void writeFile(Map result, String path) { - // 生成压缩包 - String[] paths = result.keySet().toArray(new String[0]); - ByteArrayInputStream[] ins = result.values().stream().map(IoUtil::toUtf8Stream).toArray(ByteArrayInputStream[]::new); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - ZipUtil.zip(outputStream, paths, ins); - // 写入文件 - FileUtil.writeBytes(outputStream.toByteArray(), path); - } - - /** - * 【调试使用】将生成的结果,写入到文件 - * - * @param result 生成的代码 - * @param basePath 写入文件的路径(绝对路径) - */ - protected void writeResult(Map result, String basePath) { - // 写入文件内容 - List> asserts = new ArrayList<>(); - result.forEach((filePath, fileContent) -> { - String lastFilePath = StrUtil.subAfter(filePath, '/', true); - String contentPath = StrUtil.subAfter(lastFilePath, '.', true) - + '/' + StrUtil.subBefore(lastFilePath, '.', true); - asserts.add(MapUtil.builder().put("filePath", filePath) - .put("contentPath", contentPath).build()); - FileUtil.writeUtf8String(fileContent, basePath + "/" + contentPath); - }); - // 写入 assert.json 文件 - FileUtil.writeUtf8String(JsonUtils.toJsonPrettyString(asserts), basePath + "/assert.json"); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue2Test.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue2Test.java deleted file mode 100644 index 94d24bed14..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue2Test.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.codegen.inner; - -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenFrontTypeEnum; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * {@link CodegenEngine} 的 Vue2 + Element UI 单元测试 - * - * @author 芋道源码 - */ -@Disabled -public class CodegenEngineVue2Test extends CodegenEngineAbstractTest { - - @Test - public void testExecute_vue2_one() { - // 准备参数 - CodegenTableDO table = getTable("student") - .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) - .setTemplateType(CodegenTemplateTypeEnum.ONE.getType()); - List columns = getColumnList("student"); - - // 调用 - Map result = codegenEngine.execute(table, columns, null, null); - // 生成测试文件 - //writeResult(result, resourcesPath + "/vue2_one"); - // 断言 - assertResult(result, "/vue2_one"); - } - - @Test - public void testExecute_vue2_tree() { - // 准备参数 - CodegenTableDO table = getTable("category") - .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) - .setTemplateType(CodegenTemplateTypeEnum.TREE.getType()); - List columns = getColumnList("category"); - - // 调用 - Map result = codegenEngine.execute(table, columns, null, null); - // 生成测试文件 - //writeResult(result, resourcesPath + "/vue2_tree"); - // 断言 - assertResult(result, "/vue2_tree"); -// writeFile(result, "/Users/yunai/test/demo66.zip"); - } - - @Test - public void testExecute_vue2_master_normal() { - testExecute_vue2_master(CodegenTemplateTypeEnum.MASTER_NORMAL, "/vue2_master_normal"); - } - - @Test - public void testExecute_vue2_master_erp() { - testExecute_vue2_master(CodegenTemplateTypeEnum.MASTER_ERP, "/vue2_master_erp"); - } - - @Test - public void testExecute_vue2_master_inner() { - testExecute_vue2_master(CodegenTemplateTypeEnum.MASTER_INNER, "/vue2_master_inner"); - } - - private void testExecute_vue2_master(CodegenTemplateTypeEnum templateType, - String path) { - // 准备参数 - CodegenTableDO table = getTable("student") - .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) - .setTemplateType(templateType.getType()); - List columns = getColumnList("student"); - // 准备参数(子表) - CodegenTableDO contactTable = getTable("contact") - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) - .setSubJoinColumnId(100L).setSubJoinMany(true); - List contactColumns = getColumnList("contact"); - // 准备参数(班主任) - CodegenTableDO teacherTable = getTable("teacher") - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) - .setSubJoinColumnId(200L).setSubJoinMany(false); - List teacherColumns = getColumnList("teacher"); - - // 调用 - Map result = codegenEngine.execute(table, columns, - Arrays.asList(contactTable, teacherTable), Arrays.asList(contactColumns, teacherColumns)); - // 生成测试文件 - //writeResult(result, resourcesPath + path); - // 断言 - assertResult(result, path); -// writeFile(result, "/Users/yunai/test/demo11.zip"); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue3Test.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue3Test.java deleted file mode 100644 index 4684db78c7..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue3Test.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.codegen.inner; - -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenFrontTypeEnum; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * {@link CodegenEngine} 的 Vue2 + Element Plus 单元测试 - * - * @author 芋道源码 - */ -@Disabled -public class CodegenEngineVue3Test extends CodegenEngineAbstractTest { - - @Test - public void testExecute_vue3_one() { - // 准备参数 - CodegenTableDO table = getTable("student") - .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) - .setTemplateType(CodegenTemplateTypeEnum.ONE.getType()); - List columns = getColumnList("student"); - - // 调用 - Map result = codegenEngine.execute(table, columns, null, null); - // 生成测试文件 - //writeResult(result, resourcesPath + "/vue3_one"); - // 断言 - assertResult(result, "/vue3_one"); - } - - @Test - public void testExecute_vue3_tree() { - // 准备参数 - CodegenTableDO table = getTable("category") - .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) - .setTemplateType(CodegenTemplateTypeEnum.TREE.getType()); - List columns = getColumnList("category"); - - // 调用 - Map result = codegenEngine.execute(table, columns, null, null); - // 生成测试文件 - //writeResult(result, resourcesPath + "/vue3_tree"); - // 断言 - assertResult(result, "/vue3_tree"); -// writeFile(result, "/Users/yunai/test/demo66.zip"); - } - - @Test - public void testExecute_vue3_master_normal() { - testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_NORMAL, "/vue3_master_normal"); - } - - @Test - public void testExecute_vue3_master_erp() { - testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_ERP, "/vue3_master_erp"); - } - - @Test - public void testExecute_vue3_master_inner() { - testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_INNER, "/vue3_master_inner"); - } - - private void testExecute_vue3_master(CodegenTemplateTypeEnum templateType, - String path) { - // 准备参数 - CodegenTableDO table = getTable("student") - .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) - .setTemplateType(templateType.getType()); - List columns = getColumnList("student"); - // 准备参数(子表) - CodegenTableDO contactTable = getTable("contact") - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) - .setSubJoinColumnId(100L).setSubJoinMany(true); - List contactColumns = getColumnList("contact"); - // 准备参数(班主任) - CodegenTableDO teacherTable = getTable("teacher") - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) - .setSubJoinColumnId(200L).setSubJoinMany(false); - List teacherColumns = getColumnList("teacher"); - - // 调用 - Map result = codegenEngine.execute(table, columns, - Arrays.asList(contactTable, teacherTable), Arrays.asList(contactColumns, teacherColumns)); - // 生成测试文件 - //writeResult(result, resourcesPath + path); - // 断言 - assertResult(result, path); - // writeFile(result, "/Users/yunai/test/demo11.zip"); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java deleted file mode 100644 index 8459abbd92..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java +++ /dev/null @@ -1,219 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.config; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.framework.test.core.util.RandomUtils; -import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigPageReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigSaveReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO; -import cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigMapper; -import cn.iocoder.yudao.module.infra.enums.config.ConfigTypeEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; - -@Import(ConfigServiceImpl.class) -public class ConfigServiceImplTest extends BaseDbUnitTest { - - @Resource - private ConfigServiceImpl configService; - - @Resource - private ConfigMapper configMapper; - - @Test - public void testCreateConfig_success() { - // 准备参数 - ConfigSaveReqVO reqVO = randomPojo(ConfigSaveReqVO.class) - .setId(null); // 防止 id 被赋值,导致唯一性校验失败 - - // 调用 - Long configId = configService.createConfig(reqVO); - // 断言 - assertNotNull(configId); - // 校验记录的属性是否正确 - ConfigDO config = configMapper.selectById(configId); - assertPojoEquals(reqVO, config, "id"); - assertEquals(ConfigTypeEnum.CUSTOM.getType(), config.getType()); - } - - @Test - public void testUpdateConfig_success() { - // mock 数据 - ConfigDO dbConfig = randomConfigDO(); - configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - ConfigSaveReqVO reqVO = randomPojo(ConfigSaveReqVO.class, o -> { - o.setId(dbConfig.getId()); // 设置更新的 ID - }); - - // 调用 - configService.updateConfig(reqVO); - // 校验是否更新正确 - ConfigDO config = configMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, config); - } - - @Test - public void testDeleteConfig_success() { - // mock 数据 - ConfigDO dbConfig = randomConfigDO(o -> { - o.setType(ConfigTypeEnum.CUSTOM.getType()); // 只能删除 CUSTOM 类型 - }); - configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbConfig.getId(); - - // 调用 - configService.deleteConfig(id); - // 校验数据不存在了 - assertNull(configMapper.selectById(id)); - } - - @Test - public void testDeleteConfig_canNotDeleteSystemType() { - // mock 数据 - ConfigDO dbConfig = randomConfigDO(o -> { - o.setType(ConfigTypeEnum.SYSTEM.getType()); // SYSTEM 不允许删除 - }); - configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbConfig.getId(); - - // 调用, 并断言异常 - assertServiceException(() -> configService.deleteConfig(id), CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE); - } - - @Test - public void testValidateConfigExists_success() { - // mock 数据 - ConfigDO dbConfigDO = randomConfigDO(); - configMapper.insert(dbConfigDO);// @Sql: 先插入出一条存在的数据 - - // 调用成功 - configService.validateConfigExists(dbConfigDO.getId()); - } - - @Test - public void testValidateConfigExist_notExists() { - assertServiceException(() -> configService.validateConfigExists(randomLongId()), CONFIG_NOT_EXISTS); - } - - @Test - public void testValidateConfigKeyUnique_success() { - // 调用,成功 - configService.validateConfigKeyUnique(randomLongId(), randomString()); - } - - @Test - public void testValidateConfigKeyUnique_keyDuplicateForCreate() { - // 准备参数 - String key = randomString(); - // mock 数据 - configMapper.insert(randomConfigDO(o -> o.setConfigKey(key))); - - // 调用,校验异常 - assertServiceException(() -> configService.validateConfigKeyUnique(null, key), - CONFIG_KEY_DUPLICATE); - } - - @Test - public void testValidateConfigKeyUnique_keyDuplicateForUpdate() { - // 准备参数 - Long id = randomLongId(); - String key = randomString(); - // mock 数据 - configMapper.insert(randomConfigDO(o -> o.setConfigKey(key))); - - // 调用,校验异常 - assertServiceException(() -> configService.validateConfigKeyUnique(id, key), - CONFIG_KEY_DUPLICATE); - } - - @Test - public void testGetConfigPage() { - // mock 数据 - ConfigDO dbConfig = randomConfigDO(o -> { // 等会查询到 - o.setName("芋艿"); - o.setConfigKey("yunai"); - o.setType(ConfigTypeEnum.SYSTEM.getType()); - o.setCreateTime(buildTime(2021, 2, 1)); - }); - configMapper.insert(dbConfig); - // 测试 name 不匹配 - configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setName("土豆"))); - // 测试 key 不匹配 - configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setConfigKey("tudou"))); - // 测试 type 不匹配 - configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setType(ConfigTypeEnum.CUSTOM.getType()))); - // 测试 createTime 不匹配 - configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setCreateTime(buildTime(2021, 1, 1)))); - // 准备参数 - ConfigPageReqVO reqVO = new ConfigPageReqVO(); - reqVO.setName("艿"); - reqVO.setKey("nai"); - reqVO.setType(ConfigTypeEnum.SYSTEM.getType()); - reqVO.setCreateTime(buildBetweenTime(2021, 1, 15, 2021, 2, 15)); - - // 调用 - PageResult pageResult = configService.getConfigPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbConfig, pageResult.getList().get(0)); - } - - @Test - public void testGetConfig() { - // mock 数据 - ConfigDO dbConfig = randomConfigDO(); - configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbConfig.getId(); - - // 调用 - ConfigDO config = configService.getConfig(id); - // 断言 - assertNotNull(config); - assertPojoEquals(dbConfig, config); - } - - @Test - public void testGetConfigByKey() { - // mock 数据 - ConfigDO dbConfig = randomConfigDO(); - configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - String key = dbConfig.getConfigKey(); - - // 调用 - ConfigDO config = configService.getConfigByKey(key); - // 断言 - assertNotNull(config); - assertPojoEquals(dbConfig, config); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static ConfigDO randomConfigDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setType(randomEle(ConfigTypeEnum.values()).getType()); // 保证 key 的范围 - }; - return RandomUtils.randomPojo(ConfigDO.class, ArrayUtils.append(consumer, consumers)); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java deleted file mode 100755 index 4be9e28589..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java +++ /dev/null @@ -1,208 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.db; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ReflectUtil; -import cn.hutool.crypto.symmetric.AES; -import cn.iocoder.yudao.framework.mybatis.core.type.EncryptTypeHandler; -import cn.iocoder.yudao.framework.mybatis.core.util.JdbcUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigSaveReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO; -import cn.iocoder.yudao.module.infra.dal.mysql.db.DataSourceConfigMapper; -import com.baomidou.dynamic.datasource.creator.DataSourceProperty; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.mockito.stubbing.Answer; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.DATA_SOURCE_CONFIG_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.when; - -/** - * {@link DataSourceConfigServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(DataSourceConfigServiceImpl.class) -public class DataSourceConfigServiceImplTest extends BaseDbUnitTest { - - @Resource - private DataSourceConfigServiceImpl dataSourceConfigService; - - @Resource - private DataSourceConfigMapper dataSourceConfigMapper; - - @MockBean - private AES aes; - - @MockBean - private DynamicDataSourceProperties dynamicDataSourceProperties; - - @BeforeEach - public void setUp() { - // mock 一个空实现的 StringEncryptor,避免 EncryptTypeHandler 报错 - ReflectUtil.setFieldValue(EncryptTypeHandler.class, "aes", aes); - when(aes.encryptBase64(anyString())).then((Answer) invocation -> invocation.getArgument(0)); - when(aes.decryptStr(anyString())).then((Answer) invocation -> invocation.getArgument(0)); - - // mock DynamicDataSourceProperties - when(dynamicDataSourceProperties.getPrimary()).thenReturn("primary"); - DataSourceProperty dataSourceProperty = new DataSourceProperty(); - dataSourceProperty.setUrl("http://localhost:3306"); - dataSourceProperty.setUsername("yunai"); - dataSourceProperty.setPassword("tudou"); - when(dynamicDataSourceProperties.getDatasource()).thenReturn(MapUtil.of("primary", dataSourceProperty)); - } - - @Test - public void testCreateDataSourceConfig_success() { - try (MockedStatic databaseUtilsMock = mockStatic(JdbcUtils.class)) { - // 准备参数 - DataSourceConfigSaveReqVO reqVO = randomPojo(DataSourceConfigSaveReqVO.class) - .setId(null); // 避免 id 被设置 - // mock 方法 - databaseUtilsMock.when(() -> JdbcUtils.isConnectionOK(eq(reqVO.getUrl()), - eq(reqVO.getUsername()), eq(reqVO.getPassword()))).thenReturn(true); - - // 调用 - Long dataSourceConfigId = dataSourceConfigService.createDataSourceConfig(reqVO); - // 断言 - assertNotNull(dataSourceConfigId); - // 校验记录的属性是否正确 - DataSourceConfigDO dataSourceConfig = dataSourceConfigMapper.selectById(dataSourceConfigId); - assertPojoEquals(reqVO, dataSourceConfig, "id"); - } - } - - @Test - public void testUpdateDataSourceConfig_success() { - try (MockedStatic databaseUtilsMock = mockStatic(JdbcUtils.class)) { - // mock 数据 - DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); - dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - DataSourceConfigSaveReqVO reqVO = randomPojo(DataSourceConfigSaveReqVO.class, o -> { - o.setId(dbDataSourceConfig.getId()); // 设置更新的 ID - }); - // mock 方法 - databaseUtilsMock.when(() -> JdbcUtils.isConnectionOK(eq(reqVO.getUrl()), - eq(reqVO.getUsername()), eq(reqVO.getPassword()))).thenReturn(true); - - // 调用 - dataSourceConfigService.updateDataSourceConfig(reqVO); - // 校验是否更新正确 - DataSourceConfigDO dataSourceConfig = dataSourceConfigMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, dataSourceConfig); - } - } - - @Test - public void testUpdateDataSourceConfig_notExists() { - // 准备参数 - DataSourceConfigSaveReqVO reqVO = randomPojo(DataSourceConfigSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> dataSourceConfigService.updateDataSourceConfig(reqVO), DATA_SOURCE_CONFIG_NOT_EXISTS); - } - - @Test - public void testDeleteDataSourceConfig_success() { - // mock 数据 - DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); - dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDataSourceConfig.getId(); - - // 调用 - dataSourceConfigService.deleteDataSourceConfig(id); - // 校验数据不存在了 - assertNull(dataSourceConfigMapper.selectById(id)); - } - - @Test - public void testDeleteDataSourceConfig_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> dataSourceConfigService.deleteDataSourceConfig(id), DATA_SOURCE_CONFIG_NOT_EXISTS); - } - - @Test // 测试使用 password 查询,可以查询到数据 - public void testSelectPassword() { - // mock 数据 - DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); - dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 - - // 调用 - DataSourceConfigDO result = dataSourceConfigMapper.selectOne(DataSourceConfigDO::getPassword, - EncryptTypeHandler.encrypt(dbDataSourceConfig.getPassword())); - assertPojoEquals(dbDataSourceConfig, result); - } - - @Test - public void testGetDataSourceConfig_master() { - // 准备参数 - Long id = 0L; - // mock 方法 - - // 调用 - DataSourceConfigDO dataSourceConfig = dataSourceConfigService.getDataSourceConfig(id); - // 断言 - assertEquals(id, dataSourceConfig.getId()); - assertEquals("primary", dataSourceConfig.getName()); - assertEquals("http://localhost:3306", dataSourceConfig.getUrl()); - assertEquals("yunai", dataSourceConfig.getUsername()); - assertEquals("tudou", dataSourceConfig.getPassword()); - } - - @Test - public void testGetDataSourceConfig_normal() { - // mock 数据 - DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); - dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDataSourceConfig.getId(); - - // 调用 - DataSourceConfigDO dataSourceConfig = dataSourceConfigService.getDataSourceConfig(id); - // 断言 - assertPojoEquals(dbDataSourceConfig, dataSourceConfig); - } - - @Test - public void testGetDataSourceConfigList() { - // mock 数据 - DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); - dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - - // 调用 - List dataSourceConfigList = dataSourceConfigService.getDataSourceConfigList(); - // 断言 - assertEquals(2, dataSourceConfigList.size()); - // master - assertEquals(0L, dataSourceConfigList.get(0).getId()); - assertEquals("primary", dataSourceConfigList.get(0).getName()); - assertEquals("http://localhost:3306", dataSourceConfigList.get(0).getUrl()); - assertEquals("yunai", dataSourceConfigList.get(0).getUsername()); - assertEquals("tudou", dataSourceConfigList.get(0).getPassword()); - // normal - assertPojoEquals(dbDataSourceConfig, dataSourceConfigList.get(1)); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java deleted file mode 100644 index e7a5072a04..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.db; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO; -import com.baomidou.mybatisplus.generator.config.po.TableField; -import com.baomidou.mybatisplus.generator.config.po.TableInfo; -import com.baomidou.mybatisplus.generator.config.rules.DbColumnType; -import org.apache.ibatis.type.JdbcType; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -@Import(DatabaseTableServiceImpl.class) -public class DatabaseTableServiceImplTest extends BaseDbUnitTest { - - @Resource - private DatabaseTableServiceImpl databaseTableService; - - @MockBean - private DataSourceConfigService dataSourceConfigService; - - @Test - public void testGetTableList() { - // 准备参数 - Long dataSourceConfigId = randomLongId(); - // mock 方法 - DataSourceConfigDO dataSourceConfig = new DataSourceConfigDO().setUsername("sa").setPassword("") - .setUrl("jdbc:h2:mem:testdb"); - when(dataSourceConfigService.getDataSourceConfig(eq(dataSourceConfigId))) - .thenReturn(dataSourceConfig); - - // 调用 - List tables = databaseTableService.getTableList(dataSourceConfigId, - "config", "参数"); - // 断言 - assertEquals(1, tables.size()); - assertTableInfo(tables.get(0)); - } - - @Test - public void testGetTable() { - // 准备参数 - Long dataSourceConfigId = randomLongId(); - // mock 方法 - DataSourceConfigDO dataSourceConfig = new DataSourceConfigDO().setUsername("sa").setPassword("") - .setUrl("jdbc:h2:mem:testdb"); - when(dataSourceConfigService.getDataSourceConfig(eq(dataSourceConfigId))) - .thenReturn(dataSourceConfig); - - // 调用 - TableInfo tableInfo = databaseTableService.getTable(dataSourceConfigId, "infra_config"); - // 断言 - assertTableInfo(tableInfo); - } - - private void assertTableInfo(TableInfo tableInfo) { - assertEquals("infra_config", tableInfo.getName()); - assertEquals("参数配置表", tableInfo.getComment()); - assertEquals(13, tableInfo.getFields().size()); - // id 字段 - TableField idField = tableInfo.getFields().get(0); - assertEquals("id", idField.getName()); - assertEquals(JdbcType.BIGINT, idField.getMetaInfo().getJdbcType()); - assertEquals("编号", idField.getComment()); - assertFalse(idField.getMetaInfo().isNullable()); - assertTrue(idField.isKeyFlag()); - assertTrue(idField.isKeyIdentityFlag()); - assertEquals(DbColumnType.LONG, idField.getColumnType()); - assertEquals("id", idField.getPropertyName()); - // name 字段 - TableField nameField = tableInfo.getFields().get(3); - assertEquals("name", nameField.getName()); - assertEquals(JdbcType.VARCHAR, nameField.getMetaInfo().getJdbcType()); - assertEquals("名字", nameField.getComment()); - assertFalse(nameField.getMetaInfo().isNullable()); - assertFalse(nameField.isKeyFlag()); - assertFalse(nameField.isKeyIdentityFlag()); - assertEquals(DbColumnType.STRING, nameField.getColumnType()); - assertEquals("name", nameField.getPropertyName()); - } -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java deleted file mode 100755 index 7f43225704..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java +++ /dev/null @@ -1,281 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.file; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.file.core.client.FileClient; -import cn.iocoder.yudao.framework.file.core.client.FileClientConfig; -import cn.iocoder.yudao.framework.file.core.client.FileClientFactory; -import cn.iocoder.yudao.framework.file.core.client.local.LocalFileClient; -import cn.iocoder.yudao.framework.file.core.client.local.LocalFileClientConfig; -import cn.iocoder.yudao.framework.file.core.enums.FileStorageEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileConfigDO; -import cn.iocoder.yudao.module.infra.dal.mysql.file.FileConfigMapper; -import lombok.Data; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import jakarta.validation.Validator; -import java.io.Serializable; -import java.time.LocalDateTime; -import java.util.Map; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_CONFIG_DELETE_FAIL_MASTER; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_CONFIG_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -/** - * {@link FileConfigServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(FileConfigServiceImpl.class) -public class FileConfigServiceImplTest extends BaseDbUnitTest { - - @Resource - private FileConfigServiceImpl fileConfigService; - - @Resource - private FileConfigMapper fileConfigMapper; - - @MockBean - private Validator validator; - @MockBean - private FileClientFactory fileClientFactory; - - @Test - public void testCreateFileConfig_success() { - // 准备参数 - Map config = MapUtil.builder().put("basePath", "/yunai") - .put("domain", "https://www.iocoder.cn").build(); - FileConfigSaveReqVO reqVO = randomPojo(FileConfigSaveReqVO.class, - o -> o.setStorage(FileStorageEnum.LOCAL.getStorage()).setConfig(config)) - .setId(null); // 避免 id 被赋值 - - // 调用 - Long fileConfigId = fileConfigService.createFileConfig(reqVO); - // 断言 - assertNotNull(fileConfigId); - // 校验记录的属性是否正确 - FileConfigDO fileConfig = fileConfigMapper.selectById(fileConfigId); - assertPojoEquals(reqVO, fileConfig, "id", "config"); - assertFalse(fileConfig.getMaster()); - assertEquals("/yunai", ((LocalFileClientConfig) fileConfig.getConfig()).getBasePath()); - assertEquals("https://www.iocoder.cn", ((LocalFileClientConfig) fileConfig.getConfig()).getDomain()); - // 验证 cache - assertNull(fileConfigService.getClientCache().getIfPresent(fileConfigId)); - } - - @Test - public void testUpdateFileConfig_success() { - // mock 数据 - FileConfigDO dbFileConfig = randomPojo(FileConfigDO.class, o -> o.setStorage(FileStorageEnum.LOCAL.getStorage()) - .setConfig(new LocalFileClientConfig().setBasePath("/yunai").setDomain("https://www.iocoder.cn"))); - fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - FileConfigSaveReqVO reqVO = randomPojo(FileConfigSaveReqVO.class, o -> { - o.setId(dbFileConfig.getId()); // 设置更新的 ID - o.setStorage(FileStorageEnum.LOCAL.getStorage()); - Map config = MapUtil.builder().put("basePath", "/yunai2") - .put("domain", "https://doc.iocoder.cn").build(); - o.setConfig(config); - }); - - // 调用 - fileConfigService.updateFileConfig(reqVO); - // 校验是否更新正确 - FileConfigDO fileConfig = fileConfigMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, fileConfig, "config"); - assertEquals("/yunai2", ((LocalFileClientConfig) fileConfig.getConfig()).getBasePath()); - assertEquals("https://doc.iocoder.cn", ((LocalFileClientConfig) fileConfig.getConfig()).getDomain()); - // 验证 cache - assertNull(fileConfigService.getClientCache().getIfPresent(fileConfig.getId())); - } - - @Test - public void testUpdateFileConfig_notExists() { - // 准备参数 - FileConfigSaveReqVO reqVO = randomPojo(FileConfigSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> fileConfigService.updateFileConfig(reqVO), FILE_CONFIG_NOT_EXISTS); - } - - @Test - public void testUpdateFileConfigMaster_success() { - // mock 数据 - FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false); - fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 - FileConfigDO masterFileConfig = randomFileConfigDO().setMaster(true); - fileConfigMapper.insert(masterFileConfig);// @Sql: 先插入出一条存在的数据 - - // 调用 - fileConfigService.updateFileConfigMaster(dbFileConfig.getId()); - // 断言数据 - assertTrue(fileConfigMapper.selectById(dbFileConfig.getId()).getMaster()); - assertFalse(fileConfigMapper.selectById(masterFileConfig.getId()).getMaster()); - // 验证 cache - assertNull(fileConfigService.getClientCache().getIfPresent(0L)); - } - - @Test - public void testUpdateFileConfigMaster_notExists() { - // 调用, 并断言异常 - assertServiceException(() -> fileConfigService.updateFileConfigMaster(randomLongId()), FILE_CONFIG_NOT_EXISTS); - } - - @Test - public void testDeleteFileConfig_success() { - // mock 数据 - FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false); - fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbFileConfig.getId(); - - // 调用 - fileConfigService.deleteFileConfig(id); - // 校验数据不存在了 - assertNull(fileConfigMapper.selectById(id)); - // 验证 cache - assertNull(fileConfigService.getClientCache().getIfPresent(id)); - } - - @Test - public void testDeleteFileConfig_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> fileConfigService.deleteFileConfig(id), FILE_CONFIG_NOT_EXISTS); - } - - @Test - public void testDeleteFileConfig_master() { - // mock 数据 - FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(true); - fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbFileConfig.getId(); - - // 调用, 并断言异常 - assertServiceException(() -> fileConfigService.deleteFileConfig(id), FILE_CONFIG_DELETE_FAIL_MASTER); - } - - @Test - public void testGetFileConfigPage() { - // mock 数据 - FileConfigDO dbFileConfig = randomFileConfigDO().setName("芋道源码") - .setStorage(FileStorageEnum.LOCAL.getStorage()); - dbFileConfig.setCreateTime(LocalDateTimeUtil.parse("2020-01-23", DatePattern.NORM_DATE_PATTERN));// 等会查询到 - fileConfigMapper.insert(dbFileConfig); - // 测试 name 不匹配 - fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setName("源码"))); - // 测试 storage 不匹配 - fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setStorage(FileStorageEnum.DB.getStorage()))); - // 测试 createTime 不匹配 - fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setCreateTime(LocalDateTimeUtil.parse("2020-11-23", DatePattern.NORM_DATE_PATTERN)))); - // 准备参数 - FileConfigPageReqVO reqVO = new FileConfigPageReqVO(); - reqVO.setName("芋道"); - reqVO.setStorage(FileStorageEnum.LOCAL.getStorage()); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2020, 1, 1), - buildTime(2020, 1, 24)})); - - // 调用 - PageResult pageResult = fileConfigService.getFileConfigPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbFileConfig, pageResult.getList().get(0)); - } - - @Test - public void testFileConfig() throws Exception { - // mock 数据 - FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false); - fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbFileConfig.getId(); - // mock 获得 Client - FileClient fileClient = mock(FileClient.class); - when(fileClientFactory.getFileClient(eq(id))).thenReturn(fileClient); - when(fileClient.upload(any(), any(), any())).thenReturn("https://www.iocoder.cn"); - - // 调用,并断言 - assertEquals("https://www.iocoder.cn", fileConfigService.testFileConfig(id)); - } - - @Test - public void testGetFileConfig() { - // mock 数据 - FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false); - fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbFileConfig.getId(); - - // 调用,并断言 - assertPojoEquals(dbFileConfig, fileConfigService.getFileConfig(id)); - } - - @Test - public void testGetFileClient() { - // mock 数据 - FileConfigDO fileConfig = randomFileConfigDO().setMaster(false); - fileConfigMapper.insert(fileConfig); - // 准备参数 - Long id = fileConfig.getId(); - // mock 获得 Client - FileClient fileClient = new LocalFileClient(id, new LocalFileClientConfig()); - when(fileClientFactory.getFileClient(eq(id))).thenReturn(fileClient); - - // 调用,并断言 - assertSame(fileClient, fileConfigService.getFileClient(id)); - // 断言缓存 - verify(fileClientFactory).createOrUpdateFileClient(eq(id), eq(fileConfig.getStorage()), - eq(fileConfig.getConfig())); - } - - @Test - public void testGetMasterFileClient() { - // mock 数据 - FileConfigDO fileConfig = randomFileConfigDO().setMaster(true); - fileConfigMapper.insert(fileConfig); - // 准备参数 - Long id = fileConfig.getId(); - // mock 获得 Client - FileClient fileClient = new LocalFileClient(id, new LocalFileClientConfig()); - when(fileClientFactory.getFileClient(eq(fileConfig.getId()))).thenReturn(fileClient); - - // 调用,并断言 - assertSame(fileClient, fileConfigService.getMasterFileClient()); - // 断言缓存 - verify(fileClientFactory).createOrUpdateFileClient(eq(fileConfig.getId()), eq(fileConfig.getStorage()), - eq(fileConfig.getConfig())); - } - - private FileConfigDO randomFileConfigDO() { - return randomPojo(FileConfigDO.class).setStorage(randomEle(FileStorageEnum.values()).getStorage()) - .setConfig(new EmptyFileClientConfig()); - } - - @Data - public static class EmptyFileClientConfig implements FileClientConfig, Serializable { - - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java deleted file mode 100644 index 4cceb373e2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java +++ /dev/null @@ -1,143 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.file; - -import cn.hutool.core.io.resource.ResourceUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.file.core.client.FileClient; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.framework.test.core.util.AssertUtils; -import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO; -import cn.iocoder.yudao.module.infra.dal.mysql.file.FileMapper; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.same; -import static org.mockito.Mockito.*; - -@Import({FileServiceImpl.class}) -public class FileServiceImplTest extends BaseDbUnitTest { - - @Resource - private FileService fileService; - - @Resource - private FileMapper fileMapper; - - @MockBean - private FileConfigService fileConfigService; - - @Test - public void testGetFilePage() { - // mock 数据 - FileDO dbFile = randomPojo(FileDO.class, o -> { // 等会查询到 - o.setPath("yunai"); - o.setType("image/jpg"); - o.setCreateTime(buildTime(2021, 1, 15)); - }); - fileMapper.insert(dbFile); - // 测试 path 不匹配 - fileMapper.insert(ObjectUtils.cloneIgnoreId(dbFile, o -> o.setPath("tudou"))); - // 测试 type 不匹配 - fileMapper.insert(ObjectUtils.cloneIgnoreId(dbFile, o -> { - o.setType("image/png"); - })); - // 测试 createTime 不匹配 - fileMapper.insert(ObjectUtils.cloneIgnoreId(dbFile, o -> { - o.setCreateTime(buildTime(2020, 1, 15)); - })); - // 准备参数 - FilePageReqVO reqVO = new FilePageReqVO(); - reqVO.setPath("yunai"); - reqVO.setType("jp"); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 1, 10), buildTime(2021, 1, 20)})); - - // 调用 - PageResult pageResult = fileService.getFilePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - AssertUtils.assertPojoEquals(dbFile, pageResult.getList().get(0)); - } - - @Test - public void testCreateFile_success() throws Exception { - // 准备参数 - String path = randomString(); - byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); - // mock Master 文件客户端 - FileClient client = mock(FileClient.class); - when(fileConfigService.getMasterFileClient()).thenReturn(client); - String url = randomString(); - when(client.upload(same(content), same(path), eq("image/jpeg"))).thenReturn(url); - when(client.getId()).thenReturn(10L); - String name = "单测文件名"; - // 调用 - String result = fileService.createFile(name, path, content); - // 断言 - assertEquals(result, url); - // 校验数据 - FileDO file = fileMapper.selectOne(FileDO::getPath, path); - assertEquals(10L, file.getConfigId()); - assertEquals(path, file.getPath()); - assertEquals(url, file.getUrl()); - assertEquals("image/jpeg", file.getType()); - assertEquals(content.length, file.getSize()); - } - - @Test - public void testDeleteFile_success() throws Exception { - // mock 数据 - FileDO dbFile = randomPojo(FileDO.class, o -> o.setConfigId(10L).setPath("tudou.jpg")); - fileMapper.insert(dbFile);// @Sql: 先插入出一条存在的数据 - // mock Master 文件客户端 - FileClient client = mock(FileClient.class); - when(fileConfigService.getFileClient(eq(10L))).thenReturn(client); - // 准备参数 - Long id = dbFile.getId(); - - // 调用 - fileService.deleteFile(id); - // 校验数据不存在了 - assertNull(fileMapper.selectById(id)); - // 校验调用 - verify(client).delete(eq("tudou.jpg")); - } - - @Test - public void testDeleteFile_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> fileService.deleteFile(id), FILE_NOT_EXISTS); - } - - @Test - public void testGetFileContent() throws Exception { - // 准备参数 - Long configId = 10L; - String path = "tudou.jpg"; - // mock 方法 - FileClient client = mock(FileClient.class); - when(fileConfigService.getFileClient(eq(10L))).thenReturn(client); - byte[] content = new byte[]{}; - when(client.getContent(eq("tudou.jpg"))).thenReturn(content); - - // 调用 - byte[] result = fileService.getFileContent(configId, path); - // 断言 - assertSame(result, content); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImplTest.java deleted file mode 100644 index d3342eeeca..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImplTest.java +++ /dev/null @@ -1,171 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.job; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; -import cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper; -import cn.iocoder.yudao.module.infra.enums.job.JobLogStatusEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -@Import(JobLogServiceImpl.class) -public class JobLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private JobLogServiceImpl jobLogService; - @Resource - private JobLogMapper jobLogMapper; - - @Test - public void testCreateJobLog() { - // 准备参数 - JobLogDO reqVO = randomPojo(JobLogDO.class, o -> o.setExecuteIndex(1)); - - // 调用 - Long id = jobLogService.createJobLog(reqVO.getJobId(), reqVO.getBeginTime(), - reqVO.getHandlerName(), reqVO.getHandlerParam(), reqVO.getExecuteIndex()); - // 断言 - assertNotNull(id); - // 校验记录的属性是否正确 - JobLogDO job = jobLogMapper.selectById(id); - assertEquals(JobLogStatusEnum.RUNNING.getStatus(), job.getStatus()); - } - - @Test - public void testUpdateJobLogResultAsync_success() { - // mock 数据 - JobLogDO log = randomPojo(JobLogDO.class, o -> { - o.setExecuteIndex(1); - o.setStatus(JobLogStatusEnum.RUNNING.getStatus()); - }); - jobLogMapper.insert(log); - // 准备参数 - Long logId = log.getId(); - LocalDateTime endTime = randomLocalDateTime(); - Integer duration = randomInteger(); - boolean success = true; - String result = randomString(); - - // 调用 - jobLogService.updateJobLogResultAsync(logId, endTime, duration, success, result); - // 校验记录的属性是否正确 - JobLogDO dbLog = jobLogMapper.selectById(log.getId()); - assertEquals(endTime, dbLog.getEndTime()); - assertEquals(duration, dbLog.getDuration()); - assertEquals(JobLogStatusEnum.SUCCESS.getStatus(), dbLog.getStatus()); - assertEquals(result, dbLog.getResult()); - } - - @Test - public void testUpdateJobLogResultAsync_failure() { - // mock 数据 - JobLogDO log = randomPojo(JobLogDO.class, o -> { - o.setExecuteIndex(1); - o.setStatus(JobLogStatusEnum.RUNNING.getStatus()); - }); - jobLogMapper.insert(log); - // 准备参数 - Long logId = log.getId(); - LocalDateTime endTime = randomLocalDateTime(); - Integer duration = randomInteger(); - boolean success = false; - String result = randomString(); - - // 调用 - jobLogService.updateJobLogResultAsync(logId, endTime, duration, success, result); - // 校验记录的属性是否正确 - JobLogDO dbLog = jobLogMapper.selectById(log.getId()); - assertEquals(endTime, dbLog.getEndTime()); - assertEquals(duration, dbLog.getDuration()); - assertEquals(JobLogStatusEnum.FAILURE.getStatus(), dbLog.getStatus()); - assertEquals(result, dbLog.getResult()); - } - - @Test - public void testCleanJobLog() { - // mock 数据 - JobLogDO log01 = randomPojo(JobLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-3)))) - .setExecuteIndex(1); - jobLogMapper.insert(log01); - JobLogDO log02 = randomPojo(JobLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-1)))) - .setExecuteIndex(1); - jobLogMapper.insert(log02); - // 准备参数 - Integer exceedDay = 2; - Integer deleteLimit = 1; - - // 调用 - Integer count = jobLogService.cleanJobLog(exceedDay, deleteLimit); - // 断言 - assertEquals(1, count); - List logs = jobLogMapper.selectList(); - assertEquals(1, logs.size()); - assertEquals(log02, logs.get(0)); - } - - @Test - public void testGetJobLog() { - // mock 数据 - JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> o.setExecuteIndex(1)); - jobLogMapper.insert(dbJobLog); - // 准备参数 - Long id = dbJobLog.getId(); - - // 调用 - JobLogDO jobLog = jobLogService.getJobLog(id); - // 断言 - assertPojoEquals(dbJobLog, jobLog); - } - - @Test - public void testGetJobPage() { - // mock 数据 - JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> { - o.setExecuteIndex(1); - o.setHandlerName("handlerName 单元测试"); - o.setStatus(JobLogStatusEnum.SUCCESS.getStatus()); - o.setBeginTime(buildTime(2021, 1, 8)); - o.setEndTime(buildTime(2021, 1, 8)); - }); - jobLogMapper.insert(dbJobLog); - // 测试 jobId 不匹配 - jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setJobId(randomLongId()))); - // 测试 handlerName 不匹配 - jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setHandlerName(randomString()))); - // 测试 beginTime 不匹配 - jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setBeginTime(buildTime(2021, 1, 7)))); - // 测试 endTime 不匹配 - jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setEndTime(buildTime(2021, 1, 9)))); - // 测试 status 不匹配 - jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setStatus(JobLogStatusEnum.FAILURE.getStatus()))); - // 准备参数 - JobLogPageReqVO reqVo = new JobLogPageReqVO(); - reqVo.setJobId(dbJobLog.getJobId()); - reqVo.setHandlerName("单元"); - reqVo.setBeginTime(dbJobLog.getBeginTime()); - reqVo.setEndTime(dbJobLog.getEndTime()); - reqVo.setStatus(JobLogStatusEnum.SUCCESS.getStatus()); - - // 调用 - PageResult pageResult = jobLogService.getJobLogPage(reqVo); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbJobLog, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobServiceImplTest.java deleted file mode 100644 index eedbb1d507..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobServiceImplTest.java +++ /dev/null @@ -1,238 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.job; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobSaveReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO; -import cn.iocoder.yudao.module.infra.dal.mysql.job.JobMapper; -import cn.iocoder.yudao.module.infra.enums.job.JobStatusEnum; -import org.junit.jupiter.api.Test; -import org.quartz.SchedulerException; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; - -@Import(JobServiceImpl.class) -public class JobServiceImplTest extends BaseDbUnitTest { - - @Resource - private JobServiceImpl jobService; - @Resource - private JobMapper jobMapper; - @MockBean - private SchedulerManager schedulerManager; - - @Test - public void testCreateJob_cronExpressionValid() { - // 准备参数。Cron 表达式为 String 类型,默认随机字符串。 - JobSaveReqVO reqVO = randomPojo(JobSaveReqVO.class); - - // 调用,并断言异常 - assertServiceException(() -> jobService.createJob(reqVO), JOB_CRON_EXPRESSION_VALID); - } - - @Test - public void testCreateJob_jobHandlerExists() throws SchedulerException { - // 准备参数 指定 Cron 表达式 - JobSaveReqVO reqVO = randomPojo(JobSaveReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *")); - - // 调用 - jobService.createJob(reqVO); - // 调用,并断言异常 - assertServiceException(() -> jobService.createJob(reqVO), JOB_HANDLER_EXISTS); - } - - @Test - public void testCreateJob_success() throws SchedulerException { - // 准备参数 指定 Cron 表达式 - JobSaveReqVO reqVO = randomPojo(JobSaveReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *")) - .setId(null); - - // 调用 - Long jobId = jobService.createJob(reqVO); - // 断言 - assertNotNull(jobId); - // 校验记录的属性是否正确 - JobDO job = jobMapper.selectById(jobId); - assertPojoEquals(reqVO, job, "id"); - assertEquals(JobStatusEnum.NORMAL.getStatus(), job.getStatus()); - // 校验调用 - verify(schedulerManager).addJob(eq(job.getId()), eq(job.getHandlerName()), eq(job.getHandlerParam()), - eq(job.getCronExpression()), eq(reqVO.getRetryCount()), eq(reqVO.getRetryInterval())); - } - - @Test - public void testUpdateJob_jobNotExists(){ - // 准备参数 - JobSaveReqVO reqVO = randomPojo(JobSaveReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *")); - - // 调用,并断言异常 - assertServiceException(() -> jobService.updateJob(reqVO), JOB_NOT_EXISTS); - } - - @Test - public void testUpdateJob_onlyNormalStatus(){ - // mock 数据 - JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.INIT.getStatus())); - jobMapper.insert(job); - // 准备参数 - JobSaveReqVO updateReqVO = randomPojo(JobSaveReqVO.class, o -> { - o.setId(job.getId()); - o.setCronExpression("0 0/1 * * * ? *"); - }); - - // 调用,并断言异常 - assertServiceException(() -> jobService.updateJob(updateReqVO), - JOB_UPDATE_ONLY_NORMAL_STATUS); - } - - @Test - public void testUpdateJob_success() throws SchedulerException { - // mock 数据 - JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus())); - jobMapper.insert(job); - // 准备参数 - JobSaveReqVO updateReqVO = randomPojo(JobSaveReqVO.class, o -> { - o.setId(job.getId()); - o.setCronExpression("0 0/1 * * * ? *"); - }); - - // 调用 - jobService.updateJob(updateReqVO); - // 校验记录的属性是否正确 - JobDO updateJob = jobMapper.selectById(updateReqVO.getId()); - assertPojoEquals(updateReqVO, updateJob); - // 校验调用 - verify(schedulerManager).updateJob(eq(job.getHandlerName()), eq(updateReqVO.getHandlerParam()), - eq(updateReqVO.getCronExpression()), eq(updateReqVO.getRetryCount()), eq(updateReqVO.getRetryInterval())); - } - - @Test - public void testUpdateJobStatus_changeStatusInvalid() { - // 调用,并断言异常 - assertServiceException(() -> jobService.updateJobStatus(1L, JobStatusEnum.INIT.getStatus()), - JOB_CHANGE_STATUS_INVALID); - } - - @Test - public void testUpdateJobStatus_changeStatusEquals() { - // mock 数据 - JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus())); - jobMapper.insert(job); - - // 调用,并断言异常 - assertServiceException(() -> jobService.updateJobStatus(job.getId(), job.getStatus()), - JOB_CHANGE_STATUS_EQUALS); - } - - @Test - public void testUpdateJobStatus_stopSuccess() throws SchedulerException { - // mock 数据 - JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus())); - jobMapper.insert(job); - - // 调用 - jobService.updateJobStatus(job.getId(), JobStatusEnum.STOP.getStatus()); - // 校验记录的属性是否正确 - JobDO dbJob = jobMapper.selectById(job.getId()); - assertEquals(JobStatusEnum.STOP.getStatus(), dbJob.getStatus()); - // 校验调用 - verify(schedulerManager).pauseJob(eq(job.getHandlerName())); - } - - @Test - public void testUpdateJobStatus_normalSuccess() throws SchedulerException { - // mock 数据 - JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.STOP.getStatus())); - jobMapper.insert(job); - - // 调用 - jobService.updateJobStatus(job.getId(), JobStatusEnum.NORMAL.getStatus()); - // 校验记录的属性是否正确 - JobDO dbJob = jobMapper.selectById(job.getId()); - assertEquals(JobStatusEnum.NORMAL.getStatus(), dbJob.getStatus()); - // 校验调用 - verify(schedulerManager).resumeJob(eq(job.getHandlerName())); - } - - @Test - public void testTriggerJob_success() throws SchedulerException { - // mock 数据 - JobDO job = randomPojo(JobDO.class); - jobMapper.insert(job); - - // 调用 - jobService.triggerJob(job.getId()); - // 校验调用 - verify(schedulerManager).triggerJob(eq(job.getId()), - eq(job.getHandlerName()), eq(job.getHandlerParam())); - } - - @Test - public void testDeleteJob_success() throws SchedulerException { - // mock 数据 - JobDO job = randomPojo(JobDO.class); - jobMapper.insert(job); - - // 调用 - jobService.deleteJob(job.getId()); - // 校验不存在 - assertNull(jobMapper.selectById(job.getId())); - // 校验调用 - verify(schedulerManager).deleteJob(eq(job.getHandlerName())); - } - - @Test - public void testGetJobPage() { - // mock 数据 - JobDO dbJob = randomPojo(JobDO.class, o -> { - o.setName("定时任务测试"); - o.setHandlerName("handlerName 单元测试"); - o.setStatus(JobStatusEnum.INIT.getStatus()); - }); - jobMapper.insert(dbJob); - // 测试 name 不匹配 - jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setName("土豆"))); - // 测试 status 不匹配 - jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus()))); - // 测试 handlerName 不匹配 - jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setHandlerName(randomString()))); - // 准备参数 - JobPageReqVO reqVo = new JobPageReqVO(); - reqVo.setName("定时"); - reqVo.setStatus(JobStatusEnum.INIT.getStatus()); - reqVo.setHandlerName("单元"); - - // 调用 - PageResult pageResult = jobService.getJobPage(reqVo); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbJob, pageResult.getList().get(0)); - } - - @Test - public void testGetJob() { - // mock 数据 - JobDO dbJob = randomPojo(JobDO.class); - jobMapper.insert(dbJob); - // 调用 - JobDO job = jobService.getJob(dbJob.getId()); - // 断言 - assertPojoEquals(dbJob, job); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java deleted file mode 100644 index 660f3d38f0..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.logger; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO; -import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiAccessLogMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; - -@Import(ApiAccessLogServiceImpl.class) -public class ApiAccessLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private ApiAccessLogServiceImpl apiAccessLogService; - - @Resource - private ApiAccessLogMapper apiAccessLogMapper; - - @Test - public void testGetApiAccessLogPage() { - ApiAccessLogDO apiAccessLogDO = randomPojo(ApiAccessLogDO.class, o -> { - o.setUserId(2233L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setApplicationName("yudao-test"); - o.setRequestUrl("foo"); - o.setBeginTime(buildTime(2021, 3, 13)); - o.setDuration(1000); - o.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode()); - }); - apiAccessLogMapper.insert(apiAccessLogDO); - // 测试 userId 不匹配 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserId(3344L))); - // 测试 userType 不匹配 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 applicationName 不匹配 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setApplicationName("test"))); - // 测试 requestUrl 不匹配 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setRequestUrl("bar"))); - // 测试 beginTime 不匹配:构造一个早期时间 2021-02-06 00:00:00 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setBeginTime(buildTime(2021, 2, 6)))); - // 测试 duration 不匹配 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setDuration(100))); - // 测试 resultCode 不匹配 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setResultCode(2))); - // 准备参数 - ApiAccessLogPageReqVO reqVO = new ApiAccessLogPageReqVO(); - reqVO.setUserId(2233L); - reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); - reqVO.setApplicationName("yudao-test"); - reqVO.setRequestUrl("foo"); - reqVO.setBeginTime(buildBetweenTime(2021, 3, 13, 2021, 3, 13)); - reqVO.setDuration(1000); - reqVO.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode()); - - // 调用 - PageResult pageResult = apiAccessLogService.getApiAccessLogPage(reqVO); - // 断言,只查到了一条符合条件的 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(apiAccessLogDO, pageResult.getList().get(0)); - } - - @Test - public void testCleanJobLog() { - // mock 数据 - ApiAccessLogDO log01 = randomPojo(ApiAccessLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-3)))); - apiAccessLogMapper.insert(log01); - ApiAccessLogDO log02 = randomPojo(ApiAccessLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-1)))); - apiAccessLogMapper.insert(log02); - // 准备参数 - Integer exceedDay = 2; - Integer deleteLimit = 1; - - // 调用 - Integer count = apiAccessLogService.cleanAccessLog(exceedDay, deleteLimit); - // 断言 - assertEquals(1, count); - List logs = apiAccessLogMapper.selectList(); - assertEquals(1, logs.size()); - assertEquals(log02, logs.get(0)); - } - - @Test - public void testCreateApiAccessLog() { - // 准备参数 - ApiAccessLogCreateReqDTO createDTO = randomPojo(ApiAccessLogCreateReqDTO.class); - - // 调用 - apiAccessLogService.createApiAccessLog(createDTO); - // 断言 - ApiAccessLogDO apiAccessLogDO = apiAccessLogMapper.selectOne(null); - assertPojoEquals(createDTO, apiAccessLogDO); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java deleted file mode 100644 index 66514e0d40..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java +++ /dev/null @@ -1,163 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.logger; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO; -import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper; -import cn.iocoder.yudao.module.infra.enums.logger.ApiErrorLogProcessStatusEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.util.List; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_NOT_FOUND; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_PROCESSED; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -@Import(ApiErrorLogServiceImpl.class) -public class ApiErrorLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private ApiErrorLogServiceImpl apiErrorLogService; - - @Resource - private ApiErrorLogMapper apiErrorLogMapper; - - @Test - public void testGetApiErrorLogPage() { - // mock 数据 - ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, o -> { - o.setUserId(2233L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setApplicationName("yudao-test"); - o.setRequestUrl("foo"); - o.setExceptionTime(buildTime(2021, 3, 13)); - o.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus()); - }); - apiErrorLogMapper.insert(apiErrorLogDO); - // 测试 userId 不匹配 - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setUserId(3344L))); - // 测试 userType 不匹配 - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 applicationName 不匹配 - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setApplicationName("test"))); - // 测试 requestUrl 不匹配 - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setRequestUrl("bar"))); - // 测试 exceptionTime 不匹配:构造一个早期时间 2021-02-06 00:00:00 - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setExceptionTime(buildTime(2021, 2, 6)))); - // 测试 progressStatus 不匹配 - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus()))); - // 准备参数 - ApiErrorLogPageReqVO reqVO = new ApiErrorLogPageReqVO(); - reqVO.setUserId(2233L); - reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); - reqVO.setApplicationName("yudao-test"); - reqVO.setRequestUrl("foo"); - reqVO.setExceptionTime(buildBetweenTime(2021, 3, 1, 2021, 3, 31)); - reqVO.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus()); - - // 调用 - PageResult pageResult = apiErrorLogService.getApiErrorLogPage(reqVO); - // 断言,只查到了一条符合条件的 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(apiErrorLogDO, pageResult.getList().get(0)); - } - - @Test - public void testCreateApiErrorLog() { - // 准备参数 - ApiErrorLogCreateReqDTO createDTO = randomPojo(ApiErrorLogCreateReqDTO.class); - - // 调用 - apiErrorLogService.createApiErrorLog(createDTO); - // 断言 - ApiErrorLogDO apiErrorLogDO = apiErrorLogMapper.selectOne(null); - assertPojoEquals(createDTO, apiErrorLogDO); - assertEquals(ApiErrorLogProcessStatusEnum.INIT.getStatus(), apiErrorLogDO.getProcessStatus()); - } - - @Test - public void testUpdateApiErrorLogProcess_success() { - // 准备参数 - ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, - o -> o.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus())); - apiErrorLogMapper.insert(apiErrorLogDO); - // 准备参数 - Long id = apiErrorLogDO.getId(); - Integer processStatus = randomEle(ApiErrorLogProcessStatusEnum.values()).getStatus(); - Long processUserId = randomLongId(); - - // 调用 - apiErrorLogService.updateApiErrorLogProcess(id, processStatus, processUserId); - // 断言 - ApiErrorLogDO dbApiErrorLogDO = apiErrorLogMapper.selectById(apiErrorLogDO.getId()); - assertEquals(processStatus, dbApiErrorLogDO.getProcessStatus()); - assertEquals(processUserId, dbApiErrorLogDO.getProcessUserId()); - assertNotNull(dbApiErrorLogDO.getProcessTime()); - } - - @Test - public void testUpdateApiErrorLogProcess_processed() { - // 准备参数 - ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, - o -> o.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus())); - apiErrorLogMapper.insert(apiErrorLogDO); - // 准备参数 - Long id = apiErrorLogDO.getId(); - Integer processStatus = randomEle(ApiErrorLogProcessStatusEnum.values()).getStatus(); - Long processUserId = randomLongId(); - - // 调用,并断言异常 - assertServiceException(() -> - apiErrorLogService.updateApiErrorLogProcess(id, processStatus, processUserId), - API_ERROR_LOG_PROCESSED); - } - - @Test - public void testUpdateApiErrorLogProcess_notFound() { - // 准备参数 - Long id = randomLongId(); - Integer processStatus = randomEle(ApiErrorLogProcessStatusEnum.values()).getStatus(); - Long processUserId = randomLongId(); - - // 调用,并断言异常 - assertServiceException(() -> - apiErrorLogService.updateApiErrorLogProcess(id, processStatus, processUserId), - API_ERROR_LOG_NOT_FOUND); - } - - @Test - public void testCleanJobLog() { - // mock 数据 - ApiErrorLogDO log01 = randomPojo(ApiErrorLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-3)))); - apiErrorLogMapper.insert(log01); - ApiErrorLogDO log02 = randomPojo(ApiErrorLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-1)))); - apiErrorLogMapper.insert(log02); - // 准备参数 - Integer exceedDay = 2; - Integer deleteLimit = 1; - - // 调用 - Integer count = apiErrorLogService.cleanErrorLog(exceedDay, deleteLimit); - // 断言 - assertEquals(1, count); - List logs = apiErrorLogMapper.selectList(); - assertEquals(1, logs.size()); - assertEquals(log02, logs.get(0)); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 2d0d827d29..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,51 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/category.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/category.json deleted file mode 100644 index 210613f5d9..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/category.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "table": { - "id": 10, - "scene" : 1, - "parentMenuId" : 888, - "tableName" : "infra_category", - "tableComment" : "分类表", - "moduleName" : "infra", - "businessName" : "demo", - "className" : "InfraCategory", - "classComment" : "分类", - "author" : "芋道源码", - "treeParentColumnId" : 22, - "treeNameColumnId" : 11 - }, - "columns": [ { - "columnName" : "id", - "dataType" : "BIGINT", - "columnComment" : "编号", - "primaryKey" : true, - "autoIncrement" : true, - "javaType" : "Long", - "javaField" : "id", - "example" : "1024", - "updateOperation" : true, - "listOperationResult" : true - }, { - "id" : 11, - "columnName" : "name", - "dataType" : "VARCHAR", - "columnComment" : "名字", - "javaType" : "String", - "javaField" : "name", - "example" : "芋头", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "LIKE", - "listOperationResult" : true, - "htmlType" : "input" - }, { - "id" : 22, - "columnName" : "description", - "dataType" : "VARCHAR", - "columnComment" : "父编号", - "javaType" : "Long", - "javaField" : "parentId", - "example" : "2048", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true - } ] -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/contact.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/contact.json deleted file mode 100644 index 6a310570f5..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/contact.json +++ /dev/null @@ -1,144 +0,0 @@ -{ - "table": { - "scene" : 1, - "tableName" : "infra_student_contact", - "tableComment" : "学生联系人表", - "moduleName" : "infra", - "businessName" : "demo", - "className" : "InfraStudentContact", - "classComment" : "学生联系人", - "author" : "芋道源码" - }, - "columns": [ { - "columnName" : "id", - "dataType" : "BIGINT", - "columnComment" : "编号", - "primaryKey" : true, - "autoIncrement" : true, - "javaType" : "Long", - "javaField" : "id", - "example" : "1024", - "updateOperation" : true, - "listOperationResult" : true - }, { - "id" : 100, - "columnName" : "student_id", - "dataType" : "BIGINT", - "columnComment" : "学生编号", - "javaType" : "Long", - "javaField" : "studentId", - "example" : "2048", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true - }, { - "columnName" : "name", - "dataType" : "VARCHAR", - "columnComment" : "名字", - "javaType" : "String", - "javaField" : "name", - "example" : "芋头", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "LIKE", - "listOperationResult" : true, - "htmlType" : "input" - }, { - "columnName" : "description", - "dataType" : "VARCHAR", - "columnComment" : "简介", - "javaType" : "String", - "javaField" : "description", - "example" : "我是介绍", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "textarea" - }, { - "columnName" : "birthday", - "dataType" : "DATE", - "columnComment" : "出生日期", - "javaType" : "LocalDateTime", - "javaField" : "birthday", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "datetime" - }, { - "columnName" : "sex", - "dataType" : "INTEGER", - "columnComment" : "性别", - "javaType" : "Integer", - "javaField" : "sex", - "dictType" : "system_user_sex", - "example" : "1", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "select" - }, { - "columnName" : "enabled", - "dataType" : "BOOLEAN", - "columnComment" : "是否有效", - "javaType" : "Boolean", - "javaField" : "enabled", - "dictType" : "infra_boolean_string", - "example" : "true", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "radio" - }, { - "columnName" : "avatar", - "dataType" : "VARCHAR", - "columnComment" : "头像", - "javaType" : "String", - "javaField" : "avatar", - "example" : "https://www.iocoder.cn/1.png", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "imageUpload" - }, { - "columnName" : "video", - "dataType" : "VARCHAR", - "columnComment" : "附件", - "nullable" : true, - "javaType" : "String", - "javaField" : "video", - "example" : "https://www.iocoder.cn/1.mp4", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "fileUpload" - }, { - "columnName" : "memo", - "dataType" : "VARCHAR", - "columnComment" : "备注", - "javaType" : "String", - "javaField" : "memo", - "example" : "我是备注", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "editor" - }, { - "columnName" : "create_time", - "dataType" : "DATE", - "columnComment" : "创建时间", - "nullable" : true, - "javaType" : "LocalDateTime", - "javaField" : "createTime", - "listOperation" : true, - "listOperationCondition" : "BETWEEN", - "listOperationResult" : true, - "htmlType" : "datetime" - } ] -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/student.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/student.json deleted file mode 100644 index 0cc29c5a93..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/student.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "table": { - "id": 1, - "scene" : 1, - "parentMenuId" : 888, - "tableName" : "infra_student", - "tableComment" : "学生表", - "moduleName" : "infra", - "businessName" : "demo", - "className" : "InfraStudent", - "classComment" : "学生", - "author" : "芋道源码" - }, - "columns": [ { - "id" : 100, - "columnName" : "id", - "dataType" : "BIGINT", - "columnComment" : "编号", - "primaryKey" : true, - "autoIncrement" : true, - "javaType" : "Long", - "javaField" : "id", - "example" : "1024", - "updateOperation" : true, - "listOperationResult" : true - }, { - "columnName" : "name", - "dataType" : "VARCHAR", - "columnComment" : "名字", - "javaType" : "String", - "javaField" : "name", - "example" : "芋头", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "LIKE", - "listOperationResult" : true, - "htmlType" : "input" - }, { - "columnName" : "description", - "dataType" : "VARCHAR", - "columnComment" : "简介", - "javaType" : "String", - "javaField" : "description", - "example" : "我是介绍", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "textarea" - }, { - "columnName" : "birthday", - "dataType" : "DATE", - "columnComment" : "出生日期", - "javaType" : "LocalDateTime", - "javaField" : "birthday", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "datetime" - }, { - "columnName" : "sex", - "dataType" : "INTEGER", - "columnComment" : "性别", - "javaType" : "Integer", - "javaField" : "sex", - "dictType" : "system_user_sex", - "example" : "1", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "select" - }, { - "columnName" : "enabled", - "dataType" : "BOOLEAN", - "columnComment" : "是否有效", - "javaType" : "Boolean", - "javaField" : "enabled", - "dictType" : "infra_boolean_string", - "example" : "true", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "radio" - }, { - "columnName" : "avatar", - "dataType" : "VARCHAR", - "columnComment" : "头像", - "javaType" : "String", - "javaField" : "avatar", - "example" : "https://www.iocoder.cn/1.png", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "imageUpload" - }, { - "columnName" : "video", - "dataType" : "VARCHAR", - "columnComment" : "附件", - "javaType" : "String", - "javaField" : "video", - "example" : "https://www.iocoder.cn/1.mp4", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "fileUpload" - }, { - "columnName" : "memo", - "dataType" : "VARCHAR", - "columnComment" : "备注", - "javaType" : "String", - "javaField" : "memo", - "example" : "我是备注", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "editor" - }, { - "columnName" : "create_time", - "dataType" : "DATE", - "columnComment" : "创建时间", - "nullable" : true, - "javaType" : "LocalDateTime", - "javaField" : "createTime", - "listOperation" : true, - "listOperationCondition" : "BETWEEN", - "listOperationResult" : true, - "htmlType" : "datetime" - } ] -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/teacher.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/teacher.json deleted file mode 100644 index 7ef460400a..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/teacher.json +++ /dev/null @@ -1,144 +0,0 @@ -{ - "table": { - "scene" : 1, - "tableName" : "infra_student_teacher", - "tableComment" : "学生班主任表", - "moduleName" : "infra", - "businessName" : "demo", - "className" : "InfraStudentTeacher", - "classComment" : "学生班主任", - "author" : "芋道源码" - }, - "columns": [ { - "columnName" : "id", - "dataType" : "BIGINT", - "columnComment" : "编号", - "primaryKey" : true, - "autoIncrement" : true, - "javaType" : "Long", - "javaField" : "id", - "example" : "1024", - "updateOperation" : true, - "listOperationResult" : true - }, { - "id" : 200, - "columnName" : "student_id", - "dataType" : "BIGINT", - "columnComment" : "学生编号", - "javaType" : "Long", - "javaField" : "studentId", - "example" : "2048", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true - }, { - "columnName" : "name", - "dataType" : "VARCHAR", - "columnComment" : "名字", - "javaType" : "String", - "javaField" : "name", - "example" : "芋头", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "LIKE", - "listOperationResult" : true, - "htmlType" : "input" - }, { - "columnName" : "description", - "dataType" : "VARCHAR", - "columnComment" : "简介", - "javaType" : "String", - "javaField" : "description", - "example" : "我是介绍", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "textarea" - }, { - "columnName" : "birthday", - "dataType" : "DATE", - "columnComment" : "出生日期", - "javaType" : "LocalDateTime", - "javaField" : "birthday", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "datetime" - }, { - "columnName" : "sex", - "dataType" : "INTEGER", - "columnComment" : "性别", - "javaType" : "Integer", - "javaField" : "sex", - "dictType" : "system_user_sex", - "example" : "1", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "select" - }, { - "columnName" : "enabled", - "dataType" : "BOOLEAN", - "columnComment" : "是否有效", - "javaType" : "Boolean", - "javaField" : "enabled", - "dictType" : "infra_boolean_string", - "example" : "true", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "radio" - }, { - "columnName" : "avatar", - "dataType" : "VARCHAR", - "columnComment" : "头像", - "javaType" : "String", - "javaField" : "avatar", - "example" : "https://www.iocoder.cn/1.png", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "imageUpload" - }, { - "columnName" : "video", - "dataType" : "VARCHAR", - "columnComment" : "附件", - "nullable" : true, - "javaType" : "String", - "javaField" : "video", - "example" : "https://www.iocoder.cn/1.mp4", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "fileUpload" - }, { - "columnName" : "memo", - "dataType" : "VARCHAR", - "columnComment" : "备注", - "javaType" : "String", - "javaField" : "memo", - "example" : "我是备注", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "editor" - }, { - "columnName" : "create_time", - "dataType" : "DATE", - "columnComment" : "创建时间", - "nullable" : true, - "javaType" : "LocalDateTime", - "javaField" : "createTime", - "listOperation" : true, - "listOperationCondition" : "BETWEEN", - "listOperationResult" : true, - "htmlType" : "datetime" - } ] -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/assert.json deleted file mode 100644 index 8edb8e612f..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/assert.json +++ /dev/null @@ -1,73 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentContactDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" -}, { - "contentPath" : "java/InfraStudentTeacherDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "java/InfraStudentContactMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" -}, { - "contentPath" : "java/InfraStudentTeacherMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" -}, { - "contentPath": "js/index", - "filePath": "yudao-ui-admin-vue2/src/api/infra/demo/index.js" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "vue/StudentContactForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactForm.vue" -}, { - "contentPath" : "vue/StudentTeacherForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherForm.vue" -}, { - "contentPath" : "vue/StudentContactList", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactList.vue" -}, { - "contentPath" : "vue/StudentTeacherList", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherList.vue" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index d3201dec33..0000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,6 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); -ErrorCode STUDENT_CONTACT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生联系人不存在"); -ErrorCode STUDENT_TEACHER_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生班主任不存在"); -ErrorCode STUDENT_TEACHER_EXISTS = new ErrorCode(TODO 补充编号, "学生班主任已存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentContactDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentContactDO deleted file mode 100644 index 17c668eaac..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentContactDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生联系人 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_contact") -@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentContactDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentContactMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentContactMapper deleted file mode 100644 index ca662d19ca..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentContactMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentContactMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long studentId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(InfraStudentContactDO::getStudentId, studentId) - .orderByDesc(InfraStudentContactDO::getId)); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentContactDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentController deleted file mode 100644 index d6f20183de..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentController +++ /dev/null @@ -1,183 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - - // ==================== 子表(学生联系人) ==================== - - @GetMapping("/student-contact/page") - @Operation(summary = "获得学生联系人分页") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentContactPage(PageParam pageReqVO, - @RequestParam("studentId") Long studentId) { - return success(studentService.getStudentContactPage(pageReqVO, studentId)); - } - - @PostMapping("/student-contact/create") - @Operation(summary = "创建学生联系人") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudentContact(@Valid @RequestBody InfraStudentContactDO studentContact) { - return success(studentService.createStudentContact(studentContact)); - } - - @PutMapping("/student-contact/update") - @Operation(summary = "更新学生联系人") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudentContact(@Valid @RequestBody InfraStudentContactDO studentContact) { - studentService.updateStudentContact(studentContact); - return success(true); - } - - @DeleteMapping("/student-contact/delete") - @Parameter(name = "id", description = "编号", required = true) - @Operation(summary = "删除学生联系人") - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudentContact(@RequestParam("id") Long id) { - studentService.deleteStudentContact(id); - return success(true); - } - - @GetMapping("/student-contact/get") - @Operation(summary = "获得学生联系人") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentContact(@RequestParam("id") Long id) { - return success(studentService.getStudentContact(id)); - } - - // ==================== 子表(学生班主任) ==================== - - @GetMapping("/student-teacher/page") - @Operation(summary = "获得学生班主任分页") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentTeacherPage(PageParam pageReqVO, - @RequestParam("studentId") Long studentId) { - return success(studentService.getStudentTeacherPage(pageReqVO, studentId)); - } - - @PostMapping("/student-teacher/create") - @Operation(summary = "创建学生班主任") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudentTeacher(@Valid @RequestBody InfraStudentTeacherDO studentTeacher) { - return success(studentService.createStudentTeacher(studentTeacher)); - } - - @PutMapping("/student-teacher/update") - @Operation(summary = "更新学生班主任") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudentTeacher(@Valid @RequestBody InfraStudentTeacherDO studentTeacher) { - studentService.updateStudentTeacher(studentTeacher); - return success(true); - } - - @DeleteMapping("/student-teacher/delete") - @Parameter(name = "id", description = "编号", required = true) - @Operation(summary = "删除学生班主任") - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudentTeacher(@RequestParam("id") Long id) { - studentService.deleteStudentTeacher(id); - return success(true); - } - - @GetMapping("/student-teacher/get") - @Operation(summary = "获得学生班主任") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentTeacher(@RequestParam("id") Long id) { - return success(studentService.getStudentTeacher(id)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentDO deleted file mode 100644 index b0d4bd2167..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentMapper deleted file mode 100644 index 34e70a0822..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentPageReqVO deleted file mode 100644 index 41a3730125..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentRespVO deleted file mode 100644 index c41a5501fe..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentSaveReqVO deleted file mode 100644 index eaadf7432d..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentService deleted file mode 100644 index 7df090d7f6..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentService +++ /dev/null @@ -1,139 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - - // ==================== 子表(学生联系人) ==================== - - /** - * 获得学生联系人分页 - * - * @param pageReqVO 分页查询 - * @param studentId 学生编号 - * @return 学生联系人分页 - */ - PageResult getStudentContactPage(PageParam pageReqVO, Long studentId); - - /** - * 创建学生联系人 - * - * @param studentContact 创建信息 - * @return 编号 - */ - Long createStudentContact(@Valid InfraStudentContactDO studentContact); - - /** - * 更新学生联系人 - * - * @param studentContact 更新信息 - */ - void updateStudentContact(@Valid InfraStudentContactDO studentContact); - - /** - * 删除学生联系人 - * - * @param id 编号 - */ - void deleteStudentContact(Long id); - - /** - * 获得学生联系人 - * - * @param id 编号 - * @return 学生联系人 - */ - InfraStudentContactDO getStudentContact(Long id); - - // ==================== 子表(学生班主任) ==================== - - /** - * 获得学生班主任分页 - * - * @param pageReqVO 分页查询 - * @param studentId 学生编号 - * @return 学生班主任分页 - */ - PageResult getStudentTeacherPage(PageParam pageReqVO, Long studentId); - - /** - * 创建学生班主任 - * - * @param studentTeacher 创建信息 - * @return 编号 - */ - Long createStudentTeacher(@Valid InfraStudentTeacherDO studentTeacher); - - /** - * 更新学生班主任 - * - * @param studentTeacher 更新信息 - */ - void updateStudentTeacher(@Valid InfraStudentTeacherDO studentTeacher); - - /** - * 删除学生班主任 - * - * @param id 编号 - */ - void deleteStudentTeacher(Long id); - - /** - * 获得学生班主任 - * - * @param id 编号 - * @return 学生班主任 - */ - InfraStudentTeacherDO getStudentTeacher(Long id); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentServiceImpl deleted file mode 100644 index 793b2dd22c..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentServiceImpl +++ /dev/null @@ -1,180 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - @Resource - private InfraStudentContactMapper studentContactMapper; - @Resource - private InfraStudentTeacherMapper studentTeacherMapper; - - @Override - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - // 返回 - return student.getId(); - } - - @Override - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - - // 删除子表 - deleteStudentContactByStudentId(id); - deleteStudentTeacherByStudentId(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生联系人) ==================== - - @Override - public PageResult getStudentContactPage(PageParam pageReqVO, Long studentId) { - return studentContactMapper.selectPage(pageReqVO, studentId); - } - - @Override - public Long createStudentContact(InfraStudentContactDO studentContact) { - studentContactMapper.insert(studentContact); - return studentContact.getId(); - } - - @Override - public void updateStudentContact(InfraStudentContactDO studentContact) { - // 校验存在 - validateStudentContactExists(studentContact.getId()); - // 更新 - studentContactMapper.updateById(studentContact); - } - - @Override - public void deleteStudentContact(Long id) { - // 校验存在 - validateStudentContactExists(id); - // 删除 - studentContactMapper.deleteById(id); - } - - @Override - public InfraStudentContactDO getStudentContact(Long id) { - return studentContactMapper.selectById(id); - } - - private void validateStudentContactExists(Long id) { - if (studentContactMapper.selectById(id) == null) { - throw exception(STUDENT_CONTACT_NOT_EXISTS); - } - } - - private void deleteStudentContactByStudentId(Long studentId) { - studentContactMapper.deleteByStudentId(studentId); - } - - // ==================== 子表(学生班主任) ==================== - - @Override - public PageResult getStudentTeacherPage(PageParam pageReqVO, Long studentId) { - return studentTeacherMapper.selectPage(pageReqVO, studentId); - } - - @Override - public Long createStudentTeacher(InfraStudentTeacherDO studentTeacher) { - // 校验是否已经存在 - if (studentTeacherMapper.selectByStudentId(studentTeacher.getStudentId()) != null) { - throw exception(STUDENT_TEACHER_EXISTS); - } - // 插入 - studentTeacherMapper.insert(studentTeacher); - return studentTeacher.getId(); - } - - @Override - public void updateStudentTeacher(InfraStudentTeacherDO studentTeacher) { - // 校验存在 - validateStudentTeacherExists(studentTeacher.getId()); - // 更新 - studentTeacherMapper.updateById(studentTeacher); - } - - @Override - public void deleteStudentTeacher(Long id) { - // 校验存在 - validateStudentTeacherExists(id); - // 删除 - studentTeacherMapper.deleteById(id); - } - - @Override - public InfraStudentTeacherDO getStudentTeacher(Long id) { - return studentTeacherMapper.selectById(id); - } - - private void validateStudentTeacherExists(Long id) { - if (studentTeacherMapper.selectById(id) == null) { - throw exception(STUDENT_TEACHER_NOT_EXISTS); - } - } - - private void deleteStudentTeacherByStudentId(Long studentId) { - studentTeacherMapper.deleteByStudentId(studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentTeacherDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentTeacherDO deleted file mode 100644 index c19cf9fab2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentTeacherDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生班主任 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_teacher") -@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentTeacherDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentTeacherMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentTeacherMapper deleted file mode 100644 index 994212dabf..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentTeacherMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生班主任 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentTeacherMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long studentId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(InfraStudentTeacherDO::getStudentId, studentId) - .orderByDesc(InfraStudentTeacherDO::getId)); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentTeacherDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/js/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/js/index deleted file mode 100644 index 211d95e42b..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/js/index +++ /dev/null @@ -1,141 +0,0 @@ -import request from '@/utils/request' - -// 创建学生 -export function createStudent(data) { - return request({ - url: '/infra/student/create', - method: 'post', - data: data - }) -} - -// 更新学生 -export function updateStudent(data) { - return request({ - url: '/infra/student/update', - method: 'put', - data: data - }) -} - -// 删除学生 -export function deleteStudent(id) { - return request({ - url: '/infra/student/delete?id=' + id, - method: 'delete' - }) -} - -// 获得学生 -export function getStudent(id) { - return request({ - url: '/infra/student/get?id=' + id, - method: 'get' - }) -} - -// 获得学生分页 -export function getStudentPage(params) { - return request({ - url: '/infra/student/page', - method: 'get', - params - }) -} -// 导出学生 Excel -export function exportStudentExcel(params) { - return request({ - url: '/infra/student/export-excel', - method: 'get', - params, - responseType: 'blob' - }) -} - -// ==================== 子表(学生联系人) ==================== - - // 获得学生联系人分页 - export function getStudentContactPage(params) { - return request({ - url: '/infra/student/student-contact/page', - method: 'get', - params - }) - } - // 新增学生联系人 - export function createStudentContact(data) { - return request({ - url: `/infra/student/student-contact/create`, - method: 'post', - data - }) - } - - // 修改学生联系人 - export function updateStudentContact(data) { - return request({ - url: `/infra/student/student-contact/update`, - method: 'post', - data - }) - } - - // 删除学生联系人 - export function deleteStudentContact(id) { - return request({ - url: `/infra/student/student-contact/delete?id=` + id, - method: 'delete' - }) - } - - // 获得学生联系人 - export function getStudentContact(id) { - return request({ - url: `/infra/student/student-contact/get?id=` + id, - method: 'get' - }) - } - -// ==================== 子表(学生班主任) ==================== - - // 获得学生班主任分页 - export function getStudentTeacherPage(params) { - return request({ - url: '/infra/student/student-teacher/page', - method: 'get', - params - }) - } - // 新增学生班主任 - export function createStudentTeacher(data) { - return request({ - url: `/infra/student/student-teacher/create`, - method: 'post', - data - }) - } - - // 修改学生班主任 - export function updateStudentTeacher(data) { - return request({ - url: `/infra/student/student-teacher/update`, - method: 'post', - data - }) - } - - // 删除学生班主任 - export function deleteStudentTeacher(id) { - return request({ - url: `/infra/student/student-teacher/delete?id=` + id, - method: 'delete' - }) - } - - // 获得学生班主任 - export function getStudentTeacher(id) { - return request({ - url: `/infra/student/student-teacher/get?id=` + id, - method: 'get' - }) - } \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/sql/h2 deleted file mode 100644 index 6c1875f601..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/sql/sql deleted file mode 100644 index 83df279264..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentContactForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentContactForm deleted file mode 100644 index de3b0a7347..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentContactForm +++ /dev/null @@ -1,151 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentContactList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentContactList deleted file mode 100644 index 00f1ce0408..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentContactList +++ /dev/null @@ -1,129 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentForm deleted file mode 100644 index d89e5066db..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentForm +++ /dev/null @@ -1,149 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentTeacherForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentTeacherForm deleted file mode 100644 index 874a03bbc4..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentTeacherForm +++ /dev/null @@ -1,151 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentTeacherList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentTeacherList deleted file mode 100644 index 7d561a0ee4..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentTeacherList +++ /dev/null @@ -1,129 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/index deleted file mode 100644 index 9c7588f2ad..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/index +++ /dev/null @@ -1,233 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27a..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/assert.json deleted file mode 100644 index 8edb8e612f..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/assert.json +++ /dev/null @@ -1,73 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentContactDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" -}, { - "contentPath" : "java/InfraStudentTeacherDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "java/InfraStudentContactMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" -}, { - "contentPath" : "java/InfraStudentTeacherMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" -}, { - "contentPath": "js/index", - "filePath": "yudao-ui-admin-vue2/src/api/infra/demo/index.js" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "vue/StudentContactForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactForm.vue" -}, { - "contentPath" : "vue/StudentTeacherForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherForm.vue" -}, { - "contentPath" : "vue/StudentContactList", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactList.vue" -}, { - "contentPath" : "vue/StudentTeacherList", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherList.vue" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index f8be66202f..0000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,3 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentContactDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentContactDO deleted file mode 100644 index 17c668eaac..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentContactDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生联系人 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_contact") -@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentContactDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentContactMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentContactMapper deleted file mode 100644 index 35bbd53c2d..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentContactMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentContactMapper extends BaseMapperX { - - default List selectListByStudentId(Long studentId) { - return selectList(InfraStudentContactDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentContactDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentController deleted file mode 100644 index b9a587b448..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentController +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - - // ==================== 子表(学生联系人) ==================== - - @GetMapping("/student-contact/list-by-student-id") - @Operation(summary = "获得学生联系人列表") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentContactListByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentContactListByStudentId(studentId)); - } - - // ==================== 子表(学生班主任) ==================== - - @GetMapping("/student-teacher/get-by-student-id") - @Operation(summary = "获得学生班主任") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentTeacherByStudentId(studentId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentDO deleted file mode 100644 index b0d4bd2167..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentMapper deleted file mode 100644 index 34e70a0822..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentPageReqVO deleted file mode 100644 index 41a3730125..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentRespVO deleted file mode 100644 index c41a5501fe..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentSaveReqVO deleted file mode 100644 index faa491dfb8..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - - @Schema(description = "学生联系人列表") - private List studentContacts; - - @Schema(description = "学生班主任") - private InfraStudentTeacherDO studentTeacher; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentService deleted file mode 100644 index afa7d22eb3..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentService +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - - // ==================== 子表(学生联系人) ==================== - - /** - * 获得学生联系人列表 - * - * @param studentId 学生编号 - * @return 学生联系人列表 - */ - List getStudentContactListByStudentId(Long studentId); - - // ==================== 子表(学生班主任) ==================== - - /** - * 获得学生班主任 - * - * @param studentId 学生编号 - * @return 学生班主任 - */ - InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentServiceImpl deleted file mode 100644 index c57cba6137..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentServiceImpl +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - @Resource - private InfraStudentContactMapper studentContactMapper; - @Resource - private InfraStudentTeacherMapper studentTeacherMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - - // 插入子表 - createStudentContactList(student.getId(), createReqVO.getStudentContacts()); - createStudentTeacher(student.getId(), createReqVO.getStudentTeacher()); - // 返回 - return student.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - - // 更新子表 - updateStudentContactList(updateReqVO.getId(), updateReqVO.getStudentContacts()); - updateStudentTeacher(updateReqVO.getId(), updateReqVO.getStudentTeacher()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - - // 删除子表 - deleteStudentContactByStudentId(id); - deleteStudentTeacherByStudentId(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生联系人) ==================== - - @Override - public List getStudentContactListByStudentId(Long studentId) { - return studentContactMapper.selectListByStudentId(studentId); - } - - private void createStudentContactList(Long studentId, List list) { - list.forEach(o -> o.setStudentId(studentId)); - studentContactMapper.insertBatch(list); - } - - private void updateStudentContactList(Long studentId, List list) { - deleteStudentContactByStudentId(studentId); - list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 - createStudentContactList(studentId, list); - } - - private void deleteStudentContactByStudentId(Long studentId) { - studentContactMapper.deleteByStudentId(studentId); - } - - // ==================== 子表(学生班主任) ==================== - - @Override - public InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId) { - return studentTeacherMapper.selectByStudentId(studentId); - } - - private void createStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacherMapper.insert(studentTeacher); - } - - private void updateStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 - studentTeacherMapper.insertOrUpdate(studentTeacher); - } - - private void deleteStudentTeacherByStudentId(Long studentId) { - studentTeacherMapper.deleteByStudentId(studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentTeacherDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentTeacherDO deleted file mode 100644 index c19cf9fab2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentTeacherDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生班主任 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_teacher") -@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentTeacherDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentTeacherMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentTeacherMapper deleted file mode 100644 index 0521bbaf45..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentTeacherMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生班主任 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentTeacherMapper extends BaseMapperX { - - default InfraStudentTeacherDO selectByStudentId(Long studentId) { - return selectOne(InfraStudentTeacherDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentTeacherDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/js/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/js/index deleted file mode 100644 index b4e6ac5e48..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/js/index +++ /dev/null @@ -1,74 +0,0 @@ -import request from '@/utils/request' - -// 创建学生 -export function createStudent(data) { - return request({ - url: '/infra/student/create', - method: 'post', - data: data - }) -} - -// 更新学生 -export function updateStudent(data) { - return request({ - url: '/infra/student/update', - method: 'put', - data: data - }) -} - -// 删除学生 -export function deleteStudent(id) { - return request({ - url: '/infra/student/delete?id=' + id, - method: 'delete' - }) -} - -// 获得学生 -export function getStudent(id) { - return request({ - url: '/infra/student/get?id=' + id, - method: 'get' - }) -} - -// 获得学生分页 -export function getStudentPage(params) { - return request({ - url: '/infra/student/page', - method: 'get', - params - }) -} -// 导出学生 Excel -export function exportStudentExcel(params) { - return request({ - url: '/infra/student/export-excel', - method: 'get', - params, - responseType: 'blob' - }) -} - -// ==================== 子表(学生联系人) ==================== - - // 获得学生联系人列表 - export function getStudentContactListByStudentId(studentId) { - return request({ - url: `/infra/student/student-contact/list-by-student-id?studentId=` + studentId, - method: 'get' - }) - } - -// ==================== 子表(学生班主任) ==================== - - // 获得学生班主任 - export function getStudentTeacherByStudentId(studentId) { - return request({ - url: `/infra/student/student-teacher/get-by-student-id?studentId=` + studentId, - method: 'get' - }) - } - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/sql/h2 deleted file mode 100644 index 6c1875f601..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/sql/sql deleted file mode 100644 index 83df279264..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentContactForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentContactForm deleted file mode 100644 index c953bfa13c..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentContactForm +++ /dev/null @@ -1,177 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentContactList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentContactList deleted file mode 100644 index c0a8710e9a..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentContactList +++ /dev/null @@ -1,89 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentForm deleted file mode 100644 index 6d93b61227..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentForm +++ /dev/null @@ -1,180 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentTeacherForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentTeacherForm deleted file mode 100644 index 0dac19bb3e..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentTeacherForm +++ /dev/null @@ -1,127 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentTeacherList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentTeacherList deleted file mode 100644 index 9f572742db..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentTeacherList +++ /dev/null @@ -1,93 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/index deleted file mode 100644 index ddeafdf294..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/index +++ /dev/null @@ -1,222 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27a..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/assert.json deleted file mode 100644 index 6f94535e09..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/assert.json +++ /dev/null @@ -1,67 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentContactDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" -}, { - "contentPath" : "java/InfraStudentTeacherDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "java/InfraStudentContactMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" -}, { - "contentPath" : "java/InfraStudentTeacherMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" -}, { - "contentPath": "js/index", - "filePath": "yudao-ui-admin-vue2/src/api/infra/demo/index.js" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "vue/StudentContactForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactForm.vue" -}, { - "contentPath" : "vue/StudentTeacherForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherForm.vue" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index f8be66202f..0000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,3 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentContactDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentContactDO deleted file mode 100644 index 17c668eaac..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentContactDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生联系人 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_contact") -@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentContactDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentContactMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentContactMapper deleted file mode 100644 index 35bbd53c2d..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentContactMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentContactMapper extends BaseMapperX { - - default List selectListByStudentId(Long studentId) { - return selectList(InfraStudentContactDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentContactDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentController deleted file mode 100644 index b9a587b448..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentController +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - - // ==================== 子表(学生联系人) ==================== - - @GetMapping("/student-contact/list-by-student-id") - @Operation(summary = "获得学生联系人列表") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentContactListByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentContactListByStudentId(studentId)); - } - - // ==================== 子表(学生班主任) ==================== - - @GetMapping("/student-teacher/get-by-student-id") - @Operation(summary = "获得学生班主任") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentTeacherByStudentId(studentId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentDO deleted file mode 100644 index b0d4bd2167..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentMapper deleted file mode 100644 index 34e70a0822..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentPageReqVO deleted file mode 100644 index 41a3730125..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentRespVO deleted file mode 100644 index c41a5501fe..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentSaveReqVO deleted file mode 100644 index faa491dfb8..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - - @Schema(description = "学生联系人列表") - private List studentContacts; - - @Schema(description = "学生班主任") - private InfraStudentTeacherDO studentTeacher; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentService deleted file mode 100644 index afa7d22eb3..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentService +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - - // ==================== 子表(学生联系人) ==================== - - /** - * 获得学生联系人列表 - * - * @param studentId 学生编号 - * @return 学生联系人列表 - */ - List getStudentContactListByStudentId(Long studentId); - - // ==================== 子表(学生班主任) ==================== - - /** - * 获得学生班主任 - * - * @param studentId 学生编号 - * @return 学生班主任 - */ - InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentServiceImpl deleted file mode 100644 index c57cba6137..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentServiceImpl +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - @Resource - private InfraStudentContactMapper studentContactMapper; - @Resource - private InfraStudentTeacherMapper studentTeacherMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - - // 插入子表 - createStudentContactList(student.getId(), createReqVO.getStudentContacts()); - createStudentTeacher(student.getId(), createReqVO.getStudentTeacher()); - // 返回 - return student.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - - // 更新子表 - updateStudentContactList(updateReqVO.getId(), updateReqVO.getStudentContacts()); - updateStudentTeacher(updateReqVO.getId(), updateReqVO.getStudentTeacher()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - - // 删除子表 - deleteStudentContactByStudentId(id); - deleteStudentTeacherByStudentId(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生联系人) ==================== - - @Override - public List getStudentContactListByStudentId(Long studentId) { - return studentContactMapper.selectListByStudentId(studentId); - } - - private void createStudentContactList(Long studentId, List list) { - list.forEach(o -> o.setStudentId(studentId)); - studentContactMapper.insertBatch(list); - } - - private void updateStudentContactList(Long studentId, List list) { - deleteStudentContactByStudentId(studentId); - list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 - createStudentContactList(studentId, list); - } - - private void deleteStudentContactByStudentId(Long studentId) { - studentContactMapper.deleteByStudentId(studentId); - } - - // ==================== 子表(学生班主任) ==================== - - @Override - public InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId) { - return studentTeacherMapper.selectByStudentId(studentId); - } - - private void createStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacherMapper.insert(studentTeacher); - } - - private void updateStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 - studentTeacherMapper.insertOrUpdate(studentTeacher); - } - - private void deleteStudentTeacherByStudentId(Long studentId) { - studentTeacherMapper.deleteByStudentId(studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentTeacherDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentTeacherDO deleted file mode 100644 index c19cf9fab2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentTeacherDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生班主任 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_teacher") -@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentTeacherDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentTeacherMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentTeacherMapper deleted file mode 100644 index 0521bbaf45..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentTeacherMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生班主任 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentTeacherMapper extends BaseMapperX { - - default InfraStudentTeacherDO selectByStudentId(Long studentId) { - return selectOne(InfraStudentTeacherDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentTeacherDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/js/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/js/index deleted file mode 100644 index b4e6ac5e48..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/js/index +++ /dev/null @@ -1,74 +0,0 @@ -import request from '@/utils/request' - -// 创建学生 -export function createStudent(data) { - return request({ - url: '/infra/student/create', - method: 'post', - data: data - }) -} - -// 更新学生 -export function updateStudent(data) { - return request({ - url: '/infra/student/update', - method: 'put', - data: data - }) -} - -// 删除学生 -export function deleteStudent(id) { - return request({ - url: '/infra/student/delete?id=' + id, - method: 'delete' - }) -} - -// 获得学生 -export function getStudent(id) { - return request({ - url: '/infra/student/get?id=' + id, - method: 'get' - }) -} - -// 获得学生分页 -export function getStudentPage(params) { - return request({ - url: '/infra/student/page', - method: 'get', - params - }) -} -// 导出学生 Excel -export function exportStudentExcel(params) { - return request({ - url: '/infra/student/export-excel', - method: 'get', - params, - responseType: 'blob' - }) -} - -// ==================== 子表(学生联系人) ==================== - - // 获得学生联系人列表 - export function getStudentContactListByStudentId(studentId) { - return request({ - url: `/infra/student/student-contact/list-by-student-id?studentId=` + studentId, - method: 'get' - }) - } - -// ==================== 子表(学生班主任) ==================== - - // 获得学生班主任 - export function getStudentTeacherByStudentId(studentId) { - return request({ - url: `/infra/student/student-teacher/get-by-student-id?studentId=` + studentId, - method: 'get' - }) - } - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/sql/h2 deleted file mode 100644 index 6c1875f601..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/sql/sql deleted file mode 100644 index 83df279264..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentContactForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentContactForm deleted file mode 100644 index c953bfa13c..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentContactForm +++ /dev/null @@ -1,177 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentForm deleted file mode 100644 index 6d93b61227..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentForm +++ /dev/null @@ -1,180 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentTeacherForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentTeacherForm deleted file mode 100644 index 0dac19bb3e..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentTeacherForm +++ /dev/null @@ -1,127 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/index deleted file mode 100644 index 4607581270..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/index +++ /dev/null @@ -1,205 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27a..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/assert.json deleted file mode 100644 index 5a37c376aa..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/assert.json +++ /dev/null @@ -1,49 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" -}, { - "contentPath": "js/index", - "filePath": "yudao-ui-admin-vue2/src/api/infra/demo/index.js" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/StudentForm.vue" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index f8be66202f..0000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,3 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentController deleted file mode 100644 index 3796982c44..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentController +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentDO deleted file mode 100644 index b0d4bd2167..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentMapper deleted file mode 100644 index 34e70a0822..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentPageReqVO deleted file mode 100644 index 41a3730125..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentRespVO deleted file mode 100644 index c41a5501fe..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentSaveReqVO deleted file mode 100644 index 43e7f147d6..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentService deleted file mode 100644 index c4a0e1792c..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentService +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentServiceImpl deleted file mode 100644 index 2292a66f37..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentServiceImpl +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - - @Override - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - // 返回 - return student.getId(); - } - - @Override - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - } - - @Override - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/js/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/js/index deleted file mode 100644 index 44db46806c..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/js/index +++ /dev/null @@ -1,53 +0,0 @@ -import request from '@/utils/request' - -// 创建学生 -export function createStudent(data) { - return request({ - url: '/infra/student/create', - method: 'post', - data: data - }) -} - -// 更新学生 -export function updateStudent(data) { - return request({ - url: '/infra/student/update', - method: 'put', - data: data - }) -} - -// 删除学生 -export function deleteStudent(id) { - return request({ - url: '/infra/student/delete?id=' + id, - method: 'delete' - }) -} - -// 获得学生 -export function getStudent(id) { - return request({ - url: '/infra/student/get?id=' + id, - method: 'get' - }) -} - -// 获得学生分页 -export function getStudentPage(params) { - return request({ - url: '/infra/student/page', - method: 'get', - params - }) -} -// 导出学生 Excel -export function exportStudentExcel(params) { - return request({ - url: '/infra/student/export-excel', - method: 'get', - params, - responseType: 'blob' - }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/sql/h2 deleted file mode 100644 index 6c1875f601..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/sql/sql deleted file mode 100644 index 83df279264..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/vue/StudentForm deleted file mode 100644 index d89e5066db..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/vue/StudentForm +++ /dev/null @@ -1,149 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/vue/index deleted file mode 100644 index 4607581270..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/vue/index +++ /dev/null @@ -1,205 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27a..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/assert.json deleted file mode 100644 index a7d2f569c7..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/assert.json +++ /dev/null @@ -1,49 +0,0 @@ -[ { - "contentPath" : "java/InfraCategoryListReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategoryListReqVO.java" -}, { - "contentPath" : "java/InfraCategoryRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategoryRespVO.java" -}, { - "contentPath" : "java/InfraCategorySaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategorySaveReqVO.java" -}, { - "contentPath" : "java/InfraCategoryController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraCategoryController.java" -}, { - "contentPath" : "java/InfraCategoryDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraCategoryDO.java" -}, { - "contentPath" : "java/InfraCategoryMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraCategoryMapper.java" -}, { - "contentPath" : "xml/InfraCategoryMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraCategoryMapper.xml" -}, { - "contentPath" : "java/InfraCategoryServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryServiceImpl.java" -}, { - "contentPath" : "java/InfraCategoryService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryService.java" -}, { - "contentPath" : "java/InfraCategoryServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" -}, { - "contentPath": "js/index", - "filePath": "yudao-ui-admin-vue2/src/api/infra/demo/index.js" -}, { - "contentPath" : "vue/CategoryForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/CategoryForm.vue" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index 36df6752e9..0000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,8 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 分类 TODO 补充编号 ========== -ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(TODO 补充编号, "分类不存在"); -ErrorCode CATEGORY_EXITS_CHILDREN = new ErrorCode(TODO 补充编号, "存在存在子分类,无法删除"); -ErrorCode CATEGORY_PARENT_NOT_EXITS = new ErrorCode(TODO 补充编号,"父级分类不存在"); -ErrorCode CATEGORY_PARENT_ERROR = new ErrorCode(TODO 补充编号, "不能设置自己为父分类"); -ErrorCode CATEGORY_NAME_DUPLICATE = new ErrorCode(TODO 补充编号, "已经存在该名字的分类"); -ErrorCode CATEGORY_PARENT_IS_CHILD = new ErrorCode(TODO 补充编号, "不能设置自己的子InfraCategory为父InfraCategory"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryController deleted file mode 100644 index a7b2f81632..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryController +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraCategoryService; - -@Tag(name = "管理后台 - 分类") -@RestController -@RequestMapping("/infra/category") -@Validated -public class InfraCategoryController { - - @Resource - private InfraCategoryService categoryService; - - @PostMapping("/create") - @Operation(summary = "创建分类") - @PreAuthorize("@ss.hasPermission('infra:category:create')") - public CommonResult createCategory(@Valid @RequestBody InfraCategorySaveReqVO createReqVO) { - return success(categoryService.createCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新分类") - @PreAuthorize("@ss.hasPermission('infra:category:update')") - public CommonResult updateCategory(@Valid @RequestBody InfraCategorySaveReqVO updateReqVO) { - categoryService.updateCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:category:delete')") - public CommonResult deleteCategory(@RequestParam("id") Long id) { - categoryService.deleteCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:category:query')") - public CommonResult getCategory(@RequestParam("id") Long id) { - InfraCategoryDO category = categoryService.getCategory(id); - return success(BeanUtils.toBean(category, InfraCategoryRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得分类列表") - @PreAuthorize("@ss.hasPermission('infra:category:query')") - public CommonResult> getCategoryList(@Valid InfraCategoryListReqVO listReqVO) { - List list = categoryService.getCategoryList(listReqVO); - return success(BeanUtils.toBean(list, InfraCategoryRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出分类 Excel") - @PreAuthorize("@ss.hasPermission('infra:category:export')") - @OperateLog(type = EXPORT) - public void exportCategoryExcel(@Valid InfraCategoryListReqVO listReqVO, - HttpServletResponse response) throws IOException { - List list = categoryService.getCategoryList(listReqVO); - // 导出 Excel - ExcelUtils.write(response, "分类.xls", "数据", InfraCategoryRespVO.class, - BeanUtils.toBean(list, InfraCategoryRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryDO deleted file mode 100644 index 9bf21c08bc..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryDO +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 分类 DO - * - * @author 芋道源码 - */ -@TableName("infra_category") -@KeySequence("infra_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraCategoryDO extends BaseDO { - - public static final Long PARENT_ID_ROOT = 0L; - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 父编号 - */ - private Long parentId; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryListReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryListReqVO deleted file mode 100644 index e5c6f181f9..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryListReqVO +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -@Schema(description = "管理后台 - 分类列表 Request VO") -@Data -public class InfraCategoryListReqVO { - - @Schema(description = "名字", example = "芋头") - private String name; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryMapper deleted file mode 100644 index 9dadbf1d9d..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryMapper +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 分类 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraCategoryMapper extends BaseMapperX { - - default List selectList(InfraCategoryListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(InfraCategoryDO::getName, reqVO.getName()) - .orderByDesc(InfraCategoryDO::getId)); - } - - default InfraCategoryDO selectByParentIdAndName(Long parentId, String name) { - return selectOne(InfraCategoryDO::getParentId, parentId, InfraCategoryDO::getName, name); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(InfraCategoryDO::getParentId, parentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryRespVO deleted file mode 100644 index 6325d866c5..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryRespVO +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import com.alibaba.excel.annotation.*; - -@Schema(description = "管理后台 - 分类 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraCategoryRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "父编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @ExcelProperty("父编号") - private Long parentId; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategorySaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategorySaveReqVO deleted file mode 100644 index 3c03b977fb..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategorySaveReqVO +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; - -@Schema(description = "管理后台 - 分类新增/修改 Request VO") -@Data -public class InfraCategorySaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "父编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "父编号不能为空") - private Long parentId; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryService deleted file mode 100644 index 9d0ae1afab..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryService +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 分类 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraCategoryService { - - /** - * 创建分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCategory(@Valid InfraCategorySaveReqVO createReqVO); - - /** - * 更新分类 - * - * @param updateReqVO 更新信息 - */ - void updateCategory(@Valid InfraCategorySaveReqVO updateReqVO); - - /** - * 删除分类 - * - * @param id 编号 - */ - void deleteCategory(Long id); - - /** - * 获得分类 - * - * @param id 编号 - * @return 分类 - */ - InfraCategoryDO getCategory(Long id); - - /** - * 获得分类列表 - * - * @param listReqVO 查询条件 - * @return 分类列表 - */ - List getCategoryList(InfraCategoryListReqVO listReqVO); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryServiceImpl deleted file mode 100644 index 351568b186..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryServiceImpl +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraCategoryMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 分类 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraCategoryServiceImpl implements InfraCategoryService { - - @Resource - private InfraCategoryMapper categoryMapper; - - @Override - public Long createCategory(InfraCategorySaveReqVO createReqVO) { - // 校验父编号的有效性 - validateParentCategory(null, createReqVO.getParentId()); - // 校验名字的唯一性 - validateCategoryNameUnique(null, createReqVO.getParentId(), createReqVO.getName()); - - // 插入 - InfraCategoryDO category = BeanUtils.toBean(createReqVO, InfraCategoryDO.class); - categoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateCategory(InfraCategorySaveReqVO updateReqVO) { - // 校验存在 - validateCategoryExists(updateReqVO.getId()); - // 校验父编号的有效性 - validateParentCategory(updateReqVO.getId(), updateReqVO.getParentId()); - // 校验名字的唯一性 - validateCategoryNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); - - // 更新 - InfraCategoryDO updateObj = BeanUtils.toBean(updateReqVO, InfraCategoryDO.class); - categoryMapper.updateById(updateObj); - } - - @Override - public void deleteCategory(Long id) { - // 校验存在 - validateCategoryExists(id); - // 校验是否有子分类 - if (categoryMapper.selectCountByParentId(id) > 0) { - throw exception(CATEGORY_EXITS_CHILDREN); - } - // 删除 - categoryMapper.deleteById(id); - } - - private void validateCategoryExists(Long id) { - if (categoryMapper.selectById(id) == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - } - - private void validateParentCategory(Long id, Long parentId) { - if (parentId == null || CategoryDO.PARENT_ID_ROOT.equals(parentId)) { - return; - } - // 1. 不能设置自己为父分类 - if (Objects.equals(id, parentId)) { - throw exception(CATEGORY_PARENT_ERROR); - } - // 2. 父分类不存在 - CategoryDO parentCategory = categoryMapper.selectById(parentId); - if (parentCategory == null) { - throw exception(CATEGORY_PARENT_NOT_EXITS); - } - // 3. 递归校验父分类,如果父分类是自己的子分类,则报错,避免形成环路 - if (id == null) { // id 为空,说明新增,不需要考虑环路 - return; - } - for (int i = 0; i < Short.MAX_VALUE; i++) { - // 3.1 校验环路 - parentId = parentCategory.getParentId(); - if (Objects.equals(id, parentId)) { - throw exception(CATEGORY_PARENT_IS_CHILD); - } - // 3.2 继续递归下一级父分类 - if (parentId == null || CategoryDO.PARENT_ID_ROOT.equals(parentId)) { - break; - } - parentCategory = categoryMapper.selectById(parentId); - if (parentCategory == null) { - break; - } - } - } - - private void validateCategoryNameUnique(Long id, Long parentId, String name) { - CategoryDO category = categoryMapper.selectByParentIdAndName(parentId, name); - if (category == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的分类 - if (id == null) { - throw exception(CATEGORY_NAME_DUPLICATE); - } - if (!Objects.equals(category.getId(), id)) { - throw exception(CATEGORY_NAME_DUPLICATE); - } - } - - @Override - public InfraCategoryDO getCategory(Long id) { - return categoryMapper.selectById(id); - } - - @Override - public List getCategoryList(InfraCategoryListReqVO listReqVO) { - return categoryMapper.selectList(listReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryServiceImplTest deleted file mode 100644 index efb70fd332..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryServiceImplTest +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraCategoryMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraCategoryServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraCategoryServiceImpl.class) -public class InfraCategoryServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraCategoryServiceImpl categoryService; - - @Resource - private InfraCategoryMapper categoryMapper; - - @Test - public void testCreateCategory_success() { - // 准备参数 - InfraCategorySaveReqVO createReqVO = randomPojo(InfraCategorySaveReqVO.class).setId(null); - - // 调用 - Long categoryId = categoryService.createCategory(createReqVO); - // 断言 - assertNotNull(categoryId); - // 校验记录的属性是否正确 - InfraCategoryDO category = categoryMapper.selectById(categoryId); - assertPojoEquals(createReqVO, category, "id"); - } - - @Test - public void testUpdateCategory_success() { - // mock 数据 - InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class); - categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraCategorySaveReqVO updateReqVO = randomPojo(InfraCategorySaveReqVO.class, o -> { - o.setId(dbCategory.getId()); // 设置更新的 ID - }); - - // 调用 - categoryService.updateCategory(updateReqVO); - // 校验是否更新正确 - InfraCategoryDO category = categoryMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, category); - } - - @Test - public void testUpdateCategory_notExists() { - // 准备参数 - InfraCategorySaveReqVO updateReqVO = randomPojo(InfraCategorySaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> categoryService.updateCategory(updateReqVO), CATEGORY_NOT_EXISTS); - } - - @Test - public void testDeleteCategory_success() { - // mock 数据 - InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class); - categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCategory.getId(); - - // 调用 - categoryService.deleteCategory(id); - // 校验数据不存在了 - assertNull(categoryMapper.selectById(id)); - } - - @Test - public void testDeleteCategory_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> categoryService.deleteCategory(id), CATEGORY_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetCategoryList() { - // mock 数据 - InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class, o -> { // 等会查询到 - o.setName(null); - }); - categoryMapper.insert(dbCategory); - // 测试 name 不匹配 - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName(null))); - // 准备参数 - InfraCategoryListReqVO reqVO = new InfraCategoryListReqVO(); - reqVO.setName(null); - - // 调用 - List list = categoryService.getCategoryList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbCategory, list.get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/js/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/js/index deleted file mode 100644 index 1e6ffdcea9..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/js/index +++ /dev/null @@ -1,53 +0,0 @@ -import request from '@/utils/request' - -// 创建分类 -export function createCategory(data) { - return request({ - url: '/infra/category/create', - method: 'post', - data: data - }) -} - -// 更新分类 -export function updateCategory(data) { - return request({ - url: '/infra/category/update', - method: 'put', - data: data - }) -} - -// 删除分类 -export function deleteCategory(id) { - return request({ - url: '/infra/category/delete?id=' + id, - method: 'delete' - }) -} - -// 获得分类 -export function getCategory(id) { - return request({ - url: '/infra/category/get?id=' + id, - method: 'get' - }) -} - -// 获得分类列表 -export function getCategoryList(params) { - return request({ - url: '/infra/category/list', - method: 'get', - params - }) -} -// 导出分类 Excel -export function exportCategoryExcel(params) { - return request({ - url: '/infra/category/export-excel', - method: 'get', - params, - responseType: 'blob' - }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/sql/h2 deleted file mode 100644 index 4141766cf4..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/sql/h2 +++ /dev/null @@ -1,10 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_category" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '分类表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_category"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/sql/sql deleted file mode 100644 index 81409488a5..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '分类管理', '', 2, 0, 888, - 'category', '', 'infra/demo/index', 0, 'InfraCategory' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类查询', 'infra:category:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类创建', 'infra:category:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类更新', 'infra:category:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类删除', 'infra:category:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类导出', 'infra:category:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/vue/CategoryForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/vue/CategoryForm deleted file mode 100644 index 7fa06e8cf0..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/vue/CategoryForm +++ /dev/null @@ -1,130 +0,0 @@ - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/vue/index deleted file mode 100644 index 88da682544..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/vue/index +++ /dev/null @@ -1,161 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/xml/InfraCategoryMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/xml/InfraCategoryMapper deleted file mode 100644 index 025ac85071..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/xml/InfraCategoryMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/assert.json deleted file mode 100644 index 0937ba9148..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/assert.json +++ /dev/null @@ -1,73 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentContactDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" -}, { - "contentPath" : "java/InfraStudentTeacherDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "java/InfraStudentContactMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" -}, { - "contentPath" : "java/InfraStudentTeacherMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "vue/StudentContactForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactForm.vue" -}, { - "contentPath" : "vue/StudentTeacherForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherForm.vue" -}, { - "contentPath" : "vue/StudentContactList", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactList.vue" -}, { - "contentPath" : "vue/StudentTeacherList", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherList.vue" -}, { - "contentPath" : "ts/index", - "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index d3201dec33..0000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,6 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); -ErrorCode STUDENT_CONTACT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生联系人不存在"); -ErrorCode STUDENT_TEACHER_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生班主任不存在"); -ErrorCode STUDENT_TEACHER_EXISTS = new ErrorCode(TODO 补充编号, "学生班主任已存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentContactDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentContactDO deleted file mode 100644 index 17c668eaac..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentContactDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生联系人 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_contact") -@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentContactDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentContactMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentContactMapper deleted file mode 100644 index ca662d19ca..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentContactMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentContactMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long studentId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(InfraStudentContactDO::getStudentId, studentId) - .orderByDesc(InfraStudentContactDO::getId)); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentContactDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentController deleted file mode 100644 index d6f20183de..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentController +++ /dev/null @@ -1,183 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - - // ==================== 子表(学生联系人) ==================== - - @GetMapping("/student-contact/page") - @Operation(summary = "获得学生联系人分页") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentContactPage(PageParam pageReqVO, - @RequestParam("studentId") Long studentId) { - return success(studentService.getStudentContactPage(pageReqVO, studentId)); - } - - @PostMapping("/student-contact/create") - @Operation(summary = "创建学生联系人") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudentContact(@Valid @RequestBody InfraStudentContactDO studentContact) { - return success(studentService.createStudentContact(studentContact)); - } - - @PutMapping("/student-contact/update") - @Operation(summary = "更新学生联系人") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudentContact(@Valid @RequestBody InfraStudentContactDO studentContact) { - studentService.updateStudentContact(studentContact); - return success(true); - } - - @DeleteMapping("/student-contact/delete") - @Parameter(name = "id", description = "编号", required = true) - @Operation(summary = "删除学生联系人") - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudentContact(@RequestParam("id") Long id) { - studentService.deleteStudentContact(id); - return success(true); - } - - @GetMapping("/student-contact/get") - @Operation(summary = "获得学生联系人") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentContact(@RequestParam("id") Long id) { - return success(studentService.getStudentContact(id)); - } - - // ==================== 子表(学生班主任) ==================== - - @GetMapping("/student-teacher/page") - @Operation(summary = "获得学生班主任分页") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentTeacherPage(PageParam pageReqVO, - @RequestParam("studentId") Long studentId) { - return success(studentService.getStudentTeacherPage(pageReqVO, studentId)); - } - - @PostMapping("/student-teacher/create") - @Operation(summary = "创建学生班主任") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudentTeacher(@Valid @RequestBody InfraStudentTeacherDO studentTeacher) { - return success(studentService.createStudentTeacher(studentTeacher)); - } - - @PutMapping("/student-teacher/update") - @Operation(summary = "更新学生班主任") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudentTeacher(@Valid @RequestBody InfraStudentTeacherDO studentTeacher) { - studentService.updateStudentTeacher(studentTeacher); - return success(true); - } - - @DeleteMapping("/student-teacher/delete") - @Parameter(name = "id", description = "编号", required = true) - @Operation(summary = "删除学生班主任") - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudentTeacher(@RequestParam("id") Long id) { - studentService.deleteStudentTeacher(id); - return success(true); - } - - @GetMapping("/student-teacher/get") - @Operation(summary = "获得学生班主任") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentTeacher(@RequestParam("id") Long id) { - return success(studentService.getStudentTeacher(id)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentDO deleted file mode 100644 index b0d4bd2167..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentMapper deleted file mode 100644 index 34e70a0822..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentPageReqVO deleted file mode 100644 index 41a3730125..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentRespVO deleted file mode 100644 index c41a5501fe..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentSaveReqVO deleted file mode 100644 index eaadf7432d..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentService deleted file mode 100644 index 7df090d7f6..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentService +++ /dev/null @@ -1,139 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - - // ==================== 子表(学生联系人) ==================== - - /** - * 获得学生联系人分页 - * - * @param pageReqVO 分页查询 - * @param studentId 学生编号 - * @return 学生联系人分页 - */ - PageResult getStudentContactPage(PageParam pageReqVO, Long studentId); - - /** - * 创建学生联系人 - * - * @param studentContact 创建信息 - * @return 编号 - */ - Long createStudentContact(@Valid InfraStudentContactDO studentContact); - - /** - * 更新学生联系人 - * - * @param studentContact 更新信息 - */ - void updateStudentContact(@Valid InfraStudentContactDO studentContact); - - /** - * 删除学生联系人 - * - * @param id 编号 - */ - void deleteStudentContact(Long id); - - /** - * 获得学生联系人 - * - * @param id 编号 - * @return 学生联系人 - */ - InfraStudentContactDO getStudentContact(Long id); - - // ==================== 子表(学生班主任) ==================== - - /** - * 获得学生班主任分页 - * - * @param pageReqVO 分页查询 - * @param studentId 学生编号 - * @return 学生班主任分页 - */ - PageResult getStudentTeacherPage(PageParam pageReqVO, Long studentId); - - /** - * 创建学生班主任 - * - * @param studentTeacher 创建信息 - * @return 编号 - */ - Long createStudentTeacher(@Valid InfraStudentTeacherDO studentTeacher); - - /** - * 更新学生班主任 - * - * @param studentTeacher 更新信息 - */ - void updateStudentTeacher(@Valid InfraStudentTeacherDO studentTeacher); - - /** - * 删除学生班主任 - * - * @param id 编号 - */ - void deleteStudentTeacher(Long id); - - /** - * 获得学生班主任 - * - * @param id 编号 - * @return 学生班主任 - */ - InfraStudentTeacherDO getStudentTeacher(Long id); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentServiceImpl deleted file mode 100644 index 793b2dd22c..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentServiceImpl +++ /dev/null @@ -1,180 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - @Resource - private InfraStudentContactMapper studentContactMapper; - @Resource - private InfraStudentTeacherMapper studentTeacherMapper; - - @Override - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - // 返回 - return student.getId(); - } - - @Override - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - - // 删除子表 - deleteStudentContactByStudentId(id); - deleteStudentTeacherByStudentId(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生联系人) ==================== - - @Override - public PageResult getStudentContactPage(PageParam pageReqVO, Long studentId) { - return studentContactMapper.selectPage(pageReqVO, studentId); - } - - @Override - public Long createStudentContact(InfraStudentContactDO studentContact) { - studentContactMapper.insert(studentContact); - return studentContact.getId(); - } - - @Override - public void updateStudentContact(InfraStudentContactDO studentContact) { - // 校验存在 - validateStudentContactExists(studentContact.getId()); - // 更新 - studentContactMapper.updateById(studentContact); - } - - @Override - public void deleteStudentContact(Long id) { - // 校验存在 - validateStudentContactExists(id); - // 删除 - studentContactMapper.deleteById(id); - } - - @Override - public InfraStudentContactDO getStudentContact(Long id) { - return studentContactMapper.selectById(id); - } - - private void validateStudentContactExists(Long id) { - if (studentContactMapper.selectById(id) == null) { - throw exception(STUDENT_CONTACT_NOT_EXISTS); - } - } - - private void deleteStudentContactByStudentId(Long studentId) { - studentContactMapper.deleteByStudentId(studentId); - } - - // ==================== 子表(学生班主任) ==================== - - @Override - public PageResult getStudentTeacherPage(PageParam pageReqVO, Long studentId) { - return studentTeacherMapper.selectPage(pageReqVO, studentId); - } - - @Override - public Long createStudentTeacher(InfraStudentTeacherDO studentTeacher) { - // 校验是否已经存在 - if (studentTeacherMapper.selectByStudentId(studentTeacher.getStudentId()) != null) { - throw exception(STUDENT_TEACHER_EXISTS); - } - // 插入 - studentTeacherMapper.insert(studentTeacher); - return studentTeacher.getId(); - } - - @Override - public void updateStudentTeacher(InfraStudentTeacherDO studentTeacher) { - // 校验存在 - validateStudentTeacherExists(studentTeacher.getId()); - // 更新 - studentTeacherMapper.updateById(studentTeacher); - } - - @Override - public void deleteStudentTeacher(Long id) { - // 校验存在 - validateStudentTeacherExists(id); - // 删除 - studentTeacherMapper.deleteById(id); - } - - @Override - public InfraStudentTeacherDO getStudentTeacher(Long id) { - return studentTeacherMapper.selectById(id); - } - - private void validateStudentTeacherExists(Long id) { - if (studentTeacherMapper.selectById(id) == null) { - throw exception(STUDENT_TEACHER_NOT_EXISTS); - } - } - - private void deleteStudentTeacherByStudentId(Long studentId) { - studentTeacherMapper.deleteByStudentId(studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentTeacherDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentTeacherDO deleted file mode 100644 index c19cf9fab2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentTeacherDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生班主任 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_teacher") -@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentTeacherDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentTeacherMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentTeacherMapper deleted file mode 100644 index 994212dabf..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentTeacherMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生班主任 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentTeacherMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long studentId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(InfraStudentTeacherDO::getStudentId, studentId) - .orderByDesc(InfraStudentTeacherDO::getId)); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentTeacherDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/sql/h2 deleted file mode 100644 index 6c1875f601..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/sql/sql deleted file mode 100644 index 83df279264..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/ts/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/ts/index deleted file mode 100644 index 2fe87b741d..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/ts/index +++ /dev/null @@ -1,95 +0,0 @@ -import request from '@/config/axios' - -export interface StudentVO { - id: number - name: string - description: string - birthday: Date - sex: number - enabled: boolean - avatar: string - video: string - memo: string -} - -// 查询学生分页 -export const getStudentPage = async (params) => { - return await request.get({ url: `/infra/student/page`, params }) -} - -// 查询学生详情 -export const getStudent = async (id: number) => { - return await request.get({ url: `/infra/student/get?id=` + id }) -} - -// 新增学生 -export const createStudent = async (data: StudentVO) => { - return await request.post({ url: `/infra/student/create`, data }) -} - -// 修改学生 -export const updateStudent = async (data: StudentVO) => { - return await request.put({ url: `/infra/student/update`, data }) -} - -// 删除学生 -export const deleteStudent = async (id: number) => { - return await request.delete({ url: `/infra/student/delete?id=` + id }) -} - -// 导出学生 Excel -export const exportStudent = async (params) => { - return await request.download({ url: `/infra/student/export-excel`, params }) -} - -// ==================== 子表(学生联系人) ==================== - -// 获得学生联系人分页 -export const getStudentContactPage = async (params) => { - return await request.get({ url: `/infra/student/student-contact/page`, params }) -} -// 新增学生联系人 -export const createStudentContact = async (data) => { - return await request.post({ url: `/infra/student/student-contact/create`, data }) -} - -// 修改学生联系人 -export const updateStudentContact = async (data) => { - return await request.put({ url: `/infra/student/student-contact/update`, data }) -} - -// 删除学生联系人 -export const deleteStudentContact = async (id: number) => { - return await request.delete({ url: `/infra/student/student-contact/delete?id=` + id }) -} - -// 获得学生联系人 -export const getStudentContact = async (id: number) => { - return await request.get({ url: `/infra/student/student-contact/get?id=` + id }) -} - -// ==================== 子表(学生班主任) ==================== - -// 获得学生班主任分页 -export const getStudentTeacherPage = async (params) => { - return await request.get({ url: `/infra/student/student-teacher/page`, params }) -} -// 新增学生班主任 -export const createStudentTeacher = async (data) => { - return await request.post({ url: `/infra/student/student-teacher/create`, data }) -} - -// 修改学生班主任 -export const updateStudentTeacher = async (data) => { - return await request.put({ url: `/infra/student/student-teacher/update`, data }) -} - -// 删除学生班主任 -export const deleteStudentTeacher = async (id: number) => { - return await request.delete({ url: `/infra/student/student-teacher/delete?id=` + id }) -} - -// 获得学生班主任 -export const getStudentTeacher = async (id: number) => { - return await request.get({ url: `/infra/student/student-teacher/get?id=` + id }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentContactForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentContactForm deleted file mode 100644 index 4a139355de..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentContactForm +++ /dev/null @@ -1,155 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentContactList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentContactList deleted file mode 100644 index eada66a759..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentContactList +++ /dev/null @@ -1,146 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentForm deleted file mode 100644 index 0dabcb5f3e..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentForm +++ /dev/null @@ -1,152 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentTeacherForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentTeacherForm deleted file mode 100644 index f93c21c414..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentTeacherForm +++ /dev/null @@ -1,155 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentTeacherList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentTeacherList deleted file mode 100644 index 1eba0a3d0b..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentTeacherList +++ /dev/null @@ -1,146 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/index deleted file mode 100644 index 9d15146121..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/index +++ /dev/null @@ -1,278 +0,0 @@ - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27a..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/assert.json deleted file mode 100644 index 0937ba9148..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/assert.json +++ /dev/null @@ -1,73 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentContactDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" -}, { - "contentPath" : "java/InfraStudentTeacherDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "java/InfraStudentContactMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" -}, { - "contentPath" : "java/InfraStudentTeacherMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "vue/StudentContactForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactForm.vue" -}, { - "contentPath" : "vue/StudentTeacherForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherForm.vue" -}, { - "contentPath" : "vue/StudentContactList", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactList.vue" -}, { - "contentPath" : "vue/StudentTeacherList", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherList.vue" -}, { - "contentPath" : "ts/index", - "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index f8be66202f..0000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,3 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentContactDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentContactDO deleted file mode 100644 index 17c668eaac..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentContactDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生联系人 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_contact") -@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentContactDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentContactMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentContactMapper deleted file mode 100644 index 35bbd53c2d..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentContactMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentContactMapper extends BaseMapperX { - - default List selectListByStudentId(Long studentId) { - return selectList(InfraStudentContactDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentContactDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentController deleted file mode 100644 index b9a587b448..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentController +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - - // ==================== 子表(学生联系人) ==================== - - @GetMapping("/student-contact/list-by-student-id") - @Operation(summary = "获得学生联系人列表") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentContactListByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentContactListByStudentId(studentId)); - } - - // ==================== 子表(学生班主任) ==================== - - @GetMapping("/student-teacher/get-by-student-id") - @Operation(summary = "获得学生班主任") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentTeacherByStudentId(studentId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentDO deleted file mode 100644 index b0d4bd2167..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentMapper deleted file mode 100644 index 34e70a0822..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentPageReqVO deleted file mode 100644 index 41a3730125..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentRespVO deleted file mode 100644 index c41a5501fe..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentSaveReqVO deleted file mode 100644 index faa491dfb8..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - - @Schema(description = "学生联系人列表") - private List studentContacts; - - @Schema(description = "学生班主任") - private InfraStudentTeacherDO studentTeacher; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentService deleted file mode 100644 index afa7d22eb3..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentService +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - - // ==================== 子表(学生联系人) ==================== - - /** - * 获得学生联系人列表 - * - * @param studentId 学生编号 - * @return 学生联系人列表 - */ - List getStudentContactListByStudentId(Long studentId); - - // ==================== 子表(学生班主任) ==================== - - /** - * 获得学生班主任 - * - * @param studentId 学生编号 - * @return 学生班主任 - */ - InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentServiceImpl deleted file mode 100644 index c57cba6137..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentServiceImpl +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - @Resource - private InfraStudentContactMapper studentContactMapper; - @Resource - private InfraStudentTeacherMapper studentTeacherMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - - // 插入子表 - createStudentContactList(student.getId(), createReqVO.getStudentContacts()); - createStudentTeacher(student.getId(), createReqVO.getStudentTeacher()); - // 返回 - return student.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - - // 更新子表 - updateStudentContactList(updateReqVO.getId(), updateReqVO.getStudentContacts()); - updateStudentTeacher(updateReqVO.getId(), updateReqVO.getStudentTeacher()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - - // 删除子表 - deleteStudentContactByStudentId(id); - deleteStudentTeacherByStudentId(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生联系人) ==================== - - @Override - public List getStudentContactListByStudentId(Long studentId) { - return studentContactMapper.selectListByStudentId(studentId); - } - - private void createStudentContactList(Long studentId, List list) { - list.forEach(o -> o.setStudentId(studentId)); - studentContactMapper.insertBatch(list); - } - - private void updateStudentContactList(Long studentId, List list) { - deleteStudentContactByStudentId(studentId); - list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 - createStudentContactList(studentId, list); - } - - private void deleteStudentContactByStudentId(Long studentId) { - studentContactMapper.deleteByStudentId(studentId); - } - - // ==================== 子表(学生班主任) ==================== - - @Override - public InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId) { - return studentTeacherMapper.selectByStudentId(studentId); - } - - private void createStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacherMapper.insert(studentTeacher); - } - - private void updateStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 - studentTeacherMapper.insertOrUpdate(studentTeacher); - } - - private void deleteStudentTeacherByStudentId(Long studentId) { - studentTeacherMapper.deleteByStudentId(studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentTeacherDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentTeacherDO deleted file mode 100644 index c19cf9fab2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentTeacherDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生班主任 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_teacher") -@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentTeacherDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentTeacherMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentTeacherMapper deleted file mode 100644 index 0521bbaf45..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentTeacherMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生班主任 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentTeacherMapper extends BaseMapperX { - - default InfraStudentTeacherDO selectByStudentId(Long studentId) { - return selectOne(InfraStudentTeacherDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentTeacherDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/sql/h2 deleted file mode 100644 index 6c1875f601..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/sql/sql deleted file mode 100644 index 83df279264..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/ts/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/ts/index deleted file mode 100644 index 6112800a94..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/ts/index +++ /dev/null @@ -1,57 +0,0 @@ -import request from '@/config/axios' - -export interface StudentVO { - id: number - name: string - description: string - birthday: Date - sex: number - enabled: boolean - avatar: string - video: string - memo: string -} - -// 查询学生分页 -export const getStudentPage = async (params) => { - return await request.get({ url: `/infra/student/page`, params }) -} - -// 查询学生详情 -export const getStudent = async (id: number) => { - return await request.get({ url: `/infra/student/get?id=` + id }) -} - -// 新增学生 -export const createStudent = async (data: StudentVO) => { - return await request.post({ url: `/infra/student/create`, data }) -} - -// 修改学生 -export const updateStudent = async (data: StudentVO) => { - return await request.put({ url: `/infra/student/update`, data }) -} - -// 删除学生 -export const deleteStudent = async (id: number) => { - return await request.delete({ url: `/infra/student/delete?id=` + id }) -} - -// 导出学生 Excel -export const exportStudent = async (params) => { - return await request.download({ url: `/infra/student/export-excel`, params }) -} - -// ==================== 子表(学生联系人) ==================== - -// 获得学生联系人列表 -export const getStudentContactListByStudentId = async (studentId) => { - return await request.get({ url: `/infra/student/student-contact/list-by-student-id?studentId=` + studentId }) -} - -// ==================== 子表(学生班主任) ==================== - -// 获得学生班主任 -export const getStudentTeacherByStudentId = async (studentId) => { - return await request.get({ url: `/infra/student/student-teacher/get-by-student-id?studentId=` + studentId }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentContactForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentContactForm deleted file mode 100644 index 55ca9945e0..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentContactForm +++ /dev/null @@ -1,174 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentContactList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentContactList deleted file mode 100644 index d0e89dac20..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentContactList +++ /dev/null @@ -1,72 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentForm deleted file mode 100644 index d8e7bc3d08..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentForm +++ /dev/null @@ -1,184 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentTeacherForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentTeacherForm deleted file mode 100644 index b22a4801f0..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentTeacherForm +++ /dev/null @@ -1,122 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentTeacherList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentTeacherList deleted file mode 100644 index e510adcf45..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentTeacherList +++ /dev/null @@ -1,76 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/index deleted file mode 100644 index ee7c05f1f4..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/index +++ /dev/null @@ -1,267 +0,0 @@ - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27a..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/assert.json deleted file mode 100644 index 60e7f47675..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/assert.json +++ /dev/null @@ -1,67 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentContactDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" -}, { - "contentPath" : "java/InfraStudentTeacherDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "java/InfraStudentContactMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" -}, { - "contentPath" : "java/InfraStudentTeacherMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "vue/StudentContactForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactForm.vue" -}, { - "contentPath" : "vue/StudentTeacherForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherForm.vue" -}, { - "contentPath" : "ts/index", - "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index f8be66202f..0000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,3 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentContactDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentContactDO deleted file mode 100644 index 17c668eaac..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentContactDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生联系人 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_contact") -@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentContactDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentContactMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentContactMapper deleted file mode 100644 index 35bbd53c2d..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentContactMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentContactMapper extends BaseMapperX { - - default List selectListByStudentId(Long studentId) { - return selectList(InfraStudentContactDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentContactDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentController deleted file mode 100644 index b9a587b448..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentController +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - - // ==================== 子表(学生联系人) ==================== - - @GetMapping("/student-contact/list-by-student-id") - @Operation(summary = "获得学生联系人列表") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentContactListByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentContactListByStudentId(studentId)); - } - - // ==================== 子表(学生班主任) ==================== - - @GetMapping("/student-teacher/get-by-student-id") - @Operation(summary = "获得学生班主任") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentTeacherByStudentId(studentId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentDO deleted file mode 100644 index b0d4bd2167..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentMapper deleted file mode 100644 index 34e70a0822..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentPageReqVO deleted file mode 100644 index 41a3730125..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentRespVO deleted file mode 100644 index c41a5501fe..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentSaveReqVO deleted file mode 100644 index faa491dfb8..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - - @Schema(description = "学生联系人列表") - private List studentContacts; - - @Schema(description = "学生班主任") - private InfraStudentTeacherDO studentTeacher; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentService deleted file mode 100644 index afa7d22eb3..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentService +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - - // ==================== 子表(学生联系人) ==================== - - /** - * 获得学生联系人列表 - * - * @param studentId 学生编号 - * @return 学生联系人列表 - */ - List getStudentContactListByStudentId(Long studentId); - - // ==================== 子表(学生班主任) ==================== - - /** - * 获得学生班主任 - * - * @param studentId 学生编号 - * @return 学生班主任 - */ - InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentServiceImpl deleted file mode 100644 index c57cba6137..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentServiceImpl +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - @Resource - private InfraStudentContactMapper studentContactMapper; - @Resource - private InfraStudentTeacherMapper studentTeacherMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - - // 插入子表 - createStudentContactList(student.getId(), createReqVO.getStudentContacts()); - createStudentTeacher(student.getId(), createReqVO.getStudentTeacher()); - // 返回 - return student.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - - // 更新子表 - updateStudentContactList(updateReqVO.getId(), updateReqVO.getStudentContacts()); - updateStudentTeacher(updateReqVO.getId(), updateReqVO.getStudentTeacher()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - - // 删除子表 - deleteStudentContactByStudentId(id); - deleteStudentTeacherByStudentId(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生联系人) ==================== - - @Override - public List getStudentContactListByStudentId(Long studentId) { - return studentContactMapper.selectListByStudentId(studentId); - } - - private void createStudentContactList(Long studentId, List list) { - list.forEach(o -> o.setStudentId(studentId)); - studentContactMapper.insertBatch(list); - } - - private void updateStudentContactList(Long studentId, List list) { - deleteStudentContactByStudentId(studentId); - list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 - createStudentContactList(studentId, list); - } - - private void deleteStudentContactByStudentId(Long studentId) { - studentContactMapper.deleteByStudentId(studentId); - } - - // ==================== 子表(学生班主任) ==================== - - @Override - public InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId) { - return studentTeacherMapper.selectByStudentId(studentId); - } - - private void createStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacherMapper.insert(studentTeacher); - } - - private void updateStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 - studentTeacherMapper.insertOrUpdate(studentTeacher); - } - - private void deleteStudentTeacherByStudentId(Long studentId) { - studentTeacherMapper.deleteByStudentId(studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentTeacherDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentTeacherDO deleted file mode 100644 index c19cf9fab2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentTeacherDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生班主任 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_teacher") -@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentTeacherDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentTeacherMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentTeacherMapper deleted file mode 100644 index 0521bbaf45..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentTeacherMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生班主任 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentTeacherMapper extends BaseMapperX { - - default InfraStudentTeacherDO selectByStudentId(Long studentId) { - return selectOne(InfraStudentTeacherDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentTeacherDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/sql/h2 deleted file mode 100644 index 6c1875f601..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/sql/sql deleted file mode 100644 index 83df279264..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/ts/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/ts/index deleted file mode 100644 index 6112800a94..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/ts/index +++ /dev/null @@ -1,57 +0,0 @@ -import request from '@/config/axios' - -export interface StudentVO { - id: number - name: string - description: string - birthday: Date - sex: number - enabled: boolean - avatar: string - video: string - memo: string -} - -// 查询学生分页 -export const getStudentPage = async (params) => { - return await request.get({ url: `/infra/student/page`, params }) -} - -// 查询学生详情 -export const getStudent = async (id: number) => { - return await request.get({ url: `/infra/student/get?id=` + id }) -} - -// 新增学生 -export const createStudent = async (data: StudentVO) => { - return await request.post({ url: `/infra/student/create`, data }) -} - -// 修改学生 -export const updateStudent = async (data: StudentVO) => { - return await request.put({ url: `/infra/student/update`, data }) -} - -// 删除学生 -export const deleteStudent = async (id: number) => { - return await request.delete({ url: `/infra/student/delete?id=` + id }) -} - -// 导出学生 Excel -export const exportStudent = async (params) => { - return await request.download({ url: `/infra/student/export-excel`, params }) -} - -// ==================== 子表(学生联系人) ==================== - -// 获得学生联系人列表 -export const getStudentContactListByStudentId = async (studentId) => { - return await request.get({ url: `/infra/student/student-contact/list-by-student-id?studentId=` + studentId }) -} - -// ==================== 子表(学生班主任) ==================== - -// 获得学生班主任 -export const getStudentTeacherByStudentId = async (studentId) => { - return await request.get({ url: `/infra/student/student-teacher/get-by-student-id?studentId=` + studentId }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentContactForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentContactForm deleted file mode 100644 index 55ca9945e0..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentContactForm +++ /dev/null @@ -1,174 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentForm deleted file mode 100644 index d8e7bc3d08..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentForm +++ /dev/null @@ -1,184 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentTeacherForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentTeacherForm deleted file mode 100644 index b22a4801f0..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentTeacherForm +++ /dev/null @@ -1,122 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/index deleted file mode 100644 index b115b13deb..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/index +++ /dev/null @@ -1,252 +0,0 @@ - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27a..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/assert.json deleted file mode 100644 index 5a0eebdeb2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/assert.json +++ /dev/null @@ -1,49 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "ts/index", - "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index f8be66202f..0000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,3 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentController deleted file mode 100644 index 3796982c44..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentController +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentDO deleted file mode 100644 index b0d4bd2167..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentMapper deleted file mode 100644 index 34e70a0822..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentPageReqVO deleted file mode 100644 index 41a3730125..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentRespVO deleted file mode 100644 index c41a5501fe..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentSaveReqVO deleted file mode 100644 index 43e7f147d6..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentService deleted file mode 100644 index c4a0e1792c..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentService +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentServiceImpl deleted file mode 100644 index 2292a66f37..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentServiceImpl +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - - @Override - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - // 返回 - return student.getId(); - } - - @Override - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - } - - @Override - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/sql/h2 deleted file mode 100644 index 6c1875f601..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/sql/sql deleted file mode 100644 index 83df279264..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/ts/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/ts/index deleted file mode 100644 index 8cdf2548d2..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/ts/index +++ /dev/null @@ -1,43 +0,0 @@ -import request from '@/config/axios' - -export interface StudentVO { - id: number - name: string - description: string - birthday: Date - sex: number - enabled: boolean - avatar: string - video: string - memo: string -} - -// 查询学生分页 -export const getStudentPage = async (params) => { - return await request.get({ url: `/infra/student/page`, params }) -} - -// 查询学生详情 -export const getStudent = async (id: number) => { - return await request.get({ url: `/infra/student/get?id=` + id }) -} - -// 新增学生 -export const createStudent = async (data: StudentVO) => { - return await request.post({ url: `/infra/student/create`, data }) -} - -// 修改学生 -export const updateStudent = async (data: StudentVO) => { - return await request.put({ url: `/infra/student/update`, data }) -} - -// 删除学生 -export const deleteStudent = async (id: number) => { - return await request.delete({ url: `/infra/student/delete?id=` + id }) -} - -// 导出学生 Excel -export const exportStudent = async (params) => { - return await request.download({ url: `/infra/student/export-excel`, params }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/vue/StudentForm deleted file mode 100644 index 0dabcb5f3e..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/vue/StudentForm +++ /dev/null @@ -1,152 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/vue/index deleted file mode 100644 index b115b13deb..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/vue/index +++ /dev/null @@ -1,252 +0,0 @@ - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27a..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/assert.json deleted file mode 100644 index 357df0080b..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/assert.json +++ /dev/null @@ -1,49 +0,0 @@ -[ { - "contentPath" : "java/InfraCategoryListReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategoryListReqVO.java" -}, { - "contentPath" : "java/InfraCategoryRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategoryRespVO.java" -}, { - "contentPath" : "java/InfraCategorySaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategorySaveReqVO.java" -}, { - "contentPath" : "java/InfraCategoryController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraCategoryController.java" -}, { - "contentPath" : "java/InfraCategoryDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraCategoryDO.java" -}, { - "contentPath" : "java/InfraCategoryMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraCategoryMapper.java" -}, { - "contentPath" : "xml/InfraCategoryMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraCategoryMapper.xml" -}, { - "contentPath" : "java/InfraCategoryServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryServiceImpl.java" -}, { - "contentPath" : "java/InfraCategoryService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryService.java" -}, { - "contentPath" : "java/InfraCategoryServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" -}, { - "contentPath" : "vue/CategoryForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/CategoryForm.vue" -}, { - "contentPath" : "ts/index", - "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index 36df6752e9..0000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,8 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 分类 TODO 补充编号 ========== -ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(TODO 补充编号, "分类不存在"); -ErrorCode CATEGORY_EXITS_CHILDREN = new ErrorCode(TODO 补充编号, "存在存在子分类,无法删除"); -ErrorCode CATEGORY_PARENT_NOT_EXITS = new ErrorCode(TODO 补充编号,"父级分类不存在"); -ErrorCode CATEGORY_PARENT_ERROR = new ErrorCode(TODO 补充编号, "不能设置自己为父分类"); -ErrorCode CATEGORY_NAME_DUPLICATE = new ErrorCode(TODO 补充编号, "已经存在该名字的分类"); -ErrorCode CATEGORY_PARENT_IS_CHILD = new ErrorCode(TODO 补充编号, "不能设置自己的子InfraCategory为父InfraCategory"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryController deleted file mode 100644 index a7b2f81632..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryController +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraCategoryService; - -@Tag(name = "管理后台 - 分类") -@RestController -@RequestMapping("/infra/category") -@Validated -public class InfraCategoryController { - - @Resource - private InfraCategoryService categoryService; - - @PostMapping("/create") - @Operation(summary = "创建分类") - @PreAuthorize("@ss.hasPermission('infra:category:create')") - public CommonResult createCategory(@Valid @RequestBody InfraCategorySaveReqVO createReqVO) { - return success(categoryService.createCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新分类") - @PreAuthorize("@ss.hasPermission('infra:category:update')") - public CommonResult updateCategory(@Valid @RequestBody InfraCategorySaveReqVO updateReqVO) { - categoryService.updateCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:category:delete')") - public CommonResult deleteCategory(@RequestParam("id") Long id) { - categoryService.deleteCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:category:query')") - public CommonResult getCategory(@RequestParam("id") Long id) { - InfraCategoryDO category = categoryService.getCategory(id); - return success(BeanUtils.toBean(category, InfraCategoryRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得分类列表") - @PreAuthorize("@ss.hasPermission('infra:category:query')") - public CommonResult> getCategoryList(@Valid InfraCategoryListReqVO listReqVO) { - List list = categoryService.getCategoryList(listReqVO); - return success(BeanUtils.toBean(list, InfraCategoryRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出分类 Excel") - @PreAuthorize("@ss.hasPermission('infra:category:export')") - @OperateLog(type = EXPORT) - public void exportCategoryExcel(@Valid InfraCategoryListReqVO listReqVO, - HttpServletResponse response) throws IOException { - List list = categoryService.getCategoryList(listReqVO); - // 导出 Excel - ExcelUtils.write(response, "分类.xls", "数据", InfraCategoryRespVO.class, - BeanUtils.toBean(list, InfraCategoryRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryDO deleted file mode 100644 index 9bf21c08bc..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryDO +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 分类 DO - * - * @author 芋道源码 - */ -@TableName("infra_category") -@KeySequence("infra_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraCategoryDO extends BaseDO { - - public static final Long PARENT_ID_ROOT = 0L; - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 父编号 - */ - private Long parentId; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryListReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryListReqVO deleted file mode 100644 index e5c6f181f9..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryListReqVO +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -@Schema(description = "管理后台 - 分类列表 Request VO") -@Data -public class InfraCategoryListReqVO { - - @Schema(description = "名字", example = "芋头") - private String name; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryMapper deleted file mode 100644 index 9dadbf1d9d..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryMapper +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 分类 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraCategoryMapper extends BaseMapperX { - - default List selectList(InfraCategoryListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(InfraCategoryDO::getName, reqVO.getName()) - .orderByDesc(InfraCategoryDO::getId)); - } - - default InfraCategoryDO selectByParentIdAndName(Long parentId, String name) { - return selectOne(InfraCategoryDO::getParentId, parentId, InfraCategoryDO::getName, name); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(InfraCategoryDO::getParentId, parentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryRespVO deleted file mode 100644 index 6325d866c5..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryRespVO +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import com.alibaba.excel.annotation.*; - -@Schema(description = "管理后台 - 分类 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraCategoryRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "父编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @ExcelProperty("父编号") - private Long parentId; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategorySaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategorySaveReqVO deleted file mode 100644 index 3c03b977fb..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategorySaveReqVO +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; - -@Schema(description = "管理后台 - 分类新增/修改 Request VO") -@Data -public class InfraCategorySaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "父编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "父编号不能为空") - private Long parentId; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryService deleted file mode 100644 index 9d0ae1afab..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryService +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 分类 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraCategoryService { - - /** - * 创建分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCategory(@Valid InfraCategorySaveReqVO createReqVO); - - /** - * 更新分类 - * - * @param updateReqVO 更新信息 - */ - void updateCategory(@Valid InfraCategorySaveReqVO updateReqVO); - - /** - * 删除分类 - * - * @param id 编号 - */ - void deleteCategory(Long id); - - /** - * 获得分类 - * - * @param id 编号 - * @return 分类 - */ - InfraCategoryDO getCategory(Long id); - - /** - * 获得分类列表 - * - * @param listReqVO 查询条件 - * @return 分类列表 - */ - List getCategoryList(InfraCategoryListReqVO listReqVO); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryServiceImpl deleted file mode 100644 index 351568b186..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryServiceImpl +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraCategoryMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 分类 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraCategoryServiceImpl implements InfraCategoryService { - - @Resource - private InfraCategoryMapper categoryMapper; - - @Override - public Long createCategory(InfraCategorySaveReqVO createReqVO) { - // 校验父编号的有效性 - validateParentCategory(null, createReqVO.getParentId()); - // 校验名字的唯一性 - validateCategoryNameUnique(null, createReqVO.getParentId(), createReqVO.getName()); - - // 插入 - InfraCategoryDO category = BeanUtils.toBean(createReqVO, InfraCategoryDO.class); - categoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateCategory(InfraCategorySaveReqVO updateReqVO) { - // 校验存在 - validateCategoryExists(updateReqVO.getId()); - // 校验父编号的有效性 - validateParentCategory(updateReqVO.getId(), updateReqVO.getParentId()); - // 校验名字的唯一性 - validateCategoryNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); - - // 更新 - InfraCategoryDO updateObj = BeanUtils.toBean(updateReqVO, InfraCategoryDO.class); - categoryMapper.updateById(updateObj); - } - - @Override - public void deleteCategory(Long id) { - // 校验存在 - validateCategoryExists(id); - // 校验是否有子分类 - if (categoryMapper.selectCountByParentId(id) > 0) { - throw exception(CATEGORY_EXITS_CHILDREN); - } - // 删除 - categoryMapper.deleteById(id); - } - - private void validateCategoryExists(Long id) { - if (categoryMapper.selectById(id) == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - } - - private void validateParentCategory(Long id, Long parentId) { - if (parentId == null || CategoryDO.PARENT_ID_ROOT.equals(parentId)) { - return; - } - // 1. 不能设置自己为父分类 - if (Objects.equals(id, parentId)) { - throw exception(CATEGORY_PARENT_ERROR); - } - // 2. 父分类不存在 - CategoryDO parentCategory = categoryMapper.selectById(parentId); - if (parentCategory == null) { - throw exception(CATEGORY_PARENT_NOT_EXITS); - } - // 3. 递归校验父分类,如果父分类是自己的子分类,则报错,避免形成环路 - if (id == null) { // id 为空,说明新增,不需要考虑环路 - return; - } - for (int i = 0; i < Short.MAX_VALUE; i++) { - // 3.1 校验环路 - parentId = parentCategory.getParentId(); - if (Objects.equals(id, parentId)) { - throw exception(CATEGORY_PARENT_IS_CHILD); - } - // 3.2 继续递归下一级父分类 - if (parentId == null || CategoryDO.PARENT_ID_ROOT.equals(parentId)) { - break; - } - parentCategory = categoryMapper.selectById(parentId); - if (parentCategory == null) { - break; - } - } - } - - private void validateCategoryNameUnique(Long id, Long parentId, String name) { - CategoryDO category = categoryMapper.selectByParentIdAndName(parentId, name); - if (category == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的分类 - if (id == null) { - throw exception(CATEGORY_NAME_DUPLICATE); - } - if (!Objects.equals(category.getId(), id)) { - throw exception(CATEGORY_NAME_DUPLICATE); - } - } - - @Override - public InfraCategoryDO getCategory(Long id) { - return categoryMapper.selectById(id); - } - - @Override - public List getCategoryList(InfraCategoryListReqVO listReqVO) { - return categoryMapper.selectList(listReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryServiceImplTest deleted file mode 100644 index efb70fd332..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryServiceImplTest +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraCategoryMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraCategoryServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraCategoryServiceImpl.class) -public class InfraCategoryServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraCategoryServiceImpl categoryService; - - @Resource - private InfraCategoryMapper categoryMapper; - - @Test - public void testCreateCategory_success() { - // 准备参数 - InfraCategorySaveReqVO createReqVO = randomPojo(InfraCategorySaveReqVO.class).setId(null); - - // 调用 - Long categoryId = categoryService.createCategory(createReqVO); - // 断言 - assertNotNull(categoryId); - // 校验记录的属性是否正确 - InfraCategoryDO category = categoryMapper.selectById(categoryId); - assertPojoEquals(createReqVO, category, "id"); - } - - @Test - public void testUpdateCategory_success() { - // mock 数据 - InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class); - categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraCategorySaveReqVO updateReqVO = randomPojo(InfraCategorySaveReqVO.class, o -> { - o.setId(dbCategory.getId()); // 设置更新的 ID - }); - - // 调用 - categoryService.updateCategory(updateReqVO); - // 校验是否更新正确 - InfraCategoryDO category = categoryMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, category); - } - - @Test - public void testUpdateCategory_notExists() { - // 准备参数 - InfraCategorySaveReqVO updateReqVO = randomPojo(InfraCategorySaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> categoryService.updateCategory(updateReqVO), CATEGORY_NOT_EXISTS); - } - - @Test - public void testDeleteCategory_success() { - // mock 数据 - InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class); - categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCategory.getId(); - - // 调用 - categoryService.deleteCategory(id); - // 校验数据不存在了 - assertNull(categoryMapper.selectById(id)); - } - - @Test - public void testDeleteCategory_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> categoryService.deleteCategory(id), CATEGORY_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetCategoryList() { - // mock 数据 - InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class, o -> { // 等会查询到 - o.setName(null); - }); - categoryMapper.insert(dbCategory); - // 测试 name 不匹配 - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName(null))); - // 准备参数 - InfraCategoryListReqVO reqVO = new InfraCategoryListReqVO(); - reqVO.setName(null); - - // 调用 - List list = categoryService.getCategoryList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbCategory, list.get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/sql/h2 deleted file mode 100644 index 4141766cf4..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/sql/h2 +++ /dev/null @@ -1,10 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_category" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '分类表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_category"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/sql/sql deleted file mode 100644 index 81409488a5..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '分类管理', '', 2, 0, 888, - 'category', '', 'infra/demo/index', 0, 'InfraCategory' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类查询', 'infra:category:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类创建', 'infra:category:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类更新', 'infra:category:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类删除', 'infra:category:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类导出', 'infra:category:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/ts/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/ts/index deleted file mode 100644 index 453c885c17..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/ts/index +++ /dev/null @@ -1,37 +0,0 @@ -import request from '@/config/axios' - -export interface CategoryVO { - id: number - name: string - parentId: number -} - -// 查询分类列表 -export const getCategoryList = async (params) => { - return await request.get({ url: `/infra/category/list`, params }) -} - -// 查询分类详情 -export const getCategory = async (id: number) => { - return await request.get({ url: `/infra/category/get?id=` + id }) -} - -// 新增分类 -export const createCategory = async (data: CategoryVO) => { - return await request.post({ url: `/infra/category/create`, data }) -} - -// 修改分类 -export const updateCategory = async (data: CategoryVO) => { - return await request.put({ url: `/infra/category/update`, data }) -} - -// 删除分类 -export const deleteCategory = async (id: number) => { - return await request.delete({ url: `/infra/category/delete?id=` + id }) -} - -// 导出分类 Excel -export const exportCategory = async (params) => { - return await request.download({ url: `/infra/category/export-excel`, params }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/vue/CategoryForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/vue/CategoryForm deleted file mode 100644 index 8e139fb137..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/vue/CategoryForm +++ /dev/null @@ -1,114 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/vue/index deleted file mode 100644 index 46902e73c4..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/vue/index +++ /dev/null @@ -1,185 +0,0 @@ - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/xml/InfraCategoryMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/xml/InfraCategoryMapper deleted file mode 100644 index 025ac85071..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/xml/InfraCategoryMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/logback.xml b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff0..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/clean.sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index a3e0fd0299..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,12 +0,0 @@ -DELETE FROM "infra_config"; -DELETE FROM "infra_file_config"; -DELETE FROM "infra_file"; -DELETE FROM "infra_job"; -DELETE FROM "infra_job_log"; -DELETE FROM "infra_api_access_log"; -DELETE FROM "infra_api_error_log"; -DELETE FROM "infra_file_config"; -DELETE FROM "infra_test_demo"; -DELETE FROM "infra_data_source_config"; -DELETE FROM "infra_codegen_table"; -DELETE FROM "infra_codegen_column"; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/create_tables.sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index a5f896ce1e..0000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,228 +0,0 @@ - -CREATE TABLE IF NOT EXISTS "infra_config" ( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '编号', - "category" varchar(50) NOT NULL, - "type" tinyint NOT NULL, - "name" varchar(100) NOT NULL DEFAULT '' COMMENT '名字', - "config_key" varchar(100) NOT NULL DEFAULT '', - "value" varchar(500) NOT NULL DEFAULT '', - "visible" bit NOT NULL, - "remark" varchar(500) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '参数配置表'; - -CREATE TABLE IF NOT EXISTS "infra_file_config" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "storage" tinyint NOT NULL, - "remark" varchar(255), - "master" bit(1) NOT NULL, - "config" varchar(4096) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '文件配置表'; - -CREATE TABLE IF NOT EXISTS "infra_file" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "config_id" bigint NOT NULL, - "name" varchar(256), - "path" varchar(512), - "url" varchar(1024), - "type" varchar(63) DEFAULT NULL, - "size" bigint NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '文件表'; - -CREATE TABLE IF NOT EXISTS "infra_job" ( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '任务编号', - "name" varchar(32) NOT NULL COMMENT '任务名称', - "status" tinyint(4) NOT NULL COMMENT '任务状态', - "handler_name" varchar(64) NOT NULL COMMENT '处理器的名字', - "handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数', - "cron_expression" varchar(32) NOT NULL COMMENT 'CRON 表达式', - "retry_count" int(11) NOT NULL DEFAULT '0' COMMENT '重试次数', - "retry_interval" int(11) NOT NULL DEFAULT '0' COMMENT '重试间隔', - "monitor_timeout" int(11) NOT NULL DEFAULT '0' COMMENT '监控超时时间', - "creator" varchar(64) DEFAULT '' COMMENT '创建者', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - "updater" varchar(64) DEFAULT '' COMMENT '更新者', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - "deleted" bit NOT NULL DEFAULT FALSE COMMENT '是否删除', - PRIMARY KEY ("id") -) COMMENT='定时任务表'; - -CREATE TABLE IF NOT EXISTS "infra_job_log" ( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '日志编号', - "job_id" bigint(20) NOT NULL COMMENT '任务编号', - "handler_name" varchar(64) NOT NULL COMMENT '处理器的名字', - "handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数', - "execute_index" tinyint(4) NOT NULL DEFAULT '1' COMMENT '第几次执行', - "begin_time" datetime NOT NULL COMMENT '开始执行时间', - "end_time" datetime DEFAULT NULL COMMENT '结束执行时间', - "duration" int(11) DEFAULT NULL COMMENT '执行时长', - "status" tinyint(4) NOT NULL COMMENT '任务状态', - "result" varchar(4000) DEFAULT '' COMMENT '结果数据', - "creator" varchar(64) DEFAULT '' COMMENT '创建者', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - "updater" varchar(64) DEFAULT '' COMMENT '更新者', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - "deleted" bit(1) NOT NULL DEFAULT FALSE COMMENT '是否删除', - PRIMARY KEY ("id") -)COMMENT='定时任务日志表'; - -CREATE TABLE IF NOT EXISTS "infra_api_access_log" ( - "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, - "trace_id" varchar(64) not null default '', - "user_id" bigint not null default '0', - "user_type" tinyint not null default '0', - "application_name" varchar(50) not null, - "request_method" varchar(16) not null default '', - "request_url" varchar(255) not null default '', - "request_params" varchar(8000) not null default '', - "user_ip" varchar(50) not null, - "user_agent" varchar(512) not null, - "begin_time" timestamp not null, - "end_time" timestamp not null, - "duration" integer not null, - "result_code" integer not null default '0', - "result_msg" varchar(512) default '', - "creator" varchar(64) default '', - "create_time" timestamp not null default current_timestamp, - "updater" varchar(64) default '', - "update_time" timestamp not null default current_timestamp, - "deleted" bit not null default false, - "tenant_id" bigint not null default '0', - primary key ("id") - ) COMMENT 'API 访问日志表'; - -CREATE TABLE IF NOT EXISTS "infra_api_error_log" ( - "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, - "trace_id" varchar(64) not null, - "user_id" bigint not null default '0', - "user_type" tinyint not null default '0', - "application_name" varchar(50) not null, - "request_method" varchar(16) not null, - "request_url" varchar(255) not null, - "request_params" varchar(8000) not null, - "user_ip" varchar(50) not null, - "user_agent" varchar(512) not null, - "exception_time" timestamp not null, - "exception_name" varchar(128) not null default '', - "exception_message" clob not null, - "exception_root_cause_message" clob not null, - "exception_stack_trace" clob not null, - "exception_class_name" varchar(512) not null, - "exception_file_name" varchar(512) not null, - "exception_method_name" varchar(512) not null, - "exception_line_number" integer not null, - "process_status" tinyint not null, - "process_time" timestamp default null, - "process_user_id" bigint default '0', - "creator" varchar(64) default '', - "create_time" timestamp not null default current_timestamp, - "updater" varchar(64) default '', - "update_time" timestamp not null default current_timestamp, - "deleted" bit not null default false, - "tenant_id" bigint not null default '0', - primary key ("id") -) COMMENT '系统异常日志'; - -CREATE TABLE IF NOT EXISTS "infra_test_demo" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(100) NOT NULL, - "status" tinyint NOT NULL, - "type" tinyint NOT NULL, - "category" tinyint NOT NULL, - "remark" varchar(500), - "creator" varchar(64) DEFAULT '''', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '''', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '字典类型表'; - -CREATE TABLE IF NOT EXISTS "infra_data_source_config" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(100) NOT NULL, - "url" varchar(1024) NOT NULL, - "username" varchar(255) NOT NULL, - "password" varchar(255) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '数据源配置表'; - -CREATE TABLE IF NOT EXISTS "infra_codegen_table" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "data_source_config_id" bigint not null, - "scene" tinyint not null DEFAULT 1, - "table_name" varchar(200) NOT NULL, - "table_comment" varchar(500) NOT NULL, - "remark" varchar(500) NOT NULL, - "module_name" varchar(30) NOT NULL, - "business_name" varchar(30) NOT NULL, - "class_name" varchar(100) NOT NULL, - "class_comment" varchar(50) NOT NULL, - "author" varchar(50) NOT NULL, - "template_type" tinyint not null DEFAULT 1, - "front_type" tinyint not null, - "parent_menu_id" bigint not null, - "master_table_id" bigint not null, - "sub_join_column_id" bigint not null, - "sub_join_many" bit not null, - "tree_parent_column_id" bigint not null, - "tree_name_column_id" bigint not null, - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '代码生成表定义表'; - -CREATE TABLE IF NOT EXISTS "infra_codegen_column" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "table_id" bigint not null, - "column_name" varchar(200) NOT NULL, - "data_type" varchar(100) NOT NULL, - "column_comment" varchar(500) NOT NULL, - "nullable" tinyint not null, - "primary_key" tinyint not null, - "auto_increment" varchar(5) not null, - "ordinal_position" int not null, - "java_type" varchar(32) NOT NULL, - "java_field" varchar(64) NOT NULL, - "dict_type" varchar(200) NOT NULL, - "example" varchar(64) NOT NULL, - "create_operation" bit not null, - "update_operation" bit not null, - "list_operation" bit not null, - "list_operation_condition" varchar(32) not null, - "list_operation_result" bit not null, - "html_type" varchar(32) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '代码生成表字段定义表'; \ No newline at end of file diff --git a/yudao-module-mall/pom.xml b/yudao-module-mall/pom.xml deleted file mode 100644 index f4854aef0a..0000000000 --- a/yudao-module-mall/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - yudao - cn.iocoder.boot - ${revision} - - 4.0.0 - - yudao-module-mall - pom - - ${project.artifactId} - - - 商城大模块,由 product 商品、promotion 营销、trade 交易、statistics 统计等组成 - - - yudao-module-promotion-api - yudao-module-promotion-biz - yudao-module-product-api - yudao-module-product-biz - yudao-module-trade-api - yudao-module-trade-biz - yudao-module-statistics-api - yudao-module-statistics-biz - - - diff --git a/yudao-module-mall/yudao-module-product-api/pom.xml b/yudao-module-mall/yudao-module-product-api/pom.xml deleted file mode 100644 index 123e7c3349..0000000000 --- a/yudao-module-mall/yudao-module-product-api/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - 4.0.0 - - cn.iocoder.boot - yudao-module-mall - ${revision} - - - yudao-module-product-api - jar - - ${project.artifactId} - - product 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApi.java deleted file mode 100644 index 38feb96d68..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApi.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.product.api.category; - -import java.util.Collection; - -/** - * 商品分类 API 接口 - * - * @author owen - */ -public interface ProductCategoryApi { - - /** - * 校验商品分类是否有效。如下情况,视为无效: - * 1. 商品分类编号不存在 - * 2. 商品分类被禁用 - * - * @param ids 商品分类编号数组 - */ - void validateCategoryList(Collection ids); -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java deleted file mode 100644 index b0ba1f7fef..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.product.api.comment; - -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; - -/** - * 产品评论 API 接口 - * - * @author HUIHUI - */ -public interface ProductCommentApi { - - /** - * 创建评论 - * - * @param createReqDTO 评论参数 - * @return 返回评论创建后的 id - */ - Long createComment(ProductCommentCreateReqDTO createReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java deleted file mode 100644 index 66caeed4b9..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.product.api.comment.dto; - -import lombok.Data; - -import jakarta.validation.constraints.NotNull; -import java.util.List; - -/** - * 评论创建请求 DTO - * - * @author HUIHUI - */ -@Data -public class ProductCommentCreateReqDTO { - - /** - * 商品 SKU 编号 - */ - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - /** - * 订单编号 - */ - private Long orderId; - /** - * 交易订单项编号 - */ - private Long orderItemId; - - /** - * 描述星级 1-5 分 - */ - @NotNull(message = "描述星级不能为空") - private Integer descriptionScores; - /** - * 服务星级 1-5 分 - */ - @NotNull(message = "服务星级不能为空") - private Integer benefitScores; - /** - * 评论内容 - */ - @NotNull(message = "评论内容不能为空") - private String content; - /** - * 评论图片地址数组,以逗号分隔最多上传 9 张 - */ - private List picUrls; - - /** - * 是否匿名 - */ - @NotNull(message = "是否匿名不能为空") - private Boolean anonymous; - /** - * 评价人 - */ - @NotNull(message = "评价人不能为空") - private Long userId; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java deleted file mode 100644 index b190928532..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.product.api; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java deleted file mode 100644 index 2a1ab71a9b..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.product.api.property.dto; - -import lombok.Data; - -/** - * 商品属性项的明细 Response DTO - * - * @author 芋道源码 - */ -@Data -public class ProductPropertyValueDetailRespDTO { - - /** - * 属性的编号 - */ - private Long propertyId; - - /** - * 属性的名称 - */ - private String propertyName; - - /** - * 属性值的编号 - */ - private Long valueId; - - /** - * 属性值的名称 - */ - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java deleted file mode 100644 index 3581fdb913..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku; - -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; - -import java.util.Collection; -import java.util.List; - -/** - * 商品 SKU API 接口 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface ProductSkuApi { - - /** - * 查询 SKU 信息 - * - * @param id SKU 编号 - * @return SKU 信息 - */ - ProductSkuRespDTO getSku(Long id); - - /** - * 批量查询 SKU 数组 - * - * @param ids SKU 编号列表 - * @return SKU 数组 - */ - List getSkuList(Collection ids); - - /** - * 批量查询 SKU 数组 - * - * @param spuIds SPU 编号列表 - * @return SKU 数组 - */ - List getSkuListBySpuId(Collection spuIds); - - /** - * 更新 SKU 库存(增加 or 减少) - * - * @param updateStockReqDTO 更新请求 - */ - void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java deleted file mode 100644 index 338c4dd859..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku.dto; - -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import lombok.Data; - -import java.util.List; - -/** - * 商品 SKU 信息 Response DTO - * - * @author LeeYan9 - * @since 2022-08-26 - */ -@Data -public class ProductSkuRespDTO { - - /** - * 商品 SKU 编号,自增 - */ - private Long id; - /** - * SPU 编号 - */ - private Long spuId; - - /** - * 属性数组 - */ - private List properties; - /** - * 销售价格,单位:分 - */ - private Integer price; - /** - * 市场价,单位:分 - */ - private Integer marketPrice; - /** - * 成本价,单位:分 - */ - private Integer costPrice; - /** - * SKU 的条形码 - */ - private String barCode; - /** - * 图片地址 - */ - private String picUrl; - /** - * 库存 - */ - private Integer stock; - /** - * 商品重量,单位:kg 千克 - */ - private Double weight; - /** - * 商品体积,单位:m^3 平米 - */ - private Double volume; - /** - * 一级分销的佣金,单位:分 - */ - private Integer firstBrokeragePrice; - /** - * 二级分销的佣金,单位:分 - */ - private Integer secondBrokeragePrice; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuUpdateStockReqDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuUpdateStockReqDTO.java deleted file mode 100644 index 98c63c747b..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuUpdateStockReqDTO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku.dto; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotNull; -import java.util.List; - -/** - * 商品 SKU 更新库存 Request DTO - * - * @author LeeYan9 - * @since 2022-08-26 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ProductSkuUpdateStockReqDTO { - - /** - * 商品 SKU - */ - @NotNull(message = "商品 SKU 不能为空") - private List items; - - @Data - public static class Item { - - /** - * 商品 SKU 编号 - */ - @NotNull(message = "商品 SKU 编号不能为空") - private Long id; - - /** - * 库存变化数量 - * - * 正数:增加库存 - * 负数:扣减库存 - */ - @NotNull(message = "库存变化数量不能为空") - private Integer incrCount; - - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java deleted file mode 100644 index 233d129fac..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.api.spu; - -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; - -import java.util.Collection; -import java.util.List; - -/** - * 商品 SPU API 接口 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface ProductSpuApi { - - /** - * 批量查询 SPU 数组 - * - * @param ids SPU 编号列表 - * @return SPU 数组 - */ - List getSpuList(Collection ids); - - /** - * 批量查询 SPU 数组,并且校验是否 SPU 是否有效。 - * - * 如下情况,视为无效: - * 1. 商品编号不存在 - * 2. 商品被禁用 - * - * @param ids SPU 编号列表 - * @return SPU 数组 - */ - List validateSpuList(Collection ids); - - /** - * 获得 SPU - * - * @return SPU - */ - ProductSpuRespDTO getSpu(Long id); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java deleted file mode 100644 index dfe43ba387..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.product.api.spu.dto; - -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import lombok.Data; - -// TODO @LeeYan9: ProductSpuRespDTO -/** - * 商品 SPU 信息 Response DTO - * - * @author LeeYan9 - * @since 2022-08-26 - */ -@Data -public class ProductSpuRespDTO { - - /** - * 商品 SPU 编号,自增 - */ - private Long id; - - // ========== 基本信息 ========= - - /** - * 商品名称 - */ - private String name; - /** - * 单位 - * - * 对应 product_unit 数据字典 - */ - private Integer unit; - - /** - * 商品分类编号 - */ - private Long categoryId; - /** - * 商品封面图 - */ - private String picUrl; - - /** - * 商品状态 - *

- * 枚举 {@link ProductSpuStatusEnum} - */ - private Integer status; - - // ========== SKU 相关字段 ========= - - /** - * 规格类型 - * - * false - 单规格 - * true - 多规格 - */ - private Boolean specType; - /** - * 商品价格,单位使用:分 - */ - private Integer price; - /** - * 市场价,单位使用:分 - */ - private Integer marketPrice; - /** - * 成本价,单位使用:分 - */ - private Integer costPrice; - /** - * 库存 - */ - private Integer stock; - - // ========== 物流相关字段 ========= - - /** - * 物流配置模板编号 - * - * 对应 TradeDeliveryExpressTemplateDO 的 id 编号 - */ - private Long deliveryTemplateId; - - // ========== 营销相关字段 ========= - - /** - * 赠送积分 - */ - private Integer giveIntegral; - - // ========== 分销相关字段 ========= - - /** - * 分销类型 - * - * false - 默认 - * true - 自行设置 - */ - private Boolean subCommissionType; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/DictTypeConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/DictTypeConstants.java deleted file mode 100644 index 85725a18ea..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/DictTypeConstants.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.product.enums; - -/** - * product 字典类型的枚举类 - * - * @author HUIHUI - */ -public interface DictTypeConstants { - - String PRODUCT_UNIT = "product_unit"; // 商品单位 - String PRODUCT_SPU_STATUS = "product_spu_status"; // 商品 SPU 状态 - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java deleted file mode 100644 index 1d0ea189f3..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.product.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Product 错误码枚举类 - * - * product 系统,使用 1-008-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 商品分类相关 1-008-001-000 ============ - ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(1_008_001_000, "商品分类不存在"); - ErrorCode CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1_008_001_001, "父分类不存在"); - ErrorCode CATEGORY_PARENT_NOT_FIRST_LEVEL = new ErrorCode(1_008_001_002, "父分类不能是二级分类"); - ErrorCode CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_008_001_003, "存在子分类,无法删除"); - ErrorCode CATEGORY_DISABLED = new ErrorCode(1_008_001_004, "商品分类({})已禁用,无法使用"); - ErrorCode CATEGORY_HAVE_BIND_SPU = new ErrorCode(1_008_001_005, "类别下存在商品,无法删除"); - - // ========== 商品品牌相关编号 1-008-002-000 ========== - ErrorCode BRAND_NOT_EXISTS = new ErrorCode(1_008_002_000, "品牌不存在"); - ErrorCode BRAND_DISABLED = new ErrorCode(1_008_002_001, "品牌已禁用"); - ErrorCode BRAND_NAME_EXISTS = new ErrorCode(1_008_002_002, "品牌名称已存在"); - - // ========== 商品属性项 1-008-003-000 ========== - ErrorCode PROPERTY_NOT_EXISTS = new ErrorCode(1_008_003_000, "属性项不存在"); - ErrorCode PROPERTY_EXISTS = new ErrorCode(1_008_003_001, "属性项的名称已存在"); - ErrorCode PROPERTY_DELETE_FAIL_VALUE_EXISTS = new ErrorCode(1_008_003_002, "属性项下存在属性值,无法删除"); - - // ========== 商品属性值 1-008-004-000 ========== - ErrorCode PROPERTY_VALUE_NOT_EXISTS = new ErrorCode(1_008_004_000, "属性值不存在"); - ErrorCode PROPERTY_VALUE_EXISTS = new ErrorCode(1_008_004_001, "属性值的名称已存在"); - - // ========== 商品 SPU 1-008-005-000 ========== - ErrorCode SPU_NOT_EXISTS = new ErrorCode(1_008_005_000, "商品 SPU 不存在"); - ErrorCode SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR = new ErrorCode(1_008_005_001, "商品分类不正确,原因:必须使用第二级的商品分类及以下"); - ErrorCode SPU_SAVE_FAIL_COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1_008_005_002, "商品 SPU 保存失败,原因:优惠卷不存在"); - ErrorCode SPU_NOT_ENABLE = new ErrorCode(1_008_005_003, "商品 SPU【{}】不处于上架状态"); - ErrorCode SPU_NOT_RECYCLE = new ErrorCode(1_008_005_004, "商品 SPU 不处于回收站状态"); - - // ========== 商品 SKU 1-008-006-000 ========== - ErrorCode SKU_NOT_EXISTS = new ErrorCode(1_008_006_000, "商品 SKU 不存在"); - ErrorCode SKU_PROPERTIES_DUPLICATED = new ErrorCode(1_008_006_001, "商品 SKU 的属性组合存在重复"); - ErrorCode SPU_ATTR_NUMBERS_MUST_BE_EQUALS = new ErrorCode(1_008_006_002, "一个 SPU 下的每个 SKU,其属性项必须一致"); - ErrorCode SPU_SKU_NOT_DUPLICATE = new ErrorCode(1_008_006_003, "一个 SPU 下的每个 SKU,必须不重复"); - ErrorCode SKU_STOCK_NOT_ENOUGH = new ErrorCode(1_008_006_004, "商品 SKU 库存不足"); - - // ========== 商品 评价 1-008-007-000 ========== - ErrorCode COMMENT_NOT_EXISTS = new ErrorCode(1_008_007_000, "商品评价不存在"); - ErrorCode COMMENT_ORDER_EXISTS = new ErrorCode(1_008_007_001, "订单的商品评价已存在"); - - // ========== 商品 收藏 1-008-008-000 ========== - ErrorCode FAVORITE_EXISTS = new ErrorCode(1_008_008_000, "该商品已经被收藏"); - ErrorCode FAVORITE_NOT_EXISTS = new ErrorCode(1_008_008_001, "商品收藏不存在"); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ProductConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ProductConstants.java deleted file mode 100644 index f3570c5896..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ProductConstants.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.product.enums; - -/** - * Product 常量 - * - * @author HUIHUI - */ -public interface ProductConstants { - - /** - * 警戒库存 TODO 警戒库存暂时为 10,后期需要使用常量或者数据库配置替换 - */ - int ALERT_STOCK = 10; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java deleted file mode 100644 index 276839dafd..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.comment; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品评论的审批状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum ProductCommentAuditStatusEnum implements IntArrayValuable { - - NONE(1, "待审核"), - APPROVE(2, "审批通过"), - REJECT(2, "审批不通过"),; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentAuditStatusEnum::getStatus).toArray(); - - /** - * 审批状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentScoresEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentScoresEnum.java deleted file mode 100644 index a114e1ab8b..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentScoresEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.comment; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品评论的星级枚举 - * - * @author wangzhs - */ -@Getter -@AllArgsConstructor -public enum ProductCommentScoresEnum implements IntArrayValuable { - - ONE(1, "1星"), - TWO(2, "2星"), - THREE(3, "3星"), - FOUR(4, "4星"), - FIVE(5, "5星"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentScoresEnum::getScores).toArray(); - - /** - * 星级 - */ - private final Integer scores; - - /** - * 星级名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java deleted file mode 100644 index 4ba6124e00..0000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.spu; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品 SPU 状态 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum ProductSpuStatusEnum implements IntArrayValuable { - - RECYCLE(-1, "回收站"), - DISABLE(0, "下架"), - ENABLE(1, "上架"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductSpuStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - /** - * 判断是否处于【上架】状态 - * - * @param status 状态 - * @return 是否处于【上架】状态 - */ - public static boolean isEnable(Integer status) { - return ENABLE.getStatus().equals(status); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/pom.xml b/yudao-module-mall/yudao-module-product-biz/pom.xml deleted file mode 100644 index f6190ceda1..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-product-biz - jar - - ${project.artifactId} - - product 模块,主要实现商品相关功能 - 例如:品牌、商品分类、spu、sku等功能。 - - - - - cn.iocoder.boot - yudao-module-product-api - ${revision} - - - cn.iocoder.boot - yudao-module-member-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-dict - - - - - cn.iocoder.boot - yudao-spring-boot-starter-web - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - - - - - cn.iocoder.boot - yudao-spring-boot-starter-excel - - - - diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApiImpl.java deleted file mode 100644 index b339a47d0c..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApiImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.product.api.category; - -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; - -/** - * 商品分类 API 接口实现类 - * - * @author owen - */ -@Service -@Validated -public class ProductCategoryApiImpl implements ProductCategoryApi { - - @Resource - private ProductCategoryService productCategoryService; - - @Override - public void validateCategoryList(Collection ids) { - productCategoryService.validateCategoryList(ids); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java deleted file mode 100644 index 7bda131dd4..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.product.api.comment; - -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -/** - * 商品评论 API 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class ProductCommentApiImpl implements ProductCommentApi { - - @Resource - private ProductCommentService productCommentService; - - @Override - public Long createComment(ProductCommentCreateReqDTO createReqDTO) { - return productCommentService.createComment(createReqDTO); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java deleted file mode 100644 index 162453c3c9..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.product.api; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java deleted file mode 100644 index 3866d2c7e2..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku; - -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -/** - * 商品 SKU API 实现类 - * - * @author LeeYan9 - * @since 2022-09-06 - */ -@Service -@Validated -public class ProductSkuApiImpl implements ProductSkuApi { - - @Resource - private ProductSkuService productSkuService; - - @Override - public ProductSkuRespDTO getSku(Long id) { - ProductSkuDO sku = productSkuService.getSku(id); - return ProductSkuConvert.INSTANCE.convert02(sku); - } - - @Override - public List getSkuList(Collection ids) { - List skus = productSkuService.getSkuList(ids); - return ProductSkuConvert.INSTANCE.convertList04(skus); - } - - @Override - public List getSkuListBySpuId(Collection spuIds) { - List skus = productSkuService.getSkuListBySpuId(spuIds); - return ProductSkuConvert.INSTANCE.convertList04(skus); - } - - @Override - public void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO) { - productSkuService.updateSkuStock(updateStockReqDTO); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java deleted file mode 100644 index 231554ee17..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.api.spu; - -import cn.hutool.core.collection.CollectionUtil; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * 商品 SPU API 接口实现类 - * - * @author LeeYan9 - * @since 2022-09-06 - */ -@Service -@Validated -public class ProductSpuApiImpl implements ProductSpuApi { - - @Resource - private ProductSpuService spuService; - - @Override - public List getSpuList(Collection ids) { - return ProductSpuConvert.INSTANCE.convertList2(spuService.getSpuList(ids)); - } - - @Override - public List validateSpuList(Collection ids) { - return ProductSpuConvert.INSTANCE.convertList2(spuService.validateSpuList(ids)); - } - - @Override - public ProductSpuRespDTO getSpu(Long id) { - return ProductSpuConvert.INSTANCE.convert02(spuService.getSpu(id)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java deleted file mode 100644 index aff47c7fc4..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.*; -import cn.iocoder.yudao.module.product.convert.brand.ProductBrandConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品品牌") -@RestController -@RequestMapping("/product/brand") -@Validated -public class ProductBrandController { - - @Resource - private ProductBrandService brandService; - - @PostMapping("/create") - @Operation(summary = "创建品牌") - @PreAuthorize("@ss.hasPermission('product:brand:create')") - public CommonResult createBrand(@Valid @RequestBody ProductBrandCreateReqVO createReqVO) { - return success(brandService.createBrand(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新品牌") - @PreAuthorize("@ss.hasPermission('product:brand:update')") - public CommonResult updateBrand(@Valid @RequestBody ProductBrandUpdateReqVO updateReqVO) { - brandService.updateBrand(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除品牌") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:brand:delete')") - public CommonResult deleteBrand(@RequestParam("id") Long id) { - brandService.deleteBrand(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得品牌") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:brand:query')") - public CommonResult getBrand(@RequestParam("id") Long id) { - ProductBrandDO brand = brandService.getBrand(id); - return success(ProductBrandConvert.INSTANCE.convert(brand)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取品牌精简信息列表", description = "主要用于前端的下拉选项") - public CommonResult> getSimpleBrandList() { - // 获取品牌列表,只要开启状态的 - List list = brandService.getBrandListByStatus(CommonStatusEnum.ENABLE.getStatus()); - // 排序后,返回给前端 - return success(ProductBrandConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得品牌分页") - @PreAuthorize("@ss.hasPermission('product:brand:query')") - public CommonResult> getBrandPage(@Valid ProductBrandPageReqVO pageVO) { - PageResult pageResult = brandService.getBrandPage(pageVO); - return success(ProductBrandConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list") - @Operation(summary = "获得品牌列表") - @PreAuthorize("@ss.hasPermission('product:brand:query')") - public CommonResult> getBrandList(@Valid ProductBrandListReqVO listVO) { - List list = brandService.getBrandList(listVO); - list.sort(Comparator.comparing(ProductBrandDO::getSort)); - return success(ProductBrandConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java deleted file mode 100644 index 152de72116..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** -* 商品品牌 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class ProductBrandBaseVO { - - @Schema(description = "品牌名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果") - @NotNull(message = "品牌名称不能为空") - private String name; - - @Schema(description = "品牌图片", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "品牌图片不能为空") - private String picUrl; - - @Schema(description = "品牌排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "品牌排序不能为空") - private Integer sort; - - @Schema(description = "品牌描述", example = "描述") - private String description; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java deleted file mode 100644 index dc85a476bb..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品品牌创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandCreateReqVO extends ProductBrandBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java deleted file mode 100644 index ed93ff090f..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商品品牌分页 Request VO") -@Data -public class ProductBrandListReqVO { - - @Schema(description = "品牌名称", example = "苹果") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java deleted file mode 100644 index 3a6efc93f2..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品品牌分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandPageReqVO extends PageParam { - - @Schema(description = "品牌名称", example = "苹果") - private String name; - - @Schema(description = "状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java deleted file mode 100644 index 486fe764b7..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 品牌 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandRespVO extends ProductBrandBaseVO { - - @Schema(description = "品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java deleted file mode 100644 index 6379a5fb1d..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - 品牌精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ProductBrandSimpleRespVO { - - @Schema(description = "品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "品牌名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java deleted file mode 100644 index b9585b62b4..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品品牌更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandUpdateReqVO extends ProductBrandBaseVO { - - @Schema(description = "品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "品牌编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java deleted file mode 100644 index 16e6a4e6b9..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryRespVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品分类") -@RestController -@RequestMapping("/product/category") -@Validated -public class ProductCategoryController { - - @Resource - private ProductCategoryService categoryService; - - @PostMapping("/create") - @Operation(summary = "创建商品分类") - @PreAuthorize("@ss.hasPermission('product:category:create')") - public CommonResult createCategory(@Valid @RequestBody ProductCategoryCreateReqVO createReqVO) { - return success(categoryService.createCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新商品分类") - @PreAuthorize("@ss.hasPermission('product:category:update')") - public CommonResult updateCategory(@Valid @RequestBody ProductCategoryUpdateReqVO updateReqVO) { - categoryService.updateCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商品分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('product:category:delete')") - public CommonResult deleteCategory(@RequestParam("id") Long id) { - categoryService.deleteCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得商品分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:category:query')") - public CommonResult getCategory(@RequestParam("id") Long id) { - ProductCategoryDO category = categoryService.getCategory(id); - return success(ProductCategoryConvert.INSTANCE.convert(category)); - } - - @GetMapping("/list") - @Operation(summary = "获得商品分类列表") - @PreAuthorize("@ss.hasPermission('product:category:query')") - public CommonResult> getCategoryList(@Valid ProductCategoryListReqVO treeListReqVO) { - List list = categoryService.getEnableCategoryList(treeListReqVO); - list.sort(Comparator.comparing(ProductCategoryDO::getSort)); - return success(ProductCategoryConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryBaseVO.java deleted file mode 100644 index 4174f3c987..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryBaseVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; - -/** -* 商品分类 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class ProductCategoryBaseVO { - - @Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "父分类编号不能为空") - private Long parentId; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "办公文具") - @NotBlank(message = "分类名称不能为空") - private String name; - - @Schema(description = "移动端分类图", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "移动端分类图不能为空") - private String picUrl; - - @Schema(description = "PC 端分类图") - private String bigPicUrl; - - @Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sort; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "开启状态不能为空") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java deleted file mode 100644 index 5451d2e822..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotBlank; - -@Schema(description = "管理后台 - 商品分类创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductCategoryCreateReqVO extends ProductCategoryBaseVO { - - @Schema(description = "分类描述", example = "描述") - private String description; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java deleted file mode 100644 index 16f5df8575..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商品分类列表查询 Request VO") -@Data -public class ProductCategoryListReqVO { - - @Schema(description = "分类名称", example = "办公文具") - private String name; - - @Schema(description = "开启状态", example = "0") - private Integer status; - - @Schema(description = "父分类编号", example = "1") - private Long parentId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java deleted file mode 100644 index 8f46ff60f2..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商品分类 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductCategoryRespVO extends ProductCategoryBaseVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java deleted file mode 100644 index 73909b7569..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品分类更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductCategoryUpdateReqVO extends ProductCategoryBaseVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "分类编号不能为空") - private Long id; - - @Schema(description = "分类描述", example = "描述") - private String description; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.http deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java deleted file mode 100644 index c28c28394b..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.*; -import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 商品评价") -@RestController -@RequestMapping("/product/comment") -@Validated -public class ProductCommentController { - - @Resource - private ProductCommentService productCommentService; - - @GetMapping("/page") - @Operation(summary = "获得商品评价分页") - @PreAuthorize("@ss.hasPermission('product:comment:query')") - public CommonResult> getCommentPage(@Valid ProductCommentPageReqVO pageVO) { - PageResult pageResult = productCommentService.getCommentPage(pageVO); - return success(ProductCommentConvert.INSTANCE.convertPage(pageResult)); - } - - @PutMapping("/update-visible") - @Operation(summary = "显示 / 隐藏评论") - @PreAuthorize("@ss.hasPermission('product:comment:update')") - public CommonResult updateCommentVisible(@Valid @RequestBody ProductCommentUpdateVisibleReqVO updateReqVO) { - productCommentService.updateCommentVisible(updateReqVO); - return success(true); - } - - @PutMapping("/reply") - @Operation(summary = "商家回复") - @PreAuthorize("@ss.hasPermission('product:comment:update')") - public CommonResult commentReply(@Valid @RequestBody ProductCommentReplyReqVO replyVO) { - productCommentService.replyComment(replyVO, getLoginUserId()); - return success(true); - } - - @PostMapping("/create") - @Operation(summary = "添加自评") - @PreAuthorize("@ss.hasPermission('product:comment:update')") - public CommonResult createComment(@Valid @RequestBody ProductCommentCreateReqVO createReqVO) { - productCommentService.createComment(createReqVO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentBaseVO.java deleted file mode 100644 index a8394afab9..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentBaseVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; -import java.util.List; - -@Data -public class ProductCommentBaseVO { - - @Schema(description = "评价人", requiredMode = Schema.RequiredMode.REQUIRED, example = "16868") - private Long userId; - - @Schema(description = "评价订单项", requiredMode = Schema.RequiredMode.REQUIRED, example = "19292") - private Long orderItemId; - - @Schema(description = "评价人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小姑凉") - @NotNull(message = "评价人名称不能为空") - private String userNickname; - - @Schema(description = "评价人头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - @NotNull(message = "评价人头像不能为空") - private String userAvatar; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "描述星级不能为空") - private Integer descriptionScores; - - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "服务星级分不能为空") - private Integer benefitScores; - - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "穿起来非常丝滑凉快") - @NotNull(message = "评论内容不能为空") - private String content; - - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") - private List picUrls; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java deleted file mode 100644 index f976b756db..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品评价创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductCommentCreateReqVO extends ProductCommentBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java deleted file mode 100644 index 3791f572e0..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.product.enums.comment.ProductCommentScoresEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品评价分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductCommentPageReqVO extends PageParam { - - @Schema(description = "评价人名称", example = "王二狗") - private String userNickname; - - @Schema(description = "交易订单编号", example = "24428") - private Long orderId; - - @Schema(description = "商品SPU编号", example = "29502") - private Long spuId; - - @Schema(description = "商品SPU名称", example = "感冒药") - private String spuName; - - @Schema(description = "评分星级 1-5 分", example = "5") - @InEnum(ProductCommentScoresEnum.class) - private Integer scores; - - @Schema(description = "商家是否回复", example = "true") - private Boolean replyStatus; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyReqVO.java deleted file mode 100644 index 9d2aa42c59..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品评价的商家回复 Request VO") -@Data -@ToString(callSuper = true) -public class ProductCommentReplyReqVO { - - @Schema(description = "评价编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - @NotNull(message = "评价编号不能为空") - private Long id; - - @Schema(description = "商家回复内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "谢谢亲") - @NotEmpty(message = "商家回复内容不能为空") - private String replyContent; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java deleted file mode 100644 index 05ed9b8590..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 商品评价 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductCommentRespVO extends ProductCommentBaseVO { - - @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24965") - private Long id; - - @Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean anonymous; - - @Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24428") - private Long orderId; - - @Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED) - private Boolean visible; - - @Schema(description = "商家是否回复", requiredMode = Schema.RequiredMode.REQUIRED) - private Boolean replyStatus; - - @Schema(description = "回复管理员编号", example = "9527") - private Long replyUserId; - - @Schema(description = "商家回复内容", example = "感谢好评哦亲(づ ̄3 ̄)づ╭❤~") - private String replyContent; - - @Schema(description = "商家回复时间", example = "2023-08-08 12:20:55") - private LocalDateTime replyTime; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "评分星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer scores; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑透气小短袖") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - @NotNull(message = "商品 SPU 名称不能为空") - private String spuName; - - @Schema(description = "商品 SKU 图片地址", example = "https://www.iocoder.cn/yudao.jpg") - private String skuPicUrl; - - @Schema(description = "商品 SKU 规格值数组") - private List skuProperties; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentUpdateVisibleReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentUpdateVisibleReqVO.java deleted file mode 100644 index d970c3f952..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentUpdateVisibleReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品评价可见修改 Request VO") -@Data -@ToString(callSuper = true) -public class ProductCommentUpdateVisibleReqVO { - - @Schema(description = "评价编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - @NotNull(message = "评价编号不能为空") - private Long id; - - @Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - @NotNull(message = "是否可见不能为空") - private Boolean visible; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/ProductFavoriteController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/ProductFavoriteController.java deleted file mode 100644 index b0ff22c7dd..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/ProductFavoriteController.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoriteRespVO; -import cn.iocoder.yudao.module.product.convert.favorite.ProductFavoriteConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.service.favorite.ProductFavoriteService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 商品收藏") -@RestController -@RequestMapping("/product/favorite") -@Validated -public class ProductFavoriteController { - - @Resource - private ProductFavoriteService productFavoriteService; - - @Resource - private ProductSpuService productSpuService; - - @GetMapping("/page") - @Operation(summary = "获得商品收藏分页") - @PreAuthorize("@ss.hasPermission('product:favorite:query')") - public CommonResult> getFavoritePage(@Valid ProductFavoritePageReqVO pageVO) { - PageResult pageResult = productFavoriteService.getFavoritePage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - // 拼接数据 - List spuList = productSpuService.getSpuList(convertSet(pageResult.getList(), ProductFavoriteDO::getSpuId)); - return success(ProductFavoriteConvert.INSTANCE.convertPage(pageResult, spuList)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteBaseVO.java deleted file mode 100644 index 9ecf2fcff5..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteBaseVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 商品收藏 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class ProductFavoriteBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5036") - @NotNull(message = "用户编号不能为空") - private Long userId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoritePageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoritePageReqVO.java deleted file mode 100644 index 3d78883ec9..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoritePageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品收藏分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductFavoritePageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "5036") - private Long userId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteReqVO.java deleted file mode 100644 index 823310091a..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品收藏的单个 Response VO") -@Data -@ToString(callSuper = true) -public class ProductFavoriteReqVO extends ProductFavoriteBaseVO { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32734") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteRespVO.java deleted file mode 100644 index 3c09aa8fc6..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; - -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品收藏 Response VO") -@Data -@ToString(callSuper = true) -public class ProductFavoriteRespVO extends ProductSpuRespVO { - - @Schema(description = "userId", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - private Long userId; - - @Schema(description = "spuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java deleted file mode 100644 index 1ebc2d8903..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.*; -import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 商品属性项") -@RestController -@RequestMapping("/product/property") -@Validated -public class ProductPropertyController { - - @Resource - private ProductPropertyService productPropertyService; - @Resource - private ProductPropertyValueService productPropertyValueService; - - @PostMapping("/create") - @Operation(summary = "创建属性项") - @PreAuthorize("@ss.hasPermission('product:property:create')") - public CommonResult createProperty(@Valid @RequestBody ProductPropertyCreateReqVO createReqVO) { - return success(productPropertyService.createProperty(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新属性项") - @PreAuthorize("@ss.hasPermission('product:property:update')") - public CommonResult updateProperty(@Valid @RequestBody ProductPropertyUpdateReqVO updateReqVO) { - productPropertyService.updateProperty(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除属性项") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('product:property:delete')") - public CommonResult deleteProperty(@RequestParam("id") Long id) { - productPropertyService.deleteProperty(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得属性项") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult getProperty(@RequestParam("id") Long id) { - return success(ProductPropertyConvert.INSTANCE.convert(productPropertyService.getProperty(id))); - } - - @GetMapping("/list") - @Operation(summary = "获得属性项列表") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyList(@Valid ProductPropertyListReqVO listReqVO) { - return success(ProductPropertyConvert.INSTANCE.convertList(productPropertyService.getPropertyList(listReqVO))); - } - - @GetMapping("/page") - @Operation(summary = "获得属性项分页") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyPage(@Valid ProductPropertyPageReqVO pageVO) { - return success(ProductPropertyConvert.INSTANCE.convertPage(productPropertyService.getPropertyPage(pageVO))); - } - - @PostMapping("/get-value-list") - @Operation(summary = "获得属性项列表") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyAndValueList( - @Valid @RequestBody ProductPropertyListReqVO listReqVO) { - // 查询属性项 - List keys = productPropertyService.getPropertyList(listReqVO); - if (CollUtil.isEmpty(keys)) { - return success(Collections.emptyList()); - } - // 查询属性值 - List values = productPropertyValueService.getPropertyValueListByPropertyId( - convertSet(keys, ProductPropertyDO::getId)); - return success(ProductPropertyConvert.INSTANCE.convertList(keys, values)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java deleted file mode 100644 index 8a0595aa30..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品属性值") -@RestController -@RequestMapping("/product/property/value") -@Validated -public class ProductPropertyValueController { - - @Resource - private ProductPropertyValueService productPropertyValueService; - - @PostMapping("/create") - @Operation(summary = "创建属性值") - @PreAuthorize("@ss.hasPermission('product:property:create')") - public CommonResult createPropertyValue(@Valid @RequestBody ProductPropertyValueCreateReqVO createReqVO) { - return success(productPropertyValueService.createPropertyValue(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新属性值") - @PreAuthorize("@ss.hasPermission('product:property:update')") - public CommonResult updatePropertyValue(@Valid @RequestBody ProductPropertyValueUpdateReqVO updateReqVO) { - productPropertyValueService.updatePropertyValue(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除属性值") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:property:delete')") - public CommonResult deletePropertyValue(@RequestParam("id") Long id) { - productPropertyValueService.deletePropertyValue(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得属性值") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult getPropertyValue(@RequestParam("id") Long id) { - return success(ProductPropertyValueConvert.INSTANCE.convert(productPropertyValueService.getPropertyValue(id))); - } - - @GetMapping("/page") - @Operation(summary = "获得属性值分页") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyValuePage(@Valid ProductPropertyValuePageReqVO pageVO) { - return success(ProductPropertyValueConvert.INSTANCE.convertPage(productPropertyValueService.getPropertyValuePage(pageVO))); - } -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyAndValueRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyAndValueRespVO.java deleted file mode 100644 index 6ef051451b..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyAndValueRespVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - 商品属性项 + 属性值 Response VO") -@Data -public class ProductPropertyAndValueRespVO { - - @Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "属性项的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String name; - - /** - * 属性值的集合 - */ - private List values; - - @Schema(description = "管理后台 - 属性值的简单 Response VO") - @Data - public static class Value { - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long id; - - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String name; - - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyBaseVO.java deleted file mode 100644 index cbe2b1ec9b..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyBaseVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotBlank; - -/** - * 商品属性项 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class ProductPropertyBaseVO { - - @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - @NotBlank(message = "名称不能为空") - private String name; - - @Schema(description = "备注", example = "颜色") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyCreateReqVO.java deleted file mode 100644 index b854dd73c0..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyCreateReqVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 属性项创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyCreateReqVO extends ProductPropertyBaseVO { - - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyListReqVO.java deleted file mode 100644 index 3ff46484f3..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyListReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 属性项 List Request VO") -@Data -@ToString(callSuper = true) -public class ProductPropertyListReqVO { - - @Schema(description = "属性名称", example = "颜色") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java deleted file mode 100644 index 97b959d6a7..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 属性项 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyPageReqVO extends PageParam { - - @Schema(description = "名称", example = "颜色") - private String name; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java deleted file mode 100644 index 5f541230a8..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 属性项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyRespVO extends ProductPropertyBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyUpdateReqVO.java deleted file mode 100644 index b32a8511d7..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 属性项更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyUpdateReqVO extends ProductPropertyBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "主键不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java deleted file mode 100644 index c0c2e25930..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** -* 属性值 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class ProductPropertyValueBaseVO { - - @Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "属性项的编号不能为空") - private Long propertyId; - - @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - @NotEmpty(message = "名称名字不能为空") - private String name; - - @Schema(description = "备注", example = "颜色") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueCreateReqVO.java deleted file mode 100644 index d3fe4d0f16..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品属性值创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyValueCreateReqVO extends ProductPropertyValueBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueDetailRespVO.java deleted file mode 100644 index 4d22f0dbf1..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商品属性值的明细 Response VO") -@Data -public class ProductPropertyValueDetailRespVO { - - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long propertyId; - - @Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long valueId; - - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java deleted file mode 100644 index ff0c326146..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品属性值分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyValuePageReqVO extends PageParam { - - @Schema(description = "属性项的编号", example = "1024") - private String propertyId; - - @Schema(description = "名称", example = "红色") - private String name; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java deleted file mode 100644 index 6ef17c32e3..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商品属性值 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyValueRespVO extends ProductPropertyValueBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java deleted file mode 100644 index 4745e7019d..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品属性值更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyValueUpdateReqVO extends ProductPropertyValueBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "主键不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java deleted file mode 100755 index 9acbacd662..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku; - -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@Tag(name = "管理后台 - 商品 SKU") -@RestController -@RequestMapping("/product/sku") -@Validated -public class ProductSkuController { - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java deleted file mode 100755 index 1acc6a08ae..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -/** -* 商品 SKU Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class ProductSkuBaseVO { - - @Schema(description = "商品 SKU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - @NotEmpty(message = "商品 SKU 名字不能为空") - private String name; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - @NotNull(message = "销售价格,单位:分不能为空") - private Integer price; - - @Schema(description = "市场价", example = "2999") - private Integer marketPrice; - - @Schema(description = "成本价", example = "19") - private Integer costPrice; - - @Schema(description = "条形码", example = "15156165456") - private String barCode; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - @NotNull(message = "图片地址不能为空") - private String picUrl; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - @NotNull(message = "库存不能为空") - private Integer stock; - - @Schema(description = "预警预存", example = "10") - private Integer warnStock; - - @Schema(description = "商品重量,单位:kg 千克", example = "1.2") - private Double weight; - - @Schema(description = "商品体积,单位:m^3 平米", example = "2.5") - private Double volume; - - @Schema(description = "一级分销的佣金,单位:分", example = "199") - private Integer firstBrokeragePrice; - - @Schema(description = "二级分销的佣金,单位:分", example = "19") - private Integer secondBrokeragePrice; - - @Schema(description = "属性数组") - private List properties; - - @Schema(description = "商品属性") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Property { - - @Schema(description = "属性编号", example = "10") - private Long propertyId; - - @Schema(description = "属性名字", example = "颜色") - private String propertyName; - - @Schema(description = "属性值编号", example = "10") - private Long valueId; - - @Schema(description = "属性值名字", example = "红色") - private String valueName; - - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java deleted file mode 100755 index e750013d5b..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 商品 SKU 创建/更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java deleted file mode 100755 index e0f98f5e63..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 商品 SKU Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSkuRespVO extends ProductSkuBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.http deleted file mode 100644 index 4ab7b4f714..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.http +++ /dev/null @@ -1,4 +0,0 @@ -### 获得商品 SPU 明细 -GET {{baseUrl}}/product/spu/get-detail?id=4 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java deleted file mode 100755 index 35011288e3..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; - -@Tag(name = "管理后台 - 商品 SPU") -@RestController -@RequestMapping("/product/spu") -@Validated -public class ProductSpuController { - - @Resource - private ProductSpuService productSpuService; - @Resource - private ProductSkuService productSkuService; - - @PostMapping("/create") - @Operation(summary = "创建商品 SPU") - @PreAuthorize("@ss.hasPermission('product:spu:create')") - public CommonResult createProductSpu(@Valid @RequestBody ProductSpuCreateReqVO createReqVO) { - return success(productSpuService.createSpu(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新商品 SPU") - @PreAuthorize("@ss.hasPermission('product:spu:update')") - public CommonResult updateSpu(@Valid @RequestBody ProductSpuUpdateReqVO updateReqVO) { - productSpuService.updateSpu(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新商品 SPU Status") - @PreAuthorize("@ss.hasPermission('product:spu:update')") - public CommonResult updateStatus(@Valid @RequestBody ProductSpuUpdateStatusReqVO updateReqVO) { - productSpuService.updateSpuStatus(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商品 SPU") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:spu:delete')") - public CommonResult deleteSpu(@RequestParam("id") Long id) { - productSpuService.deleteSpu(id); - return success(true); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得商品 SPU 明细") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult getSpuDetail(@RequestParam("id") Long id) { - // 获得商品 SPU - ProductSpuDO spu = productSpuService.getSpu(id); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - // 查询商品 SKU - List skus = productSkuService.getSkuListBySpuId(spu.getId()); - return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获得商品 SPU 精简列表") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuSimpleList() { - List list = productSpuService.getSpuListByStatus(ProductSpuStatusEnum.ENABLE.getStatus()); - // 降序排序后,返回给前端 - list.sort(Comparator.comparing(ProductSpuDO::getSort).reversed()); - return success(ProductSpuConvert.INSTANCE.convertList02(list)); - } - - @GetMapping("/list") - @Operation(summary = "获得商品 SPU 详情列表") - @Parameter(name = "spuIds", description = "spu 编号列表", required = true, example = "[1,2,3]") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuList(@RequestParam("spuIds") Collection spuIds) { - return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespListVO( - productSpuService.getSpuList(spuIds), productSkuService.getSkuListBySpuId(spuIds))); - } - - @GetMapping("/page") - @Operation(summary = "获得商品 SPU 分页") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuPage(@Valid ProductSpuPageReqVO pageVO) { - return success(ProductSpuConvert.INSTANCE.convertPage(productSpuService.getSpuPage(pageVO))); - } - - @GetMapping("/get-count") - @Operation(summary = "获得商品 SPU 分页 tab count") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuCount() { - return success(productSpuService.getTabsCount()); - } - - @GetMapping("/export") - @Operation(summary = "导出商品") - @PreAuthorize("@ss.hasPermission('product:spu:export')") - @OperateLog(type = EXPORT) - public void exportUserList(@Validated ProductSpuExportReqVO reqVO, - HttpServletResponse response) throws IOException { - List spuList = productSpuService.getSpuList(reqVO); - // 导出 Excel - List datas = ProductSpuConvert.INSTANCE.convertList03(spuList); - ExcelUtils.write(response, "商品列表.xls", "数据", ProductSpuExcelVO.class, datas); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java deleted file mode 100755 index 749898e205..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -/** -* 商品 SPU Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class ProductSpuBaseVO { - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - @NotEmpty(message = "商品名称不能为空") - private String name; - - @Schema(description = "关键字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑不出汗") - @NotEmpty(message = "商品关键字不能为空") - private String keyword; - - @Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖简介") - @NotEmpty(message = "商品简介不能为空") - private String introduction; - - @Schema(description = "商品详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖详情") - @NotEmpty(message = "商品详情不能为空") - private String description; - - @Schema(description = "商品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品分类不能为空") - private Long categoryId; - - @Schema(description = "商品品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品品牌不能为空") - private Long brandId; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - @NotEmpty(message = "商品封面图不能为空") - private String picUrl; - - @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") - private List sliderPicUrls; - - @Schema(description = "商品视频", example = "https://www.iocoder.cn/xx.mp4") - private String videoUrl; - - @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品单位不能为空") - private Integer unit; - - @Schema(description = "排序字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品排序字段不能为空") - private Integer sort; - - // ========== SKU 相关字段 ========= - - @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "商品规格类型不能为空") - private Boolean specType; - - // ========== 物流相关字段 ========= - - @Schema(description = "物流配置模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - @NotNull(message = "物流配置模板编号不能为空") - private Long deliveryTemplateId; - - // ========== 营销相关字段 ========= - - @Schema(description = "是否热卖推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "商品推荐不能为空") - private Boolean recommendHot; - - @Schema(description = "是否优惠推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "商品推荐不能为空") - private Boolean recommendBenefit; - - @Schema(description = "是否精品推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "商品推荐不能为空") - private Boolean recommendBest; - - @Schema(description = "是否新品推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "商品推荐不能为空") - private Boolean recommendNew; - - @Schema(description = "是否优品推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "商品推荐不能为空") - private Boolean recommendGood; - - @Schema(description = "赠送积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - @NotNull(message = "商品赠送积分不能为空") - private Integer giveIntegral; - - @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "商品分销类型不能为空") - private Boolean subCommissionType; - - @Schema(description = "活动展示顺序", example = "[1, 3, 2, 4, 5]") - private List activityOrders; - - // ========== 统计相关字段 ========= - - @Schema(description = "虚拟销量", example = "66") - private Integer virtualSalesCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java deleted file mode 100755 index 39bc8a5564..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.Valid; -import java.util.List; - -@Schema(description = "管理后台 - 商品 SPU 创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuCreateReqVO extends ProductSpuBaseVO { - - // ========== SKU 相关字段 ========= - - @Schema(description = "SKU 数组") - @Valid - private List skus; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java deleted file mode 100644 index 336d44467a..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 商品 SPU 详细 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuDetailRespVO extends ProductSpuRespVO { - - // ========== SKU 相关字段 ========= - - @Schema(description = "SKU 数组") - private List skus; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExcelVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExcelVO.java deleted file mode 100644 index 38cbd8472e..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExcelVO.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.product.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - - -import java.time.LocalDateTime; - -/** - * 商品 Spu Excel 导出 VO TODO 暂定 - * - * @author HUIHUI - */ -@Data -public class ProductSpuExcelVO { - - @ExcelProperty("商品编号") - private Long id; - - @ExcelProperty("商品名称") - private String name; - - @ExcelProperty("关键字") - private String keyword; - - @ExcelProperty("商品简介") - private String introduction; - - @ExcelProperty("商品详情") - private String description; - - @ExcelProperty("条形码") - private String barCode; - - @ExcelProperty("商品分类编号") - private Long categoryId; - - @ExcelProperty("商品品牌编号") - private Long brandId; - - @ExcelProperty("商品封面图") - private String picUrl; - - @ExcelProperty("商品视频") - private String videoUrl; - - @ExcelProperty(value = "商品单位", converter = DictConvert.class) - @DictFormat(DictTypeConstants.PRODUCT_UNIT) - private Integer unit; - - @ExcelProperty("排序字段") - private Integer sort; - - @ExcelProperty(value = "商品状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.PRODUCT_SPU_STATUS) - private Integer status; - - @ExcelProperty("规格类型") - private Boolean specType; - - @ExcelProperty("商品价格") - private Integer price; - - @ExcelProperty("市场价") - private Integer marketPrice; - - @ExcelProperty("成本价") - private Integer costPrice; - - @ExcelProperty("库存") - private Integer stock; - - @ExcelProperty("物流配置模板编号") - private Long deliveryTemplateId; - - @ExcelProperty("是否热卖推荐") - private Boolean recommendHot; - - @ExcelProperty("是否优惠推荐") - private Boolean recommendBenefit; - - @ExcelProperty("是否精品推荐") - private Boolean recommendBest; - - @ExcelProperty("是否新品推荐") - private Boolean recommendNew; - - @ExcelProperty("是否优品推荐") - private Boolean recommendGood; - - @ExcelProperty("赠送积分") - private Integer giveIntegral; - - @ExcelProperty("分销类型") - private Boolean subCommissionType; - - @ExcelProperty("商品销量") - private Integer salesCount; - - @ExcelProperty("虚拟销量") - private Integer virtualSalesCount; - - @ExcelProperty("商品点击量") - private Integer browseCount; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExportReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExportReqVO.java deleted file mode 100644 index 3b3dccd7e8..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExportReqVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品 SPU 导出 Request VO,参数和 ProductSpuPageReqVO 是一致的") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ProductSpuExportReqVO { - - @Schema(description = "商品名称", example = "清凉小短袖") - private String name; - - @Schema(description = "前端请求的tab类型", example = "1") - private Integer tabType; - - @Schema(description = "商品分类编号", example = "100") - private Long categoryId; - - @Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java deleted file mode 100755 index 81cff42106..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品 SPU 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuPageReqVO extends PageParam { - - /** - * 出售中商品 - */ - public static final Integer FOR_SALE = 0; - - /** - * 仓库中商品 - */ - public static final Integer IN_WAREHOUSE = 1; - - /** - * 已售空商品 - */ - public static final Integer SOLD_OUT = 2; - - /** - * 警戒库存 - */ - public static final Integer ALERT_STOCK = 3; - - /** - * 商品回收站 - */ - public static final Integer RECYCLE_BIN = 4; - - @Schema(description = "商品名称", example = "清凉小短袖") - private String name; - - @Schema(description = "前端请求的tab类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer tabType; - - @Schema(description = "商品分类编号", example = "1") - private Long categoryId; - - @Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java deleted file mode 100755 index faf8a55721..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商品 SPU Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuRespVO extends ProductSpuBaseVO { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - private Long id; - - @Schema(description = "商品价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - private Integer price; - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - private Integer salesCount; - - @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "199") - private Integer marketPrice; - - @Schema(description = "成本价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "19") - private Integer costPrice; - - @Schema(description = "商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private Integer stock; - - @Schema(description = "商品创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-05-24 00:00:00") - private LocalDateTime createTime; - - @Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Integer browseCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java deleted file mode 100755 index 7d9d0d05d3..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品 SPU 精简 Response VO") -@Data -@ToString(callSuper = true) -public class ProductSpuSimpleRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "213") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - private String name; - - @Schema(description = "商品价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - private Integer price; - - @Schema(description = "商品市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "199") - private Integer marketPrice; - - @Schema(description = "商品成本价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "19") - private Integer costPrice; - - @Schema(description = "商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - private Integer stock; - - // ========== 统计相关字段 ========= - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer salesCount; - - @Schema(description = "商品虚拟销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20000") - private Integer virtualSalesCount; - - @Schema(description = "商品浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - private Integer browseCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java deleted file mode 100755 index 7673ca751c..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 商品 SPU 更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuUpdateReqVO extends ProductSpuBaseVO { - - @Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品编号不能为空") - private Long id; - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - private Integer salesCount; - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - private Integer browseCount; - - @Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(ProductSpuStatusEnum.class) - private Integer status; - - // ========== SKU 相关字段 ========= - - @Schema(description = "SKU 数组") - @Valid - private List skus; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateStatusReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateStatusReqVO.java deleted file mode 100644 index 0bc0158979..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateStatusReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品 SPU Status 更新 Request VO") -@Data -public class ProductSpuUpdateStatusReqVO{ - - @Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品编号不能为空") - private Long id; - - @Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品状态不能为空") - @InEnum(ProductSpuStatusEnum.class) - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java deleted file mode 100644 index 4c13154b5d..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.category; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO; -import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 商品分类") -@RestController -@RequestMapping("/product/category") -@Validated -public class AppCategoryController { - - @Resource - private ProductCategoryService categoryService; - - @GetMapping("/list") - @Operation(summary = "获得商品分类列表") - public CommonResult> getProductCategoryList() { - List list = categoryService.getEnableCategoryList(); - list.sort(Comparator.comparing(ProductCategoryDO::getSort)); - return success(ProductCategoryConvert.INSTANCE.convertList03(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java deleted file mode 100644 index 1ddec5fe49..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; - -@Data -@Schema(description = "用户 APP - 商品分类 Response VO") -public class AppCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Long id; - - @Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "父分类编号不能为空") - private Long parentId; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "办公文具") - @NotBlank(message = "分类名称不能为空") - private String name; - - @Schema(description = "分类图片", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "分类图片不能为空") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppCommentController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppCommentController.http deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java deleted file mode 100644 index 0fadfeb931..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.comment; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppProductCommentRespVO; -import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.context.annotation.Lazy; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "用户 APP - 商品评价") -@RestController -@RequestMapping("/product/comment") -@Validated -public class AppProductCommentController { - - @Resource - private ProductCommentService productCommentService; - - @Resource - @Lazy - private ProductSkuService productSkuService; - - @GetMapping("/list") - @Operation(summary = "获得最近的 n 条商品评价") - @Parameters({ - @Parameter(name = "spuId", description = "商品 SPU 编号", required = true, example = "1024"), - @Parameter(name = "count", description = "数量", required = true, example = "10") - }) - public CommonResult> getCommentList( - @RequestParam("spuId") Long spuId, - @RequestParam(value = "count", defaultValue = "10") Integer count) { - return success(productCommentService.getCommentList(spuId, count)); - } - - @GetMapping("/page") - @Operation(summary = "获得商品评价分页") - public CommonResult> getCommentPage(@Valid AppCommentPageReqVO pageVO) { - // 查询评论分页 - PageResult commentPageResult = productCommentService.getCommentPage(pageVO, Boolean.TRUE); - if (CollUtil.isEmpty(commentPageResult.getList())) { - return success(PageResult.empty(commentPageResult.getTotal())); - } - - // 拼接返回 - Set skuIds = convertSet(commentPageResult.getList(), ProductCommentDO::getSkuId); - PageResult commentVOPageResult = ProductCommentConvert.INSTANCE.convertPage02( - commentPageResult, productSkuService.getSkuList(skuIds)); - return success(commentVOPageResult); - } - - // TODO 芋艿:需要搞下 - @GetMapping("/statistics") - @Operation(summary = "获得商品的评价统计") - public CommonResult getCommentStatistics(@Valid @RequestParam("spuId") Long spuId) { - return success(productCommentService.getCommentStatistics(spuId, Boolean.TRUE)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java deleted file mode 100644 index e387539976..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.comment.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 App - 商品评价分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppCommentPageReqVO extends PageParam { - - /** - * 好评 - */ - public static final Integer GOOD_COMMENT = 1; - /** - * 中评 - */ - public static final Integer MEDIOCRE_COMMENT = 2; - /** - * 差评 - */ - public static final Integer NEGATIVE_COMMENT = 3; - - @Schema(description = "商品SPU编号", example = "29502") - @NotNull(message = "商品SPU编号不能为空") - private Long spuId; - - @Schema(description = "app 评论页 tab 类型 (0 全部、1 好评、2 中评、3 差评)", example = "0") - @NotNull(message = "商品SPU编号不能为空") - private Integer type; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentStatisticsRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentStatisticsRespVO.java deleted file mode 100644 index e863ab02c3..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentStatisticsRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.comment.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "APP - 商品评价页评论分类数统计 Response VO") -@Data -@ToString(callSuper = true) -public class AppCommentStatisticsRespVO { - - @Schema(description = "好评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - private Long goodCount; - - @Schema(description = "中评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - private Long mediocreCount; - - @Schema(description = "差评数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - private Long negativeCount; - - @Schema(description = "总平均分", requiredMode = Schema.RequiredMode.REQUIRED, example = "3.55") - private Double scores; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java deleted file mode 100644 index 1d42bab80e..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.comment.vo; - -import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 商品评价详情 Response VO") -@Data -@ToString(callSuper = true) -public class AppProductCommentRespVO { - - @Schema(description = "评价人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - private Long userId; - - @Schema(description = "评价人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String userNickname; - - @Schema(description = "评价人头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String userAvatar; - - @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24965") - private Long id; - - @Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean anonymous; - - @Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24428") - private Long orderId; - - @Schema(description = "交易订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8233") - private Long orderItemId; - - @Schema(description = "商家是否回复", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean replyStatus; - - @Schema(description = "回复管理员编号", example = "22212") - private Long replyUserId; - - @Schema(description = "商家回复内容", example = "亲,你的好评就是我的动力(*^▽^*)") - private String replyContent; - - @Schema(description = "商家回复时间") - private LocalDateTime replyTime; - - @Schema(description = "追加评价内容", example = "穿了很久都很丝滑诶") - private String additionalContent; - - @Schema(description = "追评评价图片地址数组,以逗号分隔最多上传 9 张", example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") - private List additionalPicUrls; - - @Schema(description = "追加评价时间") - private LocalDateTime additionalTime; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "91192") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑小短袖") - @NotNull(message = "商品 SPU 名称不能为空") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "81192") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品 SKU 属性", requiredMode = Schema.RequiredMode.REQUIRED) - private List skuProperties; - - @Schema(description = "评分星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "评分星级 1-5 分不能为空") - private Integer scores; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "描述星级 1-5 分不能为空") - private Integer descriptionScores; - - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "服务星级 1-5 分不能为空") - private Integer benefitScores; - - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "哇,真的很丝滑凉快诶,好评") - @NotNull(message = "评论内容不能为空") - private String content; - - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") - private List picUrls; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/AppFavoriteController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/AppFavoriteController.java deleted file mode 100644 index 9f6b47883f..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/AppFavoriteController.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteBatchReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO; -import cn.iocoder.yudao.module.product.convert.favorite.ProductFavoriteConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.service.favorite.ProductFavoriteService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 商品收藏") -@RestController -@RequestMapping("/product/favorite") -public class AppFavoriteController { - - @Resource - private ProductFavoriteService productFavoriteService; - @Resource - private ProductSpuService productSpuService; - - @PostMapping(value = "/create") - @Operation(summary = "添加商品收藏") - @PreAuthenticated - public CommonResult createFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) { - return success(productFavoriteService.createFavorite(getLoginUserId(), reqVO.getSpuId())); - } - - @PostMapping(value = "/create-list") - @Operation(summary = "添加多个商品收藏") - @PreAuthenticated - public CommonResult createFavoriteList(@RequestBody @Valid AppFavoriteBatchReqVO reqVO) { - // todo @jason:待实现;如果有已经收藏的,不用报错,忽略即可; - return success(true); - } - - @DeleteMapping(value = "/delete") - @Operation(summary = "取消单个商品收藏") - @PreAuthenticated - public CommonResult deleteFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) { - productFavoriteService.deleteFavorite(getLoginUserId(), reqVO.getSpuId()); - return success(Boolean.TRUE); - } - - @DeleteMapping(value = "/delete-list") - @Operation(summary = "取消多个商品收藏") - @PreAuthenticated - public CommonResult deleteFavoriteList(@RequestBody @Valid AppFavoriteBatchReqVO reqVO) { - // todo @jason:待实现 -// productFavoriteService.deleteFavorite(getLoginUserId(), reqVO.getSpuId()); - return success(Boolean.TRUE); - } - - @GetMapping(value = "/page") - @Operation(summary = "获得商品收藏分页") - @PreAuthenticated - public CommonResult> getFavoritePage(AppFavoritePageReqVO reqVO) { - PageResult favoritePage = productFavoriteService.getFavoritePage(getLoginUserId(), reqVO); - if (CollUtil.isEmpty(favoritePage.getList())) { - return success(PageResult.empty()); - } - - // 得到商品 spu 信息 - List favorites = favoritePage.getList(); - List spuIds = convertList(favorites, ProductFavoriteDO::getSpuId); - List spus = productSpuService.getSpuList(spuIds); - - // 转换 VO 结果 - PageResult pageResult = new PageResult<>(favoritePage.getTotal()); - pageResult.setList(ProductFavoriteConvert.INSTANCE.convertList(favorites, spus)); - return success(pageResult); - } - - @GetMapping(value = "/exits") - @Operation(summary = "检查是否收藏过商品") - @PreAuthenticated - public CommonResult isFavoriteExists(AppFavoriteReqVO reqVO) { - ProductFavoriteDO favorite = productFavoriteService.getFavorite(getLoginUserId(), reqVO.getSpuId()); - return success(favorite != null); - } - - @GetMapping(value = "/get-count") - @Operation(summary = "获得商品收藏数量") - @PreAuthenticated - public CommonResult getFavoriteCount() { - return success(productFavoriteService.getFavoriteCount(getLoginUserId())); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteBatchReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteBatchReqVO.java deleted file mode 100644 index 842cb36c1a..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteBatchReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import java.util.List; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 APP - 商品收藏的批量 Request VO") // 用于收藏、取消收藏、获取收藏 -@Data -public class AppFavoriteBatchReqVO { - - @Schema(description = "商品 SPU 编号数组", requiredMode = REQUIRED, example = "29502") - @NotEmpty(message = "商品 SPU 编号数组不能为空") - private List spuIds; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoritePageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoritePageReqVO.java deleted file mode 100644 index 2aacc3e545..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoritePageReqVO.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 商品收藏分页查询 Request VO") -@Data -public class AppFavoritePageReqVO extends PageParam { -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteReqVO.java deleted file mode 100644 index 8ff1aac84d..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 APP - 商品收藏的单个 Request VO") // 用于收藏、取消收藏、获取收藏 -@Data -public class AppFavoriteReqVO { - - @Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteRespVO.java deleted file mode 100644 index db2ea90a43..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 App - 商品收藏 Response VO") -@Data -public class AppFavoriteRespVO { - - @Schema(description = "编号", requiredMode = REQUIRED, example = "1") - private Long id; - - @Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502") - private Long spuId; - - // ========== 商品相关字段 ========== - - @Schema(description = "商品 SPU 名称", example = "赵六") - private String spuName; - - @Schema(description = "商品封面图", example = "https://domain/pic.png") - private String picUrl; - - @Schema(description = "商品单价", example = "100") - private Integer price; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/package-info.java deleted file mode 100644 index 379e85180a..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,无时间作用,避免 package 缩进 - */ -package cn.iocoder.yudao.module.product.controller.app.property; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/property/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/property/package-info.java deleted file mode 100644 index 6538bea3c1..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/property/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,无时间作用,避免 package 缩进 - */ -package cn.iocoder.yudao.module.product.controller.app.property.vo.property; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java deleted file mode 100644 index 5cac091438..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 商品属性值的明细 Response VO") -@Data -public class AppProductPropertyValueDetailRespVO { - - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long propertyId; - - @Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long valueId; - - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http deleted file mode 100644 index c391b5873d..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http +++ /dev/null @@ -1,18 +0,0 @@ -### 获得订单交易的分页(默认) -GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得订单交易的分页(价格) -GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&sortField=price&sortAsc=true -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得订单交易的分页(销售) -GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&sortField=salesCount&sortAsc=true -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得商品 SPU 明细 -GET {{appApi}}/product/spu/get-detail?id=102 -tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java deleted file mode 100644 index d0784bc77f..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java +++ /dev/null @@ -1,164 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageRespVO; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_ENABLE; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; - -@Tag(name = "用户 APP - 商品 SPU") -@RestController -@RequestMapping("/product/spu") -@Validated -public class AppProductSpuController { - - @Resource - private ProductSpuService productSpuService; - @Resource - private ProductSkuService productSkuService; - - @Resource - private MemberLevelApi memberLevelApi; - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/list") - @Operation(summary = "获得商品 SPU 列表") - @Parameters({ - @Parameter(name = "recommendType", description = "推荐类型", required = true), // 参见 AppProductSpuPageReqVO.RECOMMEND_TYPE_XXX 常量 - @Parameter(name = "count", description = "数量", required = true) - }) - public CommonResult> getSpuList( - @RequestParam("recommendType") String recommendType, - @RequestParam(value = "count", defaultValue = "10") Integer count) { - List list = productSpuService.getSpuList(recommendType, count); - if (CollUtil.isEmpty(list)) { - return success(Collections.emptyList()); - } - - // 拼接返回 - List voList = ProductSpuConvert.INSTANCE.convertListForGetSpuList(list); - // 处理 vip 价格 - MemberLevelRespDTO memberLevel = getMemberLevel(); - voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel))); - return success(voList); - } - - @GetMapping("/list-by-ids") - @Operation(summary = "获得商品 SPU 列表") - @Parameters({ - @Parameter(name = "ids", description = "编号列表", required = true) - }) - public CommonResult> getSpuList(@RequestParam("ids") Set ids) { - List list = productSpuService.getSpuList(ids); - if (CollUtil.isEmpty(list)) { - return success(Collections.emptyList()); - } - - // 拼接返回 - List voList = ProductSpuConvert.INSTANCE.convertListForGetSpuList(list); - // 处理 vip 价格 - MemberLevelRespDTO memberLevel = getMemberLevel(); - voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel))); - return success(voList); - } - - @GetMapping("/page") - @Operation(summary = "获得商品 SPU 分页") - public CommonResult> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) { - PageResult pageResult = productSpuService.getSpuPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接返回 - PageResult voPageResult = ProductSpuConvert.INSTANCE.convertPageForGetSpuPage(pageResult); - // 处理 vip 价格 - MemberLevelRespDTO memberLevel = getMemberLevel(); - voPageResult.getList().forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel))); - return success(voPageResult); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得商品 SPU 明细") - @Parameter(name = "id", description = "编号", required = true) - public CommonResult getSpuDetail(@RequestParam("id") Long id) { - // 获得商品 SPU - ProductSpuDO spu = productSpuService.getSpu(id); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) { - throw exception(SPU_NOT_ENABLE); - } - - // 拼接返回 - List skus = productSkuService.getSkuListBySpuId(spu.getId()); - AppProductSpuDetailRespVO detailVO = ProductSpuConvert.INSTANCE.convertForGetSpuDetail(spu, skus); - // 处理 vip 价格 - MemberLevelRespDTO memberLevel = getMemberLevel(); - detailVO.setVipPrice(calculateVipPrice(detailVO.getPrice(), memberLevel)); - return success(detailVO); - } - - private MemberLevelRespDTO getMemberLevel() { - Long userId = getLoginUserId(); - if (userId == null) { - return null; - } - MemberUserRespDTO user = memberUserApi.getUser(userId); - if (user.getLevelId() == null || user.getLevelId() <= 0) { - return null; - } - return memberLevelApi.getMemberLevel(user.getLevelId()); - } - - /** - * 计算会员 VIP 优惠价格 - * - * @param price 原价 - * @param memberLevel 会员等级 - * @return 优惠价格 - */ - public Integer calculateVipPrice(Integer price, MemberLevelRespDTO memberLevel) { - if (memberLevel == null || memberLevel.getDiscountPercent() == null) { - return 0; - } - Integer newPrice = price * memberLevel.getDiscountPercent() / 100; - return price - newPrice; - } - - // TODO 芋艿:商品的浏览记录; -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java deleted file mode 100644 index c890a7961a..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 商品 SPU 明细 Response VO") -@Data -public class AppProductSpuDetailRespVO { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - // ========== 基本信息 ========= - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是一个快乐简介") - private String introduction; - - @Schema(description = "商品详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是商品描述") - private String description; - - @Schema(description = "商品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long categoryId; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED) - private String picUrl; - - @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED) - private List sliderPicUrls; - - @Schema(description = "商品视频", requiredMode = Schema.RequiredMode.REQUIRED) - private String videoUrl; - - @Schema(description = "单位名", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") - private String unitName; - - // ========== 营销相关字段 ========= - - @Schema(description = "活动排序数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private List activityOrders; - - // ========== SKU 相关字段 ========= - - @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean specType; - - @Schema(description = "商品价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer price; - - @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer marketPrice; - - @Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格 - private Integer vipPrice; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") - private Integer stock; - - /** - * SKU 数组 - */ - private List skus; - - // ========== 统计相关字段 ========= - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer salesCount; - - @Schema(description = "用户 App - 商品 SPU 明细的 SKU 信息") - @Data - public static class Sku { - - @Schema(description = "商品 SKU 编号", example = "1") - private Long id; - - /** - * 商品属性数组 - */ - private List properties; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer price; - - @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer marketPrice; - - @Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格 - private Integer vipPrice; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer stock; - - @Schema(description = "商品重量", example = "1") // 单位:kg 千克 - private Double weight; - - @Schema(description = "商品体积", example = "1024") // 单位:m^3 平米 - private Double volume; - - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java deleted file mode 100644 index cda799d46d..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.AssertTrue; - -@Schema(description = "用户 App - 商品 SPU 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppProductSpuPageReqVO extends PageParam { - - public static final String SORT_FIELD_PRICE = "price"; - public static final String SORT_FIELD_SALES_COUNT = "salesCount"; - - public static final String RECOMMEND_TYPE_HOT = "hot"; - public static final String RECOMMEND_TYPE_BENEFIT = "benefit"; - public static final String RECOMMEND_TYPE_BEST = "best"; - public static final String RECOMMEND_TYPE_NEW = "new"; - public static final String RECOMMEND_TYPE_GOOD = "good"; - - @Schema(description = "分类编号", example = "1") - private Long categoryId; - - @Schema(description = "关键字", example = "好看") - private String keyword; - - @Schema(description = "排序字段", example = "price") // 参见 AppProductSpuPageReqVO.SORT_FIELD_XXX 常量 - private String sortField; - - @Schema(description = "排序方式", example = "true") - private Boolean sortAsc; - - @Schema(description = "推荐类型", example = "hot") // 参见 AppProductSpuPageReqVO.RECOMMEND_TYPE_XXX 常量 - private String recommendType; - - @AssertTrue(message = "排序字段不合法") - @JsonIgnore - public boolean isSortFieldValid() { - if (StrUtil.isEmpty(sortField)) { - return true; - } - return StrUtil.equalsAny(sortField, SORT_FIELD_PRICE, SORT_FIELD_SALES_COUNT); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageRespVO.java deleted file mode 100644 index 07b0d8e952..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageRespVO.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 商品 SPU Response VO") -@Data -public class AppProductSpuPageRespVO { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖简介") - private String introduction; - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long categoryId; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED) - private String picUrl; - - @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED) - private List sliderPicUrls; - - @Schema(description = "单位名", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") - private String unitName; - - // ========== SKU 相关字段 ========= - - @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean specType; - - @Schema(description = "商品价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer price; - - @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer marketPrice; - - @Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格 - private Integer vipPrice; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") - private Integer stock; - - // ========== 营销相关字段 ========= - - @Schema(description = "活动排序数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private List activityOrders; - - // ========== 统计相关字段 ========= - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer salesCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/brand/ProductBrandConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/brand/ProductBrandConvert.java deleted file mode 100644 index e6c72fb497..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/brand/ProductBrandConvert.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.brand; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandRespVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandSimpleRespVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 品牌 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductBrandConvert { - - ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class); - - ProductBrandDO convert(ProductBrandCreateReqVO bean); - - ProductBrandDO convert(ProductBrandUpdateReqVO bean); - - ProductBrandRespVO convert(ProductBrandDO bean); - - List convertList1(List list); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/ProductCategoryConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/ProductCategoryConvert.java deleted file mode 100644 index ae01ca9d55..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/ProductCategoryConvert.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.category; - -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryRespVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 商品分类 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductCategoryConvert { - - ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class); - - ProductCategoryDO convert(ProductCategoryCreateReqVO bean); - - ProductCategoryDO convert(ProductCategoryUpdateReqVO bean); - - ProductCategoryRespVO convert(ProductCategoryDO bean); - - List convertList(List list); - - List convertList03(List list); -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java deleted file mode 100644 index 944eb2bc21..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java +++ /dev/null @@ -1,132 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.comment; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppProductCommentRespVO; -import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 商品评价 Convert - * - * @author wangzhs - */ -@Mapper -public interface ProductCommentConvert { - - ProductCommentConvert INSTANCE = Mappers.getMapper(ProductCommentConvert.class); - - ProductCommentRespVO convert(ProductCommentDO bean); - - @Mapping(target = "scores", expression = "java(calculateOverallScore(goodCount, mediocreCount, negativeCount))") - AppCommentStatisticsRespVO convert(Long goodCount, Long mediocreCount, Long negativeCount); - - @Named("calculateOverallScore") - default double calculateOverallScore(long goodCount, long mediocreCount, long negativeCount) { - return (goodCount * 5 + mediocreCount * 3 + negativeCount) / (double) (goodCount + mediocreCount + negativeCount); - } - - List convertList(List list); - - PageResult convertPage(PageResult page); - - PageResult convertPage01(PageResult pageResult); - - default PageResult convertPage02(PageResult pageResult, - List skuList) { - Map skuMap = CollectionUtils.convertMap(skuList, ProductSkuDO::getId); - PageResult page = convertPage01(pageResult); - page.getList().forEach(item -> { - // 判断用户是否选择匿名 - if (ObjectUtil.equal(item.getAnonymous(), true)) { - item.setUserNickname(ProductCommentDO.NICKNAME_ANONYMOUS); - } - // 设置 SKU 规格值 - findAndThen(skuMap, item.getSkuId(), - sku -> item.setSkuProperties(convertList01(sku.getProperties()))); - }); - return page; - } - - List convertList01(List properties); - - /** - * 计算综合评分 - * - * @param descriptionScores 描述星级 - * @param benefitScores 服务星级 - * @return 综合评分 - */ - @Named("convertScores") - default Integer convertScores(Integer descriptionScores, Integer benefitScores) { - // 计算评价最终综合评分 最终星数 = (商品评星 + 服务评星) / 2 - BigDecimal sumScore = new BigDecimal(descriptionScores + benefitScores); - BigDecimal divide = sumScore.divide(BigDecimal.valueOf(2L), 0, RoundingMode.DOWN); - return divide.intValue(); - } - - ProductCommentDO convert(ProductCommentCreateReqDTO createReqDTO); - - @Mapping(target = "scores", - expression = "java(convertScores(createReqDTO.getDescriptionScores(), createReqDTO.getBenefitScores()))") - default ProductCommentDO convert(ProductCommentCreateReqDTO createReqDTO, ProductSpuDO spuDO, ProductSkuDO skuDO, MemberUserRespDTO user) { - ProductCommentDO commentDO = convert(createReqDTO); - if (user != null) { - commentDO.setUserId(user.getId()); - commentDO.setUserNickname(user.getNickname()); - commentDO.setUserAvatar(user.getAvatar()); - } - if (spuDO != null) { - commentDO.setSpuId(spuDO.getId()); - commentDO.setSpuName(spuDO.getName()); - } - if (skuDO != null) { - commentDO.setSkuPicUrl(skuDO.getPicUrl()); - commentDO.setSkuProperties(skuDO.getProperties()); - } - return commentDO; - } - - @Mapping(target = "visible", constant = "true") - @Mapping(target = "replyStatus", constant = "false") - @Mapping(target = "userId", constant = "0L") - @Mapping(target = "orderId", constant = "0L") - @Mapping(target = "orderItemId", constant = "0L") - @Mapping(target = "anonymous", expression = "java(Boolean.FALSE)") - @Mapping(target = "scores", - expression = "java(convertScores(createReq.getDescriptionScores(), createReq.getBenefitScores()))") - ProductCommentDO convert(ProductCommentCreateReqVO createReq); - - List convertList02(List list); - - default ProductCommentDO convert(ProductCommentCreateReqVO createReq, ProductSpuDO spu, ProductSkuDO sku) { - ProductCommentDO commentDO = convert(createReq); - if (spu != null) { - commentDO.setSpuId(spu.getId()).setSpuName(spu.getName()); - } - if (sku != null) { - commentDO.setSkuPicUrl(sku.getPicUrl()).setSkuProperties(sku.getProperties()); - } - return commentDO; - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/favorite/ProductFavoriteConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/favorite/ProductFavoriteConvert.java deleted file mode 100644 index 7b419b6a85..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/favorite/ProductFavoriteConvert.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.favorite; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoriteRespVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -@Mapper -public interface ProductFavoriteConvert { - - ProductFavoriteConvert INSTANCE = Mappers.getMapper(ProductFavoriteConvert.class); - - ProductFavoriteDO convert(Long userId, Long spuId); - - @Mapping(target = "id", source = "favorite.id") - @Mapping(target = "spuName", source = "spu.name") - AppFavoriteRespVO convert(ProductSpuDO spu, ProductFavoriteDO favorite); - - default List convertList(List favorites, List spus) { - List resultList = new ArrayList<>(favorites.size()); - Map spuMap = convertMap(spus, ProductSpuDO::getId); - for (ProductFavoriteDO favorite : favorites) { - ProductSpuDO spuDO = spuMap.get(favorite.getSpuId()); - resultList.add(convert(spuDO, favorite)); - } - return resultList; - } - - default PageResult convertPage(PageResult pageResult, List spuList) { - Map spuMap = convertMap(spuList, ProductSpuDO::getId); - List voList = CollectionUtils.convertList(pageResult.getList(), favorite -> { - ProductSpuDO spu = spuMap.get(favorite.getSpuId()); - return convert02(spu, favorite); - }); - return new PageResult<>(voList, pageResult.getTotal()); - } - @Mapping(target = "id", source = "favorite.id") - @Mapping(target = "userId", source = "favorite.userId") - @Mapping(target = "spuId", source = "favorite.spuId") - @Mapping(target = "createTime", source = "favorite.createTime") - ProductFavoriteRespVO convert02(ProductSpuDO spu, ProductFavoriteDO favorite); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java deleted file mode 100644 index 368da94162..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.property; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyAndValueRespVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyRespVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 属性项 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductPropertyConvert { - - ProductPropertyConvert INSTANCE = Mappers.getMapper(ProductPropertyConvert.class); - - ProductPropertyDO convert(ProductPropertyCreateReqVO bean); - - ProductPropertyDO convert(ProductPropertyUpdateReqVO bean); - - ProductPropertyRespVO convert(ProductPropertyDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default List convertList(List keys, List values) { - Map> valueMap = CollectionUtils.convertMultiMap(values, ProductPropertyValueDO::getPropertyId); - return CollectionUtils.convertList(keys, key -> { - ProductPropertyAndValueRespVO respVO = convert02(key); - // 如果属性值为空value不为null,返回空列表 - if (CollUtil.isEmpty(values)) { - respVO.setValues(Collections.emptyList()); - }else { - respVO.setValues(convertList02(valueMap.get(key.getId()))); - } - return respVO; - }); - } - ProductPropertyAndValueRespVO convert02(ProductPropertyDO bean); - List convertList02(List list); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyValueConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyValueConvert.java deleted file mode 100644 index 57ac4e1726..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyValueConvert.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 属性值 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductPropertyValueConvert { - - ProductPropertyValueConvert INSTANCE = Mappers.getMapper(ProductPropertyValueConvert.class); - - ProductPropertyValueDO convert(ProductPropertyValueCreateReqVO bean); - - ProductPropertyValueDO convert(ProductPropertyValueUpdateReqVO bean); - - ProductPropertyValueRespVO convert(ProductPropertyValueDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java deleted file mode 100755 index 5065a9c405..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.sku; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商品 SKU Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductSkuConvert { - - ProductSkuConvert INSTANCE = Mappers.getMapper(ProductSkuConvert.class); - - ProductSkuDO convert(ProductSkuCreateOrUpdateReqVO bean); - - ProductSkuRespVO convert(ProductSkuDO bean); - - List convertList(List list); - - List convertList06(List list); - - default List convertList06(List list, Long spuId) { - List result = convertList06(list); - result.forEach(item -> item.setSpuId(spuId)); - return result; - } - - ProductSkuRespDTO convert02(ProductSkuDO bean); - - List convertList04(List list); - - /** - * 获得 SPU 的库存变化 Map - * - * @param items SKU 库存变化 - * @param skus SKU 列表 - * @return SPU 的库存变化 Map - */ - default Map convertSpuStockMap(List items, - List skus) { - Map skuIdAndSpuIdMap = convertMap(skus, ProductSkuDO::getId, ProductSkuDO::getSpuId); // SKU 与 SKU 编号的 Map 关系 - Map spuIdAndStockMap = new HashMap<>(); // SPU 的库存变化 Map 关系 - items.forEach(item -> { - Long spuId = skuIdAndSpuIdMap.get(item.getId()); - if (spuId == null) { - return; - } - Integer stock = spuIdAndStockMap.getOrDefault(spuId, 0) + item.getIncrCount(); - spuIdAndStockMap.put(spuId, stock); - }); - return spuIdAndStockMap; - } - - default String buildPropertyKey(ProductSkuDO bean) { - if (CollUtil.isEmpty(bean.getProperties())) { - return StrUtil.EMPTY; - } - List properties = new ArrayList<>(bean.getProperties()); - properties.sort(Comparator.comparing(ProductSkuDO.Property::getValueId)); - return properties.stream().map(m -> String.valueOf(m.getValueId())).collect(Collectors.joining()); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java deleted file mode 100755 index 30dd2d8b9d..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.spu; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageRespVO; -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.enums.DictTypeConstants; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.hutool.core.util.ObjectUtil.defaultIfNull; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; - -/** - * 商品 SPU Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductSpuConvert { - - ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class); - - ProductSpuDO convert(ProductSpuCreateReqVO bean); - - ProductSpuDO convert(ProductSpuUpdateReqVO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - ProductSpuPageReqVO convert(AppProductSpuPageReqVO bean); - - List convertList2(List list); - - List convertList02(List list); - - @Mapping(target = "price", expression = "java(spu.getPrice() / 100)") - @Mapping(target = "marketPrice", expression = "java(spu.getMarketPrice() / 100)") - @Mapping(target = "costPrice", expression = "java(spu.getCostPrice() / 100)") - ProductSpuExcelVO convert(ProductSpuDO spu); - - default List convertList03(List list) { - List spuExcelVOs = new ArrayList<>(); - list.forEach(spu -> { - ProductSpuExcelVO spuExcelVO = convert(spu); - spuExcelVOs.add(spuExcelVO); - }); - return spuExcelVOs; - } - - ProductSpuDetailRespVO convert03(ProductSpuDO spu); - - ProductSpuRespDTO convert02(ProductSpuDO bean); - - // ========== 用户 App 相关 ========== - - PageResult convertPageForGetSpuPage(PageResult page); - - default List convertListForGetSpuList(List list) { - // 处理虚拟销量 - list.forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount())); - // 处理 VO 字段 - List voList = convertListForGetSpuList0(list); - for (int i = 0; i < list.size(); i++) { - ProductSpuDO spu = list.get(i); - AppProductSpuPageRespVO spuVO = voList.get(i); - spuVO.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit())); - } - return voList; - } - - @Named("convertListForGetSpuList0") - List convertListForGetSpuList0(List list); - - default AppProductSpuDetailRespVO convertForGetSpuDetail(ProductSpuDO spu, List skus) { - // 处理 SPU - AppProductSpuDetailRespVO spuVO = convertForGetSpuDetail(spu) - .setSalesCount(spu.getSalesCount() + defaultIfNull(spu.getVirtualSalesCount(), 0)) - .setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit())); - // 处理 SKU - spuVO.setSkus(convertListForGetSpuDetail(skus)); - return spuVO; - } - - AppProductSpuDetailRespVO convertForGetSpuDetail(ProductSpuDO spu); - - List convertListForGetSpuDetail(List skus); - - default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List skus) { - return convert03(spu).setSkus(ProductSkuConvert.INSTANCE.convertList(skus)); - } - - default List convertForSpuDetailRespListVO(List spus, List skus) { - Map> skuMultiMap = convertMultiMap(skus, ProductSkuDO::getSpuId); - return CollectionUtils.convertList(spus, spu -> convert03(spu) - .setSkus(ProductSkuConvert.INSTANCE.convertList(skuMultiMap.get(spu.getId())))); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/brand/ProductBrandDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/brand/ProductBrandDO.java deleted file mode 100644 index 9775f36a5d..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/brand/ProductBrandDO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品品牌 DO - * - * @author 芋道源码 - */ -@TableName("product_brand") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductBrandDO extends BaseDO { - - /** - * 品牌编号 - */ - @TableId - private Long id; - /** - * 品牌名称 - */ - private String name; - /** - * 品牌图片 - */ - private String picUrl; - /** - * 品牌排序 - */ - private Integer sort; - /** - * 品牌描述 - */ - private String description; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - - // TODO 芋艿:firstLetter 首字母 - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java deleted file mode 100644 index bf69e00280..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.category; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品分类 DO - * - * @author 芋道源码 - */ -@TableName("product_category") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductCategoryDO extends BaseDO { - - /** - * 父分类编号 - 根分类 - */ - public static final Long PARENT_ID_NULL = 0L; - /** - * 限定分类层级 - */ - public static final int CATEGORY_LEVEL = 2; - - /** - * 分类编号 - */ - @TableId - private Long id; - /** - * 父分类编号 - */ - private Long parentId; - /** - * 分类名称 - */ - private String name; - /** - * 移动端分类图 - * - * 建议 180*180 分辨率 - */ - private String picUrl; - /** - * PC 端分类图 - * - * 建议 468*340 分辨率 - */ - private String bigPicUrl; - /** - * 分类排序 - */ - private Integer sort; - /** - * 开启状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java deleted file mode 100644 index 40b04caf08..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java +++ /dev/null @@ -1,159 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.comment; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 商品评论 DO - * - * @author 芋道源码 - */ -@TableName(value = "product_comment", autoResultMap = true) -@KeySequence("product_comment_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductCommentDO extends BaseDO { - - /** - * 默认匿名昵称 - */ - public static final String NICKNAME_ANONYMOUS = "匿名用户"; - - /** - * 评论编号,主键自增 - */ - @TableId - private Long id; - - /** - * 评价人的用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 评价人名称 - */ - private String userNickname; - /** - * 评价人头像 - */ - private String userAvatar; - /** - * 是否匿名 - */ - private Boolean anonymous; - - /** - * 交易订单编号 - * - * 关联 TradeOrderDO 的 id 编号 - */ - private Long orderId; - /** - * 交易订单项编号 - * - * 关联 TradeOrderItemDO 的 id 编号 - */ - private Long orderItemId; - - /** - * 商品 SPU 编号 - * - * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - /** - * 商品 SPU 名称 - * - * 关联 {@link ProductSpuDO#getName()} - */ - private String spuName; - /** - * 商品 SKU 编号 - * - * 关联 {@link ProductSkuDO#getId()} - */ - private Long skuId; - /** - * 商品 SKU 图片地址 - * - * 关联 {@link ProductSkuDO#getPicUrl()} - */ - private String skuPicUrl; - /** - * 属性数组,JSON 格式 - * - * 关联 {@link ProductSkuDO#getProperties()} - */ - @TableField(typeHandler = ProductSkuDO.PropertyTypeHandler.class) - private List skuProperties; - - /** - * 是否可见 - * - * true:显示 - * false:隐藏 - */ - private Boolean visible; - /** - * 评分星级 - * - * 1-5 分 - */ - private Integer scores; - /** - * 描述星级 - * - * 1-5 星 - */ - private Integer descriptionScores; - /** - * 服务星级 - * - * 1-5 星 - */ - private Integer benefitScores; - /** - * 评论内容 - */ - private String content; - /** - * 评论图片地址数组 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List picUrls; - - /** - * 商家是否回复 - */ - private Boolean replyStatus; - /** - * 回复管理员编号 - * 关联 AdminUserDO 的 id 编号 - */ - private Long replyUserId; - /** - * 商家回复内容 - */ - private String replyContent; - /** - * 商家回复时间 - */ - private LocalDateTime replyTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDO.java deleted file mode 100644 index 6e00eaa6c8..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.favorite; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品收藏 DO - * - * @author 芋道源码 - */ -@TableName("product_favorite") -@KeySequence("product_favorite_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductFavoriteDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 商品 SPU 编号 - * - * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java deleted file mode 100644 index 8cc646bd5e..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.property; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品属性项 DO - * - * @author 芋道源码 - */ -@TableName("product_property") -@KeySequence("product_property_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductPropertyDO extends BaseDO { - - /** - * SPU 单规格时,默认属性 id - */ - public static final Long ID_DEFAULT = 0L; - /** - * SPU 单规格时,默认属性名字 - */ - public static final String NAME_DEFAULT = "默认"; - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 名称 - */ - private String name; - /** - * 状态 - */ - private Integer status; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java deleted file mode 100644 index cefa2d9584..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.property; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - - -/** - * 商品属性值 DO - * - * @author 芋道源码 - */ -@TableName("product_property_value") -@KeySequence("product_property_value_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductPropertyValueDO extends BaseDO { - - /** - * SPU 单规格时,默认属性值 id - */ - public static final Long ID_DEFAULT = 0L; - /** - * SPU 单规格时,默认属性值名字 - */ - public static final String NAME_DEFAULT = "默认"; - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 属性项的编号 - * - * 关联 {@link ProductPropertyDO#getId()} - */ - private Long propertyId; - /** - * 名称 - */ - private String name; - /** - * 备注 - * - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java deleted file mode 100755 index dacb02ec8e..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java +++ /dev/null @@ -1,156 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.sku; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 商品 SKU DO - * - * @author 芋道源码 - */ -@TableName(value = "product_sku", autoResultMap = true) -@KeySequence("product_sku_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductSkuDO extends BaseDO { - - /** - * 商品 SKU 编号,自增 - */ - @TableId - private Long id; - /** - * SPU 编号 - * - * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - /** - * 属性数组,JSON 格式 - */ - @TableField(typeHandler = PropertyTypeHandler.class) - private List properties; - /** - * 商品价格,单位:分 - */ - private Integer price; - /** - * 市场价,单位:分 - */ - private Integer marketPrice; - /** - * 成本价,单位:分 - */ - private Integer costPrice; - /** - * 商品条码 - */ - private String barCode; - /** - * 图片地址 - */ - private String picUrl; - /** - * 库存 - */ - private Integer stock; - /** - * 商品重量,单位:kg 千克 - */ - private Double weight; - /** - * 商品体积,单位:m^3 平米 - */ - private Double volume; - - /** - * 一级分销的佣金,单位:分 - */ - private Integer firstBrokeragePrice; - /** - * 二级分销的佣金,单位:分 - */ - private Integer secondBrokeragePrice; - - // ========== 营销相关字段 ========= - - // ========== 统计相关字段 ========= - /** - * 商品销量 - */ - private Integer salesCount; - - /** - * 商品属性 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Property { - - /** - * 属性编号 - * 关联 {@link ProductPropertyDO#getId()} - */ - private Long propertyId; - /** - * 属性名字 - * 冗余 {@link ProductPropertyDO#getName()} - * - * 注意:每次属性名字发生变化时,需要更新该冗余 - */ - private String propertyName; - - /** - * 属性值编号 - * 关联 {@link ProductPropertyValueDO#getId()} - */ - private Long valueId; - /** - * 属性值名字 - * 冗余 {@link ProductPropertyValueDO#getName()} - * - * 注意:每次属性值名字发生变化时,需要更新该冗余 - */ - private String valueName; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class PropertyTypeHandler extends AbstractJsonTypeHandler { - - @Override - protected Object parse(String json) { - return JsonUtils.parseArray(json, Property.class); - } - - @Override - protected String toJson(Object obj) { - return JsonUtils.toJsonString(obj); - } - - } - - // TODO 芋艿:integral from y - // TODO 芋艿:pinkPrice from y - // TODO 芋艿:seckillPrice from y - // TODO 芋艿:pinkStock from y - // TODO 芋艿:seckillStock from y - -} - diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java deleted file mode 100755 index 9ce55a0965..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java +++ /dev/null @@ -1,213 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.spu; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 商品 SPU DO - * - * @author 芋道源码 - */ -@TableName(value = "product_spu", autoResultMap = true) -@KeySequence("product_spu_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductSpuDO extends BaseDO { - - /** - * 商品 SPU 编号,自增 - */ - @TableId - private Long id; - - // ========== 基本信息 ========= - - /** - * 商品名称 - */ - private String name; - /** - * 关键字 - */ - private String keyword; - /** - * 商品简介 - */ - private String introduction; - /** - * 商品详情 - */ - private String description; - // TODO @芋艿:是不是要删除 - /** - * 商品条码(一维码) - */ - private String barCode; - - /** - * 商品分类编号 - * - * 关联 {@link ProductCategoryDO#getId()} - */ - private Long categoryId; - /** - * 商品品牌编号 - * - * 关联 {@link ProductBrandDO#getId()} - */ - private Long brandId; - /** - * 商品封面图 - */ - private String picUrl; - /** - * 商品轮播图 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List sliderPicUrls; - /** - * 商品视频 - */ - private String videoUrl; - - /** - * 单位 - * - * 对应 product_unit 数据字典 - */ - private Integer unit; - /** - * 排序字段 - */ - private Integer sort; - /** - * 商品状态 - * - * 枚举 {@link ProductSpuStatusEnum} - */ - private Integer status; - - // ========== SKU 相关字段 ========= - - /** - * 规格类型 - * - * false - 单规格 - * true - 多规格 - */ - private Boolean specType; - /** - * 商品价格,单位使用:分 - * - * 基于其对应的 {@link ProductSkuDO#getPrice()} sku单价最低的商品的 - */ - private Integer price; - /** - * 市场价,单位使用:分 - * - * 基于其对应的 {@link ProductSkuDO#getMarketPrice()} sku单价最低的商品的 - */ - private Integer marketPrice; - /** - * 成本价,单位使用:分 - * - * 基于其对应的 {@link ProductSkuDO#getCostPrice()} sku单价最低的商品的 - */ - private Integer costPrice; - /** - * 库存 - * - * 基于其对应的 {@link ProductSkuDO#getStock()} 求和 - */ - private Integer stock; - - // ========== 物流相关字段 ========= - - /** - * 物流配置模板编号 - * - * 对应 TradeDeliveryExpressTemplateDO 的 id 编号 - */ - private Long deliveryTemplateId; - - // ========== 营销相关字段 ========= - /** - * 是否热卖推荐 - */ - private Boolean recommendHot; - /** - * 是否优惠推荐 - */ - private Boolean recommendBenefit; - /** - * 是否精品推荐 - */ - private Boolean recommendBest; - /** - * 是否新品推荐 - */ - private Boolean recommendNew; - /** - * 是否优品推荐 - */ - private Boolean recommendGood; - - /** - * 赠送积分 - */ - private Integer giveIntegral; - /** - * 赠送的优惠劵编号的数组 - * - * 对应 CouponTemplateDO 的 id 属性 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List giveCouponTemplateIds; - - // TODO @puhui999:字段估计要改成 brokerageType - /** - * 分销类型 - * - * false - 默认 - * true - 自行设置 - */ - private Boolean subCommissionType; - - /** - * 活动展示顺序 - * - * 对应 PromotionTypeEnum 枚举 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List activityOrders; // TODO @芋艿: 活动顺序字段长度需要增加 - - // ========== 统计相关字段 ========= - - /** - * 商品销量 - */ - private Integer salesCount; - /** - * 虚拟销量 - */ - private Integer virtualSalesCount; - /** - * 浏览量 - */ - private Integer browseCount; -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java deleted file mode 100644 index b2c4bd5fbb..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.brand; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface ProductBrandMapper extends BaseMapperX { - - default PageResult selectPage(ProductBrandPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductBrandDO::getName, reqVO.getName()) - .eqIfPresent(ProductBrandDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(ProductBrandDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductBrandDO::getId)); - } - - - default List selectList(ProductBrandListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(ProductBrandDO::getName, reqVO.getName())); - } - - default ProductBrandDO selectByName(String name) { - return selectOne(ProductBrandDO::getName, name); - } - - default List selectListByStatus(Integer status) { - return selectList(ProductBrandDO::getStatus, status); - } -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java deleted file mode 100644 index fbb88f592c..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.category; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 商品分类 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ProductCategoryMapper extends BaseMapperX { - - default List selectList(ProductCategoryListReqVO listReqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(ProductCategoryDO::getName, listReqVO.getName()) - .eqIfPresent(ProductCategoryDO::getParentId, listReqVO.getParentId()) - .eqIfPresent(ProductCategoryDO::getStatus, listReqVO.getStatus()) - .orderByDesc(ProductCategoryDO::getId)); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(ProductCategoryDO::getParentId, parentId); - } - - default List selectListByStatus(Integer status) { - return selectList(ProductCategoryDO::getStatus, status); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java deleted file mode 100644 index 387a3736bb..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java +++ /dev/null @@ -1,79 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.comment; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface ProductCommentMapper extends BaseMapperX { - - default PageResult selectPage(ProductCommentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductCommentDO::getUserNickname, reqVO.getUserNickname()) - .eqIfPresent(ProductCommentDO::getOrderId, reqVO.getOrderId()) - .eqIfPresent(ProductCommentDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(ProductCommentDO::getScores, reqVO.getScores()) - .eqIfPresent(ProductCommentDO::getReplyStatus, reqVO.getReplyStatus()) - .betweenIfPresent(ProductCommentDO::getCreateTime, reqVO.getCreateTime()) - .likeIfPresent(ProductCommentDO::getSpuName, reqVO.getSpuName()) - .orderByDesc(ProductCommentDO::getId)); - } - - static void appendTabQuery(LambdaQueryWrapperX queryWrapper, Integer type) { - LambdaQueryWrapperX queryWrapperX = new LambdaQueryWrapperX<>(); - // 构建好评查询语句:好评计算 总评 >= 4 - if (ObjectUtil.equal(type, AppCommentPageReqVO.GOOD_COMMENT)) { - queryWrapperX.ge(ProductCommentDO::getScores, 4); - } - // 构建中评查询语句:中评计算 总评 >= 3 且 总评 < 4 - if (ObjectUtil.equal(type, AppCommentPageReqVO.MEDIOCRE_COMMENT)) { - queryWrapperX.ge(ProductCommentDO::getScores, 3); - queryWrapperX.lt(ProductCommentDO::getScores, 4); - } - // 构建差评查询语句:差评计算 总评 < 3 - if (ObjectUtil.equal(type, AppCommentPageReqVO.NEGATIVE_COMMENT)) { - queryWrapperX.lt(ProductCommentDO::getScores, 3); - } - } - - default PageResult selectPage(AppCommentPageReqVO reqVO, Boolean visible) { - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX() - .eqIfPresent(ProductCommentDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(ProductCommentDO::getVisible, visible); - // 构建评价查询语句 - appendTabQuery(queryWrapper, reqVO.getType()); - // 按评价时间排序最新的显示在前面 - queryWrapper.orderByDesc(ProductCommentDO::getCreateTime); - return selectPage(reqVO, queryWrapper); - } - - default ProductCommentDO selectByUserIdAndOrderItemId(Long userId, Long orderItemId) { - return selectOne(new LambdaQueryWrapperX() - .eq(ProductCommentDO::getUserId, userId) - .eq(ProductCommentDO::getOrderItemId, orderItemId)); - } - - default Long selectCountBySpuId(Long spuId, Boolean visible, Integer type) { - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX() - .eqIfPresent(ProductCommentDO::getSpuId, spuId) - .eqIfPresent(ProductCommentDO::getVisible, visible); - // 构建评价查询语句 - appendTabQuery(queryWrapper, type); - return selectCount(queryWrapper); - } - - default PageResult selectCommentList(Long spuId, Integer count) { - // 构建分页查询条件 - return selectPage(new PageParam().setPageSize(count), new LambdaQueryWrapperX() - .eqIfPresent(ProductCommentDO::getSpuId, spuId) - .orderByDesc(ProductCommentDO::getCreateTime) - ); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/favorite/ProductFavoriteMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/favorite/ProductFavoriteMapper.java deleted file mode 100644 index a681d42a72..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/favorite/ProductFavoriteMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.favorite; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface ProductFavoriteMapper extends BaseMapperX { - - default ProductFavoriteDO selectByUserIdAndSpuId(Long userId, Long spuId) { - return selectOne(ProductFavoriteDO::getUserId, userId, - ProductFavoriteDO::getSpuId, spuId); - } - - default PageResult selectPageByUserAndType(Long userId, AppFavoritePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapper() - .eq(ProductFavoriteDO::getUserId, userId) - .orderByDesc(ProductFavoriteDO::getId)); - } - - default PageResult selectPageByUserId(ProductFavoritePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ProductFavoriteDO::getUserId, reqVO.getUserId()) - .orderByDesc(ProductFavoriteDO::getId)); - } - - default Long selectCountByUserId(Long userId) { - return selectCount(ProductFavoriteDO::getUserId, userId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java deleted file mode 100644 index 26f8d52397..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface ProductPropertyMapper extends BaseMapperX { - - default PageResult selectPage(ProductPropertyPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductPropertyDO::getName, reqVO.getName()) - .betweenIfPresent(ProductPropertyDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductPropertyDO::getId)); - } - - default ProductPropertyDO selectByName(String name) { - return selectOne(ProductPropertyDO::getName, name); - } - - default List selectList(ProductPropertyListReqVO listReqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(ProductPropertyDO::getName, listReqVO.getName())); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java deleted file mode 100644 index 402df51e70..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface ProductPropertyValueMapper extends BaseMapperX { - - default List selectListByPropertyId(Collection propertyIds) { - return selectList(new LambdaQueryWrapperX() - .inIfPresent(ProductPropertyValueDO::getPropertyId, propertyIds)); - } - - default ProductPropertyValueDO selectByName(Long propertyId, String name) { - return selectOne(new LambdaQueryWrapperX() - .eq(ProductPropertyValueDO::getPropertyId, propertyId) - .eq(ProductPropertyValueDO::getName, name)); - } - - default void deleteByPropertyId(Long propertyId) { - delete(new LambdaQueryWrapperX() - .eq(ProductPropertyValueDO::getPropertyId, propertyId)); - } - - default PageResult selectPage(ProductPropertyValuePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ProductPropertyValueDO::getPropertyId, reqVO.getPropertyId()) - .likeIfPresent(ProductPropertyValueDO::getName, reqVO.getName()) - .orderByDesc(ProductPropertyValueDO::getId)); - } - - default Integer selectCountByPropertyId(Long propertyId) { - return selectCount(ProductPropertyValueDO::getPropertyId, propertyId).intValue(); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java deleted file mode 100755 index 6da00caf49..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.sku; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface ProductSkuMapper extends BaseMapperX { - - default List selectListBySpuId(Long spuId) { - return selectList(ProductSkuDO::getSpuId, spuId); - } - - default List selectListBySpuId(Collection spuIds) { - return selectList(ProductSkuDO::getSpuId, spuIds); - } - - default void deleteBySpuId(Long spuId) { - delete(new LambdaQueryWrapperX().eq(ProductSkuDO::getSpuId, spuId)); - } - - /** - * 更新 SKU 库存(增加) - * - * @param id 编号 - * @param incrCount 增加库存(正数) - */ - default void updateStockIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" stock = stock + " + incrCount) - .eq(ProductSkuDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新 SKU 库存(减少) - * - * @param id 编号 - * @param incrCount 减少库存(负数) - * @return 更新条数 - */ - default int updateStockDecr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() - .setSql(" stock = stock + " + incrCount) // 负数,所以使用 + 号 - .eq(ProductSkuDO::getId, id) - .ge(ProductSkuDO::getStock, -incrCount); // cas 逻辑 - return update(null, updateWrapper); - } - - default List selectListByAlarmStock() { - return selectList(new QueryWrapper().apply("stock <= warn_stock")); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java deleted file mode 100755 index 861ca475e8..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java +++ /dev/null @@ -1,169 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.spu; - -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuExportReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.enums.ProductConstants; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.Objects; -import java.util.Set; - -@Mapper -public interface ProductSpuMapper extends BaseMapperX { - - /** - * 获取商品 SPU 分页列表数据 - * - * @param reqVO 分页请求参数 - * @return 商品 SPU 分页列表数据 - */ - default PageResult selectPage(ProductSpuPageReqVO reqVO) { - Integer tabType = reqVO.getTabType(); - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX() - .likeIfPresent(ProductSpuDO::getName, reqVO.getName()) - .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) - .betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductSpuDO::getSort); - appendTabQuery(tabType, queryWrapper); - return selectPage(reqVO, queryWrapper); - } - - /** - * 查询触发警戒库存的 SPU 数量 - * - * @return 触发警戒库存的 SPU 数量 - */ - default Long selectCount() { - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX<>(); - // 库存小于等于警戒库存 - queryWrapper.le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK) - // 如果库存触发警戒库存且状态为回收站的话则不计入触发警戒库存的个数 - .notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); - return selectCount(queryWrapper); - } - - /** - * 获得商品 SPU 分页,提供给用户 App 使用 - */ - default PageResult selectPage(AppProductSpuPageReqVO pageReqVO, Set categoryIds) { - LambdaQueryWrapperX query = new LambdaQueryWrapperX() - // 关键字匹配,目前只匹配商品名 - .likeIfPresent(ProductSpuDO::getName, pageReqVO.getKeyword()) - // 分类 - .inIfPresent(ProductSpuDO::getCategoryId, categoryIds); - // 上架状态 且有库存 - query.eq(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()); - // 推荐类型的过滤条件 - if (ObjUtil.equal(pageReqVO.getRecommendType(), AppProductSpuPageReqVO.RECOMMEND_TYPE_HOT)) { - query.eq(ProductSpuDO::getRecommendHot, true); - } else if (ObjUtil.equal(pageReqVO.getRecommendType(), AppProductSpuPageReqVO.RECOMMEND_TYPE_BENEFIT)) { - query.eq(ProductSpuDO::getRecommendBenefit, true); - } else if (ObjUtil.equal(pageReqVO.getRecommendType(), AppProductSpuPageReqVO.RECOMMEND_TYPE_BEST)) { - query.eq(ProductSpuDO::getRecommendBest, true); - } else if (ObjUtil.equal(pageReqVO.getRecommendType(), AppProductSpuPageReqVO.RECOMMEND_TYPE_NEW)) { - query.eq(ProductSpuDO::getRecommendNew, true); - } else if (ObjUtil.equal(pageReqVO.getRecommendType(), AppProductSpuPageReqVO.RECOMMEND_TYPE_GOOD)) { - query.eq(ProductSpuDO::getRecommendGood, true); - } - - // 排序逻辑 - if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_SALES_COUNT)) { - query.last(String.format(" ORDER BY (sales_count + virtual_sales_count) %s, sort DESC, id DESC", - pageReqVO.getSortAsc() ? "ASC" : "DESC")); - } else if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_PRICE)) { - query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getPrice) - .orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId); - } else { - query.orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId); - } - return selectPage(pageReqVO, query); - } - - default List selectListByRecommendType(String recommendType, Integer count) { - QueryWrapperX query = new QueryWrapperX<>(); - // 上架状态 且有库存 - query.eq("status", ProductSpuStatusEnum.ENABLE.getStatus()).gt("stock", 0); - // 推荐类型的过滤条件 - if (ObjUtil.equal(recommendType, AppProductSpuPageReqVO.RECOMMEND_TYPE_HOT)) { - query.eq("recommend_hot", true); - } else if (ObjUtil.equal(recommendType, AppProductSpuPageReqVO.RECOMMEND_TYPE_GOOD)) { - query.eq("recommend_good", true); - } - // 设置最大长度 - query.limitN(count); - return selectList(query); - } - - /** - * 更新商品 SPU 库存 - * - * @param id 商品 SPU 编号 - * @param incrCount 增加的库存数量 - */ - default void updateStock(Long id, Integer incrCount) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() - // 负数,所以使用 + 号 - .setSql(" stock = stock +" + incrCount) - .eq(ProductSpuDO::getId, id); - update(null, updateWrapper); - } - - /** - * 获得 Spu 列表 - * - * @param reqVO 查询条件 - * @return Spu 列表 - */ - default List selectList(ProductSpuExportReqVO reqVO) { - Integer tabType = reqVO.getTabType(); - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX<>(); - queryWrapper.eqIfPresent(ProductSpuDO::getName, reqVO.getName()); - queryWrapper.eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()); - queryWrapper.betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime()); - appendTabQuery(tabType, queryWrapper); - return selectList(queryWrapper); - } - - /** - * 添加后台 Tab 选项的查询条件 - * - * @param tabType 标签类型 - * @param query 查询条件 - */ - static void appendTabQuery(Integer tabType, LambdaQueryWrapperX query) { - // 出售中商品 - if (ObjectUtil.equals(ProductSpuPageReqVO.FOR_SALE, tabType)) { - query.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()); - } - // 仓储中商品 - if (ObjectUtil.equals(ProductSpuPageReqVO.IN_WAREHOUSE, tabType)) { - query.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus()); - } - // 已售空商品 - if (ObjectUtil.equals(ProductSpuPageReqVO.SOLD_OUT, tabType)) { - query.eqIfPresent(ProductSpuDO::getStock, 0); - } - // 警戒库存 - if (ObjectUtil.equals(ProductSpuPageReqVO.ALERT_STOCK, tabType)) { - query.le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK) - // 如果库存触发警戒库存且状态为回收站的话则不在警戒库存列表展示 - .notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); - } - // 回收站 - if (ObjectUtil.equals(ProductSpuPageReqVO.RECYCLE_BIN, tabType)) { - query.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); - } - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/package-info.java deleted file mode 100644 index d2e1c934a4..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 product 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.product.framework; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/web/config/ProductWebConfiguration.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/web/config/ProductWebConfiguration.java deleted file mode 100644 index 7da179960b..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/web/config/ProductWebConfiguration.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.framework.web.config; - -import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration; -import org.springdoc.core.models.GroupedOpenApi; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * product 模块的 web 组件的 Configuration - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -public class ProductWebConfiguration { - - /** - * product 模块的 API 分组 - */ - @Bean - public GroupedOpenApi productGroupedOpenApi() { - return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("product"); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/web/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/web/package-info.java deleted file mode 100644 index f4adb2d76b..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/web/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * product 模块的 web 配置 - */ -package cn.iocoder.yudao.module.product.framework.web; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java deleted file mode 100644 index e329429337..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * product 模块,主要实现交易相关功能 - * 例如:订单、退款、购物车等功能。 - * - * 1. Controller URL:以 /product/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 product_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.product; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandService.java deleted file mode 100644 index a7ed6b4f4c..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandService.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.product.service.brand; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.*; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 商品品牌 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductBrandService { - - /** - * 创建品牌 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBrand(@Valid ProductBrandCreateReqVO createReqVO); - - /** - * 更新品牌 - * - * @param updateReqVO 更新信息 - */ - void updateBrand(@Valid ProductBrandUpdateReqVO updateReqVO); - - /** - * 删除品牌 - * - * @param id 编号 - */ - void deleteBrand(Long id); - - /** - * 获得品牌 - * - * @param id 编号 - * @return 品牌 - */ - ProductBrandDO getBrand(Long id); - - /** - * 获得品牌列表 - * - * @param ids 编号 - * @return 品牌列表 - */ - List getBrandList(Collection ids); - - /** - * 获得品牌列表 - * - * @param listReqVO 请求参数 - * @return 品牌列表 - */ - List getBrandList(ProductBrandListReqVO listReqVO); - - /** - * 验证选择的商品分类是否合法 - * - * @param id 分类编号 - */ - void validateProductBrand(Long id); - - /** - * 获得品牌分页 - * - * @param pageReqVO 分页查询 - * @return 品牌分页 - */ - PageResult getBrandPage(ProductBrandPageReqVO pageReqVO); - - /** - * 获取指定状态的品牌列表 - * - * @param status 状态 - * @return 返回品牌列表 - */ - List getBrandListByStatus(Integer status); -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImpl.java deleted file mode 100644 index a3fc918340..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImpl.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.product.service.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.brand.ProductBrandConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.dal.mysql.brand.ProductBrandMapper; -import com.google.common.annotations.VisibleForTesting; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 品牌 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductBrandServiceImpl implements ProductBrandService { - - @Resource - private ProductBrandMapper brandMapper; - - @Override - public Long createBrand(ProductBrandCreateReqVO createReqVO) { - // 校验 - validateBrandNameUnique(null, createReqVO.getName()); - - // 插入 - ProductBrandDO brand = ProductBrandConvert.INSTANCE.convert(createReqVO); - brandMapper.insert(brand); - // 返回 - return brand.getId(); - } - - @Override - public void updateBrand(ProductBrandUpdateReqVO updateReqVO) { - // 校验存在 - validateBrandExists(updateReqVO.getId()); - validateBrandNameUnique(updateReqVO.getId(), updateReqVO.getName()); - // 更新 - ProductBrandDO updateObj = ProductBrandConvert.INSTANCE.convert(updateReqVO); - brandMapper.updateById(updateObj); - } - - @Override - public void deleteBrand(Long id) { - // 校验存在 - validateBrandExists(id); - // 删除 - brandMapper.deleteById(id); - } - - private void validateBrandExists(Long id) { - if (brandMapper.selectById(id) == null) { - throw exception(BRAND_NOT_EXISTS); - } - } - - @VisibleForTesting - public void validateBrandNameUnique(Long id, String name) { - ProductBrandDO brand = brandMapper.selectByName(name); - if (brand == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的字典类型 - if (id == null) { - throw exception(BRAND_NAME_EXISTS); - } - if (!brand.getId().equals(id)) { - throw exception(BRAND_NAME_EXISTS); - } - } - - @Override - public ProductBrandDO getBrand(Long id) { - return brandMapper.selectById(id); - } - - @Override - public List getBrandList(Collection ids) { - return brandMapper.selectBatchIds(ids); - } - - @Override - public List getBrandList(ProductBrandListReqVO listReqVO) { - return brandMapper.selectList(listReqVO); - } - - @Override - public void validateProductBrand(Long id) { - ProductBrandDO brand = brandMapper.selectById(id); - if (brand == null) { - throw exception(BRAND_NOT_EXISTS); - } - if (brand.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { - throw exception(BRAND_DISABLED); - } - } - - @Override - public PageResult getBrandPage(ProductBrandPageReqVO pageReqVO) { - return brandMapper.selectPage(pageReqVO); - } - - @Override - public List getBrandListByStatus(Integer status) { - return brandMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java deleted file mode 100644 index 1079bfabb0..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.product.service.category; - -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 商品分类 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductCategoryService { - - /** - * 创建商品分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCategory(@Valid ProductCategoryCreateReqVO createReqVO); - - /** - * 更新商品分类 - * - * @param updateReqVO 更新信息 - */ - void updateCategory(@Valid ProductCategoryUpdateReqVO updateReqVO); - - /** - * 删除商品分类 - * - * @param id 编号 - */ - void deleteCategory(Long id); - - /** - * 获得商品分类 - * - * @param id 编号 - * @return 商品分类 - */ - ProductCategoryDO getCategory(Long id); - - /** - * 校验商品分类 - * - * @param id 分类编号 - */ - void validateCategory(Long id); - - /** - * 获得商品分类的层级 - * - * @param id 编号 - * @return 商品分类的层级 - */ - Integer getCategoryLevel(Long id); - - /** - * 获得商品分类列表 - * - * @param listReqVO 查询条件 - * @return 商品分类列表 - */ - List getEnableCategoryList(ProductCategoryListReqVO listReqVO); - - /** - * 获得开启状态的商品分类列表 - * - * @return 商品分类列表 - */ - List getEnableCategoryList(); - - /** - * 校验商品分类是否有效。如下情况,视为无效: - * 1. 商品分类编号不存在 - * 2. 商品分类被禁用 - * - * @param ids 商品分类编号数组 - */ - void validateCategoryList(Collection ids); -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java deleted file mode 100644 index 93c39374ee..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java +++ /dev/null @@ -1,173 +0,0 @@ -package cn.iocoder.yudao.module.product.service.category; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.dal.mysql.category.ProductCategoryMapper; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.PARENT_ID_NULL; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品分类 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductCategoryServiceImpl implements ProductCategoryService { - - @Resource - private ProductCategoryMapper productCategoryMapper; - @Resource - @Lazy // 循环依赖,避免报错 - private ProductSpuService productSpuService; - - @Override - public Long createCategory(ProductCategoryCreateReqVO createReqVO) { - // 校验父分类存在 - validateParentProductCategory(createReqVO.getParentId()); - - // 插入 - ProductCategoryDO category = ProductCategoryConvert.INSTANCE.convert(createReqVO); - productCategoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateCategory(ProductCategoryUpdateReqVO updateReqVO) { - // 校验分类是否存在 - validateProductCategoryExists(updateReqVO.getId()); - // 校验父分类存在 - validateParentProductCategory(updateReqVO.getParentId()); - - // 更新 - ProductCategoryDO updateObj = ProductCategoryConvert.INSTANCE.convert(updateReqVO); - productCategoryMapper.updateById(updateObj); - } - - @Override - public void deleteCategory(Long id) { - // 校验分类是否存在 - validateProductCategoryExists(id); - // 校验是否还有子分类 - if (productCategoryMapper.selectCountByParentId(id) > 0) { - throw exception(CATEGORY_EXISTS_CHILDREN); - } - // 校验分类是否绑定了 SPU - Long spuCount = productSpuService.getSpuCountByCategoryId(id); - if (spuCount > 0) { - throw exception(CATEGORY_HAVE_BIND_SPU); - } - // 删除 - productCategoryMapper.deleteById(id); - } - - private void validateParentProductCategory(Long id) { - // 如果是根分类,无需验证 - if (Objects.equals(id, PARENT_ID_NULL)) { - return; - } - // 父分类不存在 - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(CATEGORY_PARENT_NOT_EXISTS); - } - // 父分类不能是二级分类 - if (!Objects.equals(category.getParentId(), PARENT_ID_NULL)) { - throw exception(CATEGORY_PARENT_NOT_FIRST_LEVEL); - } - } - - private void validateProductCategoryExists(Long id) { - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - } - - @Override - public void validateCategoryList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - // 获得商品分类信息 - List list = productCategoryMapper.selectBatchIds(ids); - Map categoryMap = CollectionUtils.convertMap(list, ProductCategoryDO::getId); - // 校验 - ids.forEach(id -> { - ProductCategoryDO category = categoryMap.get(id); - if (category == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - if (!CommonStatusEnum.ENABLE.getStatus().equals(category.getStatus())) { - throw exception(CATEGORY_DISABLED, category.getName()); - } - }); - } - - @Override - public ProductCategoryDO getCategory(Long id) { - return productCategoryMapper.selectById(id); - } - - @Override - public void validateCategory(Long id) { - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - if (Objects.equals(category.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(CATEGORY_DISABLED, category.getName()); - } - } - - @Override - public Integer getCategoryLevel(Long id) { - if (Objects.equals(id, PARENT_ID_NULL)) { - return 0; - } - int level = 1; - // for 的原因,是因为避免脏数据,导致可能的死循环。一般不会超过 100 层哈 - for (int i = 0; i < Byte.MAX_VALUE; i++) { - // 如果没有父节点,break 结束 - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null - || Objects.equals(category.getParentId(), PARENT_ID_NULL)) { - break; - } - // 继续递归父节点 - level++; - id = category.getParentId(); - } - return level; - } - - @Override - public List getEnableCategoryList(ProductCategoryListReqVO listReqVO) { - return productCategoryMapper.selectList(listReqVO); - } - - @Override - public List getEnableCategoryList() { - return productCategoryMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java deleted file mode 100644 index e531f5513c..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.product.service.comment; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppProductCommentRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.List; - -/** - * 商品评论 Service 接口 - * - * @author wangzhs - */ -@Service -@Validated -public interface ProductCommentService { - - /** - * 创建商品评论 - * 后台管理员创建评论使用 - * - * @param createReqVO 商品评价创建 Request VO 对象 - */ - void createComment(ProductCommentCreateReqVO createReqVO); - - /** - * 创建评论 - * 创建商品评论 APP 端创建商品评论使用 - * - * @param createReqDTO 创建请求 dto - * @return 返回评论 id - */ - Long createComment(ProductCommentCreateReqDTO createReqDTO); - - /** - * 修改评论是否可见 - * - * @param updateReqVO 修改评论可见 - */ - void updateCommentVisible(ProductCommentUpdateVisibleReqVO updateReqVO); - - /** - * 商家回复 - * - * @param replyVO 商家回复 - * @param userId 管理后台商家登陆人 ID - */ - void replyComment(ProductCommentReplyReqVO replyVO, Long userId); - - /** - * 【管理员】获得商品评价分页 - * - * @param pageReqVO 分页查询 - * @return 商品评价分页 - */ - PageResult getCommentPage(ProductCommentPageReqVO pageReqVO); - - /** - * 【会员】获得商品评价分页 - * - * @param pageVO 分页查询 - * @param visible 是否可见 - * @return 商品评价分页 - */ - PageResult getCommentPage(AppCommentPageReqVO pageVO, Boolean visible); - - /** - * 获得商品的评价统计 - * - * @param spuId spu id - * @param visible 是否可见 - * @return 评价统计 - */ - AppCommentStatisticsRespVO getCommentStatistics(Long spuId, Boolean visible); - - /** - * 得到评论列表 - * - * @param spuId 商品 id - * @param count 数量 - * @return {@link Object} - */ - List getCommentList(Long spuId, Integer count); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java deleted file mode 100644 index bec1f53416..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -package cn.iocoder.yudao.module.product.service.comment; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppProductCommentRespVO; -import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.dal.mysql.comment.ProductCommentMapper; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品评论 Service 实现类 - * - * @author wangzhs - */ -@Service -@Validated -public class ProductCommentServiceImpl implements ProductCommentService { - - @Resource - private ProductCommentMapper productCommentMapper; - - @Resource - private ProductSpuService productSpuService; - - @Resource - @Lazy - private ProductSkuService productSkuService; - - @Resource - private MemberUserApi memberUserApi; - - @Override - public void createComment(ProductCommentCreateReqVO createReqVO) { - // 校验 SKU - ProductSkuDO skuDO = validateSku(createReqVO.getSkuId()); - // 校验 SPU - ProductSpuDO spuDO = validateSpu(skuDO.getSpuId()); - - // 创建评论 - ProductCommentDO comment = ProductCommentConvert.INSTANCE.convert(createReqVO, spuDO, skuDO); - productCommentMapper.insert(comment); - } - - @Override - public Long createComment(ProductCommentCreateReqDTO createReqDTO) { - // 校验 SKU - ProductSkuDO skuDO = validateSku(createReqDTO.getSkuId()); - // 校验 SPU - ProductSpuDO spuDO = validateSpu(skuDO.getSpuId()); - // 校验评论 - validateCommentExists(createReqDTO.getUserId(), createReqDTO.getOrderId()); - // 获取用户详细信息 - MemberUserRespDTO user = memberUserApi.getUser(createReqDTO.getUserId()); - - // 创建评论 - ProductCommentDO comment = ProductCommentConvert.INSTANCE.convert(createReqDTO, spuDO, skuDO, user); - productCommentMapper.insert(comment); - return comment.getId(); - } - - /** - * 判断当前订单的当前商品用户是否评价过 - * - * @param userId 用户编号 - * @param orderItemId 订单项编号 - */ - private void validateCommentExists(Long userId, Long orderItemId) { - ProductCommentDO exist = productCommentMapper.selectByUserIdAndOrderItemId(userId, orderItemId); - if (exist != null) { - throw exception(COMMENT_ORDER_EXISTS); - } - } - - private ProductSkuDO validateSku(Long skuId) { - ProductSkuDO sku = productSkuService.getSku(skuId); - if (sku == null) { - throw exception(SKU_NOT_EXISTS); - } - return sku; - } - - private ProductSpuDO validateSpu(Long spuId) { - ProductSpuDO spu = productSpuService.getSpu(spuId); - if (null == spu) { - throw exception(SPU_NOT_EXISTS); - } - return spu; - } - - @Override - public void updateCommentVisible(ProductCommentUpdateVisibleReqVO updateReqVO) { - // 校验评论是否存在 - validateCommentExists(updateReqVO.getId()); - - // 更新可见状态 - productCommentMapper.updateById(new ProductCommentDO().setId(updateReqVO.getId()) - .setVisible(true)); - } - - @Override - public void replyComment(ProductCommentReplyReqVO replyVO, Long userId) { - // 校验评论是否存在 - validateCommentExists(replyVO.getId()); - // 回复评论 - productCommentMapper.updateById(new ProductCommentDO().setId(replyVO.getId()) - .setReplyTime(LocalDateTime.now()).setReplyUserId(userId) - .setReplyStatus(Boolean.TRUE).setReplyContent(replyVO.getReplyContent())); - } - - private ProductCommentDO validateCommentExists(Long id) { - ProductCommentDO productComment = productCommentMapper.selectById(id); - if (productComment == null) { - throw exception(COMMENT_NOT_EXISTS); - } - return productComment; - } - - @Override - public AppCommentStatisticsRespVO getCommentStatistics(Long spuId, Boolean visible) { - return ProductCommentConvert.INSTANCE.convert( - // 查询商品 id = spuId 的所有好评数量 - productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.GOOD_COMMENT), - // 查询商品 id = spuId 的所有中评数量 - productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.MEDIOCRE_COMMENT), - // 查询商品 id = spuId 的所有差评数量 - productCommentMapper.selectCountBySpuId(spuId, visible, AppCommentPageReqVO.NEGATIVE_COMMENT) - ); - } - - @Override - public List getCommentList(Long spuId, Integer count) { - return ProductCommentConvert.INSTANCE.convertList02(productCommentMapper.selectCommentList(spuId, count).getList()); - } - - @Override - public PageResult getCommentPage(AppCommentPageReqVO pageVO, Boolean visible) { - return productCommentMapper.selectPage(pageVO, visible); - } - - @Override - public PageResult getCommentPage(ProductCommentPageReqVO pageReqVO) { - return productCommentMapper.selectPage(pageReqVO); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteService.java deleted file mode 100644 index e71424dc3a..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteService.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.product.service.favorite; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; - -import jakarta.validation.Valid; - -/** - * 商品收藏 Service 接口 - * - * @author jason - */ -public interface ProductFavoriteService { - - /** - * 创建商品收藏 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - Long createFavorite(Long userId, Long spuId); - - /** - * 取消商品收藏 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - void deleteFavorite(Long userId, Long spuId); - - /** - * 分页查询用户收藏列表 - * - * @param userId 用户编号 - * @param reqVO 请求 vo - */ - PageResult getFavoritePage(Long userId, @Valid AppFavoritePageReqVO reqVO); - - /** - * 分页查询用户收藏列表 - * - * @param reqVO 请求 vo - */ - PageResult getFavoritePage(@Valid ProductFavoritePageReqVO reqVO); - - /** - * 获取收藏过商品 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - ProductFavoriteDO getFavorite(Long userId, Long spuId); - - /** - * 获取用户收藏数量 - * - * @param userId 用户编号 - * @return 数量 - */ - Long getFavoriteCount(Long userId); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteServiceImpl.java deleted file mode 100644 index 61b49636be..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteServiceImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.product.service.favorite; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO; -import cn.iocoder.yudao.module.product.convert.favorite.ProductFavoriteConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import cn.iocoder.yudao.module.product.dal.mysql.favorite.ProductFavoriteMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.FAVORITE_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.FAVORITE_NOT_EXISTS; - -/** - * 商品收藏 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class ProductFavoriteServiceImpl implements ProductFavoriteService { - - @Resource - private ProductFavoriteMapper productFavoriteMapper; - - @Override - public Long createFavorite(Long userId, Long spuId) { - ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId); - if (favorite != null) { - throw exception(FAVORITE_EXISTS); - } - - ProductFavoriteDO entity = ProductFavoriteConvert.INSTANCE.convert(userId, spuId); - productFavoriteMapper.insert(entity); - return entity.getId(); - } - - @Override - public void deleteFavorite(Long userId, Long spuId) { - ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId); - if (favorite == null) { - throw exception(FAVORITE_NOT_EXISTS); - } - - productFavoriteMapper.deleteById(favorite.getId()); - } - - @Override - public PageResult getFavoritePage(Long userId, @Valid AppFavoritePageReqVO reqVO) { - return productFavoriteMapper.selectPageByUserAndType(userId, reqVO); - } - - @Override - public PageResult getFavoritePage(@Valid ProductFavoritePageReqVO reqVO) { - return productFavoriteMapper.selectPageByUserId(reqVO); - } - - @Override - public ProductFavoriteDO getFavorite(Long userId, Long spuId) { - return productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId); - } - - @Override - public Long getFavoriteCount(Long userId) { - return productFavoriteMapper.selectCountByUserId(userId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java deleted file mode 100644 index d9417ee4cc..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.*; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 商品属性项 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductPropertyService { - - /** - * 创建属性项 - * 注意,如果已经存在该属性项,直接返回它的编号即可 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProperty(@Valid ProductPropertyCreateReqVO createReqVO); - - /** - * 更新属性项 - * - * @param updateReqVO 更新信息 - */ - void updateProperty(@Valid ProductPropertyUpdateReqVO updateReqVO); - - /** - * 删除属性项 - * - * @param id 编号 - */ - void deleteProperty(Long id); - - /** - * 获得属性项列表 - * - * @param listReqVO 集合查询 - * @return 属性项集合 - */ - List getPropertyList(ProductPropertyListReqVO listReqVO); - - /** - * 获取属性名称分页 - * - * @param pageReqVO 分页条件 - * @return 属性项分页 - */ - PageResult getPropertyPage(ProductPropertyPageReqVO pageReqVO); - - /** - * 获得指定编号的属性项 - * - * @param id 编号 - * @return 属性项 - */ - ProductPropertyDO getProperty(Long id); - - /** - * 根据属性项的编号的集合,获得对应的属性项数组 - * - * @param ids 属性项的编号的集合 - * @return 属性项数组 - */ - List getPropertyList(Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java deleted file mode 100644 index cafebe3c32..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyMapper; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品属性项 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductPropertyServiceImpl implements ProductPropertyService { - - @Resource - private ProductPropertyMapper productPropertyMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖问题 - private ProductPropertyValueService productPropertyValueService; - - @Resource - private ProductSkuService productSkuService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createProperty(ProductPropertyCreateReqVO createReqVO) { - // 如果已经添加过该属性项,直接返回 - ProductPropertyDO dbProperty = productPropertyMapper.selectByName(createReqVO.getName()); - if (dbProperty != null) { - return dbProperty.getId(); - } - - // 插入 - ProductPropertyDO property = ProductPropertyConvert.INSTANCE.convert(createReqVO); - productPropertyMapper.insert(property); - // 返回 - return property.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) { - validatePropertyExists(updateReqVO.getId()); - // 校验名字重复 - ProductPropertyDO productPropertyDO = productPropertyMapper.selectByName(updateReqVO.getName()); - if (productPropertyDO != null && - ObjUtil.notEqual(productPropertyDO.getId(), updateReqVO.getId())) { - throw exception(PROPERTY_EXISTS); - } - - // 更新 - ProductPropertyDO updateObj = ProductPropertyConvert.INSTANCE.convert(updateReqVO); - productPropertyMapper.updateById(updateObj); - // 更新 sku 相关属性 - productSkuService.updateSkuProperty(updateObj.getId(), updateObj.getName()); - } - - @Override - public void deleteProperty(Long id) { - // 校验存在 - validatePropertyExists(id); - // 校验其下是否有规格值 - if (productPropertyValueService.getPropertyValueCountByPropertyId(id) > 0) { - throw exception(PROPERTY_DELETE_FAIL_VALUE_EXISTS); - } - - // 删除 - productPropertyMapper.deleteById(id); - // 同步删除属性值 - productPropertyValueService.deletePropertyValueByPropertyId(id); - } - - private void validatePropertyExists(Long id) { - if (productPropertyMapper.selectById(id) == null) { - throw exception(PROPERTY_NOT_EXISTS); - } - } - - @Override - public List getPropertyList(ProductPropertyListReqVO listReqVO) { - return productPropertyMapper.selectList(listReqVO); - } - - @Override - public PageResult getPropertyPage(ProductPropertyPageReqVO pageReqVO) { - return productPropertyMapper.selectPage(pageReqVO); - } - - @Override - public ProductPropertyDO getProperty(Long id) { - return productPropertyMapper.selectById(id); - } - - @Override - public List getPropertyList(Collection ids) { - return productPropertyMapper.selectBatchIds(ids); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java deleted file mode 100644 index 29f5e55ecc..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; - -import java.util.Collection; -import java.util.List; - -/** - * 商品属性值 Service 接口 - * - * @author LuoWenFeng - */ -public interface ProductPropertyValueService { - - /** - * 创建属性值 - * 注意,如果已经存在该属性值,直接返回它的编号即可 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO); - - /** - * 更新属性值 - * - * @param updateReqVO 更新信息 - */ - void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO); - - /** - * 删除属性值 - * - * @param id 编号 - */ - void deletePropertyValue(Long id); - - /** - * 获得属性值 - * - * @param id 编号 - * @return 属性值 - */ - ProductPropertyValueDO getPropertyValue(Long id); - - /** - * 根据属性项编号数组,获得属性值列表 - * - * @param propertyIds 属性项目编号数组 - * @return 属性值列表 - */ - List getPropertyValueListByPropertyId(Collection propertyIds); - - /** - * 根据属性项编号,活的属性值数量 - * - * @param propertyId 属性项编号数 - * @return 属性值数量 - */ - Integer getPropertyValueCountByPropertyId(Long propertyId); - - /** - * 获取属性值的分页 - * - * @param pageReqVO 查询条件 - * @return 属性值的分页 - */ - PageResult getPropertyValuePage(ProductPropertyValuePageReqVO pageReqVO); - - /** - * 删除指定属性项编号下的属性值们 - * - * @param propertyId 属性项的编号 - */ - void deletePropertyValueByPropertyId(Long propertyId); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java deleted file mode 100644 index 747c047cb9..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_NOT_EXISTS; - -/** - * 商品属性值 Service 实现类 - * - * @author LuoWenFeng - */ -@Service -@Validated -public class ProductPropertyValueServiceImpl implements ProductPropertyValueService { - - @Resource - private ProductPropertyValueMapper productPropertyValueMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ProductPropertyService productPropertyService; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ProductSkuService productSkuService; - - @Override - public Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO) { - // 如果已经添加过该属性值,直接返回 - ProductPropertyValueDO dbValue = productPropertyValueMapper.selectByName( - createReqVO.getPropertyId(), createReqVO.getName()); - if (dbValue != null) { - return dbValue.getId(); - } - - // 新增 - ProductPropertyValueDO value = ProductPropertyValueConvert.INSTANCE.convert(createReqVO); - productPropertyValueMapper.insert(value); - return value.getId(); - } - - @Override - public void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO) { - validatePropertyValueExists(updateReqVO.getId()); - // 校验名字唯一 - ProductPropertyValueDO productPropertyValueDO = productPropertyValueMapper.selectByName - (updateReqVO.getPropertyId(), updateReqVO.getName()); - if (productPropertyValueDO != null && !productPropertyValueDO.getId().equals(updateReqVO.getId())) { - throw exception(PROPERTY_VALUE_EXISTS); - } - - // 更新 - ProductPropertyValueDO updateObj = ProductPropertyValueConvert.INSTANCE.convert(updateReqVO); - productPropertyValueMapper.updateById(updateObj); - // 更新 sku 相关属性 - productSkuService.updateSkuPropertyValue(updateObj.getId(), updateObj.getName()); - } - - @Override - public void deletePropertyValue(Long id) { - validatePropertyValueExists(id); - productPropertyValueMapper.deleteById(id); - } - - private void validatePropertyValueExists(Long id) { - if (productPropertyValueMapper.selectById(id) == null) { - throw exception(PROPERTY_VALUE_NOT_EXISTS); - } - } - - @Override - public ProductPropertyValueDO getPropertyValue(Long id) { - return productPropertyValueMapper.selectById(id); - } - - @Override - public List getPropertyValueListByPropertyId(Collection propertyIds) { - return productPropertyValueMapper.selectListByPropertyId(propertyIds); - } - - @Override - public Integer getPropertyValueCountByPropertyId(Long propertyId) { - return productPropertyValueMapper.selectCountByPropertyId(propertyId); - } - - @Override - public PageResult getPropertyValuePage(ProductPropertyValuePageReqVO pageReqVO) { - return productPropertyValueMapper.selectPage(pageReqVO); - } - - @Override - public void deletePropertyValueByPropertyId(Long propertyId) { - productPropertyValueMapper.deleteByPropertyId(propertyId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java deleted file mode 100755 index fbc9830bf9..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.product.service.sku; - -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; - -import java.util.Collection; -import java.util.List; - -/** - * 商品 SKU Service 接口 - * - * @author 芋道源码 - */ -public interface ProductSkuService { - - /** - * 删除商品 SKU - * - * @param id 编号 - */ - void deleteSku(Long id); - - /** - * 获得商品 SKU 信息 - * - * @param id 编号 - * @return 商品 SKU 信息 - */ - ProductSkuDO getSku(Long id); - - /** - * 获得商品 SKU 列表 - * - * @return 商品sku列表 - */ - List getSkuList(); - - /** - * 获得商品 SKU 列表 - * - * @param ids 编号 - * @return 商品sku列表 - */ - List getSkuList(Collection ids); - - /** - * 对 sku 的组合的属性等进行合法性校验 - * - * @param list sku组合的集合 - */ - void validateSkuList(List list, Boolean specType); - - /** - * 批量创建 SKU - * - * @param spuId 商品 SPU 编号 - * @param list SKU 对象集合 - */ - void createSkuList(Long spuId, List list); - - /** - * 根据 SPU 编号,批量更新它的 SKU 信息 - * - * @param spuId SPU 编码 - * @param skus SKU 的集合 - */ - void updateSkuList(Long spuId, List skus); - - /** - * 更新 SKU 库存(增量) - *

- * 如果更新的库存不足,会抛出异常 - * - * @param updateStockReqDTO 更行请求 - */ - void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO); - - /** - * 获得商品 SKU 集合 - * - * @param spuId spu 编号 - * @return 商品sku 集合 - */ - List getSkuListBySpuId(Long spuId); - - /** - * 获得 spu 对应的 SKU 集合 - * - * @param spuIds spu 编码集合 - * @return 商品 sku 集合 - */ - List getSkuListBySpuId(Collection spuIds); - - /** - * 通过 spuId 删除 sku 信息 - * - * @param spuId spu 编码 - */ - void deleteSkuBySpuId(Long spuId); - - /** - * 获得库存预警的 SKU 数组 - * - * @return SKU 数组 - */ - List getSkuListByAlarmStock(); - - /** - * 更新 sku 属性 - * - * @param propertyId 属性 id - * @param propertyName 属性名 - * @return int 影响的行数 - */ - int updateSkuProperty(Long propertyId, String propertyName); - - /** - * 更新 sku 属性值 - * - * @param propertyValueId 属性值 id - * @param propertyValueName 属性值名字 - * @return int 影响的行数 - */ - int updateSkuPropertyValue(Long propertyValueId, String propertyValueName); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java deleted file mode 100755 index 693c574deb..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java +++ /dev/null @@ -1,281 +0,0 @@ -package cn.iocoder.yudao.module.product.service.sku; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品 SKU Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductSkuServiceImpl implements ProductSkuService { - - @Resource - private ProductSkuMapper productSkuMapper; - - @Resource - @Lazy // 循环依赖,避免报错 - private ProductSpuService productSpuService; - @Resource - @Lazy // 循环依赖,避免报错 - private ProductPropertyService productPropertyService; - @Resource - private ProductPropertyValueService productPropertyValueService; - - @Override - public void deleteSku(Long id) { - // 校验存在 - validateSkuExists(id); - // 删除 - productSkuMapper.deleteById(id); - } - - private void validateSkuExists(Long id) { - if (productSkuMapper.selectById(id) == null) { - throw exception(SKU_NOT_EXISTS); - } - } - - @Override - public ProductSkuDO getSku(Long id) { - return productSkuMapper.selectById(id); - } - - @Override - public List getSkuList() { - return productSkuMapper.selectList(); - } - - @Override - public List getSkuList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return productSkuMapper.selectBatchIds(ids); - } - - @Override - public void validateSkuList(List skus, Boolean specType) { - // 0、校验skus是否为空 - if (CollUtil.isEmpty(skus)) { - throw exception(SKU_NOT_EXISTS); - } - // 单规格,赋予单规格默认属性 - if (ObjectUtil.equal(specType, false)) { - ProductSkuCreateOrUpdateReqVO skuVO = skus.get(0); - List properties = new ArrayList<>(); - ProductSkuBaseVO.Property property = new ProductSkuBaseVO.Property(); - property.setPropertyId(ProductPropertyDO.ID_DEFAULT); - property.setPropertyName(ProductPropertyDO.NAME_DEFAULT); - property.setValueId(ProductPropertyValueDO.ID_DEFAULT); - property.setValueName(ProductPropertyValueDO.NAME_DEFAULT); - properties.add(property); - skuVO.setProperties(properties); - return; // 单规格不需要后续的校验 - } - - // 1、校验属性项存在 - Set propertyIds = skus.stream().filter(p -> p.getProperties() != null) - // 遍历多个 Property 属性 - .flatMap(p -> p.getProperties().stream()) - // 将每个 Property 转换成对应的 propertyId,最后形成集合 - .map(ProductSkuCreateOrUpdateReqVO.Property::getPropertyId) - .collect(Collectors.toSet()); - List propertyList = productPropertyService.getPropertyList(propertyIds); - if (propertyList.size() != propertyIds.size()) { - throw exception(PROPERTY_NOT_EXISTS); - } - - // 2. 校验,一个 SKU 下,没有重复的属性。校验方式是,遍历每个 SKU ,看看是否有重复的属性 propertyId - Map propertyValueMap = convertMap(productPropertyValueService.getPropertyValueListByPropertyId(propertyIds), ProductPropertyValueDO::getId); - skus.forEach(sku -> { - Set skuPropertyIds = convertSet(sku.getProperties(), propertyItem -> propertyValueMap.get(propertyItem.getValueId()).getPropertyId()); - if (skuPropertyIds.size() != sku.getProperties().size()) { - throw exception(SKU_PROPERTIES_DUPLICATED); - } - }); - - // 3. 再校验,每个 Sku 的属性值的数量,是一致的。 - int attrValueIdsSize = skus.get(0).getProperties().size(); - for (int i = 1; i < skus.size(); i++) { - if (attrValueIdsSize != skus.get(i).getProperties().size()) { - throw exception(SPU_ATTR_NUMBERS_MUST_BE_EQUALS); - } - } - - // 4. 最后校验,每个 Sku 之间不是重复的 - // 每个元素,都是一个 Sku 的 attrValueId 集合。这样,通过最外层的 Set ,判断是否有重复的. - Set> skuAttrValues = new HashSet<>(); - for (ProductSkuCreateOrUpdateReqVO sku : skus) { - // 添加失败,说明重复 - if (!skuAttrValues.add(convertSet(sku.getProperties(), ProductSkuCreateOrUpdateReqVO.Property::getValueId))) { - throw exception(SPU_SKU_NOT_DUPLICATE); - } - } - } - - @Override - public void createSkuList(Long spuId, List skuCreateReqList) { - productSkuMapper.insertBatch(ProductSkuConvert.INSTANCE.convertList06(skuCreateReqList, spuId)); - } - - @Override - public List getSkuListBySpuId(Long spuId) { - return productSkuMapper.selectListBySpuId(spuId); - } - - @Override - public List getSkuListBySpuId(Collection spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return Collections.emptyList(); - } - return productSkuMapper.selectListBySpuId(spuIds); - } - - @Override - public void deleteSkuBySpuId(Long spuId) { - productSkuMapper.deleteBySpuId(spuId); - } - - @Override - public List getSkuListByAlarmStock() { - return productSkuMapper.selectListByAlarmStock(); - } - - @Override - public int updateSkuProperty(Long propertyId, String propertyName) { - // 获取所有的 sku - List skuDOList = productSkuMapper.selectList(); - // 处理后需要更新的 sku - List updateSkus = new ArrayList<>(); - if (CollUtil.isEmpty(skuDOList)) { - return 0; - } - skuDOList.stream().filter(sku -> sku.getProperties() != null) - .forEach(sku -> sku.getProperties().forEach(property -> { - if (property.getPropertyId().equals(propertyId)) { - property.setPropertyName(propertyName); - updateSkus.add(sku); - } - })); - if (CollUtil.isEmpty(updateSkus)) { - return 0; - } - - productSkuMapper.updateBatch(updateSkus); - return updateSkus.size(); - } - - @Override - public int updateSkuPropertyValue(Long propertyValueId, String propertyValueName) { - // 获取所有的 sku - List skuDOList = productSkuMapper.selectList(); - // 处理后需要更新的 sku - List updateSkus = new ArrayList<>(); - if (CollUtil.isEmpty(skuDOList)) { - return 0; - } - skuDOList.stream() - .filter(sku -> sku.getProperties() != null) - .forEach(sku -> sku.getProperties().forEach(property -> { - if (property.getValueId().equals(propertyValueId)) { - property.setValueName(propertyValueName); - updateSkus.add(sku); - } - })); - if (CollUtil.isEmpty(updateSkus)) { - return 0; - } - - productSkuMapper.updateBatch(updateSkus); - return updateSkus.size(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSkuList(Long spuId, List skus) { - // 构建属性与 SKU 的映射关系; - Map existsSkuMap = convertMap(productSkuMapper.selectListBySpuId(spuId), - ProductSkuConvert.INSTANCE::buildPropertyKey, ProductSkuDO::getId); - - // 拆分三个集合,新插入的、需要更新的、需要删除的 - List insertSkus = new ArrayList<>(); - List updateSkus = new ArrayList<>(); - List allUpdateSkus = ProductSkuConvert.INSTANCE.convertList06(skus, spuId); - allUpdateSkus.forEach(sku -> { - String propertiesKey = ProductSkuConvert.INSTANCE.buildPropertyKey(sku); - // 1、找得到的,进行更新 - Long existsSkuId = existsSkuMap.remove(propertiesKey); - if (existsSkuId != null) { - sku.setId(existsSkuId); - updateSkus.add(sku); - return; - } - // 2、找不到,进行插入 - sku.setSpuId(spuId); - insertSkus.add(sku); - }); - - // 执行最终的批量操作 - if (CollUtil.isNotEmpty(insertSkus)) { - productSkuMapper.insertBatch(insertSkus); - } - if (CollUtil.isNotEmpty(updateSkus)) { - updateSkus.forEach(sku -> productSkuMapper.updateById(sku)); - } - if (CollUtil.isNotEmpty(existsSkuMap)) { - productSkuMapper.deleteBatchIds(existsSkuMap.values()); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO) { - // 更新 SKU 库存 - updateStockReqDTO.getItems().forEach(item -> { - if (item.getIncrCount() > 0) { - productSkuMapper.updateStockIncr(item.getId(), item.getIncrCount()); - } else if (item.getIncrCount() < 0) { - int updateStockIncr = productSkuMapper.updateStockDecr(item.getId(), item.getIncrCount()); - if (updateStockIncr == 0) { - throw exception(SKU_STOCK_NOT_ENOUGH); - } - } - }); - - // 更新 SPU 库存 - List skus = productSkuMapper.selectBatchIds( - convertSet(updateStockReqDTO.getItems(), ProductSkuUpdateStockReqDTO.Item::getId)); - Map spuStockIncrCounts = ProductSkuConvert.INSTANCE.convertSpuStockMap( - updateStockReqDTO.getItems(), skus); - productSpuService.updateSpuStock(spuStockIncrCounts); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java deleted file mode 100755 index 513f9c36df..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java +++ /dev/null @@ -1,151 +0,0 @@ -package cn.iocoder.yudao.module.product.service.spu; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商品 SPU Service 接口 - * - * @author 芋道源码 - */ -public interface ProductSpuService { - - /** - * 创建商品 SPU - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSpu(@Valid ProductSpuCreateReqVO createReqVO); - - /** - * 更新商品 SPU - * - * @param updateReqVO 更新信息 - */ - void updateSpu(@Valid ProductSpuUpdateReqVO updateReqVO); - - /** - * 删除商品 SPU - * - * @param id 编号 - */ - void deleteSpu(Long id); - - /** - * 获得商品 SPU - * - * @param id 编号 - * @return 商品 SPU - */ - ProductSpuDO getSpu(Long id); - - /** - * 获得商品 SPU 列表 - * - * @param ids 编号数组 - * @return 商品 SPU 列表 - */ - List getSpuList(Collection ids); - - /** - * 获得商品 SPU 映射 - * - * @param ids 编号数组 - * @return 商品 SPU 映射 - */ - default Map getSpuMap(Collection ids) { - return convertMap(getSpuList(ids), ProductSpuDO::getId); - } - - /** - * 获得指定状态的商品 SPU 列表 - * - * @param status 状态 - * @return 商品 SPU 列表 - */ - List getSpuListByStatus(Integer status); - - /** - * 获得所有商品 SPU 列表 - * - * @param reqVO 导出条件 - * @return 商品 SPU 列表 - */ - List getSpuList(ProductSpuExportReqVO reqVO); - - /** - * 获得商品 SPU 分页,提供给挂你兰后台使用 - * - * @param pageReqVO 分页查询 - * @return 商品spu分页 - */ - PageResult getSpuPage(ProductSpuPageReqVO pageReqVO); - - /** - * 获得商品 SPU 分页,提供给用户 App 使用 - * - * @param pageReqVO 分页查询 - * @return 商品 SPU 分页 - */ - PageResult getSpuPage(AppProductSpuPageReqVO pageReqVO); - - /** - * 获得商品 SPU 列表,提供给用户 App 使用 - * - * @param recommendType 推荐类型 - * @param count 数量 - * @return 商品 SPU 列表 - */ - List getSpuList(String recommendType, Integer count); - - /** - * 更新商品 SPU 库存(增量) - * - * @param stockIncrCounts SPU 编号与库存变化(增量)的映射 - */ - void updateSpuStock(Map stockIncrCounts); - - /** - * 更新 SPU 状态 - * - * @param updateReqVO 更新请求 - */ - void updateSpuStatus(ProductSpuUpdateStatusReqVO updateReqVO); - - /** - * 获取 SPU 列表标签对应的 Count 数量 - * - * @return Count 数量 - */ - Map getTabsCount(); - - /** - * 通过分类 categoryId 查询 SPU 个数 - * - * @param categoryId 分类 categoryId - * @return SPU 数量 - */ - Long getSpuCountByCategoryId(Long categoryId); - - - /** - * 校验商品是否有效。如下情况,视为无效: - * 1. 商品编号不存在 - * 2. 商品被禁用 - * - * @param ids 商品编号数组 - * @return 商品 SPU 列表 - */ - List validateSpuList(Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java deleted file mode 100755 index 1d4e1999e5..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ /dev/null @@ -1,274 +0,0 @@ -package cn.iocoder.yudao.module.product.service.spu; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import com.google.common.collect.Maps; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; -import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品 SPU Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductSpuServiceImpl implements ProductSpuService { - - @Resource - private ProductSpuMapper productSpuMapper; - - @Resource - @Lazy // 循环依赖,避免报错 - private ProductSkuService productSkuService; - @Resource - private ProductBrandService brandService; - @Resource - private ProductCategoryService categoryService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSpu(ProductSpuCreateReqVO createReqVO) { - // 校验分类、品牌 - validateCategory(createReqVO.getCategoryId()); - brandService.validateProductBrand(createReqVO.getBrandId()); - // 校验 SKU - List skuSaveReqList = createReqVO.getSkus(); - productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType()); - - ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); - // 初始化 SPU 中 SKU 相关属性 - initSpuFromSkus(spu, skuSaveReqList); - // 插入 SPU - productSpuMapper.insert(spu); - // 插入 SKU - productSkuService.createSkuList(spu.getId(), skuSaveReqList); - // 返回 - return spu.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSpu(ProductSpuUpdateReqVO updateReqVO) { - // 校验 SPU 是否存在 - validateSpuExists(updateReqVO.getId()); - // 校验分类、品牌 - validateCategory(updateReqVO.getCategoryId()); - brandService.validateProductBrand(updateReqVO.getBrandId()); - // 校验SKU - List skuSaveReqList = updateReqVO.getSkus(); - productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType()); - - // 更新 SPU - ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); - initSpuFromSkus(updateObj, skuSaveReqList); - productSpuMapper.updateById(updateObj); - // 批量更新 SKU - productSkuService.updateSkuList(updateObj.getId(), updateReqVO.getSkus()); - } - - /** - * 基于 SKU 的信息,初始化 SPU 的信息 - * 主要是计数相关的字段,例如说市场价、最大最小价、库存等等 - * - * @param spu 商品 SPU - * @param skus 商品 SKU 数组 - */ - private void initSpuFromSkus(ProductSpuDO spu, List skus) { - // sku 单价最低的商品的价格 - spu.setPrice(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getPrice)); - // sku 单价最低的商品的市场价格 - spu.setMarketPrice(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getMarketPrice)); - // sku 单价最低的商品的成本价格 - spu.setCostPrice(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getCostPrice)); - // sku 单价最低的商品的条形码 TODO 芋艿:条形码字段,是不是可以删除 - spu.setBarCode(""); -// spu.setBarCode(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getBarCode)); - // skus 库存总数 - spu.setStock(getSumValue(skus, ProductSkuCreateOrUpdateReqVO::getStock, Integer::sum)); - // 若是 spu 已有状态则不处理 - if (spu.getStatus() == null) { - // 默认状态为上架 - spu.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()); - // 默认商品销量 - spu.setSalesCount(0); - // 默认商品浏览量 - spu.setBrowseCount(0); - } - } - - /** - * 校验商品分类是否合法 - * - * @param id 商品分类编号 - */ - private void validateCategory(Long id) { - categoryService.validateCategory(id); - // 校验层级 - if (categoryService.getCategoryLevel(id) < CATEGORY_LEVEL) { - throw exception(SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR); - } - } - - @Override - public List validateSpuList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - // 获得商品信息 - List list = productSpuMapper.selectBatchIds(ids); - Map spuMap = CollectionUtils.convertMap(list, ProductSpuDO::getId); - // 校验 - ids.forEach(id -> { - ProductSpuDO spu = spuMap.get(id); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) { - throw exception(SPU_NOT_ENABLE, spu.getName()); - } - }); - return list; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSpu(Long id) { - // 校验存在 - validateSpuExists(id); - // 校验商品状态不是回收站不能删除 - ProductSpuDO spuDO = productSpuMapper.selectById(id); - // 判断 SPU 状态是否为回收站 - if (ObjectUtil.notEqual(spuDO.getStatus(), ProductSpuStatusEnum.RECYCLE.getStatus())) { - throw exception(SPU_NOT_RECYCLE); - } - - // 删除 SPU - productSpuMapper.deleteById(id); - // 删除关联的 SKU - productSkuService.deleteSkuBySpuId(id); - } - - private void validateSpuExists(Long id) { - if (productSpuMapper.selectById(id) == null) { - throw exception(SPU_NOT_EXISTS); - } - } - - @Override - public ProductSpuDO getSpu(Long id) { - return productSpuMapper.selectById(id); - } - - @Override - public List getSpuList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return productSpuMapper.selectBatchIds(ids); - } - - @Override - public List getSpuListByStatus(Integer status) { - return productSpuMapper.selectList(ProductSpuDO::getStatus, status); - } - - @Override - public List getSpuList(ProductSpuExportReqVO reqVO) { - return productSpuMapper.selectList(reqVO); - } - - @Override - public PageResult getSpuPage(ProductSpuPageReqVO pageReqVO) { - return productSpuMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getSpuPage(AppProductSpuPageReqVO pageReqVO) { - // 查找时,如果查找某个分类编号,则包含它的子分类。因为顶级分类不包含商品 - Set categoryIds = new HashSet<>(); - if (pageReqVO.getCategoryId() != null && pageReqVO.getCategoryId() > 0) { - categoryIds.add(pageReqVO.getCategoryId()); - List categoryChildren = categoryService.getEnableCategoryList(new ProductCategoryListReqVO() - .setParentId(pageReqVO.getCategoryId()).setStatus(CommonStatusEnum.ENABLE.getStatus())); - categoryIds.addAll(CollectionUtils.convertList(categoryChildren, ProductCategoryDO::getId)); - } - // 分页查询 - return productSpuMapper.selectPage(pageReqVO, categoryIds); - } - - @Override - public List getSpuList(String recommendType, Integer count) { - return productSpuMapper.selectListByRecommendType(recommendType, count); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSpuStock(Map stockIncrCounts) { - stockIncrCounts.forEach((id, incCount) -> productSpuMapper.updateStock(id, incCount)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSpuStatus(ProductSpuUpdateStatusReqVO updateReqVO) { - // 校验存在 - validateSpuExists(updateReqVO.getId()); - - // 更新状态 - ProductSpuDO productSpuDO = productSpuMapper.selectById(updateReqVO.getId()).setStatus(updateReqVO.getStatus()); - productSpuMapper.updateById(productSpuDO); - } - - @Override - public Map getTabsCount() { - Map counts = Maps.newLinkedHashMapWithExpectedSize(5); - // 查询销售中的商品数量 - counts.put(ProductSpuPageReqVO.FOR_SALE, - productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus())); - // 查询仓库中的商品数量 - counts.put(ProductSpuPageReqVO.IN_WAREHOUSE, - productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus())); - // 查询售空的商品数量 - counts.put(ProductSpuPageReqVO.SOLD_OUT, - productSpuMapper.selectCount(ProductSpuDO::getStock, 0)); - // 查询触发警戒库存的商品数量 - counts.put(ProductSpuPageReqVO.ALERT_STOCK, - productSpuMapper.selectCount()); - // 查询回收站中的商品数量 - counts.put(ProductSpuPageReqVO.RECYCLE_BIN, - productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus())); - return counts; - } - - @Override - public Long getSpuCountByCategoryId(Long categoryId) { - return productSpuMapper.selectCount(ProductSpuDO::getCategoryId, categoryId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImplTest.java deleted file mode 100644 index 2da86130ba..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImplTest.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.product.service.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.dal.mysql.brand.ProductBrandMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.BRAND_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link ProductBrandServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(ProductBrandServiceImpl.class) -public class ProductBrandServiceImplTest extends BaseDbUnitTest { - - @Resource - private ProductBrandServiceImpl brandService; - - @Resource - private ProductBrandMapper brandMapper; - - @Test - public void testCreateBrand_success() { - // 准备参数 - ProductBrandCreateReqVO reqVO = randomPojo(ProductBrandCreateReqVO.class); - - // 调用 - Long brandId = brandService.createBrand(reqVO); - // 断言 - assertNotNull(brandId); - // 校验记录的属性是否正确 - ProductBrandDO brand = brandMapper.selectById(brandId); - assertPojoEquals(reqVO, brand); - } - - @Test - public void testUpdateBrand_success() { - // mock 数据 - ProductBrandDO dbBrand = randomPojo(ProductBrandDO.class); - brandMapper.insert(dbBrand);// @Sql: 先插入出一条存在的数据 - // 准备参数 - ProductBrandUpdateReqVO reqVO = randomPojo(ProductBrandUpdateReqVO.class, o -> { - o.setId(dbBrand.getId()); // 设置更新的 ID - }); - - // 调用 - brandService.updateBrand(reqVO); - // 校验是否更新正确 - ProductBrandDO brand = brandMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, brand); - } - - @Test - public void testUpdateBrand_notExists() { - // 准备参数 - ProductBrandUpdateReqVO reqVO = randomPojo(ProductBrandUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> brandService.updateBrand(reqVO), BRAND_NOT_EXISTS); - } - - @Test - public void testDeleteBrand_success() { - // mock 数据 - ProductBrandDO dbBrand = randomPojo(ProductBrandDO.class); - brandMapper.insert(dbBrand);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbBrand.getId(); - - // 调用 - brandService.deleteBrand(id); - // 校验数据不存在了 - assertNull(brandMapper.selectById(id)); - } - - @Test - public void testDeleteBrand_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> brandService.deleteBrand(id), BRAND_NOT_EXISTS); - } - - @Test - public void testGetBrandPage() { - // mock 数据 - ProductBrandDO dbBrand = randomPojo(ProductBrandDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2022, 2, 1)); - }); - brandMapper.insert(dbBrand); - // 测试 name 不匹配 - brandMapper.insert(cloneIgnoreId(dbBrand, o -> o.setName("源码"))); - // 测试 status 不匹配 - brandMapper.insert(cloneIgnoreId(dbBrand, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - brandMapper.insert(cloneIgnoreId(dbBrand, o -> o.setCreateTime(buildTime(2022, 3, 1)))); - // 准备参数 - ProductBrandPageReqVO reqVO = new ProductBrandPageReqVO(); - reqVO.setName("芋道"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2022, 1, 1), buildTime(2022, 2, 25)})); - - // 调用 - PageResult pageResult = brandService.getBrandPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbBrand, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImplTest.java deleted file mode 100644 index 5db5fa7139..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImplTest.java +++ /dev/null @@ -1,163 +0,0 @@ -package cn.iocoder.yudao.module.product.service.category; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.dal.mysql.category.ProductCategoryMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.PARENT_ID_NULL; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.CATEGORY_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link ProductCategoryServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(ProductCategoryServiceImpl.class) -public class ProductCategoryServiceImplTest extends BaseDbUnitTest { - - @Resource - private ProductCategoryServiceImpl productCategoryService; - - @Resource - private ProductCategoryMapper productCategoryMapper; - - @Test - public void testCreateCategory_success() { - // 准备参数 - ProductCategoryCreateReqVO reqVO = randomPojo(ProductCategoryCreateReqVO.class); - - // mock 父类 - ProductCategoryDO parentProductCategory = randomPojo(ProductCategoryDO.class, o -> { - reqVO.setParentId(o.getId()); - o.setParentId(PARENT_ID_NULL); - }); - productCategoryMapper.insert(parentProductCategory); - - // 调用 - Long categoryId = productCategoryService.createCategory(reqVO); - // 断言 - assertNotNull(categoryId); - // 校验记录的属性是否正确 - ProductCategoryDO category = productCategoryMapper.selectById(categoryId); - assertPojoEquals(reqVO, category); - } - - @Test - public void testUpdateCategory_success() { - // mock 数据 - ProductCategoryDO dbCategory = randomPojo(ProductCategoryDO.class); - productCategoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - ProductCategoryUpdateReqVO reqVO = randomPojo(ProductCategoryUpdateReqVO.class, o -> { - o.setId(dbCategory.getId()); // 设置更新的 ID - }); - // mock 父类 - ProductCategoryDO parentProductCategory = randomPojo(ProductCategoryDO.class, o -> o.setId(reqVO.getParentId())); - productCategoryMapper.insert(parentProductCategory); - - // 调用 - productCategoryService.updateCategory(reqVO); - // 校验是否更新正确 - ProductCategoryDO category = productCategoryMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, category); - } - - @Test - public void testUpdateCategory_notExists() { - // 准备参数 - ProductCategoryUpdateReqVO reqVO = randomPojo(ProductCategoryUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> productCategoryService.updateCategory(reqVO), CATEGORY_NOT_EXISTS); - } - - @Test - public void testDeleteCategory_success() { - // mock 数据 - ProductCategoryDO dbCategory = randomPojo(ProductCategoryDO.class); - productCategoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCategory.getId(); - - // 调用 - productCategoryService.deleteCategory(id); - // 校验数据不存在了 - assertNull(productCategoryMapper.selectById(id)); - } - - @Test - public void testDeleteCategory_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> productCategoryService.deleteCategory(id), CATEGORY_NOT_EXISTS); - } - - @Test - public void testGetCategoryLevel() { - // mock 数据 - ProductCategoryDO category1 = randomPojo(ProductCategoryDO.class, - o -> o.setParentId(PARENT_ID_NULL)); - productCategoryMapper.insert(category1); - ProductCategoryDO category2 = randomPojo(ProductCategoryDO.class, - o -> o.setParentId(category1.getId())); - productCategoryMapper.insert(category2); - ProductCategoryDO category3 = randomPojo(ProductCategoryDO.class, - o -> o.setParentId(category2.getId())); - productCategoryMapper.insert(category3); - - // 调用,并断言 - assertEquals(productCategoryService.getCategoryLevel(category1.getId()), 1); - assertEquals(productCategoryService.getCategoryLevel(category2.getId()), 2); - assertEquals(productCategoryService.getCategoryLevel(category3.getId()), 3); - } - - @Test - public void testGetCategoryList() { - // mock 数据 - ProductCategoryDO dbCategory = randomPojo(ProductCategoryDO.class, o -> { // 等会查询到 - o.setName("奥特曼"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setParentId(PARENT_ID_NULL); - }); - productCategoryMapper.insert(dbCategory); - // 测试 name 不匹配 - productCategoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName("奥特块"))); - // 测试 status 不匹配 - productCategoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 parentId 不匹配 - productCategoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setParentId(3333L))); - // 准备参数 - ProductCategoryListReqVO reqVO = new ProductCategoryListReqVO(); - reqVO.setName("特曼"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setParentId(PARENT_ID_NULL); - - // 调用 - List list = productCategoryService.getEnableCategoryList(reqVO); - List all = productCategoryService.getEnableCategoryList(new ProductCategoryListReqVO()); - // 断言 - assertEquals(1, list.size()); - assertEquals(4, all.size()); - assertPojoEquals(dbCategory, list.get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java deleted file mode 100644 index 83ec2c456b..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java +++ /dev/null @@ -1,195 +0,0 @@ -package cn.iocoder.yudao.module.product.service.comment; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO; -import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.dal.mysql.comment.ProductCommentMapper; -import cn.iocoder.yudao.module.product.enums.comment.ProductCommentScoresEnum; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Lazy; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Date; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -// TODO 芋艿:单测详细 review 下 -/** - * {@link ProductCommentServiceImpl} 的单元测试类 - * - * @author wangzhs - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(ProductCommentServiceImpl.class) -public class ProductCommentServiceImplTest extends BaseDbUnitTest { - - @Resource - private ProductCommentMapper productCommentMapper; - - @Resource - @Lazy - private ProductCommentServiceImpl productCommentService; - - @MockBean - private ProductSpuService productSpuService; - @MockBean - private ProductSkuService productSkuService; - - public String generateNo() { - return DateUtil.format(new Date(), "yyyyMMddHHmmss") + RandomUtil.randomInt(100000, 999999); - } - - public Long generateId() { - return RandomUtil.randomLong(100000, 999999); - } - - @Test - public void testCreateCommentAndGet_success() { - // mock 测试 - ProductCommentDO productComment = randomPojo(ProductCommentDO.class); - productCommentMapper.insert(productComment); - - // 断言 - // 校验记录的属性是否正确 - ProductCommentDO comment = productCommentMapper.selectById(productComment.getId()); - assertPojoEquals(productComment, comment); - } - - @Test - public void testGetCommentPage_success() { - // 准备参数 - ProductCommentDO productComment = randomPojo(ProductCommentDO.class, o -> { - o.setUserNickname("王二狗"); - o.setSpuName("感冒药"); - o.setScores(ProductCommentScoresEnum.FOUR.getScores()); - o.setReplyStatus(Boolean.TRUE); - o.setVisible(Boolean.TRUE); - o.setId(generateId()); - o.setUserId(generateId()); - o.setAnonymous(Boolean.TRUE); - o.setOrderId(generateId()); - o.setOrderItemId(generateId()); - o.setSpuId(generateId()); - o.setSkuId(generateId()); - o.setDescriptionScores(ProductCommentScoresEnum.FOUR.getScores()); - o.setBenefitScores(ProductCommentScoresEnum.FOUR.getScores()); - o.setContent("真好吃"); - o.setReplyUserId(generateId()); - o.setReplyContent("确实"); - o.setReplyTime(LocalDateTime.now()); - o.setCreateTime(LocalDateTime.now()); - o.setUpdateTime(LocalDateTime.now()); - }); - productCommentMapper.insert(productComment); - - Long orderId = productComment.getOrderId(); - Long spuId = productComment.getSpuId(); - - // 测试 userNickname 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setUserNickname("王三").setScores(ProductCommentScoresEnum.ONE.getScores()))); - // 测试 orderId 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setOrderId(generateId()))); - // 测试 spuId 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setSpuId(generateId()))); - // 测试 spuName 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setSpuName("感康"))); - // 测试 scores 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setScores(ProductCommentScoresEnum.ONE.getScores()))); - // 测试 replied 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setReplyStatus(Boolean.FALSE))); - // 测试 visible 不匹配 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setVisible(Boolean.FALSE))); - - // 调用 - ProductCommentPageReqVO productCommentPageReqVO = new ProductCommentPageReqVO(); - productCommentPageReqVO.setUserNickname("王二"); - productCommentPageReqVO.setOrderId(orderId); - productCommentPageReqVO.setSpuId(spuId); - productCommentPageReqVO.setSpuName("感冒药"); - productCommentPageReqVO.setScores(ProductCommentScoresEnum.FOUR.getScores()); - productCommentPageReqVO.setReplyStatus(Boolean.TRUE); - - PageResult commentPage = productCommentService.getCommentPage(productCommentPageReqVO); - PageResult result = ProductCommentConvert.INSTANCE.convertPage(productCommentMapper.selectPage(productCommentPageReqVO)); - assertEquals(result.getTotal(), commentPage.getTotal()); - - PageResult all = productCommentService.getCommentPage(new ProductCommentPageReqVO()); - assertEquals(8, all.getTotal()); - - // 测试获取所有商品分页评论数据 - PageResult result1 = productCommentService.getCommentPage(new AppCommentPageReqVO(), Boolean.TRUE); - assertEquals(7, result1.getTotal()); - - // 测试获取所有商品分页中评数据 - PageResult result2 = productCommentService.getCommentPage(new AppCommentPageReqVO().setType(AppCommentPageReqVO.MEDIOCRE_COMMENT), Boolean.TRUE); - assertEquals(2, result2.getTotal()); - - // 测试获取指定 spuId 商品分页中评数据 - PageResult result3 = productCommentService.getCommentPage(new AppCommentPageReqVO().setSpuId(spuId).setType(AppCommentPageReqVO.MEDIOCRE_COMMENT), Boolean.TRUE); - assertEquals(2, result3.getTotal()); - - // 测试分页 tab count - AppCommentStatisticsRespVO tabsCount = productCommentService.getCommentStatistics(spuId, Boolean.TRUE); - assertEquals(4, tabsCount.getGoodCount()); - assertEquals(2, tabsCount.getMediocreCount()); - assertEquals(0, tabsCount.getNegativeCount()); - - } - - @Test - public void testUpdateCommentVisible_success() { - // mock 测试 - ProductCommentDO productComment = randomPojo(ProductCommentDO.class, o -> { - o.setVisible(Boolean.TRUE); - }); - productCommentMapper.insert(productComment); - - Long productCommentId = productComment.getId(); - - ProductCommentUpdateVisibleReqVO updateReqVO = new ProductCommentUpdateVisibleReqVO(); - updateReqVO.setId(productCommentId); - updateReqVO.setVisible(Boolean.FALSE); - productCommentService.updateCommentVisible(updateReqVO); - - ProductCommentDO productCommentDO = productCommentMapper.selectById(productCommentId); - assertFalse(productCommentDO.getVisible()); - } - - - @Test - public void testCommentReply_success() { - // mock 测试 - ProductCommentDO productComment = randomPojo(ProductCommentDO.class); - productCommentMapper.insert(productComment); - - Long productCommentId = productComment.getId(); - - ProductCommentReplyReqVO replyVO = new ProductCommentReplyReqVO(); - replyVO.setId(productCommentId); - replyVO.setReplyContent("测试"); - productCommentService.replyComment(replyVO, 1L); - - ProductCommentDO productCommentDO = productCommentMapper.selectById(productCommentId); - assertEquals("测试", productCommentDO.getReplyContent()); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceTest.java deleted file mode 100644 index b07e678af3..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceTest.java +++ /dev/null @@ -1,207 +0,0 @@ -package cn.iocoder.yudao.module.product.service.sku; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.framework.test.core.util.AssertUtils; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Arrays; -import java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_STOCK_NOT_ENOUGH; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.verify; - -/** - * {@link ProductSkuServiceImpl} 的单元测试 - * - * @author 芋道源码 - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(ProductSkuServiceImpl.class) -public class ProductSkuServiceTest extends BaseDbUnitTest { - - @Resource - private ProductSkuService productSkuService; - - @Resource - private ProductSkuMapper productSkuMapper; - - @MockBean - private ProductSpuService productSpuService; - @MockBean - private ProductPropertyService productPropertyService; - @MockBean - private ProductPropertyValueService productPropertyValueService; - - public Long generateId() { - return RandomUtil.randomLong(100000, 999999); - } - - @Test - public void testUpdateSkuList() { - // mock 数据 - ProductSkuDO sku01 = randomPojo(ProductSkuDO.class, o -> { // 测试更新 - o.setSpuId(1L); - o.setProperties(singletonList(new ProductSkuDO.Property( - 10L, "颜色", 20L, "红色"))); - }); - productSkuMapper.insert(sku01); - ProductSkuDO sku02 = randomPojo(ProductSkuDO.class, o -> { // 测试删除 - o.setSpuId(1L); - o.setProperties(singletonList(new ProductSkuDO.Property( - 10L, "颜色", 30L, "蓝色"))); - - }); - productSkuMapper.insert(sku02); - // 准备参数 - Long spuId = 1L; - String spuName = "测试商品"; - List skus = Arrays.asList( - randomPojo(ProductSkuCreateOrUpdateReqVO.class, o -> { // 测试更新 - o.setProperties(singletonList(new ProductSkuCreateOrUpdateReqVO.Property( - 10L, "颜色", 20L, "红色"))); - }), - randomPojo(ProductSkuCreateOrUpdateReqVO.class, o -> { // 测试新增 - o.setProperties(singletonList(new ProductSkuCreateOrUpdateReqVO.Property( - 10L, "颜色", 20L, "红色"))); - }) - ); - - // 调用 - productSkuService.updateSkuList(spuId, skus); - // 断言 - List dbSkus = productSkuMapper.selectListBySpuId(spuId); - assertEquals(dbSkus.size(), 2); - // 断言更新的 - assertEquals(dbSkus.get(0).getId(), sku01.getId()); - assertPojoEquals(dbSkus.get(0), skus.get(0), "properties"); - assertEquals(skus.get(0).getProperties().size(), 1); - assertPojoEquals(dbSkus.get(0).getProperties().get(0), skus.get(0).getProperties().get(0)); - // 断言新增的 - assertNotEquals(dbSkus.get(1).getId(), sku02.getId()); - assertPojoEquals(dbSkus.get(1), skus.get(1), "properties"); - assertEquals(skus.get(1).getProperties().size(), 1); - assertPojoEquals(dbSkus.get(1).getProperties().get(0), skus.get(1).getProperties().get(0)); - } - - @Test - public void testUpdateSkuStock_incrSuccess() { - // 准备参数 - ProductSkuUpdateStockReqDTO updateStockReqDTO = new ProductSkuUpdateStockReqDTO() - .setItems(singletonList(new ProductSkuUpdateStockReqDTO.Item().setId(1L).setIncrCount(10))); - // mock 数据 - productSkuMapper.insert(randomPojo(ProductSkuDO.class, o -> { - o.setId(1L).setSpuId(10L).setStock(20); - o.getProperties().forEach(p -> { - // 指定 id 范围 解决 Value too long - p.setPropertyId(generateId()); - p.setValueId(generateId()); - }); - })); - - // 调用 - productSkuService.updateSkuStock(updateStockReqDTO); - // 断言 - ProductSkuDO sku = productSkuMapper.selectById(1L); - assertEquals(sku.getStock(), 30); - verify(productSpuService).updateSpuStock(argThat(spuStockIncrCounts -> { - assertEquals(spuStockIncrCounts.size(), 1); - assertEquals(spuStockIncrCounts.get(10L), 10); - return true; - })); - } - - @Test - public void testUpdateSkuStock_decrSuccess() { - // 准备参数 - ProductSkuUpdateStockReqDTO updateStockReqDTO = new ProductSkuUpdateStockReqDTO() - .setItems(singletonList(new ProductSkuUpdateStockReqDTO.Item().setId(1L).setIncrCount(-10))); - // mock 数据 - productSkuMapper.insert(randomPojo(ProductSkuDO.class, o -> { - o.setId(1L).setSpuId(10L).setStock(20); - o.getProperties().forEach(p -> { - // 指定 id 范围 解决 Value too long - p.setPropertyId(generateId()); - p.setValueId(generateId()); - }); - })); - - // 调用 - productSkuService.updateSkuStock(updateStockReqDTO); - // 断言 - ProductSkuDO sku = productSkuMapper.selectById(1L); - assertEquals(sku.getStock(), 10); - verify(productSpuService).updateSpuStock(argThat(spuStockIncrCounts -> { - assertEquals(spuStockIncrCounts.size(), 1); - assertEquals(spuStockIncrCounts.get(10L), -10); - return true; - })); - } - - @Test - public void testUpdateSkuStock_decrFail() { - // 准备参数 - ProductSkuUpdateStockReqDTO updateStockReqDTO = new ProductSkuUpdateStockReqDTO() - .setItems(singletonList(new ProductSkuUpdateStockReqDTO.Item().setId(1L).setIncrCount(-30))); - // mock 数据 - productSkuMapper.insert(randomPojo(ProductSkuDO.class, o -> { - o.setId(1L).setSpuId(10L).setStock(20); - o.getProperties().forEach(p -> { - // 指定 id 范围 解决 Value too long - p.setPropertyId(generateId()); - p.setValueId(generateId()); - }); - })); - // 调用并断言 - AssertUtils.assertServiceException(() -> productSkuService.updateSkuStock(updateStockReqDTO), - SKU_STOCK_NOT_ENOUGH); - } - - @Test - public void testDeleteSku_success() { - ProductSkuDO dbSku = randomPojo(ProductSkuDO.class, o -> { - o.setId(generateId()).setSpuId(generateId()); - o.getProperties().forEach(p -> { - // 指定 id 范围 解决 Value too long - p.setPropertyId(generateId()); - p.setValueId(generateId()); - }); - }); - // mock 数据 - productSkuMapper.insert(dbSku); - // 准备参数 - Long id = dbSku.getId(); - - // 调用 - productSkuService.deleteSku(id); - // 校验数据不存在了 - assertNull(productSkuMapper.selectById(id)); - } - - @Test - public void testDeleteSku_notExists() { - // 准备参数 - Long id = 1L; - - // 调用, 并断言异常 - assertServiceException(() -> productSkuService.deleteSku(id), SKU_NOT_EXISTS); - } -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java deleted file mode 100755 index 88c155a77e..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java +++ /dev/null @@ -1,505 +0,0 @@ -package cn.iocoder.yudao.module.product.service.spu; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.product.service.brand.ProductBrandServiceImpl; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryServiceImpl; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuServiceImpl; -import com.google.common.collect.Lists; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.math.RoundingMode; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.assertj.core.util.Lists.newArrayList; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -// TODO @芋艿:review 下单元测试 - -/** - * {@link ProductSpuServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(ProductSpuServiceImpl.class) -public class ProductSpuServiceImplTest extends BaseDbUnitTest { - - @Resource - private ProductSpuServiceImpl productSpuService; - - @Resource - private ProductSpuMapper productSpuMapper; - - @MockBean - private ProductSkuServiceImpl productSkuService; - @MockBean - private ProductCategoryServiceImpl categoryService; - @MockBean - private ProductBrandServiceImpl brandService; - @MockBean - private ProductPropertyService productPropertyService; - @MockBean - private ProductPropertyValueService productPropertyValueService; - - public String generateNo() { - return DateUtil.format(new Date(), "yyyyMMddHHmmss") + RandomUtil.randomInt(100000, 999999); - } - - public Long generateId() { - return RandomUtil.randomLong(100000, 999999); - } - - public int generaInt(){return RandomUtil.randomInt(1,9999999);} - - // TODO @芋艿:单测后续 review 哈 - - @Test - public void testCreateSpu_success() { - // 准备参数 - ProductSkuCreateOrUpdateReqVO skuCreateOrUpdateReqVO = randomPojo(ProductSkuCreateOrUpdateReqVO.class,o->{ - // 限制范围为正整数 - o.setCostPrice(generaInt()); - o.setPrice(generaInt()); - o.setMarketPrice(generaInt()); - o.setStock(generaInt()); - o.setWarnStock(10); - o.setFirstBrokeragePrice(generaInt()); - o.setSecondBrokeragePrice(generaInt()); - // 限制分数为两位数 - o.setWeight(RandomUtil.randomDouble(10,2, RoundingMode.HALF_UP)); - o.setVolume(RandomUtil.randomDouble(10,2, RoundingMode.HALF_UP)); - }); - ProductSpuCreateReqVO createReqVO = randomPojo(ProductSpuCreateReqVO.class,o->{ - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setSkus(newArrayList(skuCreateOrUpdateReqVO,skuCreateOrUpdateReqVO,skuCreateOrUpdateReqVO)); - }); - when(categoryService.getCategoryLevel(eq(createReqVO.getCategoryId()))).thenReturn(2); - Long spu = productSpuService.createSpu(createReqVO); - ProductSpuDO productSpuDO = productSpuMapper.selectById(spu); - assertPojoEquals(createReqVO, productSpuDO); - } - - @Test - public void testUpdateSpu_success() { - // 准备参数 - ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class,o->{ - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setDeliveryTemplateId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setPrice(generaInt()); // 限制范围为正整数 - o.setMarketPrice(generaInt()); // 限制范围为正整数 - o.setCostPrice(generaInt()); // 限制范围为正整数 - o.setStock(generaInt()); // 限制范围为正整数 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - }); - productSpuMapper.insert(createReqVO); - // 准备参数 - ProductSkuCreateOrUpdateReqVO skuCreateOrUpdateReqVO = randomPojo(ProductSkuCreateOrUpdateReqVO.class,o->{ - // 限制范围为正整数 - o.setCostPrice(generaInt()); - o.setPrice(generaInt()); - o.setMarketPrice(generaInt()); - o.setStock(generaInt()); - o.setWarnStock(10); - o.setFirstBrokeragePrice(generaInt()); - o.setSecondBrokeragePrice(generaInt()); - // 限制分数为两位数 - o.setWeight(RandomUtil.randomDouble(10,2, RoundingMode.HALF_UP)); - o.setVolume(RandomUtil.randomDouble(10,2, RoundingMode.HALF_UP)); - }); - // 准备参数 - ProductSpuUpdateReqVO reqVO = randomPojo(ProductSpuUpdateReqVO.class, o -> { - o.setId(createReqVO.getId()); // 设置更新的 ID - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - o.setStatus(0); - o.setSkus(newArrayList(skuCreateOrUpdateReqVO,skuCreateOrUpdateReqVO,skuCreateOrUpdateReqVO)); - }); - when(categoryService.getCategoryLevel(eq(reqVO.getCategoryId()))).thenReturn(2); - // 调用 - productSpuService.updateSpu(reqVO); - // 校验是否更新正确 - ProductSpuDO spu = productSpuMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, spu); - } - - @Test - public void testValidateSpuExists_exception() { - ProductSpuUpdateReqVO reqVO = randomPojo(ProductSpuUpdateReqVO.class); - // 调用 - Assertions.assertThrows(ServiceException.class, () -> productSpuService.updateSpu(reqVO)); - } - - @Test - void deleteSpu() { - // 准备参数 - ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class,o->{ - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setDeliveryTemplateId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setPrice(generaInt()); // 限制范围为正整数 - o.setMarketPrice(generaInt()); // 限制范围为正整数 - o.setCostPrice(generaInt()); // 限制范围为正整数 - o.setStock(generaInt()); // 限制范围为正整数 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - o.setStatus(-1); // 加入回收站才可删除 - }); - productSpuMapper.insert(createReqVO); - - // 调用 - productSpuService.deleteSpu(createReqVO.getId()); - - Assertions.assertNull(productSpuMapper.selectById(createReqVO.getId())); - } - - @Test - void getSpu() { - // 准备参数 - ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class,o->{ - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setDeliveryTemplateId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setPrice(generaInt()); // 限制范围为正整数 - o.setMarketPrice(generaInt()); // 限制范围为正整数 - o.setCostPrice(generaInt()); // 限制范围为正整数 - o.setStock(generaInt()); // 限制范围为正整数 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - }); - productSpuMapper.insert(createReqVO); - - ProductSpuDO spu = productSpuService.getSpu(createReqVO.getId()); - assertPojoEquals(createReqVO, spu); - } - - @Test - void getSpuList() { - // 准备参数 - ArrayList createReqVOs = Lists.newArrayList(randomPojo(ProductSpuDO.class,o->{ - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setDeliveryTemplateId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setPrice(generaInt()); // 限制范围为正整数 - o.setMarketPrice(generaInt()); // 限制范围为正整数 - o.setCostPrice(generaInt()); // 限制范围为正整数 - o.setStock(generaInt()); // 限制范围为正整数 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - }), randomPojo(ProductSpuDO.class,o->{ - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setDeliveryTemplateId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setPrice(generaInt()); // 限制范围为正整数 - o.setMarketPrice(generaInt()); // 限制范围为正整数 - o.setCostPrice(generaInt()); // 限制范围为正整数 - o.setStock(generaInt()); // 限制范围为正整数 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - })); - productSpuMapper.insertBatch(createReqVOs); - - // 调用 - List spuList = productSpuService.getSpuList(createReqVOs.stream().map(ProductSpuDO::getId).collect(Collectors.toList())); - Assertions.assertIterableEquals(createReqVOs, spuList); - } - - @Test - void getSpuPage_alarmStock_empty() { - // 准备参数 - ArrayList createReqVOs = Lists.newArrayList(randomPojo(ProductSpuDO.class,o->{ - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setDeliveryTemplateId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setPrice(generaInt()); // 限制范围为正整数 - o.setMarketPrice(generaInt()); // 限制范围为正整数 - o.setCostPrice(generaInt()); // 限制范围为正整数 - o.setStock(11); // 限制范围为正整数 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - }), randomPojo(ProductSpuDO.class,o->{ - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setDeliveryTemplateId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setPrice(generaInt()); // 限制范围为正整数 - o.setMarketPrice(generaInt()); // 限制范围为正整数 - o.setCostPrice(generaInt()); // 限制范围为正整数 - o.setStock(11); // 限制范围为正整数 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - })); - productSpuMapper.insertBatch(createReqVOs); - // 调用 - ProductSpuPageReqVO productSpuPageReqVO = new ProductSpuPageReqVO(); - productSpuPageReqVO.setTabType(ProductSpuPageReqVO.ALERT_STOCK); - - PageResult spuPage = productSpuService.getSpuPage(productSpuPageReqVO); - - PageResult result = PageResult.empty(); - Assertions.assertIterableEquals(result.getList(), spuPage.getList()); - assertEquals(spuPage.getTotal(), result.getTotal()); - } - - @Test - void getSpuPage_alarmStock() { - // 准备参数 - ArrayList createReqVOs = Lists.newArrayList(randomPojo(ProductSpuDO.class,o->{ - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setDeliveryTemplateId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setPrice(generaInt()); // 限制范围为正整数 - o.setMarketPrice(generaInt()); // 限制范围为正整数 - o.setCostPrice(generaInt()); // 限制范围为正整数 - o.setStock(5); // 限制范围为正整数 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - }), randomPojo(ProductSpuDO.class,o->{ - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setDeliveryTemplateId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setPrice(generaInt()); // 限制范围为正整数 - o.setMarketPrice(generaInt()); // 限制范围为正整数 - o.setCostPrice(generaInt()); // 限制范围为正整数 - o.setStock(9); // 限制范围为正整数 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - })); - productSpuMapper.insertBatch(createReqVOs); - // 调用 - ProductSpuPageReqVO productSpuPageReqVO = new ProductSpuPageReqVO(); - productSpuPageReqVO.setTabType(ProductSpuPageReqVO.ALERT_STOCK); - PageResult spuPage = productSpuService.getSpuPage(productSpuPageReqVO); - assertEquals(createReqVOs.size(), spuPage.getTotal()); - } - - @Test - void testGetSpuPage() { - // 准备参数 - ProductSpuDO createReqVO = randomPojo(ProductSpuDO.class,o->{ - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setDeliveryTemplateId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setPrice(generaInt()); // 限制范围为正整数 - o.setMarketPrice(generaInt()); // 限制范围为正整数 - o.setCostPrice(generaInt()); // 限制范围为正整数 - o.setStock(generaInt()); // 限制范围为正整数 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - }); - - // 准备参数 - productSpuMapper.insert(createReqVO); - // 测试 status 不匹配 - productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setStatus(ProductSpuStatusEnum.DISABLE.getStatus()))); - productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setStatus(ProductSpuStatusEnum.RECYCLE.getStatus()))); - // 测试 SpecType 不匹配 - productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setSpecType(true))); - // 测试 BrandId 不匹配 - productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setBrandId(generateId()))); - // 测试 CategoryId 不匹配 - productSpuMapper.insert(cloneIgnoreId(createReqVO, o -> o.setCategoryId(generateId()))); - - // 调用 - ProductSpuPageReqVO productSpuPageReqVO = new ProductSpuPageReqVO(); - // 查询条件 按需打开 - //productSpuPageReqVO.setTabType(ProductSpuPageReqVO.ALERT_STOCK); - //productSpuPageReqVO.setTabType(ProductSpuPageReqVO.RECYCLE_BIN); - //productSpuPageReqVO.setTabType(ProductSpuPageReqVO.FOR_SALE); - //productSpuPageReqVO.setTabType(ProductSpuPageReqVO.IN_WAREHOUSE); - //productSpuPageReqVO.setTabType(ProductSpuPageReqVO.SOLD_OUT); - //productSpuPageReqVO.setName(createReqVO.getName()); - //productSpuPageReqVO.setCategoryId(createReqVO.getCategoryId()); - - PageResult spuPage = productSpuService.getSpuPage(productSpuPageReqVO); - - PageResult result = ProductSpuConvert.INSTANCE.convertPage(productSpuMapper.selectPage(productSpuPageReqVO)); - assertEquals(result.getTotal(), spuPage.getTotal()); - } - - /** - * 生成笛卡尔积 - * - * @param data 数据 - * @return 笛卡尔积 - */ - public static List> cartesianProduct(List> data) { - List> res = null; // 结果集(当前为第N个List,则该处存放的就为前N-1个List的笛卡尔积集合) - for (List list : data) { // 遍历数据 - List> temp = new ArrayList<>(); // 临时结果集,存放本次循环后生成的笛卡尔积集合 - if (res == null) { // 结果集为null表示第一次循环既list为第一个List - for (T t : list) { // 便利第一个List - // 利用stream生成List,第一个List的笛卡尔积集合约等于自己本身(需要创建一个List并把对象添加到当中),存放到临时结果集 - temp.add(Stream.of(t).collect(Collectors.toList())); - } - res = temp; // 将临时结果集赋值给结果集 - continue; // 跳过本次循环 - } - // 不为第一个List,计算前面的集合(笛卡尔积)和当前List的笛卡尔积集合 - for (T t : list) { // 便利 - for (List rl : res) { // 便利前面的笛卡尔积集合 - // 利用stream生成List - temp.add(Stream.concat(rl.stream(), Stream.of(t)).collect(Collectors.toList())); - } - } - res = temp; // 将临时结果集赋值给结果集 - } - // 返回结果 - return res; - } - - @Test - public void testUpdateSpuStock() { - // 准备参数 - Map stockIncrCounts = MapUtil.builder(1L, 10).put(2L, -20).build(); - // mock 方法(数据) - productSpuMapper.insert(randomPojo(ProductSpuDO.class, o ->{ - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setDeliveryTemplateId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setPrice(generaInt()); // 限制范围为正整数 - o.setMarketPrice(generaInt()); // 限制范围为正整数 - o.setCostPrice(generaInt()); // 限制范围为正整数 - o.setStock(generaInt()); // 限制范围为正整数 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - o.setId(1L).setStock(20); - })); - productSpuMapper.insert(randomPojo(ProductSpuDO.class, o -> { - o.setCategoryId(generateId()); - o.setBrandId(generateId()); - o.setDeliveryTemplateId(generateId()); - o.setUnit(RandomUtil.randomInt(1,20)); // 限制商品单位范围 - o.setSort(RandomUtil.randomInt(1,100)); // 限制排序范围 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setVirtualSalesCount(generaInt()); // 限制范围为正整数 - o.setActivityOrders(newArrayList(1,3,2,4,5)); // 活动排序 - o.setPrice(generaInt()); // 限制范围为正整数 - o.setMarketPrice(generaInt()); // 限制范围为正整数 - o.setCostPrice(generaInt()); // 限制范围为正整数 - o.setStock(generaInt()); // 限制范围为正整数 - o.setGiveIntegral(generaInt()); // 限制范围为正整数 - o.setSalesCount(generaInt()); // 限制范围为正整数 - o.setBrowseCount(generaInt()); // 限制范围为正整数 - o.setId(2L).setStock(30); - })); - - // 调用 - productSpuService.updateSpuStock(stockIncrCounts); - // 断言 - assertEquals(productSpuService.getSpu(1L).getStock(), 30); - assertEquals(productSpuService.getSpu(2L).getStock(), 10); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 518fa712b9..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,51 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/logback.xml b/yudao-module-mall/yudao-module-product-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff0..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index e9616cd0d5..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,7 +0,0 @@ -DELETE FROM "product_sku"; -DELETE FROM "product_spu"; -DELETE FROM "product_category"; -DELETE FROM "product_brand"; -DELETE FROM "product_property"; -DELETE FROM "product_property_value"; -DELETE FROM "product_comment"; diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index f0f0c70ee8..0000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,157 +0,0 @@ -CREATE TABLE IF NOT EXISTS `product_sku` ( - `id` bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `spu_id` bigint NOT NULL COMMENT 'spu编号', - `properties` varchar(512) DEFAULT NULL COMMENT '属性数组,JSON 格式', - `price` int NOT NULL DEFAULT '-1' COMMENT '商品价格,单位:分', - `market_price` int DEFAULT NULL COMMENT '市场价,单位:分', - `cost_price` int NOT NULL DEFAULT '-1' COMMENT '成本价,单位: 分', - `bar_code` varchar(64) DEFAULT NULL COMMENT 'SKU 的条形码', - `pic_url` varchar(256) NOT NULL COMMENT '图片地址', - `stock` int DEFAULT NULL COMMENT '库存', - `weight` double DEFAULT NULL COMMENT '商品重量,单位:kg 千克', - `volume` double DEFAULT NULL COMMENT '商品体积,单位:m^3 平米', - `sub_commission_first_price` int DEFAULT NULL COMMENT '一级分销的佣金,单位:分', - `sub_commission_second_price` int DEFAULT NULL COMMENT '二级分销的佣金,单位:分', - `sales_count` int DEFAULT NULL COMMENT '商品销量', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '商品sku'; - -CREATE TABLE IF NOT EXISTS `product_spu` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '商品 SPU 编号,自增', - `name` varchar(128) NOT NULL COMMENT '商品名称', - `keyword` varchar(256) NOT NULL COMMENT '关键字', - `introduction` varchar(256) NOT NULL COMMENT '商品简介', - `description` text NOT NULL COMMENT '商品详情', - `bar_code` varchar(64) NOT NULL COMMENT '条形码', - `category_id` bigint NOT NULL COMMENT '商品分类编号', - `brand_id` int DEFAULT NULL COMMENT '商品品牌编号', - `pic_url` varchar(256) NOT NULL COMMENT '商品封面图', - `slider_pic_urls` varchar(2000) DEFAULT '' COMMENT '商品轮播图地址\n 数组,以逗号分隔\n 最多上传15张', - `video_url` varchar(256) DEFAULT NULL COMMENT '商品视频', - `unit` tinyint NOT NULL COMMENT '单位', - `sort` int NOT NULL DEFAULT '0' COMMENT '排序字段', - `status` tinyint NOT NULL COMMENT '商品状态: 0 上架(开启) 1 下架(禁用)-1 回收', - `spec_type` bit(1) NOT NULL COMMENT '规格类型:0 单规格 1 多规格', - `price` int NOT NULL DEFAULT '-1' COMMENT '商品价格,单位使用:分', - `market_price` int NOT NULL COMMENT '市场价,单位使用:分', - `cost_price` int NOT NULL DEFAULT '-1' COMMENT '成本价,单位: 分', - `stock` int NOT NULL DEFAULT '0' COMMENT '库存', - `delivery_template_id` bigint NOT NULL COMMENT '物流配置模板编号', - `recommend_hot` bit(1) NOT NULL COMMENT '是否热卖推荐: 0 默认 1 热卖', - `recommend_benefit` bit(1) NOT NULL COMMENT '是否优惠推荐: 0 默认 1 优选', - `recommend_best` bit(1) NOT NULL COMMENT '是否精品推荐: 0 默认 1 精品', - `recommend_new` bit(1) NOT NULL COMMENT '是否新品推荐: 0 默认 1 新品', - `recommend_good` bit(1) NOT NULL COMMENT '是否优品推荐', - `give_integral` int NOT NULL COMMENT '赠送积分', - `give_coupon_template_ids` varchar(512) DEFAULT '' COMMENT '赠送的优惠劵编号的数组', - `sub_commission_type` bit(1) NOT NULL COMMENT '分销类型', - `activity_orders` varchar(16) NOT NULL DEFAULT '' COMMENT '活动显示排序0=默认, 1=秒杀,2=砍价,3=拼团', - `sales_count` int DEFAULT '0' COMMENT '商品销量', - `virtual_sales_count` int DEFAULT '0' COMMENT '虚拟销量', - `browse_count` int DEFAULT '0' COMMENT '商品点击量', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '商品spu'; - -CREATE TABLE IF NOT EXISTS `product_category` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类编号', - `parent_id` bigint NOT NULL COMMENT '父分类编号', - `name` varchar(255) NOT NULL COMMENT '分类名称', - `pic_url` varchar(255) NOT NULL COMMENT '移动端分类图', - `big_pic_url` varchar(255) DEFAULT NULL COMMENT 'PC 端分类图', - `sort` int DEFAULT '0' COMMENT '分类排序', - `status` tinyint NOT NULL COMMENT '开启状态', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '商品分类'; - -CREATE TABLE IF NOT EXISTS `product_brand` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '品牌编号', - `name` varchar(255) NOT NULL COMMENT '品牌名称', - `pic_url` varchar(255) NOT NULL COMMENT '品牌图片', - `sort` int DEFAULT '0' COMMENT '品牌排序', - `description` varchar(1024) DEFAULT NULL COMMENT '品牌描述', - `status` tinyint NOT NULL COMMENT '状态', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '商品品牌'; - -CREATE TABLE IF NOT EXISTS `product_property` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(64) DEFAULT NULL COMMENT '规格名称', - `status` tinyint DEFAULT NULL COMMENT '状态: 0 开启 ,1 禁用', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - `remark` varchar(255) DEFAULT NULL COMMENT '备注', - PRIMARY KEY("id") -) COMMENT '规格名称'; - -CREATE TABLE IF NOT EXISTS `product_property_value` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `property_id` bigint DEFAULT NULL COMMENT '规格键id', - `name` varchar(128) DEFAULT NULL COMMENT '规格值名字', - `status` tinyint DEFAULT NULL COMMENT '状态: 1 开启 ,2 禁用', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - `remark` varchar(255) DEFAULT NULL COMMENT '备注', - PRIMARY KEY("id") -) COMMENT '规格值'; - -DROP TABLE IF EXISTS `product_comment` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '评论编号,主键自增', - `user_id` bigint DEFAULT NULL COMMENT '评价人的用户编号关联 MemberUserDO 的 id 编号', - `user_nickname` varchar(255) DEFAULT NULL COMMENT '评价人名称', - `user_avatar` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '评价人头像', - `anonymous` bit(1) DEFAULT NULL COMMENT '是否匿名', - `order_id` bigint DEFAULT NULL COMMENT '交易订单编号关联 TradeOrderDO 的 id 编号', - `order_item_id` bigint DEFAULT NULL COMMENT '交易订单项编号关联 TradeOrderItemDO 的 id 编号', - `spu_id` bigint DEFAULT NULL COMMENT '商品 SPU 编号关联 ProductSpuDO 的 id', - `spu_name` varchar(255) DEFAULT NULL COMMENT '商品 SPU 名称', - `sku_id` bigint DEFAULT NULL COMMENT '商品 SKU 编号关联 ProductSkuDO 的 id 编号', - `visible` bit(1) DEFAULT NULL COMMENT '是否可见true:显示false:隐藏', - `scores` tinyint DEFAULT NULL COMMENT '评分星级1-5分', - `description_scores` tinyint DEFAULT NULL COMMENT '描述星级1-5 星', - `benefit_scores` tinyint DEFAULT NULL COMMENT '服务星级1-5 星', - `content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '评论内容', - `pic_urls` varchar(4096) DEFAULT NULL COMMENT '评论图片地址数组', - `reply_status` bit(1) DEFAULT NULL COMMENT '商家是否回复', - `reply_user_id` bigint DEFAULT NULL COMMENT '回复管理员编号关联 AdminUserDO 的 id 编号', - `reply_content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '商家回复内容', - `reply_time` datetime DEFAULT NULL COMMENT '商家回复时间', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 26 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '商品评论'; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-api/pom.xml b/yudao-module-mall/yudao-module-promotion-api/pom.xml deleted file mode 100644 index 1c21560ba7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-promotion-api - jar - - ${project.artifactId} - - promotion 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - com.fasterxml.jackson.core - jackson-databind - true - - - - diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java deleted file mode 100644 index 0f98126290..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain; - -/** - * 砍价活动 Api 接口 - * - * @author HUIHUI - */ -public interface BargainActivityApi { - - /** - * 更新砍价活动库存 - * - * @param id 砍价活动编号 - * @param count 购买数量 - */ - void updateBargainActivityStock(Long id, Integer count); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java deleted file mode 100644 index fb0e3f02b8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain; - -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; - -/** - * 砍价记录 API 接口 - * - * @author HUIHUI - */ -public interface BargainRecordApi { - - /** - * 【下单前】校验是否参与砍价活动 - *

- * 如果校验失败,则抛出业务异常 - * - * @param userId 用户编号 - * @param bargainRecordId 砍价活动编号 - * @param skuId SKU 编号 - * @return 砍价信息 - */ - BargainValidateJoinRespDTO validateJoinBargain(Long userId, Long bargainRecordId, Long skuId); - - /** - * 更新砍价记录的订单编号 - * - * 在砍价成功后,用户发起订单后,会记录该订单编号 - * - * @param id 砍价记录编号 - * @param orderId 订单编号 - */ - void updateBargainRecordOrderId(Long id, Long orderId); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainValidateJoinRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainValidateJoinRespDTO.java deleted file mode 100644 index a64e923f51..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainValidateJoinRespDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain.dto; - -import lombok.Data; - -/** - * 校验参与砍价 Response DTO - */ -@Data -public class BargainValidateJoinRespDTO { - - /** - * 砍价活动编号 - */ - private Long activityId; - /** - * 砍价活动名称 - */ - private String name; - - /** - * 砍价金额 - */ - private Integer bargainPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java deleted file mode 100644 index 942ededecf..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination; - -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; - -import jakarta.validation.Valid; - -/** - * 拼团记录 API 接口 - * - * @author HUIHUI - */ -public interface CombinationRecordApi { - - /** - * 校验是否满足拼团条件 - * - * @param userId 用户编号 - * @param activityId 活动编号 - * @param headId 团长编号 - * @param skuId sku 编号 - * @param count 数量 - */ - void validateCombinationRecord(Long userId, Long activityId, Long headId, Long skuId, Integer count); - - /** - * 创建开团记录 - * - * @param reqDTO 请求 DTO - * @return 拼团信息 - */ - CombinationRecordCreateRespDTO createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO); - - /** - * 查询拼团记录是否成功 - * - * @param userId 用户编号 - * @param orderId 订单编号 - * @return 拼团是否成功 - */ - boolean isCombinationRecordSuccess(Long userId, Long orderId); - - /** - * 【下单前】校验是否满足拼团活动条件 - * - * 如果校验失败,则抛出业务异常 - * - * @param userId 用户编号 - * @param activityId 活动编号 - * @param headId 团长编号 - * @param skuId sku 编号 - * @param count 数量 - * @return 拼团信息 - */ - CombinationValidateJoinRespDTO validateJoinCombination(Long userId, Long activityId, Long headId, - Long skuId, Integer count); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateReqDTO.java deleted file mode 100644 index eade5ca1ce..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateReqDTO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination.dto; - -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 拼团记录的创建 Request DTO - * - * @author HUIHUI - */ -@Data -public class CombinationRecordCreateReqDTO { - - /** - * 拼团活动编号 - */ - @NotNull(message = "拼团活动编号不能为空") - private Long activityId; - /** - * spu 编号 - */ - @NotNull(message = "spu 编号不能为空") - private Long spuId; - /** - * sku 编号 - */ - @NotNull(message = "sku 编号不能为空") - private Long skuId; - /** - * 购买的商品数量 - */ - @NotNull(message = "购买数量不能为空") - private Integer count; - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 团长编号 - */ - private Long headId; - /** - * 拼团商品单价 - */ - @NotNull(message = "拼团商品单价不能为空") - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateRespDTO.java deleted file mode 100644 index 5f4ea2afde..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateRespDTO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination.dto; - -import lombok.Data; - -/** - * 拼团记录的创建 Response DTO - * - * @author HUIHUI - */ -@Data -public class CombinationRecordCreateRespDTO { - - /** - * 拼团活动编号 - * - * 关联 CombinationActivityDO 的 id 字段 - */ - private Long combinationActivityId; - /** - * 拼团团长编号 - * - * 关联 CombinationRecordDO 的 headId 字段 - */ - private Long combinationHeadId; - /** - * 拼团记录编号 - * - * 关联 CombinationRecordDO 的 id 字段 - */ - private Long combinationRecordId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationValidateJoinRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationValidateJoinRespDTO.java deleted file mode 100644 index 86fe00a5f7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationValidateJoinRespDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination.dto; - -import lombok.Data; - -/** - * 校验参与拼团 Response DTO - * - * @author HUIHUI - */ -@Data -public class CombinationValidateJoinRespDTO { - - /** - * 砍价活动编号 - */ - private Long activityId; - /** - * 砍价活动名称 - */ - private String name; - - /** - * 拼团金额 - */ - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java deleted file mode 100644 index 27e5b6fb86..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon; - -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO; - -import jakarta.validation.Valid; - -/** - * 优惠劵 API 接口 - * - * @author 芋道源码 - */ -public interface CouponApi { - - /** - * 使用优惠劵 - * - * @param useReqDTO 使用请求 - */ - void useCoupon(@Valid CouponUseReqDTO useReqDTO); - - /** - * 退还已使用的优惠券 - * - * @param id 优惠券编号 - */ - void returnUsedCoupon(Long id); - - /** - * 校验优惠劵 - * - * @param validReqDTO 校验请求 - * @return 优惠劵 - */ - CouponRespDTO validateCoupon(@Valid CouponValidReqDTO validReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponRespDTO.java deleted file mode 100644 index a404bf27d8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponRespDTO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon.dto; - -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 优惠劵 Response DTO - * - * @author 芋道源码 - */ -@Data -public class CouponRespDTO { - - // ========== 基本信息 BEGIN ========== - /** - * 优惠劵编号 - */ - private Long id; - /** - * 优惠劵模板编号 - */ - private Integer templateId; - /** - * 优惠劵名 - */ - private String name; - /** - * 优惠码状态 - * - * 枚举 {@link CouponStatusEnum} - */ - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取情况 BEGIN ========== - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 领取类型 - * - * 枚举 {@link CouponTakeTypeEnum} - */ - private Integer takeType; - // ========== 领取情况 END ========== - - // ========== 使用规则 BEGIN ========== - /** - * 是否设置满多少金额可用,单位:分 - */ - private Integer usePrice; - /** - * 生效开始时间 - */ - private LocalDateTime validStartTime; - /** - * 生效结束时间 - */ - private LocalDateTime validEndTime; - /** - * 商品范围 - */ - private Integer productScope; - /** - * 商品范围编号的数组 - */ - private List productScopeValues; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - /** - * 折扣类型 - */ - private Integer discountType; - /** - * 折扣百分比 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - */ - private Integer discountPrice; - /** - * 折扣上限,仅在 {@link #discountType} 等于 {@link PromotionDiscountTypeEnum#PERCENT} 时生效 - */ - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 使用情况 BEGIN ========== - /** - * 使用订单号 - */ - private Long useOrderId; - /** - * 使用时间 - */ - private LocalDateTime useTime; - - // ========== 使用情况 END ========== -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponUseReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponUseReqDTO.java deleted file mode 100644 index 66688c0df7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponUseReqDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon.dto; - -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 优惠劵使用 Request DTO - * - * @author 芋道源码 - */ -@Data -public class CouponUseReqDTO { - - /** - * 优惠劵编号 - */ - @NotNull(message = "优惠劵编号不能为空") - private Long id; - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponValidReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponValidReqDTO.java deleted file mode 100644 index f219b6fdd4..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponValidReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon.dto; - -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 优惠劵使用 Request DTO - * - * @author 芋道源码 - */ -@Data -public class CouponValidReqDTO { - - /** - * 优惠劵编号 - */ - @NotNull(message = "优惠劵编号不能为空") - private Long id; - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApi.java deleted file mode 100644 index b25f67d9fe..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApi.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.discount; - -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; - -import java.util.Collection; -import java.util.List; - -/** - * 限时折扣 API 接口 - * - * @author 芋道源码 - */ -public interface DiscountActivityApi { - - /** - * 获得商品匹配的的限时折扣信息 - * - * @param skuIds 商品 SKU 编号数组 - * @return 限时折扣信息 - */ - List getMatchDiscountProductList(Collection skuIds); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/dto/DiscountProductRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/dto/DiscountProductRespDTO.java deleted file mode 100644 index 52dfdbe276..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/dto/DiscountProductRespDTO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.discount.dto; - -import lombok.Data; - -/** - * 限时折扣活动商品 Response DTO - * - * @author 芋道源码 - */ -@Data -public class DiscountProductRespDTO { - - /** - * 编号,主键自增 - */ - private Long id; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 折扣类型 - */ - private Integer discountType; - /** - * 折扣百分比 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - */ - private Integer discountPrice; - - // ========== 活动字段 ========== - /** - * 限时折扣活动的编号 - */ - private Long activityId; - /** - * 活动标题 - */ - private String activityName; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApi.java deleted file mode 100644 index efeddf3d5b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApi.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.reward; - -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; - -import java.util.Collection; -import java.util.List; - -/** - * 满减送活动 API 接口 - * - * @author 芋道源码 - */ -public interface RewardActivityApi { - - - /** - * 基于指定的 SPU 编号数组,获得它们匹配的满减送活动 - * - * @param spuIds SPU 编号数组 - * @return 满减送活动列表 - */ - List getMatchRewardActivityList(Collection spuIds); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/dto/RewardActivityMatchRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/dto/RewardActivityMatchRespDTO.java deleted file mode 100644 index 6ae71a1d9e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/dto/RewardActivityMatchRespDTO.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.reward.dto; - -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import lombok.Data; - -import java.util.List; - -/** - * 满减送活动的匹配 Response DTO - * - * @author 芋道源码 - */ -@Data -public class RewardActivityMatchRespDTO { - - /** - * 活动编号,主键自增 - */ - private Long id; - /** - * 活动标题 - */ - private String name; - /** - * 条件类型 - * - * 枚举 {@link PromotionConditionTypeEnum} - */ - private Integer conditionType; - /** - * 优惠规则的数组 - */ - private List rules; - - /** - * 商品 SPU 编号的数组 - */ - private List spuIds; - - // TODO 芋艿:后面 RewardActivityRespDTO 有了之后,Rule 可以放过去 - /** - * 优惠规则 - */ - @Data - public static class Rule { - - /** - * 优惠门槛 - * - * 1. 满 N 元,单位:分 - * 2. 满 N 件 - */ - private Integer limit; - /** - * 优惠价格,单位:分 - */ - private Integer discountPrice; - /** - * 是否包邮 - */ - private Boolean freeDelivery; - /** - * 赠送的积分 - */ - private Integer point; - /** - * 赠送的优惠劵编号的数组 - */ - private List couponIds; - /** - * 赠送的优惠券数量的数组 - */ - private List couponCounts; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java deleted file mode 100644 index 0d65919d15..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.seckill; - -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; - -/** - * 秒杀活动 API 接口 - * - * @author HUIHUI - */ -public interface SeckillActivityApi { - - /** - * 更新秒杀库存(减少) - * - * @param id 活动编号 - * @param skuId sku 编号 - * @param count 数量(正数) - */ - void updateSeckillStockDecr(Long id, Long skuId, Integer count); - - /** - * 更新秒杀库存(增加) - * - * @param id 活动编号 - * @param skuId sku 编号 - * @param count 数量(正数) - */ - void updateSeckillStockIncr(Long id, Long skuId, Integer count); - - /** - * 【下单前】校验是否参与秒杀活动 - * - * 如果校验失败,则抛出业务异常 - * - * @param activityId 活动编号 - * @param skuId SKU 编号 - * @param count 数量 - * @return 秒杀信息 - */ - SeckillValidateJoinRespDTO validateJoinSeckill(Long activityId, Long skuId, Integer count); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/dto/SeckillValidateJoinRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/dto/SeckillValidateJoinRespDTO.java deleted file mode 100644 index aae89a4157..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/dto/SeckillValidateJoinRespDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.seckill.dto; - -import lombok.Data; - -/** - * 校验参与秒杀 Response DTO - */ -@Data -public class SeckillValidateJoinRespDTO { - - /** - * 秒杀活动名称 - */ - private String name; - /** - * 总限购数量 - * - * 目的:目前只有 trade 有具体下单的数据,需要交给 trade 价格计算使用 - */ - private Integer totalLimitCount; - - /** - * 秒杀金额 - */ - private Integer seckillPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/DictTypeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/DictTypeConstants.java deleted file mode 100644 index f377ca239c..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/DictTypeConstants.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums; - -/** - * promotion 字典类型的枚举类 - * - * @author HUIHUI - */ -public class DictTypeConstants { - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java deleted file mode 100644 index 3b19d616a7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,128 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Promotion 错误码枚举类 - *

- * promotion 系统,使用 1-013-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 促销活动相关 1-013-001-000 ============ - ErrorCode DISCOUNT_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_001_000, "限时折扣活动不存在"); - ErrorCode DISCOUNT_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_001_001, "存在商品参加了其它限时折扣活动"); - ErrorCode DISCOUNT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_001_002, "限时折扣活动已关闭,不能修改"); - ErrorCode DISCOUNT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1_013_001_003, "限时折扣活动未关闭,不能删除"); - ErrorCode DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_001_004, "限时折扣活动已关闭,不能重复关闭"); - - // ========== Banner 相关 1-013-002-000 ============ - ErrorCode BANNER_NOT_EXISTS = new ErrorCode(1_013_002_000, "Banner 不存在"); - - // ========== Coupon 相关 1-013-003-000 ============ - ErrorCode COUPON_NO_MATCH_SPU = new ErrorCode(1_013_003_000, "优惠劵没有可使用的商品!"); - ErrorCode COUPON_NO_MATCH_MIN_PRICE = new ErrorCode(1_013_003_001, "所结算的商品中未满足使用的金额"); - - // ========== 优惠劵模板 1-013-004-000 ========== - ErrorCode COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1_013_004_000, "优惠劵模板不存在"); - ErrorCode COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL = new ErrorCode(1_013_004_001, "发放数量不能小于已领取数量({})"); - ErrorCode COUPON_TEMPLATE_NOT_ENOUGH = new ErrorCode(1_013_004_002, "当前剩余数量不够领取"); - ErrorCode COUPON_TEMPLATE_USER_ALREADY_TAKE = new ErrorCode(1_013_004_003, "用户已领取过此优惠券"); - ErrorCode COUPON_TEMPLATE_EXPIRED = new ErrorCode(1_013_004_004, "优惠券已过期"); - ErrorCode COUPON_TEMPLATE_CANNOT_TAKE = new ErrorCode(1_013_004_005, "领取方式不正确"); - - // ========== 优惠劵 1-013-005-000 ========== - ErrorCode COUPON_NOT_EXISTS = new ErrorCode(1_013_005_000, "优惠券不存在"); - ErrorCode COUPON_DELETE_FAIL_USED = new ErrorCode(1_013_005_001, "回收优惠劵失败,优惠劵已被使用"); - ErrorCode COUPON_STATUS_NOT_UNUSED = new ErrorCode(1_013_005_002, "优惠劵不处于待使用状态"); - ErrorCode COUPON_VALID_TIME_NOT_NOW = new ErrorCode(1_013_005_003, "优惠券不在使用时间范围内"); - ErrorCode COUPON_STATUS_NOT_USED = new ErrorCode(1_013_005_004, "优惠劵不是已使用状态"); - - // ========== 满减送活动 1-013-006-000 ========== - ErrorCode REWARD_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_006_000, "满减送活动不存在"); - ErrorCode REWARD_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_006_001, "存在商品参加了其它满减送活动"); - ErrorCode REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_002, "满减送活动已关闭,不能修改"); - ErrorCode REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1_013_006_003, "满减送活动未关闭,不能删除"); - ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_004, "满减送活动已关闭,不能重复关闭"); - ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_END = new ErrorCode(1_013_006_005, "满减送活动已结束,不能关闭"); - - // ========== TODO 空着 1-013-007-000 ============ - - // ========== 秒杀活动 1-013-008-000 ========== - ErrorCode SECKILL_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_008_000, "秒杀活动不存在"); - ErrorCode SECKILL_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_008_002, "存在商品参加了其它秒杀活动,秒杀时段冲突"); - ErrorCode SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_008_003, "秒杀活动已关闭,不能修改"); - ErrorCode SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1_013_008_004, "秒杀活动未关闭或未结束,不能删除"); - ErrorCode SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_008_005, "秒杀活动已关闭,不能重复关闭"); - ErrorCode SECKILL_ACTIVITY_UPDATE_STOCK_FAIL = new ErrorCode(1_013_008_006, "秒杀失败,原因:秒杀库存不足"); - ErrorCode SECKILL_JOIN_ACTIVITY_TIME_ERROR = new ErrorCode(1_013_008_007, "秒杀失败,原因:不在活动时间范围内"); - ErrorCode SECKILL_JOIN_ACTIVITY_STATUS_CLOSED = new ErrorCode(1_013_008_008, "秒杀失败,原因:秒杀活动已关闭"); - ErrorCode SECKILL_JOIN_ACTIVITY_SINGLE_LIMIT_COUNT_EXCEED = new ErrorCode(1_013_008_009, "秒杀失败,原因:单次限购超出"); - ErrorCode SECKILL_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS = new ErrorCode(1_013_008_010, "秒杀失败,原因:商品不存在"); - - // ========== 秒杀时段 1-013-009-000 ========== - ErrorCode SECKILL_CONFIG_NOT_EXISTS = new ErrorCode(1_013_009_000, "秒杀时段不存在"); - ErrorCode SECKILL_CONFIG_TIME_CONFLICTS = new ErrorCode(1_013_009_001, "秒杀时段冲突"); - ErrorCode SECKILL_CONFIG_DISABLE = new ErrorCode(1_013_009_004, "秒杀时段已关闭"); - - // ========== 拼团活动 1-013-010-000 ========== - ErrorCode COMBINATION_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_010_000, "拼团活动不存在"); - ErrorCode COMBINATION_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_010_001, "存在商品参加了其它拼团活动"); - ErrorCode COMBINATION_ACTIVITY_STATUS_DISABLE_NOT_UPDATE = new ErrorCode(1_013_010_002, "拼团活动已关闭不能修改"); - ErrorCode COMBINATION_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1_013_010_003, "拼团活动未关闭或未结束,不能删除"); - ErrorCode COMBINATION_ACTIVITY_STATUS_DISABLE = new ErrorCode(1_013_010_004, "拼团失败,原因:拼团活动已关闭"); - ErrorCode COMBINATION_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS = new ErrorCode(1_013_010_005, "拼团失败,原因:拼团活动商品不存在"); - ErrorCode COMBINATION_ACTIVITY_UPDATE_STOCK_FAIL = new ErrorCode(1_013_010_006, "拼团失败,原因:拼团活动商品库存不足"); - - // ========== 拼团记录 1-013-011-000 ========== - ErrorCode COMBINATION_RECORD_NOT_EXISTS = new ErrorCode(1_013_011_000, "拼团不存在"); - ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1_013_011_001, "拼团失败,已参与过该拼团"); - ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1_013_011_002, "拼团失败,父拼团不存在"); - ErrorCode COMBINATION_RECORD_USER_FULL = new ErrorCode(1_013_011_003, "拼团失败,拼团人数已满"); - ErrorCode COMBINATION_RECORD_FAILED_HAVE_JOINED = new ErrorCode(1_013_011_004, "拼团失败,原因:存在该活动正在进行的拼团记录"); - ErrorCode COMBINATION_RECORD_FAILED_TIME_NOT_START = new ErrorCode(1_013_011_005, "拼团失败,活动未开始"); - ErrorCode COMBINATION_RECORD_FAILED_TIME_END = new ErrorCode(1_013_011_006, "拼团失败,活动已经结束"); - ErrorCode COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED = new ErrorCode(1_013_011_007, "拼团失败,原因:单次限购超出"); - ErrorCode COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED = new ErrorCode(1_013_011_008, "拼团失败,原因:超出总购买次数"); - ErrorCode COMBINATION_RECORD_FAILED_ORDER_STATUS_UNPAID = new ErrorCode(1_013_011_009, "拼团失败,原因:存在未支付订单,请先支付"); - - // ========== 砍价活动 1-013-012-000 ========== - ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_012_000, "砍价活动不存在"); - ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_012_001, "存在商品参加了其它砍价活动"); - ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1_013_012_002, "砍价活动已关闭,不能修改"); - ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1_013_012_003, "砍价活动未关闭或未结束,不能删除"); - ErrorCode BARGAIN_ACTIVITY_STOCK_NOT_ENOUGH = new ErrorCode(1_013_012_004, "砍价活动库存不足"); - ErrorCode BARGAIN_ACTIVITY_STATUS_CLOSED = new ErrorCode(1_013_012_005, "砍价活动已关闭"); - ErrorCode BARGAIN_ACTIVITY_TIME_END = new ErrorCode(1_013_012_006, "砍价活动已经结束"); - - // ========== 砍价记录 1-013-013-000 ========== - ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1_013_013_000, "砍价记录不存在"); - ErrorCode BARGAIN_RECORD_CREATE_FAIL_EXISTS = new ErrorCode(1_013_013_001, "参与失败,您已经参与当前砍价活动"); - ErrorCode BARGAIN_RECORD_CREATE_FAIL_LIMIT = new ErrorCode(1_013_013_002, "参与失败,您已达到当前砍价活动的参与上限"); - ErrorCode BARGAIN_JOIN_RECORD_NOT_SUCCESS = new ErrorCode(1_013_013_004, "下单失败,砍价未成功"); - ErrorCode BARGAIN_JOIN_RECORD_ALREADY_ORDER = new ErrorCode(1_013_013_005, "下单失败,该砍价已经下单"); - - // ========== 砍价助力 1-013-014-000 ========== - ErrorCode BARGAIN_HELP_CREATE_FAIL_RECORD_NOT_IN_PROCESS = new ErrorCode(1_013_014_000, "助力失败,砍价记录不处于进行中"); - ErrorCode BARGAIN_HELP_CREATE_FAIL_RECORD_SELF = new ErrorCode(1_013_014_001, "助力失败,不能助力自己"); - ErrorCode BARGAIN_HELP_CREATE_FAIL_LIMIT = new ErrorCode(1_013_014_002, "助力失败,您已达到当前砍价活动的助力上限"); - ErrorCode BARGAIN_HELP_CREATE_FAIL_CONFLICT = new ErrorCode(1_013_014_003, "助力失败,请重试"); - ErrorCode BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS = new ErrorCode(1_013_014_004, "助力失败,您已经助力过了"); - - // ========== 文章分类 1-013-015-000 ========== - ErrorCode ARTICLE_CATEGORY_NOT_EXISTS = new ErrorCode(1_013_015_000, "文章分类不存在"); - ErrorCode ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES = new ErrorCode(1_013_015_001, "文章分类删除失败,存在关联文章"); - - // ========== 文章管理 1-013-016-000 ========== - ErrorCode ARTICLE_NOT_EXISTS = new ErrorCode(1_013_016_000, "文章不存在"); - - // ========== 装修模板 1-013-017-000 ========== - ErrorCode DIY_TEMPLATE_NOT_EXISTS = new ErrorCode(1_013_017_000, "装修模板不存在"); - ErrorCode DIY_TEMPLATE_NAME_USED = new ErrorCode(1_013_017_001, "装修模板名称({})已经被使用"); - ErrorCode DIY_TEMPLATE_USED_CANNOT_DELETE = new ErrorCode(1_013_017_002, "不能删除正在使用的装修模板"); - - // ========== 装修页面 1-013-018-000 ========== - ErrorCode DIY_PAGE_NOT_EXISTS = new ErrorCode(1_013_018_000, "装修页面不存在"); - ErrorCode DIY_PAGE_NAME_USED = new ErrorCode(1_013_018_001, "装修页面名称({})已经被使用"); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/banner/BannerPositionEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/banner/BannerPositionEnum.java deleted file mode 100644 index 8a8338c8a9..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/banner/BannerPositionEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.banner; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * Banner Position 枚举 - * - * @author HUIHUI - */ -@AllArgsConstructor -@Getter -public enum BannerPositionEnum implements IntArrayValuable { - - HOME_POSITION(1, "首页"), - SECKILL_POSITION(2, "秒杀活动页"), - COMBINATION_POSITION(3, "砍价活动页"), - DISCOUNT_POSITION(4, "限时折扣页"), - REWARD_POSITION(5, "满减送页"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BannerPositionEnum::getPosition).toArray(); - - /** - * 值 - */ - private final Integer position; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/bargain/BargainRecordStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/bargain/BargainRecordStatusEnum.java deleted file mode 100644 index d5c22a7c57..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/bargain/BargainRecordStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.bargain; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 砍价记录的状态枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum BargainRecordStatusEnum implements IntArrayValuable { - - IN_PROGRESS(1, "砍价中"), - SUCCESS(2, "砍价成功"), - FAILED(3, "砍价失败"), // 活动到期时,会自动将到期的砍价全部设置为过期 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BargainRecordStatusEnum::getStatus).toArray(); - - /** - * 值 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/combination/CombinationRecordStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/combination/CombinationRecordStatusEnum.java deleted file mode 100644 index 627e139468..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/combination/CombinationRecordStatusEnum.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.combination; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 拼团状态枚举 - * - * @author HUIHUI - */ -@AllArgsConstructor -@Getter -public enum CombinationRecordStatusEnum implements IntArrayValuable { - - IN_PROGRESS(0, "进行中"), - SUCCESS(1, "拼团成功"), - FAILED(2, "拼团失败"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CombinationRecordStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static boolean isSuccess(Integer status) { - return ObjectUtil.equal(status, SUCCESS.getStatus()); - } - - public static boolean isInProgress(Integer status) { - return ObjectUtil.equal(status, IN_PROGRESS.getStatus()); - } - - public static boolean isFailed(Integer status) { - return ObjectUtil.equal(status, FAILED.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java deleted file mode 100644 index db79f871b5..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 促销活动的状态枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum PromotionActivityStatusEnum implements IntArrayValuable { - - WAIT(10, "未开始"), - RUN(20, "进行中"), - END(30, "已结束"), - CLOSE(40, "已关闭"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionActivityStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionConditionTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionConditionTypeEnum.java deleted file mode 100644 index 05e62e3990..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionConditionTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销的条件类型枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum PromotionConditionTypeEnum implements IntArrayValuable { - - PRICE(10, "满 N 元"), - COUNT(20, "满 N 件"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionConditionTypeEnum::getType).toArray(); - - /** - * 类型值 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java deleted file mode 100644 index 7da6b4b08a..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠类型枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionDiscountTypeEnum implements IntArrayValuable { - - PRICE(1, "满减"), // 具体金额 - PERCENT(2, "折扣"), // 百分比 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionDiscountTypeEnum::getType).toArray(); - - /** - * 优惠类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java deleted file mode 100644 index 882dc4aee7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销的商品范围枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionProductScopeEnum implements IntArrayValuable { - - ALL(1, "通用券"), // 全部商品 - SPU(2, "商品券"), // 指定商品 - CATEGORY(3, "品类券"), // 指定品类 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionProductScopeEnum::getScope).toArray(); - - /** - * 范围值 - */ - private final Integer scope; - /** - * 范围名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java deleted file mode 100644 index 4524c198d6..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销类型枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionTypeEnum implements IntArrayValuable { - - SECKILL_ACTIVITY(1, "秒杀活动"), - BARGAIN_ACTIVITY(2, "砍价活动"), - COMBINATION_ACTIVITY(3, "拼团活动"), - - DISCOUNT_ACTIVITY(4, "限时折扣"), - REWARD_ACTIVITY(5, "满减送"), - - MEMBER_LEVEL(6, "会员折扣"), - COUPON(7, "优惠劵"), - POINT(8, "积分") - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionTypeEnum::getType).toArray(); - - /** - * 类型值 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponStatusEnum.java deleted file mode 100644 index 320345d85f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.coupon; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠劵状态枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum CouponStatusEnum implements IntArrayValuable { - - UNUSED(1, "未使用"), - USED(2, "已使用"), - EXPIRE(3, "已过期"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponStatusEnum::getStatus).toArray(); - - /** - * 值 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java deleted file mode 100644 index 1513e62ea8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.coupon; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠劵领取方式 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum CouponTakeTypeEnum implements IntArrayValuable { - - USER(1, "直接领取"), // 用户可在首页、每日领劵直接领取 - ADMIN(2, "指定发放"), // 后台指定会员赠送优惠劵 - REGISTER(3, "新人券"), // 注册时自动领取 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTakeTypeEnum::getValue).toArray(); - - /** - * 值 - */ - private final Integer value; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java deleted file mode 100644 index 391515de39..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.coupon; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠劵模板的有限期类型的枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum CouponTemplateValidityTypeEnum implements IntArrayValuable { - - DATE(1, "固定日期"), - TERM(2, "领取之后"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateValidityTypeEnum::getType).toArray(); - - /** - * 值 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecorateComponentEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecorateComponentEnum.java deleted file mode 100644 index 45bc1fe4d7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecorateComponentEnum.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.decorate; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 页面组件枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -@SuppressWarnings("JavadocLinkAsPlainText") -public enum DecorateComponentEnum { - - /** - * 格式:[{ - * "name": "标题" - * "picUrl": "https://www.iocoder.cn/xxx.png", - * "url": "/pages/users/index" - * }] - * - * 最多 10 个 - */ - MENU("menu", "菜单"), - /** - * 格式:[{ - * "name": "标题" - * "url": "/pages/users/index" - * }] - */ - ROLLING_NEWS("scrolling-news", "滚动新闻"), - /** - * 格式:[{ - * "picUrl": "https://www.iocoder.cn/xxx.png", - * "url": "/pages/users/index" - * }] - */ - SLIDE_SHOW("slide-show", "轮播图"), - /** - * 格式:[{ - * "name": "标题" - * "type": "类型", // best、hot、new、benefit、good - * "tag": "标签" // 例如说:多买多省 - * }] - * - * 最多 4 个 - */ - PRODUCT_RECOMMEND("product-recommend", "商品推荐"); - - /** - * 页面组件代码 - */ - private final String code; - - /** - * 页面组件说明 - */ - private final String desc; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageEnum.java deleted file mode 100644 index 3b662db7a7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.decorate; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 装修页面枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum DecoratePageEnum implements IntArrayValuable { - - INDEX(1, "首页"), - MY(2, "个人中心"), - ; - - private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getPage).toArray(); - - /** - * 页面编号 - */ - private final Integer page; - - /** - * 页面名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/pom.xml b/yudao-module-mall/yudao-module-promotion-biz/pom.xml deleted file mode 100644 index 5e42cf9bf0..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/pom.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-mall - ${revision} - - 4.0.0 - jar - yudao-module-promotion-biz - - ${project.artifactId} - - - promotion 模块,主要实现营销相关功能 - 例如:营销活动、banner 广告、优惠券、优惠码等功能。 - - - - - cn.iocoder.boot - yudao-module-promotion-api - ${revision} - - - cn.iocoder.boot - yudao-module-product-api - ${revision} - - - cn.iocoder.boot - yudao-module-trade-api - ${revision} - - - cn.iocoder.boot - yudao-module-member-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.boot - yudao-spring-boot-starter-web - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - - - - - cn.iocoder.boot - yudao-spring-boot-starter-excel - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-dict - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApiImpl.java deleted file mode 100644 index a817896464..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApiImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain; - -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -/** - * 砍价活动 Api 接口实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class BargainActivityApiImpl implements BargainActivityApi { - - @Resource - private BargainActivityService bargainActivityService; - - @Override - public void updateBargainActivityStock(Long id, Integer count) { - bargainActivityService.updateBargainActivityStock(id, count); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApiImpl.java deleted file mode 100644 index 3a8f0ad86b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApiImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain; - -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -/** - * 砍价活动 API 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class BargainRecordApiImpl implements BargainRecordApi { - - @Resource - private BargainRecordService bargainRecordService; - - @Override - public BargainValidateJoinRespDTO validateJoinBargain(Long userId, Long bargainRecordId, Long skuId) { - return bargainRecordService.validateJoinBargain(userId, bargainRecordId, skuId); - } - - @Override - public void updateBargainRecordOrderId(Long id, Long orderId) { - bargainRecordService.updateBargainRecordOrderId(id, orderId); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java deleted file mode 100644 index a9db09ec89..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination; - -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COMBINATION_RECORD_NOT_EXISTS; - -/** - * 拼团活动 API 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class CombinationRecordApiImpl implements CombinationRecordApi { - - @Resource - private CombinationRecordService recordService; - - @Override - public void validateCombinationRecord(Long userId, Long activityId, Long headId, Long skuId, Integer count) { - recordService.validateCombinationRecord(userId, activityId, headId, skuId, count); - } - - @Override - public CombinationRecordCreateRespDTO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { - return CombinationActivityConvert.INSTANCE.convert4(recordService.createCombinationRecord(reqDTO)); - } - - @Override - public boolean isCombinationRecordSuccess(Long userId, Long orderId) { - CombinationRecordDO record = recordService.getCombinationRecord(userId, orderId); - if (record == null) { - throw exception(COMBINATION_RECORD_NOT_EXISTS); - } - return CombinationRecordStatusEnum.isSuccess(record.getStatus()); - } - - @Override - public CombinationValidateJoinRespDTO validateJoinCombination(Long userId, Long activityId, Long headId, Long skuId, Integer count) { - return recordService.validateJoinCombination(userId, activityId, headId, skuId, count); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java deleted file mode 100644 index b7f904583e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon; - - -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -/** - * 优惠劵 API 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CouponApiImpl implements CouponApi { - - @Resource - private CouponService couponService; - - @Override - public void useCoupon(CouponUseReqDTO useReqDTO) { - couponService.useCoupon(useReqDTO.getId(), useReqDTO.getUserId(), - useReqDTO.getOrderId()); - } - - @Override - public void returnUsedCoupon(Long id) { - couponService.returnUsedCoupon(id); - } - - @Override - public CouponRespDTO validateCoupon(CouponValidReqDTO validReqDTO) { - CouponDO coupon = couponService.validCoupon(validReqDTO.getId(), validReqDTO.getUserId()); - return CouponConvert.INSTANCE.convert(coupon); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApiImpl.java deleted file mode 100644 index 82b8516f91..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApiImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.discount; - -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; -import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; -import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -/** - * 限时折扣 API 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class DiscountActivityApiImpl implements DiscountActivityApi { - - @Resource - private DiscountActivityService discountActivityService; - - @Override - public List getMatchDiscountProductList(Collection skuIds) { - return DiscountActivityConvert.INSTANCE.convertList02(discountActivityService.getMatchDiscountProductList(skuIds)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApiImpl.java deleted file mode 100644 index 936c791a3d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApiImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.reward; - -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -/** - * 满减送活动 API 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class RewardActivityApiImpl implements RewardActivityApi { - - @Resource - private RewardActivityService rewardActivityService; - - @Override - public List getMatchRewardActivityList(Collection spuIds) { - return rewardActivityService.getMatchRewardActivityList(spuIds); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java deleted file mode 100644 index d748f3766c..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.seckill; - -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -/** - * 秒杀活动接口 Api 接口实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class SeckillActivityApiImpl implements SeckillActivityApi { - - @Resource - private SeckillActivityService activityService; - - @Override - public void updateSeckillStockDecr(Long id, Long skuId, Integer count) { - activityService.updateSeckillStockDecr(id, skuId, count); - } - - @Override - public void updateSeckillStockIncr(Long id, Long skuId, Integer count) { - activityService.updateSeckillStockIncr(id, skuId, count); - } - - @Override - public SeckillValidateJoinRespDTO validateJoinSeckill(Long activityId, Long skuId, Integer count) { - return activityService.validateJoinSeckill(activityId, skuId, count); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleCategoryController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleCategoryController.java deleted file mode 100644 index 9d94c7e9d5..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleCategoryController.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.service.article.ArticleCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 文章分类") -@RestController -@RequestMapping("/promotion/article-category") -@Validated -public class ArticleCategoryController { - - @Resource - private ArticleCategoryService articleCategoryService; - - @PostMapping("/create") - @Operation(summary = "创建文章分类") - @PreAuthorize("@ss.hasPermission('promotion:article-category:create')") - public CommonResult createArticleCategory(@Valid @RequestBody ArticleCategoryCreateReqVO createReqVO) { - return success(articleCategoryService.createArticleCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新文章分类") - @PreAuthorize("@ss.hasPermission('promotion:article-category:update')") - public CommonResult updateArticleCategory(@Valid @RequestBody ArticleCategoryUpdateReqVO updateReqVO) { - articleCategoryService.updateArticleCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除文章分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:article-category:delete')") - public CommonResult deleteArticleCategory(@RequestParam("id") Long id) { - articleCategoryService.deleteArticleCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得文章分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") - public CommonResult getArticleCategory(@RequestParam("id") Long id) { - ArticleCategoryDO category = articleCategoryService.getArticleCategory(id); - return success(ArticleCategoryConvert.INSTANCE.convert(category)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取文章分类精简信息列表", description = "只包含被开启的文章分类,主要用于前端的下拉选项") - public CommonResult> getSimpleDeptList() { - // 获得分类列表,只要开启状态的 - List list = articleCategoryService.getArticleCategoryListByStatus(CommonStatusEnum.ENABLE.getStatus()); - // 降序排序后,返回给前端 - list.sort(Comparator.comparing(ArticleCategoryDO::getSort).reversed()); - return success(ArticleCategoryConvert.INSTANCE.convertList03(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得文章分类分页") - @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") - public CommonResult> getArticleCategoryPage(@Valid ArticleCategoryPageReqVO pageVO) { - PageResult pageResult = articleCategoryService.getArticleCategoryPage(pageVO); - return success(ArticleCategoryConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java deleted file mode 100644 index 62624da3c1..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import cn.iocoder.yudao.module.promotion.service.article.ArticleService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 文章管理") -@RestController -@RequestMapping("/promotion/article") -@Validated -public class ArticleController { - - @Resource - private ArticleService articleService; - - @PostMapping("/create") - @Operation(summary = "创建文章管理") - @PreAuthorize("@ss.hasPermission('promotion:article:create')") - public CommonResult createArticle(@Valid @RequestBody ArticleCreateReqVO createReqVO) { - return success(articleService.createArticle(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新文章管理") - @PreAuthorize("@ss.hasPermission('promotion:article:update')") - public CommonResult updateArticle(@Valid @RequestBody ArticleUpdateReqVO updateReqVO) { - articleService.updateArticle(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除文章管理") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:article:delete')") - public CommonResult deleteArticle(@RequestParam("id") Long id) { - articleService.deleteArticle(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得文章管理") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:article:query')") - public CommonResult getArticle(@RequestParam("id") Long id) { - ArticleDO article = articleService.getArticle(id); - return success(ArticleConvert.INSTANCE.convert(article)); - } - - @GetMapping("/page") - @Operation(summary = "获得文章管理分页") - @PreAuthorize("@ss.hasPermission('promotion:article:query')") - public CommonResult> getArticlePage(@Valid ArticlePageReqVO pageVO) { - PageResult pageResult = articleService.getArticlePage(pageVO); - return success(ArticleConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java deleted file mode 100644 index c2c14b4de4..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 文章管理 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class ArticleBaseVO { - - @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15458") - @NotNull(message = "文章分类编号不能为空") - private Long categoryId; - - @Schema(description = "关联商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22378") - @NotNull(message = "关联商品不能为空") - private Long spuId; - - @Schema(description = "文章标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个标题") - @NotNull(message = "文章标题不能为空") - private String title; - - @Schema(description = "文章作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String author; - - @Schema(description = "文章封面图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") - @NotNull(message = "文章封面图片地址不能为空") - private String picUrl; - - @Schema(description = "文章简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个简介") - private String introduction; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "是否热门(小程序)", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否热门(小程序)不能为空") - private Boolean recommendHot; - - @Schema(description = "是否轮播图(小程序)", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否轮播图(小程序)不能为空") - private Boolean recommendBanner; - - @Schema(description = "文章内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是文章内容") - @NotNull(message = "文章内容不能为空") - private String content; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java deleted file mode 100644 index d598dd7687..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 文章管理创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCreateReqVO extends ArticleBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java deleted file mode 100644 index 9c75395853..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 文章管理分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticlePageReqVO extends PageParam { - - @Schema(description = "文章分类编号", example = "15458") - private Long categoryId; - - @Schema(description = "关联商品编号", example = "22378") - private Long spuId; - - @Schema(description = "文章标题") - private String title; - - @Schema(description = "文章作者") - private String author; - - @Schema(description = "状态", example = "2") - private Integer status; - - @Schema(description = "是否热门(小程序)") - private Boolean recommendHot; - - @Schema(description = "是否轮播图(小程序)") - private Boolean recommendBanner; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java deleted file mode 100644 index 3f9281a179..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 文章管理 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleRespVO extends ArticleBaseVO { - - @Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8606") - private Long id; - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "99999") - private Integer browseCount; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java deleted file mode 100644 index f17bd79f9a..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 文章管理更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleUpdateReqVO extends ArticleBaseVO { - - @Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8606") - @NotNull(message = "文章编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryBaseVO.java deleted file mode 100644 index 11a79f7e7a..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryBaseVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 文章分类 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class ArticleCategoryBaseVO { - - @Schema(description = "文章分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "秒杀") - @NotNull(message = "文章分类名称不能为空") - private String name; - - @Schema(description = "图标地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") - private String picUrl; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "排序不能为空") - private Integer sort; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryCreateReqVO.java deleted file mode 100644 index a8dc1f2e1f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 文章分类创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCategoryCreateReqVO extends ArticleCategoryBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryPageReqVO.java deleted file mode 100644 index b161aae08e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 文章分类分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCategoryPageReqVO extends PageParam { - - @Schema(description = "文章分类名称", example = "秒杀") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryRespVO.java deleted file mode 100644 index af4b045a70..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 文章分类 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCategoryRespVO extends ArticleCategoryBaseVO { - - @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategorySimpleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategorySimpleRespVO.java deleted file mode 100644 index 4e43326c9d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategorySimpleRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 文章分类精简信息 Response VO") -@Data -public class ArticleCategorySimpleRespVO { - - @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490") - private Long id; - - @Schema(description = "文章分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "秒杀") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryUpdateReqVO.java deleted file mode 100644 index a1aa2a55b4..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 文章分类更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCategoryUpdateReqVO extends ArticleCategoryBaseVO { - - @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490") - @NotNull(message = "文章分类编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java deleted file mode 100644 index 2deaff240f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import cn.iocoder.yudao.module.promotion.service.banner.BannerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - Banner 管理") -@RestController -@RequestMapping("/promotion/banner") -@Validated -public class BannerController { - - @Resource - private BannerService bannerService; - - @PostMapping("/create") - @Operation(summary = "创建 Banner") - @PreAuthorize("@ss.hasPermission('promotion:banner:create')") - public CommonResult createBanner(@Valid @RequestBody BannerCreateReqVO createReqVO) { - return success(bannerService.createBanner(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新 Banner") - @PreAuthorize("@ss.hasPermission('promotion:banner:update')") - public CommonResult updateBanner(@Valid @RequestBody BannerUpdateReqVO updateReqVO) { - bannerService.updateBanner(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除 Banner") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:banner:delete')") - public CommonResult deleteBanner(@RequestParam("id") Long id) { - bannerService.deleteBanner(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得 Banner") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:banner:query')") - public CommonResult getBanner(@RequestParam("id") Long id) { - BannerDO banner = bannerService.getBanner(id); - return success(BannerConvert.INSTANCE.convert(banner)); - } - - @GetMapping("/page") - @Operation(summary = "获得 Banner 分页") - @PreAuthorize("@ss.hasPermission('promotion:banner:query')") - public CommonResult> getBannerPage(@Valid BannerPageReqVO pageVO) { - PageResult pageResult = bannerService.getBannerPage(pageVO); - return success(BannerConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerBaseVO.java deleted file mode 100644 index 63676a4412..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerBaseVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.banner.BannerPositionEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * Banner Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * @author xia - */ -@Data -public class BannerBaseVO { - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "标题不能为空") - private String title; - - @Schema(description = "跳转链接", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "跳转链接不能为空") - private String url; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "图片地址不能为空") - private String picUrl; - - @Schema(description = "position", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "position 不能为空") - @InEnum(BannerPositionEnum.class) - private Integer position; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "备注") - private String memo; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerCreateReqVO.java deleted file mode 100644 index 180cdfe878..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerCreateReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -/** - * @author xia - */ -@Schema(description = "管理后台 - Banner 创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BannerCreateReqVO extends BannerBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java deleted file mode 100644 index c2ac49d716..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - Banner 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BannerPageReqVO extends PageParam { - - @Schema(description = "标题", example = "这是一个标题") - private String title; - - @Schema(description = "状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerRespVO.java deleted file mode 100644 index 2eee606e19..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - Banner Response VO") -@Data -@ToString(callSuper = true) -public class BannerRespVO extends BannerBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerUpdateReqVO.java deleted file mode 100644 index 880486360c..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerUpdateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -/** - * @author xia - */ -@Schema(description = "管理后台 - Banner更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BannerUpdateReqVO extends BannerBaseVO { - - @Schema(description = "banner 编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "banner 编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java deleted file mode 100644 index 5392887096..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.*; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - 砍价活动") -@RestController -@RequestMapping("/promotion/bargain-activity") -@Validated -public class BargainActivityController { - - @Resource - private BargainActivityService bargainActivityService; - @Resource - private BargainRecordService bargainRecordService; - @Resource - private BargainHelpService bargainHelpService; - - @Resource - private ProductSpuApi spuApi; - - @PostMapping("/create") - @Operation(summary = "创建砍价活动") - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:create')") - public CommonResult createBargainActivity(@Valid @RequestBody BargainActivityCreateReqVO createReqVO) { - return success(bargainActivityService.createBargainActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新砍价活动") - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:update')") - public CommonResult updateBargainActivity(@Valid @RequestBody BargainActivityUpdateReqVO updateReqVO) { - bargainActivityService.updateBargainActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭砍价活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:close')") - public CommonResult closeSeckillActivity(@RequestParam("id") Long id) { - bargainActivityService.closeBargainActivityById(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除砍价活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:delete')") - public CommonResult deleteBargainActivity(@RequestParam("id") Long id) { - bargainActivityService.deleteBargainActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得砍价活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')") - public CommonResult getBargainActivity(@RequestParam("id") Long id) { - return success(BargainActivityConvert.INSTANCE.convert(bargainActivityService.getBargainActivity(id))); - } - - @GetMapping("/page") - @Operation(summary = "获得砍价活动分页") - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')") - public CommonResult> getBargainActivityPage( - @Valid BargainActivityPageReqVO pageVO) { - // 查询砍价活动 - PageResult pageResult = bargainActivityService.getBargainActivityPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - List spuList = spuApi.getSpuList(convertList(pageResult.getList(), BargainActivityDO::getSpuId)); - // 统计数据 - Collection activityIds = convertList(pageResult.getList(), BargainActivityDO::getId); - Map recordUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds, null); - Map recordSuccessUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds, - BargainRecordStatusEnum.SUCCESS.getStatus()); - Map helpUserCountMap = bargainHelpService.getBargainHelpUserCountMapByActivity(activityIds); - return success(BargainActivityConvert.INSTANCE.convertPage(pageResult, spuList, - recordUserCountMap, recordSuccessUserCountMap, helpUserCountMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainHelpController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainHelpController.java deleted file mode 100644 index 57a2f5acba..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainHelpController.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpRespVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainHelpConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 砍价助力") -@RestController -@RequestMapping("/promotion/bargain-help") -@Validated -public class BargainHelpController { - - @Resource - private BargainHelpService bargainHelpService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @Operation(summary = "获得砍价助力分页") - @PreAuthorize("@ss.hasPermission('promotion:bargain-help:query')") - public CommonResult> getBargainHelpPage(@Valid BargainHelpPageReqVO pageVO) { - PageResult pageResult = bargainHelpService.getBargainHelpPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - Map userMap = memberUserApi.getUserMap( - convertSet(pageResult.getList(), BargainHelpDO::getUserId)); - return success(BargainHelpConvert.INSTANCE.convertPage(pageResult, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainRecordController.java deleted file mode 100644 index e3c1c1c3e6..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainRecordController.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainRecordConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 砍价记录") -@RestController -@RequestMapping("/promotion/bargain-record") -@Validated -public class BargainRecordController { - - @Resource - private BargainRecordService bargainRecordService; - @Resource - private BargainActivityService bargainActivityService; - @Resource - private BargainHelpService bargainHelpService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @Operation(summary = "获得砍价记录分页") - @PreAuthorize("@ss.hasPermission('promotion:bargain-record:query')") - public CommonResult> getBargainRecordPage(@Valid BargainRecordPageReqVO pageVO) { - PageResult pageResult = bargainRecordService.getBargainRecordPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - Map userMap = memberUserApi.getUserMap( - convertSet(pageResult.getList(), BargainRecordDO::getUserId)); - List activityList = bargainActivityService.getBargainActivityList( - convertSet(pageResult.getList(), BargainRecordDO::getActivityId)); - Map helpCountMap = bargainHelpService.getBargainHelpUserCountMapByRecord( - convertSet(pageResult.getList(), BargainRecordDO::getId)); - return success(BargainRecordConvert.INSTANCE.convertPage(pageResult, helpCountMap, activityList, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityBaseVO.java deleted file mode 100644 index 0c239ccb57..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityBaseVO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 砍价活动 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class BargainActivityBaseVO { - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "砍得越多省得越多,是兄弟就来砍我") - @NotNull(message = "砍价名称不能为空") - private String name; - - @Schema(description = "商品 SPU 编号", example = "1") - @NotNull(message = "砍价商品不能为空") - private Long spuId; - - @Schema(description = "商品 skuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - @NotNull(message = "商品 skuId 不能为空") - private Long skuId; - - @Schema(description = "砍价起始价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - @NotNull(message = "砍价起始价格不能为空") - private Integer bargainFirstPrice; - - @Schema(description = "砍价底价", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - @NotNull(message = "砍价底价不能为空") - private Integer bargainMinPrice; - - @Schema(description = "活动库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - @NotNull(message = "活动库存不能为空") - private Integer stock; - - @Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "16218") - @NotNull(message = "总限购数量不能为空") - private Integer totalLimitCount; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]") - @NotNull(message = "活动开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]") - @NotNull(message = "活动结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "最大助力次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "最大助力次数不能为空") - private Integer helpMaxCount; - - @Schema(description = "最大帮砍次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "最大帮砍次数不能为空") - private Integer bargainCount; - - @Schema(description = "用户每次砍价的最小金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "用户每次砍价的最小金额不能为空") - private Integer randomMinPrice; - - @Schema(description = "用户每次砍价的最大金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "用户每次砍价的最大金额不能为空") - private Integer randomMaxPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityCreateReqVO.java deleted file mode 100644 index 83cb5eaf90..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 砍价活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityCreateReqVO extends BargainActivityBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageItemRespVO.java deleted file mode 100644 index c6cb501837..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageItemRespVO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 砍价活动的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityPageItemRespVO extends BargainActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促") - private String spuName; - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "活动状态不能为空") - private Integer status; - - @Schema(description = "活动总库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - private Integer totalStock; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") - private LocalDateTime createTime; - - // ========== 统计字段 ========== - - @Schema(description = "总砍价的用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "999") - private Integer recordUserCount; - - @Schema(description = "成功砍价的用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "500") - private Integer recordSuccessUserCount; - - @Schema(description = "帮助砍价的用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Integer helpUserCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageReqVO.java deleted file mode 100644 index 66f23730f5..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 砍价活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityPageReqVO extends PageParam { - - @Schema(description = "砍价名称", example = "赵六") - private String name; - - @Schema(description = "活动状态", example = "0") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java deleted file mode 100644 index 0295fddc54..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -@Schema(description = "管理后台 - 砍价活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityRespVO extends BargainActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityUpdateReqVO.java deleted file mode 100644 index 3f451183fc..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 砍价活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityUpdateReqVO extends BargainActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - @NotNull(message = "活动编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpBaseVO.java deleted file mode 100644 index 580d191ffd..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpBaseVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 砍价助力 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BargainHelpBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5402") - private Long userId; - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "16825") - private Long activityId; - - @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1800") - private Long recordId; - - @Schema(description = "减少砍价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "32300") - private Integer reducePrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpPageReqVO.java deleted file mode 100644 index 8afbe3ff65..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 砍价助力分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainHelpPageReqVO extends PageParam { - - @Schema(description = "砍价记录编号", example = "1800") - private Long recordId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpRespVO.java deleted file mode 100644 index ba07c59eb0..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 砍价助力 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainHelpRespVO extends BargainHelpBaseVO { - - @Schema(description = "砍价助力编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25860") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 用户相关 ========== - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordBaseVO.java deleted file mode 100644 index 2c743196b8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordBaseVO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 砍价记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BargainRecordBaseVO { - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "22690") - @NotNull(message = "砍价活动名称不能为空") - private Long activityId; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9430") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23622") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29950") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "31160") - @NotNull(message = "砍价起始价格,单位:分不能为空") - private Integer bargainFirstPrice; - - @Schema(description = "当前砍价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "22743") - @NotNull(message = "当前砍价,单位:分不能为空") - private Integer bargainPrice; - - @Schema(description = "砍价状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "砍价状态不能为空") - private Integer status; - - @Schema(description = "订单编号", example = "27845") - private Long orderId; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageItemRespVO.java deleted file mode 100644 index 608ed3090b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageItemRespVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod; - -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 砍价记录的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainRecordPageItemRespVO extends BargainRecordBaseVO { - - @Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") - private LocalDateTime createTime; - - @Schema(description = "帮砍次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer helpCount; - - // ========== 用户相关 ========== - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - // ========== 活动相关 ========== - - private BargainActivityRespVO activity; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageReqVO.java deleted file mode 100644 index 47b6718779..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 砍价记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainRecordPageReqVO extends PageParam { - - @Schema(description = "砍价状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationActivityController.java deleted file mode 100644 index b4befc3f57..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationActivityController.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.*; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.hutool.core.collection.CollectionUtil.newArrayList; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 拼团活动") -@RestController -@RequestMapping("/promotion/combination-activity") -@Validated -public class CombinationActivityController { - - @Resource - private CombinationActivityService combinationActivityService; - @Resource - private CombinationRecordService combinationRecordService; - - @Resource - private ProductSpuApi productSpuApi; - - @PostMapping("/create") - @Operation(summary = "创建拼团活动") - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:create')") - public CommonResult createCombinationActivity(@Valid @RequestBody CombinationActivityCreateReqVO createReqVO) { - return success(combinationActivityService.createCombinationActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新拼团活动") - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:update')") - public CommonResult updateCombinationActivity(@Valid @RequestBody CombinationActivityUpdateReqVO updateReqVO) { - combinationActivityService.updateCombinationActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭拼团活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:close')") - public CommonResult closeSeckillActivity(@RequestParam("id") Long id) { - combinationActivityService.closeCombinationActivityById(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除拼团活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:delete')") - public CommonResult deleteCombinationActivity(@RequestParam("id") Long id) { - combinationActivityService.deleteCombinationActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得拼团活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:query')") - public CommonResult getCombinationActivity(@RequestParam("id") Long id) { - CombinationActivityDO activity = combinationActivityService.getCombinationActivity(id); - List products = combinationActivityService.getCombinationProductListByActivityIds(newArrayList(id)); - return success(CombinationActivityConvert.INSTANCE.convert(activity, products)); - } - - @GetMapping("/page") - @Operation(summary = "获得拼团活动分页") - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:query')") - public CommonResult> getCombinationActivityPage( - @Valid CombinationActivityPageReqVO pageVO) { - // 查询拼团活动 - PageResult pageResult = combinationActivityService.getCombinationActivityPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 统计数据 - Set activityIds = convertSet(pageResult.getList(), CombinationActivityDO::getId); - Map groupCountMap = combinationRecordService.getCombinationRecordCountMapByActivity( - activityIds, null, CombinationRecordDO.HEAD_ID_GROUP); - Map groupSuccessCountMap = combinationRecordService.getCombinationRecordCountMapByActivity( - activityIds, CombinationRecordStatusEnum.SUCCESS.getStatus(), CombinationRecordDO.HEAD_ID_GROUP); - Map recordCountMap = combinationRecordService.getCombinationRecordCountMapByActivity( - activityIds, null, null); - // 拼接数据 - List products = combinationActivityService.getCombinationProductListByActivityIds( - convertSet(pageResult.getList(), CombinationActivityDO::getId)); - List spus = productSpuApi.getSpuList( - convertSet(pageResult.getList(), CombinationActivityDO::getSpuId)); - return success(CombinationActivityConvert.INSTANCE.convertPage(pageResult, products, - groupCountMap, groupSuccessCountMap, recordCountMap, spus)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java deleted file mode 100644 index b72215572f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordSummaryVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.context.annotation.Lazy; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 拼团记录") -@RestController -@RequestMapping("/promotion/combination-record") -@Validated -public class CombinationRecordController { - - @Resource - private CombinationActivityService combinationActivityService; - @Resource - @Lazy - private CombinationRecordService combinationRecordService; - - @GetMapping("/page") - @Operation(summary = "获得拼团记录分页") - @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") - public CommonResult> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) { - PageResult recordPage = combinationRecordService.getCombinationRecordPage(pageVO); - // 拼接数据 - List activities = combinationActivityService.getCombinationActivityListByIds( - convertSet(recordPage.getList(), CombinationRecordDO::getActivityId)); - List products = combinationActivityService.getCombinationProductListByActivityIds( - convertSet(recordPage.getList(), CombinationRecordDO::getActivityId)); - return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities, products)); - } - - @GetMapping("/get-summary") - @Operation(summary = "获得拼团记录的概要信息", description = "用于拼团记录页面展示") - @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") - public CommonResult getCombinationRecordSummary() { - CombinationRecordSummaryVO summaryVO = new CombinationRecordSummaryVO(); - summaryVO.setUserCount(combinationRecordService.getCombinationUserCount()); // 获取拼团用户参与数量 - summaryVO.setSuccessCount(combinationRecordService.getCombinationRecordCount( // 获取成团记录 - CombinationRecordStatusEnum.SUCCESS.getStatus(), null, CombinationRecordDO.HEAD_ID_GROUP)); - summaryVO.setVirtualGroupCount(combinationRecordService.getCombinationRecordCount(// 获取虚拟成团记录 - null, Boolean.TRUE, CombinationRecordDO.HEAD_ID_GROUP)); - return success(summaryVO); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityBaseVO.java deleted file mode 100644 index 624ef169f6..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityBaseVO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 拼团活动 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class CombinationActivityBaseVO { - - @Schema(description = "拼团名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "越拼越省钱") - @NotNull(message = "拼团名称不能为空") - private String name; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "拼团商品不能为空") - private Long spuId; - - @Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "16218") - @NotNull(message = "总限购数量不能为空") - private Integer totalLimitCount; - - @Schema(description = "单次限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "28265") - @NotNull(message = "单次限购数量不能为空") - private Integer singleLimitCount; - - @Schema(description = "活动时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]") - @NotNull(message = "活动时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "活动时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]") - @NotNull(message = "活动时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "开团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "开团人数不能为空") - private Integer userSize; - - @Schema(description = "虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - @NotNull(message = "虚拟成团不能为空") - private Boolean virtualGroup; - - @Schema(description = "限制时长(小时)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "限制时长不能为空") - private Integer limitDuration; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityCreateReqVO.java deleted file mode 100644 index 0081c3fa81..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityCreateReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.Valid; -import java.util.List; - -@Schema(description = "管理后台 - 拼团活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityCreateReqVO extends CombinationActivityBaseVO { - - @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageItemRespVO.java deleted file mode 100644 index 0151adfb9a..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageItemRespVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 拼团活动的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityPageItemRespVO extends CombinationActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - // ========== 商品字段 ========== - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 - example = "618大促") - private String spuName; - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - - // ========== 统计字段 ========== - - @Schema(description = "开团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "33") - private Integer groupCount; - - @Schema(description = "成团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer groupSuccessCount; - - @Schema(description = "购买次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer recordCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageReqVO.java deleted file mode 100644 index bfb54b7301..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 拼团活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityPageReqVO extends PageParam { - - @Schema(description = "拼团名称", example = "赵六") - private String name; - - @Schema(description = "活动状态", example = "0") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityRespVO.java deleted file mode 100644 index 0ac77c559e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 拼团活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityRespVO extends CombinationActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "开团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") - private Integer userSize; - - @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityUpdateReqVO.java deleted file mode 100644 index 0423a5f2cf..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityUpdateReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 拼团活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityUpdateReqVO extends CombinationActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - @NotNull(message = "活动编号不能为空") - private Long id; - - @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductBaseVO.java deleted file mode 100644 index 79693e3d6d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductBaseVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 拼团商品 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class CombinationProductBaseVO { - - @Schema(description = "商品 spuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "30563") - @NotNull(message = "商品 spuId 不能为空") - private Long spuId; - - @Schema(description = "商品 skuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "30563") - @NotNull(message = "商品 skuId 不能为空") - private Long skuId; - - @Schema(description = "拼团价格,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "27682") - @NotNull(message = "拼团价格不能为空") - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductPageReqVO.java deleted file mode 100644 index 02bcc070c8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductPageReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 拼团商品分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationProductPageReqVO extends PageParam { - - @Schema(description = "拼团活动编号", example = "6829") - private Long activityId; - - @Schema(description = "商品 SPU 编号", example = "18731") - private Long spuId; - - @Schema(description = "商品 SKU 编号", example = "31675") - private Long skuId; - - @Schema(description = "拼团商品状态", example = "2") - private Integer activityStatus; - - @Schema(description = "活动开始时间点") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] activityStartTime; - - @Schema(description = "活动结束时间点") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] activityEndTime; - - @Schema(description = "拼团价格,单位分", example = "27682") - private Integer activePrice; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductRespVO.java deleted file mode 100644 index eeac5c3b5e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 拼团商品 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationProductRespVO extends CombinationProductBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28322") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordBaseVO.java deleted file mode 100644 index 67fab5b0d8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordBaseVO.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 拼团记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class CombinationRecordBaseVO { - - @Schema(description = "拼团记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long activityId; - - @Schema(description = "团长编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long headId; - - // ========== 用户相关 ========== - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9430") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - // ========== 商品相关 ========== - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23622") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29950") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是大黄豆") - private String spuName; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime expireTime; - - @Schema(description = "可参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer userSize; - - @Schema(description = "已参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer userCount; - - @Schema(description = "拼团状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "是否虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean virtualGroup; - - @Schema(description = "开始时间 (订单付款后开始的时间)", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间(成团时间/失败时间)", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordPageItemRespVO.java deleted file mode 100644 index 7b1b10bacd..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordPageItemRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 拼团记录的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationRecordPageItemRespVO extends CombinationRecordBaseVO { - - // ========== 活动相关 ========== - - private CombinationActivityRespVO activity; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPage2VO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPage2VO.java deleted file mode 100644 index bddaf2a448..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPage2VO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 拼团记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationRecordReqPage2VO extends PageParam { - - @Schema(description = "团长编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "团长编号不能为空") - private Long headId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java deleted file mode 100644 index a66795d64b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 拼团记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationRecordReqPageVO extends PageParam { - - @Schema(description = "活动状态", example = "1") - @InEnum(BargainRecordStatusEnum.class) - private Integer status; - - @Schema(description = "团长编号", example = "1024") - private Long headId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordSummaryVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordSummaryVO.java deleted file mode 100644 index 64d63afe0d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordSummaryVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 拼团记录信息统计 Response VO") -@Data -public class CombinationRecordSummaryVO { - - @Schema(description = "所有拼团记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userCount; - - @Schema(description = "成团记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long successCount; - - @Schema(description = "虚拟成团记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long virtualGroupCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java deleted file mode 100755 index 8dfc99ad4f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponSendReqVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 优惠劵") -@RestController -@RequestMapping("/promotion/coupon") -@Validated -public class CouponController { - - @Resource - private CouponService couponService; - @Resource - private MemberUserApi memberUserApi; - - @DeleteMapping("/delete") - @Operation(summary = "回收优惠劵") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:coupon:delete')") - public CommonResult deleteCoupon(@RequestParam("id") Long id) { - couponService.deleteCoupon(id); - return success(true); - } - - @GetMapping("/page") - @Operation(summary = "获得优惠劵分页") - @PreAuthorize("@ss.hasPermission('promotion:coupon:query')") - public CommonResult> getCouponPage(@Valid CouponPageReqVO pageVO) { - PageResult pageResult = couponService.getCouponPage(pageVO); - PageResult pageResulVO = CouponConvert.INSTANCE.convertPage(pageResult); - if (CollUtil.isEmpty(pageResulVO.getList())) { - return success(pageResulVO); - } - - // 读取用户信息,进行拼接 - Map userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), CouponDO::getUserId)); - pageResulVO.getList().forEach(itemRespVO -> MapUtils.findAndThen(userMap, itemRespVO.getUserId(), - userRespDTO -> itemRespVO.setNickname(userRespDTO.getNickname()))); - return success(pageResulVO); - } - - @PostMapping("/send") - @Operation(summary = "发送优惠劵") - @PreAuthorize("@ss.hasPermission('promotion:coupon:send')") - public CommonResult sendCoupon(@Valid @RequestBody CouponSendReqVO reqVO) { - couponService.takeCouponByAdmin(reqVO.getTemplateId(), reqVO.getUserIds()); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java deleted file mode 100755 index 961836a36f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.*; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 优惠劵模板") -@RestController -@RequestMapping("/promotion/coupon-template") -@Validated -public class CouponTemplateController { - - @Resource - private CouponTemplateService couponTemplateService; - - @PostMapping("/create") - @Operation(summary = "创建优惠劵模板") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:create')") - public CommonResult createCouponTemplate(@Valid @RequestBody CouponTemplateCreateReqVO createReqVO) { - return success(couponTemplateService.createCouponTemplate(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新优惠劵模板") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:update')") - public CommonResult updateCouponTemplate(@Valid @RequestBody CouponTemplateUpdateReqVO updateReqVO) { - couponTemplateService.updateCouponTemplate(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新优惠劵模板状态") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:update')") - public CommonResult updateCouponTemplateStatus(@Valid @RequestBody CouponTemplateUpdateStatusReqVO reqVO) { - couponTemplateService.updateCouponTemplateStatus(reqVO.getId(), reqVO.getStatus()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除优惠劵模板") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:delete')") - public CommonResult deleteCouponTemplate(@RequestParam("id") Long id) { - couponTemplateService.deleteCouponTemplate(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得优惠劵模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") - public CommonResult getCouponTemplate(@RequestParam("id") Long id) { - CouponTemplateDO couponTemplate = couponTemplateService.getCouponTemplate(id); - return success(CouponTemplateConvert.INSTANCE.convert(couponTemplate)); - } - - @GetMapping("/page") - @Operation(summary = "获得优惠劵模板分页") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") - public CommonResult> getCouponTemplatePage(@Valid CouponTemplatePageReqVO pageVO) { - PageResult pageResult = couponTemplateService.getCouponTemplatePage(pageVO); - return success(CouponTemplateConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list") - @Operation(summary = "获得优惠劵模板列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") - public CommonResult> getCouponTemplateList(@RequestParam("ids") Collection ids) { - List list = couponTemplateService.getCouponTemplateList(ids); - return success(CouponTemplateConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java deleted file mode 100755 index f822a60f87..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** -* 优惠劵 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class CouponBaseVO { - - // ========== 基本信息 BEGIN ========== - @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "优惠劵模板编号不能为空") - private Long templateId; - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - @NotNull(message = "优惠劵名不能为空") - private String name; - - @Schema(description = "优惠码状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取情况 BEGIN ========== - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "领取方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "领取方式不能为空") - private Integer takeType; - // ========== 领取情况 END ========== - - // ========== 使用规则 BEGIN ========== - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 单位:分;0 - 不限制 - @NotNull(message = "是否设置满多少金额可用不能为空") - private Integer usePrice; - - @Schema(description = "固定日期 - 生效开始时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validEndTime; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品范围不能为空") - @InEnum(PromotionProductScopeEnum.class) - private Integer productScope; - - @Schema(description = "商品范围编号的数组", example = "1,3") - private List productScopeValues; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "优惠类型不能为空") - @InEnum(PromotionDiscountTypeEnum.class) - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 使用情况 BEGIN ========== - - @Schema(description = "使用订单号", example = "4096") - private Long useOrderId; - - @Schema(description = "使用时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime useTime; - - // ========== 使用情况 END ========== - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageItemRespVO.java deleted file mode 100755 index 118736ef68..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageItemRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 优惠劵分页的每一项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponPageItemRespVO extends CouponRespVO { - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageReqVO.java deleted file mode 100755 index 75aa2f74b8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.Collection; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 优惠劵分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponPageReqVO extends PageParam { - - @Schema(description = "优惠劵模板编号", example = "2048") - private Long templateId; - - @Schema(description = "优惠码状态", example = "1") - @InEnum(value = CouponStatusEnum.class, message = "优惠劵状态,必须是 {value}") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "用户昵称", example = "芋艿") - private String nickname; - - @Schema(description = "用户编号", example = "1") - private Collection userIds; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponRespVO.java deleted file mode 100755 index 7c0fa6c86c..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 优惠劵 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponRespVO extends CouponBaseVO { - - @Schema(description = "优惠劵编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponSendReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponSendReqVO.java deleted file mode 100644 index 2c2c2aa489..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponSendReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.Set; - -@Schema(description = "管理后台 - 优惠劵发放 Request VO") -@Data -@ToString(callSuper = true) -public class CouponSendReqVO { - - @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "优惠劵模板编号不能为空") - private Long templateId; - - @Schema(description = "用户编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") - @NotEmpty(message = "用户编号列表不能为空") - private Set userIds; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java deleted file mode 100755 index 419a3f443c..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java +++ /dev/null @@ -1,154 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.AssertTrue; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** -* 优惠劵模板 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class CouponTemplateBaseVO { - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - @NotNull(message = "优惠劵名不能为空") - private String name; - - @Schema(description = "发行总量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") // -1 - 则表示不限制发放数量 - @NotNull(message = "发行总量不能为空") - private Integer totalCount; - - @Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制 - @NotNull(message = "每人限领个数不能为空") - private Integer takeLimitCount; - - @Schema(description = "领取方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "领取方式不能为空") - private Integer takeType; - - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 单位:分;0 - 不限制 - @NotNull(message = "是否设置满多少金额可用不能为空") - private Integer usePrice; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品范围不能为空") - @InEnum(PromotionProductScopeEnum.class) - private Integer productScope; - - @Schema(description = "商品范围编号的数组", example = "[1, 3]") - private List productScopeValues; - - @Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "生效日期类型不能为空") - @InEnum(CouponTemplateValidityTypeEnum.class) - private Integer validityType; - - @Schema(description = "固定日期 - 生效开始时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validEndTime; - - @Schema(description = "领取日期 - 开始天数") - @Min(value = 0L, message = "开始天数必须大于 0") - private Integer fixedStartTerm; - - @Schema(description = "领取日期 - 结束天数") - @Min(value = 1L, message = "开始天数必须大于 1") - private Integer fixedEndTerm; - - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "优惠类型不能为空") - @InEnum(PromotionDiscountTypeEnum.class) - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 - private Integer discountLimitPrice; - - @AssertTrue(message = "商品范围编号的数组不能为空") - @JsonIgnore - public boolean isProductScopeValuesValid() { - return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空 - || CollUtil.isNotEmpty(productScopeValues); - } - - @AssertTrue(message = "生效开始时间不能为空") - @JsonIgnore - public boolean isValidStartTimeValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.DATE.getType()) - || validStartTime != null; - } - - @AssertTrue(message = "生效结束时间不能为空") - @JsonIgnore - public boolean isValidEndTimeValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.DATE.getType()) - || validEndTime != null; - } - - @AssertTrue(message = "开始天数不能为空") - @JsonIgnore - public boolean isFixedStartTermValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.TERM.getType()) - || fixedStartTerm != null; - } - - @AssertTrue(message = "结束天数不能为空") - @JsonIgnore - public boolean isFixedEndTermValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.TERM.getType()) - || fixedEndTerm != null; - } - - @AssertTrue(message = "折扣百分比需要大于等于 1,小于等于 99") - @JsonIgnore - public boolean isDiscountPercentValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) - || (discountPercent != null && discountPercent >= 1 && discountPercent<= 99); - } - - @AssertTrue(message = "优惠金额不能为空") - @JsonIgnore - public boolean isDiscountPriceValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PRICE.getType()) - || discountPrice != null; - } - - @AssertTrue(message = "折扣上限不能为空") - @JsonIgnore - public boolean isDiscountLimitPriceValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) - || discountLimitPrice != null; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateCreateReqVO.java deleted file mode 100755 index d9c5c326dc..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 优惠劵模板创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplateCreateReqVO extends CouponTemplateBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplatePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplatePageReqVO.java deleted file mode 100755 index 1dad778f5a..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplatePageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 优惠劵模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplatePageReqVO extends PageParam { - - @Schema(description = "优惠劵名", example = "你好") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "优惠类型", example = "1") - private Integer discountType; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "可以领取的类型", example = "[1, 2, 3]") - @InEnum(value = CouponTakeTypeEnum.class, message = "可以领取的类型,必须是 {value}") - private List canTakeTypes; - - @Schema(description = "商品范围", example = "1") - @InEnum(value = PromotionProductScopeEnum.class, message = "商品范围,必须是 {value}") - private Integer productScope; - - @Schema(description = "商品范围编号", example = "1") - private Long productScopeValue; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateRespVO.java deleted file mode 100755 index d2c9d710aa..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 优惠劵模板 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplateRespVO extends CouponTemplateBaseVO { - - @Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "领取优惠券的数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer takeCount; - - @Schema(description = "使用优惠券的次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Integer useCount; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateReqVO.java deleted file mode 100755 index f097196fe6..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 优惠劵模板更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplateUpdateReqVO extends CouponTemplateBaseVO { - - @Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "模板编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateStatusReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateStatusReqVO.java deleted file mode 100644 index 0eb03249c4..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateStatusReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 优惠劵模板更新状态 Request VO") -@Data -public class CouponTemplateUpdateStatusReqVO { - - @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "优惠劵模板编号不能为空") - private Long id; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.http b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.http deleted file mode 100644 index 79975c5906..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.http +++ /dev/null @@ -1,18 +0,0 @@ -### /promotion/decorate/save 保存页面装修组件 -POST {{baseUrl}}/promotion/decorate/save -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "page": 1, - "code": "slide-show", - "status": 0, - "value": "null" -} - -### /promotion/decorate/list 获取指定页面的组件列表 -GET {{baseUrl}}/promotion/decorate/list?page=1 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.java deleted file mode 100644 index 1a6ee6475e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.decorate; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO; -import cn.iocoder.yudao.module.promotion.convert.decorate.DecorateComponentConvert; -import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; -import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 店铺页面装修") -@RestController -@RequestMapping("/promotion/decorate") -@Validated -public class DecorateComponentController { - - @Resource - private DecorateComponentService decorateComponentService; - - @PostMapping("/save") - @Operation(summary = "保存页面装修组件") - @PreAuthorize("@ss.hasPermission('promotion:decorate:save')") - public CommonResult saveDecorateComponent(@Valid @RequestBody DecorateComponentSaveReqVO reqVO) { - decorateComponentService.saveDecorateComponent(reqVO); - return success(true); - } - - @GetMapping("/list") - @Operation(summary = "获取指定页面的组件列表") - @Parameter(name = "page", description = "页面 id", required = true) - @PreAuthorize("@ss.hasPermission('promotion:decorate:query')") - public CommonResult> getDecorateComponentListByPage( - @RequestParam("page") @InEnum(DecoratePageEnum.class) Integer page) { - return success(DecorateComponentConvert.INSTANCE.convertList02( - decorateComponentService.getDecorateComponentListByPage(page, null))); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentRespVO.java deleted file mode 100644 index 6996d58e84..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 页面装修 Resp VO") -@Data -public class DecorateComponentRespVO { - - @Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu") - private String code; - - @Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO") - private String value; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentSaveReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentSaveReqVO.java deleted file mode 100644 index c081ac80c7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentSaveReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 页面装修的保存 Request VO ") -@Data -public class DecorateComponentSaveReqVO { - - @Schema(description = "页面 id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "页面 id 不能为空") - @InEnum(DecoratePageEnum.class) - private Integer page; - - @Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu") - @NotEmpty(message = "组件编码不能为空") - private String code; - - @Schema(description = "组件对应值, json 字符串, 含内容配置,具体数据", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "组件值为空") - private String value; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java deleted file mode 100755 index 6261285bb3..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.*; -import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 限时折扣活动") -@RestController -@RequestMapping("/promotion/discount-activity") -@Validated -public class DiscountActivityController { - - @Resource - private DiscountActivityService discountActivityService; - - @Resource - private ProductSpuApi productSpuApi; - - @PostMapping("/create") - @Operation(summary = "创建限时折扣活动") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:create')") - public CommonResult createDiscountActivity(@Valid @RequestBody DiscountActivityCreateReqVO createReqVO) { - return success(discountActivityService.createDiscountActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新限时折扣活动") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:update')") - public CommonResult updateDiscountActivity(@Valid @RequestBody DiscountActivityUpdateReqVO updateReqVO) { - discountActivityService.updateDiscountActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭限时折扣活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:close')") - public CommonResult closeRewardActivity(@RequestParam("id") Long id) { - discountActivityService.closeDiscountActivity(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除限时折扣活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:delete')") - public CommonResult deleteDiscountActivity(@RequestParam("id") Long id) { - discountActivityService.deleteDiscountActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得限时折扣活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:query')") - public CommonResult getDiscountActivity(@RequestParam("id") Long id) { - DiscountActivityDO discountActivity = discountActivityService.getDiscountActivity(id); - if (discountActivity == null) { - return success(null); - } - // 拼接结果 - List discountProducts = discountActivityService.getDiscountProductsByActivityId(id); - return success(DiscountActivityConvert.INSTANCE.convert(discountActivity, discountProducts)); - } - - @GetMapping("/page") - @Operation(summary = "获得限时折扣活动分页") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:query')") - public CommonResult> getDiscountActivityPage(@Valid DiscountActivityPageReqVO pageVO) { - PageResult pageResult = discountActivityService.getDiscountActivityPage(pageVO); - - if (CollUtil.isEmpty(pageResult.getList())) { // TODO @zhangshuai:方法里的空行,目的是让代码分块,可以更清晰;所以上面这个空格可以不要,而下面判断之后的,空格,其实加下比较好;类似的还有 spuList、以及后面的 convert - return success(PageResult.empty(pageResult.getTotal())); - } - // 拼接数据 - List products = discountActivityService.getDiscountProductsByActivityId( - convertSet(pageResult.getList(), DiscountActivityDO::getId)); - - List spuList = productSpuApi.getSpuList( - convertSet(products, DiscountProductDO::getSpuId)); - - return success(DiscountActivityConvert.INSTANCE.convertPage(pageResult, products, spuList)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java deleted file mode 100755 index b983e7cb51..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.AssertTrue; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 限时折扣活动 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DiscountActivityBaseVO { - - @Schema(description = "活动标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "一个标题") - @NotNull(message = "活动标题不能为空") - private String name; - - @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "备注", example = "我是备注") - private String remark; - - @Schema(description = "商品") - @Data - public static class Product { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "优惠类型不能为空") - @InEnum(PromotionDiscountTypeEnum.class) - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @AssertTrue(message = "折扣百分比需要大于等于 1,小于等于 99") - @JsonIgnore - public boolean isDiscountPercentValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) - || (discountPercent != null && discountPercent >= 1 && discountPercent<= 99); - } - - @AssertTrue(message = "优惠金额不能为空") - @JsonIgnore - public boolean isDiscountPriceValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PRICE.getType()) - || discountPrice != null; - } - - } -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java deleted file mode 100755 index ddf5e4f85d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityCreateReqVO extends DiscountActivityBaseVO { - - /** - * 商品列表 - */ - @NotEmpty(message = "商品列表不能为空") - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityDetailRespVO.java deleted file mode 100755 index 85a989c059..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityDetailRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动的详细 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityDetailRespVO extends DiscountActivityRespVO { - - /** - * 商品列表 - */ - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java deleted file mode 100755 index 4463555ea4..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 限时折扣活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityPageReqVO extends PageParam { - - @Schema(description = "活动标题", example = "一个标题") - private String name; - - @Schema(description = "活动状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java deleted file mode 100755 index 7a9f7f0a00..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityRespVO extends DiscountActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "活动状态不能为空") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") // TODO @zhangshuai:属性和属性之间,最多空一行噢; - private Long spuId; - - @Schema(description = "限时折扣商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - // ========== 商品字段 ========== - - // TODO @zhangshuai:一个优惠活动,会关联多个商品,所以它不用返回 spuName 哈; - // TODO 最终界面展示字段就:编号、活动名称、参与商品数、活动状态、开始时间、结束时间、操作 - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 - example = "618大促") - private String spuName; - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java deleted file mode 100755 index 46d5254cb2..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityUpdateReqVO extends DiscountActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "活动编号不能为空") - private Long id; - - /** - * 商品列表 - */ - @NotEmpty(message = "商品列表不能为空") - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyPageController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyPageController.java deleted file mode 100644 index 649db9b376..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyPageController.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.*; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 装修页面") -@RestController -@RequestMapping("/promotion/diy-page") -@Validated -public class DiyPageController { - - @Resource - private DiyPageService diyPageService; - - @PostMapping("/create") - @Operation(summary = "创建装修页面") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:create')") - public CommonResult createDiyPage(@Valid @RequestBody DiyPageCreateReqVO createReqVO) { - return success(diyPageService.createDiyPage(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新装修页面") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:update')") - public CommonResult updateDiyPage(@Valid @RequestBody DiyPageUpdateReqVO updateReqVO) { - diyPageService.updateDiyPage(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除装修页面") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:diy-page:delete')") - public CommonResult deleteDiyPage(@RequestParam("id") Long id) { - diyPageService.deleteDiyPage(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得装修页面") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") - public CommonResult getDiyPage(@RequestParam("id") Long id) { - DiyPageDO diyPage = diyPageService.getDiyPage(id); - return success(DiyPageConvert.INSTANCE.convert(diyPage)); - } - - @GetMapping("/list") - @Operation(summary = "获得装修页面列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") - public CommonResult> getDiyPageList(@RequestParam("ids") Collection ids) { - List list = diyPageService.getDiyPageList(ids); - return success(DiyPageConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得装修页面分页") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") - public CommonResult> getDiyPagePage(@Valid DiyPagePageReqVO pageVO) { - PageResult pageResult = diyPageService.getDiyPagePage(pageVO); - return success(DiyPageConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/get-property") - @Operation(summary = "获得装修页面属性") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") - public CommonResult getDiyPageProperty(@RequestParam("id") Long id) { - DiyPageDO diyPage = diyPageService.getDiyPage(id); - return success(DiyPageConvert.INSTANCE.convertPropertyVo(diyPage)); - } - - @PutMapping("/update-property") - @Operation(summary = "更新装修页面属性") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:update')") - public CommonResult updateDiyPageProperty(@Valid @RequestBody DiyPagePropertyUpdateRequestVO updateReqVO) { - diyPageService.updateDiyPageProperty(updateReqVO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyTemplateController.java deleted file mode 100644 index f8aa3b1807..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyTemplateController.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.*; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; -import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 装修模板") -@RestController -@RequestMapping("/promotion/diy-template") -@Validated -public class DiyTemplateController { - - @Resource - private DiyTemplateService diyTemplateService; - @Resource - private DiyPageService diyPageService; - - @PostMapping("/create") - @Operation(summary = "创建装修模板") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:create')") - public CommonResult createDiyTemplate(@Valid @RequestBody DiyTemplateCreateReqVO createReqVO) { - return success(diyTemplateService.createDiyTemplate(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新装修模板") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:update')") - public CommonResult updateDiyTemplate(@Valid @RequestBody DiyTemplateUpdateReqVO updateReqVO) { - diyTemplateService.updateDiyTemplate(updateReqVO); - return success(true); - } - - @PutMapping("/use") - @Operation(summary = "使用装修模板") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:use')") - public CommonResult useDiyTemplate(@RequestParam("id") Long id) { - diyTemplateService.useDiyTemplate(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除装修模板") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:diy-template:delete')") - public CommonResult deleteDiyTemplate(@RequestParam("id") Long id) { - diyTemplateService.deleteDiyTemplate(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得装修模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:query')") - public CommonResult getDiyTemplate(@RequestParam("id") Long id) { - DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id); - return success(DiyTemplateConvert.INSTANCE.convert(diyTemplate)); - } - - @GetMapping("/page") - @Operation(summary = "获得装修模板分页") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:query')") - public CommonResult> getDiyTemplatePage(@Valid DiyTemplatePageReqVO pageVO) { - PageResult pageResult = diyTemplateService.getDiyTemplatePage(pageVO); - return success(DiyTemplateConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/get-property") - @Operation(summary = "获得装修模板属性") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:query')") - public CommonResult getDiyTemplateProperty(@RequestParam("id") Long id) { - DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id); - List pages = diyPageService.getDiyPageByTemplateId(id); - return success(DiyTemplateConvert.INSTANCE.convertPropertyVo(diyTemplate, pages)); - } - - @PutMapping("/update-property") - @Operation(summary = "更新装修模板属性") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:update')") - public CommonResult updateDiyTemplateProperty(@Valid @RequestBody DiyTemplatePropertyUpdateRequestVO updateReqVO) { - diyTemplateService.updateDiyTemplateProperty(updateReqVO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageBaseVO.java deleted file mode 100644 index 4ccb5a736d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageBaseVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; -import java.util.List; - -/** - * 装修页面 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class DiyPageBaseVO { - - @Schema(description = "装修模板编号", example = "26179") - private Long templateId; - - @Schema(description = "页面名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotNull(message = "页面名称不能为空") - private String name; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "预览图") - private List previewImageUrls; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageCreateReqVO.java deleted file mode 100644 index 17d3b35cba..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 装修页面创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPageCreateReqVO extends DiyPageBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePageReqVO.java deleted file mode 100644 index 5c81b9f932..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 装修页面分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPagePageReqVO extends PageParam { - - @Schema(description = "页面名称", example = "王五") - private String name; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyRespVO.java deleted file mode 100644 index 2fdd546829..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 装修页面属性 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPagePropertyRespVO extends DiyPageBaseVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "页面属性", example = "[]") - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyUpdateRequestVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyUpdateRequestVO.java deleted file mode 100644 index 0e9e2b3320..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyUpdateRequestVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 装修页面属性更新 Request VO") -@Data -@ToString(callSuper = true) -public class DiyPagePropertyUpdateRequestVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - @NotNull(message = "装修页面编号不能为空") - private Long id; - - @Schema(description = "页面属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @NotBlank(message = "页面属性不能为空") - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageRespVO.java deleted file mode 100644 index 9e2d9af863..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 装修页面 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPageRespVO extends DiyPageBaseVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12082") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageUpdateReqVO.java deleted file mode 100644 index 1b3f9b87b0..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 装修页面更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPageUpdateReqVO extends DiyPageBaseVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12082") - @NotNull(message = "装修页面编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java deleted file mode 100644 index 0d1bce0556..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import java.util.List; - -/** - * 装修模板 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class DiyTemplateBaseVO { - - @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题") - @NotEmpty(message = "模板名称不能为空") - private String name; - - @Schema(description = "备注", example = "默认主题") - private String remark; - - @Schema(description = "预览图", example = "[https://www.iocoder.cn/1.jpg]") - private List previewImageUrls; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqVO.java deleted file mode 100644 index 659f9c5909..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 装修模板创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplateCreateReqVO extends DiyTemplateBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePageReqVO.java deleted file mode 100644 index 1099226f9f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePageReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 装修模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplatePageReqVO extends PageParam { - - @Schema(description = "模板名称", example = "默认主题") - private String name; - - @Schema(description = "是否使用", example = "true") - private Boolean used; - - @Schema(description = "使用时间", example = "使用时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] usedTime; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyRespVO.java deleted file mode 100644 index 21dd46f3f1..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 装修模板属性 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplatePropertyRespVO extends DiyTemplateBaseVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - private String property; - - @Schema(description = "模板页面", requiredMode = Schema.RequiredMode.REQUIRED, example = "[]") - private List pages; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyUpdateRequestVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyUpdateRequestVO.java deleted file mode 100644 index 40c254d1fc..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyUpdateRequestVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 装修模板属性更新 Request VO") -@Data -@ToString(callSuper = true) -public class DiyTemplatePropertyUpdateRequestVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - @NotNull(message = "装修模板编号不能为空") - private Long id; - - @Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @NotBlank(message = "模板属性不能为空") - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateRespVO.java deleted file mode 100644 index e19089e6a3..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 装修模板 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplateRespVO extends DiyTemplateBaseVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "是否使用", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean used; - - @Schema(description = "使用时间", example = "使用时间") - private LocalDateTime usedTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateUpdateReqVO.java deleted file mode 100644 index 86fcd09cdf..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 装修模板更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplateUpdateReqVO extends DiyTemplateBaseVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - @NotNull(message = "装修模板编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/RewardActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/RewardActivityController.java deleted file mode 100755 index d419123378..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/RewardActivityController.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.reward.RewardActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 满减送活动") -@RestController -@RequestMapping("/promotion/reward-activity") -@Validated -public class RewardActivityController { - - @Resource - private RewardActivityService rewardActivityService; - - @PostMapping("/create") - @Operation(summary = "创建满减送活动") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:create')") - public CommonResult createRewardActivity(@Valid @RequestBody RewardActivityCreateReqVO createReqVO) { - return success(rewardActivityService.createRewardActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新满减送活动") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:update')") - public CommonResult updateRewardActivity(@Valid @RequestBody RewardActivityUpdateReqVO updateReqVO) { - rewardActivityService.updateRewardActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭满减送活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:close')") - public CommonResult closeRewardActivity(@RequestParam("id") Long id) { - rewardActivityService.closeRewardActivity(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除满减送活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:delete')") - public CommonResult deleteRewardActivity(@RequestParam("id") Long id) { - rewardActivityService.deleteRewardActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得满减送活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:query')") - public CommonResult getRewardActivity(@RequestParam("id") Long id) { - RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id); - return success(RewardActivityConvert.INSTANCE.convert(rewardActivity)); - } - - @GetMapping("/page") - @Operation(summary = "获得满减送活动分页") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:query')") - public CommonResult> getRewardActivityPage(@Valid RewardActivityPageReqVO pageVO) { - PageResult pageResult = rewardActivityService.getRewardActivityPage(pageVO); - return success(RewardActivityConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java deleted file mode 100755 index 494a5ccc95..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.AssertTrue; -import jakarta.validation.constraints.Future; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 满减送活动 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class RewardActivityBaseVO { - - @Schema(description = "活动标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "满啦满啦") - @NotNull(message = "活动标题不能为空") - private String name; - - @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Future(message = "结束时间必须大于当前时间") - private LocalDateTime endTime; - - @Schema(description = "备注", example = "biubiubiu") - private String remark; - - @Schema(description = "条件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "条件类型不能为空") - @InEnum(value = PromotionConditionTypeEnum.class, message = "条件类型必须是 {value}") - private Integer conditionType; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品范围不能为空") - @InEnum(value = PromotionConditionTypeEnum.class, message = "商品范围必须是 {value}") - private Integer productScope; - - @Schema(description = "商品 SPU 编号的数组", example = "1,2,3") - private List productSpuIds; - - /** - * 优惠规则的数组 - */ - @Valid // 校验下子对象 - private List rules; - - @Schema(description = "优惠规则") - @Data - public static class Rule { - - @Schema(description = "优惠门槛", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 1. 满 N 元,单位:分; 2. 满 N 件 - @Min(value = 1L, message = "优惠门槛必须大于等于 1") - private Integer limit; - - @Schema(description = "优惠价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @Min(value = 1L, message = "优惠价格必须大于等于 1") - private Integer discountPrice; - - @Schema(description = "是否包邮", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean freeDelivery; - - @Schema(description = "赠送的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @Min(value = 1L, message = "赠送的积分必须大于等于 1") - private Integer point; - - @Schema(description = "赠送的优惠劵编号的数组", example = "1,2,3") - private List couponIds; - - @Schema(description = "赠送的优惠券数量的数组", example = "1,2,3") - private List couponCounts; - - @AssertTrue(message = "优惠劵和数量必须一一对应") - @JsonIgnore - public boolean isCouponCountsValid() { - return CollUtil.size(couponCounts) == CollUtil.size(couponCounts); - } - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityCreateReqVO.java deleted file mode 100755 index 0710e46a4e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 满减送活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityCreateReqVO extends RewardActivityBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityPageReqVO.java deleted file mode 100755 index 7052c9c664..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 满减送活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityPageReqVO extends PageParam { - - @Schema(description = "活动标题", example = "满啦满啦") - private String name; - - @Schema(description = "活动状态", example = "1") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityRespVO.java deleted file mode 100755 index 67bf12153b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 满减送活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityRespVO extends RewardActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer id; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityUpdateReqVO.java deleted file mode 100755 index 2217ded104..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 满减送活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityUpdateReqVO extends RewardActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "活动编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java deleted file mode 100644 index 6cce8a1f79..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 秒杀活动") -@RestController -@RequestMapping("/promotion/seckill-activity") -@Validated -public class SeckillActivityController { - - @Resource - private SeckillActivityService seckillActivityService; - @Resource - private ProductSpuApi productSpuApi; - - @PostMapping("/create") - @Operation(summary = "创建秒杀活动") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:create')") - public CommonResult createSeckillActivity(@Valid @RequestBody SeckillActivityCreateReqVO createReqVO) { - return success(seckillActivityService.createSeckillActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新秒杀活动") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:update')") - public CommonResult updateSeckillActivity(@Valid @RequestBody SeckillActivityUpdateReqVO updateReqVO) { - seckillActivityService.updateSeckillActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭秒杀活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:close')") - public CommonResult closeSeckillActivity(@RequestParam("id") Long id) { - seckillActivityService.closeSeckillActivity(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除秒杀活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:delete')") - public CommonResult deleteSeckillActivity(@RequestParam("id") Long id) { - seckillActivityService.deleteSeckillActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得秒杀活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:query')") - public CommonResult getSeckillActivity(@RequestParam("id") Long id) { - SeckillActivityDO activity = seckillActivityService.getSeckillActivity(id); - List products = seckillActivityService.getSeckillProductListByActivityId(id); - return success(SeckillActivityConvert.INSTANCE.convert(activity, products)); - } - - @GetMapping("/page") - @Operation(summary = "获得秒杀活动分页") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:query')") - public CommonResult> getSeckillActivityPage(@Valid SeckillActivityPageReqVO pageVO) { - // 查询活动列表 - PageResult pageResult = seckillActivityService.getSeckillActivityPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - List products = seckillActivityService.getSeckillProductListByActivityId( - convertSet(pageResult.getList(), SeckillActivityDO::getId)); - List spuList = productSpuApi.getSpuList( - convertSet(pageResult.getList(), SeckillActivityDO::getSpuId)); - return success(SeckillActivityConvert.INSTANCE.convertPage(pageResult, products, spuList)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillConfigController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillConfigController.java deleted file mode 100644 index cfceb6d0f1..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillConfigController.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.*; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 秒杀时段") -@RestController -@RequestMapping("/promotion/seckill-config") -@Validated -public class SeckillConfigController { - - @Resource - private SeckillConfigService seckillConfigService; - - @PostMapping("/create") - @Operation(summary = "创建秒杀时段") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:create')") - public CommonResult createSeckillConfig(@Valid @RequestBody SeckillConfigCreateReqVO createReqVO) { - return success(seckillConfigService.createSeckillConfig(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新秒杀时段") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:update')") - public CommonResult updateSeckillConfig(@Valid @RequestBody SeckillConfigUpdateReqVO updateReqVO) { - seckillConfigService.updateSeckillConfig(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "修改时段配置状态") - @PreAuthorize("@ss.hasPermission('system:seckill-config:update')") - public CommonResult updateSeckillConfigStatus(@Valid @RequestBody SeckillConfigUpdateStatusReqVo reqVO) { - seckillConfigService.updateSeckillConfigStatus(reqVO.getId(), reqVO.getStatus()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除秒杀时段") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:delete')") - public CommonResult deleteSeckillConfig(@RequestParam("id") Long id) { - seckillConfigService.deleteSeckillConfig(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得秒杀时段") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:query')") - public CommonResult getSeckillConfig(@RequestParam("id") Long id) { - SeckillConfigDO seckillConfig = seckillConfigService.getSeckillConfig(id); - return success(SeckillConfigConvert.INSTANCE.convert(seckillConfig)); - } - - @GetMapping("/list") - @Operation(summary = "获得所有秒杀时段列表") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:query')") - public CommonResult> getSeckillConfigList() { - List list = seckillConfigService.getSeckillConfigList(); - return success(SeckillConfigConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获得所有开启状态的秒杀时段精简列表", description = "主要用于前端的下拉选项") - public CommonResult> getListAllSimple() { - List list = seckillConfigService.getSeckillConfigListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - return success(SeckillConfigConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得秒杀时间段分页") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:query')") - public CommonResult> getSeckillActivityPage(@Valid SeckillConfigPageReqVO pageVO) { - PageResult pageResult = seckillConfigService.getSeckillConfigPage(pageVO); - return success(SeckillConfigConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java deleted file mode 100644 index 3541c3689a..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 秒杀活动基地签证官 - * 秒杀活动 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class SeckillActivityBaseVO { - - @Schema(description = "秒杀活动商品 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "[121,1212]") - @NotNull(message = "秒杀活动商品不能为空") - private Long spuId; - - @Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促") - @NotNull(message = "秒杀活动名称不能为空") - private String name; - - @Schema(description = "备注", example = "清仓大甩卖割韭菜") - private String remark; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "活动开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "活动结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "秒杀时段 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,2,3]") - @NotNull(message = "秒杀时段不能为空") - private List configIds; - - @Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "12877") - private Integer totalLimitCount; - - @Schema(description = "单次限够数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "31683") - private Integer singleLimitCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java deleted file mode 100644 index 9b6e7291a2..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 秒杀活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityCreateReqVO extends SeckillActivityBaseVO { - - @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java deleted file mode 100644 index c3cc2ebf0e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 秒杀活动的详细 Response VO") -@Data -@ToString(callSuper = true) -public class SeckillActivityDetailRespVO extends SeckillActivityBaseVO{ - - @Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java deleted file mode 100644 index ac634a7b29..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -@Schema(description = "管理后台 - 秒杀活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityPageReqVO extends PageParam { - - @Schema(description = "秒杀活动名称", example = "晚九点限时秒杀") - private String name; - - @Schema(description = "活动状态", example = "进行中") - private Integer status; - - @Schema(description = "秒杀时段id", example = "1") - private Long configId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java deleted file mode 100644 index 742c73ba65..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 秒杀活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityRespVO extends SeckillActivityBaseVO { - - @Schema(description = "秒杀活动 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "订单实付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "22354") - private Integer totalPrice; - - @Schema(description = "秒杀库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer stock; - - @Schema(description = "秒杀总库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer totalStock; - - @Schema(description = "新增订单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer orderCount; - - @Schema(description = "付款人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer userCount; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 商品字段 ========== - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 - example = "618大促") - private String spuName; - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java deleted file mode 100644 index bf2ca35bbf..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 秒杀活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityUpdateReqVO extends SeckillActivityBaseVO { - - @Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigBaseVO.java deleted file mode 100644 index d367084030..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigBaseVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.AssertTrue; -import jakarta.validation.constraints.NotNull; -import java.time.LocalTime; -import java.util.List; - -/** - * 秒杀时段 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class SeckillConfigBaseVO { - - @Schema(description = "秒杀时段名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "早上场") - @NotNull(message = "秒杀时段名称不能为空") - private String name; - - @Schema(description = "开始时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:00:00") - @NotNull(message = "开始时间点不能为空") - private String startTime; - - @Schema(description = "结束时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "16:00:00") - @NotNull(message = "结束时间点不能为空") - private String endTime; - - @Schema(description = "秒杀轮播图", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]") - @NotNull(message = "秒杀轮播图不能为空") - private List sliderPicUrls; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "状态不能为空") - private Integer status; - - @AssertTrue(message = "秒杀时段开始时间和结束时间不能相等") - @JsonIgnore - public boolean isValidStartTimeValid() { - return !LocalTime.parse(startTime).equals(LocalTime.parse(endTime)); - } - - @AssertTrue(message = "秒杀时段开始时间不能在结束时间之后") - @JsonIgnore - public boolean isValidEndTimeValid() { - return !LocalTime.parse(startTime).isAfter(LocalTime.parse(endTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigCreateReqVO.java deleted file mode 100644 index 979ee699d0..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 秒杀时段创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillConfigCreateReqVO extends SeckillConfigBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigPageReqVO.java deleted file mode 100644 index 92211385a6..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 秒杀时段分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillConfigPageReqVO extends PageParam { - - @Schema(description = "秒杀时段名称", example = "上午场") - private String name; - - @Schema(description = "状态", example = "0") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigRespVO.java deleted file mode 100644 index 5411536c94..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 秒杀时段 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillConfigRespVO extends SeckillConfigBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "秒杀活动数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer seckillActivityCount; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigSimpleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigSimpleRespVO.java deleted file mode 100644 index 4542c95d29..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigSimpleRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 秒杀时段配置精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class SeckillConfigSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "秒杀时段名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "早上场") - @NotNull(message = "秒杀时段名称不能为空") - private String name; - - @Schema(description = "开始时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:00:00") - private String startTime; - - @Schema(description = "结束时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "16:00:00") - private String endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateReqVO.java deleted file mode 100644 index 36f7b90edf..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 秒杀时段更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillConfigUpdateReqVO extends SeckillConfigBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateStatusReqVo.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateStatusReqVo.java deleted file mode 100644 index fadf5d9c6f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateStatusReqVo.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 修改时段配置状态 Request VO") -@Data -public class SeckillConfigUpdateStatusReqVo { - - @Schema(description = "时段配置编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "时段配置编号不能为空") - private Long id; - - @Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductBaseVO.java deleted file mode 100644 index 092115c119..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductBaseVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 秒杀参与商品 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class SeckillProductBaseVO { - - @Schema(description = "商品sku_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30563") - @NotNull(message = "商品sku_id不能为空") - private Long skuId; - - @Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "6689") - @NotNull(message = "秒杀金额,单位:分不能为空") - private Integer seckillPrice; - - @Schema(description = "秒杀库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "秒杀库存不能为空") - private Integer stock; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductRespVO.java deleted file mode 100644 index 96b7eec4c3..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 秒杀参与商品 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillProductRespVO extends SeckillProductBaseVO { - - @Schema(description = "秒杀参与商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "256") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http deleted file mode 100644 index 0dda88c7d8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http +++ /dev/null @@ -1,5 +0,0 @@ -### /promotion/activity/list-by-spu-ids 获得多个商品,近期参与的每个活动 -GET {{appApi}}/promotion/activity/list-by-spu-ids?spuIds=222&spuIds=633 -Authorization: Bearer {{appToken}} -Content-Type: application/json -tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java deleted file mode 100644 index e7ac4ff1ac..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.activity; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.activity.vo.AppActivityRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; - -@Tag(name = "用户 APP - 营销活动") // 用于提供跨多个活动的 HTTP 接口 -@RestController -@RequestMapping("/promotion/activity") -@Validated -public class AppActivityController { - - @Resource - private CombinationActivityService combinationActivityService; - @Resource - private SeckillActivityService seckillActivityService; - @Resource - private BargainActivityService bargainActivityService; - - @GetMapping("/list-by-spu-id") - @Operation(summary = "获得单个商品,近期参与的每个活动") - @Parameter(name = "spuId", description = "商品编号", required = true) - public CommonResult> getActivityListBySpuId(@RequestParam("spuId") Long spuId) { - // 每种活动,只返回一个 - return success(getAppActivityList(Collections.singletonList(spuId))); - } - - @GetMapping("/list-by-spu-ids") - @Operation(summary = "获得多个商品,近期参与的每个活动") - @Parameter(name = "spuIds", description = "商品编号数组", required = true) - public CommonResult>> getActivityListBySpuIds(@RequestParam("spuIds") List spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return success(MapUtil.empty()); - } - // 每种活动,只返回一个;key 为 SPU 编号 - return success(convertMultiMap(getAppActivityList(spuIds), AppActivityRespVO::getSpuId)); - } - - private List getAppActivityList(Collection spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return new ArrayList<>(); - } - LocalDateTime now = LocalDateTime.now(); - List activityList = new ArrayList<>(); - - // 1. 拼团活动 - 获取开启的且开始的且没有结束的活动 - List combinationActivities = combinationActivityService.getCombinationActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, CommonStatusEnum.ENABLE.getStatus(), now); - if (CollUtil.isNotEmpty(combinationActivities)) { - combinationActivities.forEach(item -> { - activityList.add(new AppActivityRespVO().setId(item.getId()) - .setType(PromotionTypeEnum.COMBINATION_ACTIVITY.getType()).setName(item.getName()) - .setSpuId(item.getSpuId()).setStartTime(item.getStartTime()).setEndTime(item.getEndTime())); - }); - } - - // 2. 秒杀活动 - 获取开启的且开始的且没有结束的活动 - List seckillActivities = seckillActivityService.getSeckillActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, CommonStatusEnum.ENABLE.getStatus(), now); - if (CollUtil.isNotEmpty(seckillActivities)) { - seckillActivities.forEach(item -> { - activityList.add(new AppActivityRespVO().setId(item.getId()) - .setType(PromotionTypeEnum.SECKILL_ACTIVITY.getType()).setName(item.getName()) - .setSpuId(item.getSpuId()).setStartTime(item.getStartTime()).setEndTime(item.getEndTime())); - }); - } - - // 3. 砍价活动 - 获取开启的且开始的且没有结束的活动 - List bargainActivities = bargainActivityService.getBargainActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, CommonStatusEnum.ENABLE.getStatus(), now); - if (CollUtil.isNotEmpty(bargainActivities)) { - bargainActivities.forEach(item -> { - activityList.add(new AppActivityRespVO().setId(item.getId()) - .setType(PromotionTypeEnum.BARGAIN_ACTIVITY.getType()).setName(item.getName()) - .setSpuId(item.getSpuId()).setStartTime(item.getStartTime()).setEndTime(item.getEndTime())); - }); - } - return activityList; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/vo/AppActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/vo/AppActivityRespVO.java deleted file mode 100644 index 8cb3b281b2..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/vo/AppActivityRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.activity.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 营销活动 Response VO") -@Data -public class AppActivityRespVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "活动类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; // 对应 PromotionTypeEnum 枚举 - - @Schema(description = "活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大促") - private String name; - - @Schema(description = "spu 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "618") - private Long spuId; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java deleted file mode 100644 index 746b09acdc..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.service.article.ArticleCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 文章分类") -@RestController -@RequestMapping("/promotion/article-category") -@Validated -public class AppArticleCategoryController { - - @Resource - private ArticleCategoryService articleCategoryService; - - @RequestMapping("/list") - @Operation(summary = "获得文章分类列表") - public CommonResult> getArticleCategoryList() { - List categoryList = articleCategoryService.getArticleCategoryListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - categoryList.sort(Comparator.comparing(ArticleCategoryDO::getSort)); // 按 sort 降序排列 - return success(ArticleCategoryConvert.INSTANCE.convertList04(categoryList)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java deleted file mode 100644 index ee3a133577..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; -import cn.iocoder.yudao.module.promotion.service.article.ArticleService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 文章") -@RestController -@RequestMapping("/promotion/article") -@Validated -public class AppArticleController { - - @Resource - private ArticleService articleService; - - @RequestMapping("/list") - @Operation(summary = "获得文章详情列表") - @Parameters({ - @Parameter(name = "recommendHot", description = "是否热门", example = "false"), // 场景一:查看指定的文章 - @Parameter(name = "recommendBanner", description = "是否轮播图", example = "false") // 场景二:查看指定的文章 - }) - public CommonResult> getArticleList( - @RequestParam(value = "recommendHot", required = false) Boolean recommendHot, - @RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) { - return success(ArticleConvert.INSTANCE.convertList03( - articleService.getArticleCategoryListByRecommend(recommendHot, recommendBanner))); - } - - @RequestMapping("/page") - @Operation(summary = "获得文章详情分页") - public CommonResult> getArticlePage(AppArticlePageReqVO pageReqVO) { - return success(ArticleConvert.INSTANCE.convertPage02(articleService.getArticlePage(pageReqVO))); - } - - @RequestMapping("/get") - @Operation(summary = "获得文章详情") - @Parameter(name = "id", description = "文章编号", example = "1024") - public CommonResult getArticlePage(@RequestParam("id") Long id) { - return success(ArticleConvert.INSTANCE.convert01(articleService.getArticle(id))); - } - - @PutMapping("/add-browse-count") - @Operation(summary = "增加文章浏览量") - @Parameter(name = "id", description = "文章编号", example = "1024") - public CommonResult addBrowseCount(@RequestParam("id") Long id) { - articleService.addArticleBrowseCount(id); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticlePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticlePageReqVO.java deleted file mode 100644 index f548ae9bd3..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticlePageReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article.vo.article; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "应用 App - 文章的分页 Request VO") -@Data -public class AppArticlePageReqVO extends PageParam { - - @Schema(description = "分类编号", example = "2048") - private Long categoryId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java deleted file mode 100644 index 8f74776c46..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "应用 App - 文章 Response VO") -@Data -public class AppArticleRespVO { - - @Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "文章标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码 - 促销模块") - private String title; - - @Schema(description = "文章作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String author; - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long categoryId; - - @Schema(description = "图文封面", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "文章简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是简介") - private String introduction; - - @Schema(description = "文章内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是详细") - private String description; - - @Schema(description = "发布时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer browseCount; - - @Schema(description = "关联的商品 SPU 编号", example = "1024") - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java deleted file mode 100644 index e0f34e95d8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "应用 App - 文章分类 Response VO") -@Data -public class AppArticleCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "技术") - private String name; - - @Schema(description = "分类图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java deleted file mode 100644 index af7b116ee6..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.banner; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.banner.vo.AppBannerRespVO; -import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import cn.iocoder.yudao.module.promotion.service.banner.BannerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@RestController -@RequestMapping("/promotion/banner") -@Tag(name = "用户 APP - 首页 Banner") -@Validated -public class AppBannerController { - - @Resource - private BannerService bannerService; - - @GetMapping("/list") - @Operation(summary = "获得 banner 列表") - @Parameter(name = "position", description = "Banner position", example = "1") - public CommonResult> getBannerList(@RequestParam("position") Integer position) { - List bannerList = bannerService.getBannerListByPosition(position); - return success(BannerConvert.INSTANCE.convertList01(bannerList)); - } - - @PutMapping("/add-browse-count") - @Operation(summary = "增加 Banner 点击量") - @Parameter(name = "id", description = "Banner 编号", example = "1024") - public CommonResult addBrowseCount(@RequestParam("id") Long id) { - bannerService.addBannerBrowseCount(id); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/vo/AppBannerRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/vo/AppBannerRespVO.java deleted file mode 100644 index bd995621c3..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/vo/AppBannerRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 App - Banner Response VO") -@Data -public class AppBannerRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "标题不能为空") - private String title; - - @Schema(description = "跳转链接", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "跳转链接不能为空") - private String url; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "图片地址不能为空") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java deleted file mode 100644 index eb7e457cc1..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "用户 App - 砍价活动") -@RestController -@RequestMapping("/promotion/bargain-activity") -@Validated -public class AppBargainActivityController { - - /** - * {@link AppBargainActivityRespVO} 缓存,通过它异步刷新 {@link #getBargainActivityList0(Integer)} 所要的首页数据 - */ - private final LoadingCache> bargainActivityListCache = buildAsyncReloadingCache(Duration.ofSeconds(10L), - new CacheLoader>() { - - @Override - public List load(Integer count) { - return getBargainActivityList0(count); - } - - }); - - @Resource - private BargainActivityService bargainActivityService; - @Resource - private BargainRecordService bargainRecordService; - - @Resource - private ProductSpuApi spuApi; - - @GetMapping("/list") - @Operation(summary = "获得砍价活动列表", description = "用于小程序首页") - @Parameter(name = "count", description = "需要展示的数量", example = "6") - public CommonResult> getBargainActivityList( - @RequestParam(name = "count", defaultValue = "6") Integer count) { - return success(bargainActivityListCache.getUnchecked(count)); - } - - private ListgetBargainActivityList0(Integer count) { - List list = bargainActivityService.getBargainActivityListByCount(count); - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - // 拼接数据 - List spuList = spuApi.getSpuList(convertList(list, BargainActivityDO::getSpuId)); - return BargainActivityConvert.INSTANCE.convertAppList(list, spuList); - } - - @GetMapping("/page") - @Operation(summary = "获得砍价活动分页") - public CommonResult> getBargainActivityPage(PageParam pageReqVO) { - PageResult result = bargainActivityService.getBargainActivityPage(pageReqVO); - if (CollUtil.isEmpty(result.getList())) { - return success(PageResult.empty(result.getTotal())); - } - // 拼接数据 - List spuList = spuApi.getSpuList(convertList(result.getList(), BargainActivityDO::getSpuId)); - return success(BargainActivityConvert.INSTANCE.convertAppPage(result, spuList)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得砍价活动详情") - @Parameter(name = "id", description = "活动编号", example = "1") - public CommonResult getBargainActivityDetail(@RequestParam("id") Long id) { - BargainActivityDO activity = bargainActivityService.getBargainActivity(id); - if (activity == null) { - return success(null); - } - // 拼接数据 - Integer successUserCount = bargainRecordService.getBargainRecordUserCount(id, BargainRecordStatusEnum.SUCCESS.getStatus()); - ProductSpuRespDTO spu = spuApi.getSpu(activity.getSpuId()); - return success(BargainActivityConvert.INSTANCE.convert(activity, successUserCount, spu)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.http b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.http deleted file mode 100644 index 2e401e9d62..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.http +++ /dev/null @@ -1,9 +0,0 @@ -### /promotion/bargain-record/create 创建砍价助力 -POST {{appApi}}/promotion/bargain-help/create -Authorization: Bearer test248 -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "recordId": 26 -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.java deleted file mode 100644 index 4b160ead4d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpRespVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainHelpConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 砍价助力") -@RestController -@RequestMapping("/promotion/bargain-help") -@Validated -public class AppBargainHelpController { - - @Resource - private BargainHelpService bargainHelpService; - - @Resource - private MemberUserApi memberUserApi; - - @PostMapping("/create") - @Operation(summary = "创建砍价助力", description = "给拼团记录砍一刀") // 返回结果为砍价金额,单位:分 - public CommonResult createBargainHelp(@RequestBody AppBargainHelpCreateReqVO reqVO) { - BargainHelpDO help = bargainHelpService.createBargainHelp(getLoginUserId(), reqVO); - return success(help.getReducePrice()); - } - - @GetMapping("/list") - @Operation(summary = "获得砍价助力列表") - @Parameter(name = "recordId", description = "砍价记录编号", required = true, example = "111") - public CommonResult> getBargainHelpList(@RequestParam("recordId") Long recordId) { - List helps = bargainHelpService.getBargainHelpListByRecordId(recordId); - if (CollUtil.isEmpty(helps)) { - return success(Collections.emptyList()); - } - helps.sort((o1, o2) -> o2.getCreateTime().compareTo(o1.getCreateTime())); // 倒序展示 - - // 拼接数据 - Map userMap = memberUserApi.getUserMap( - convertSet(helps, BargainHelpDO::getUserId)); - return success(BargainHelpConvert.INSTANCE.convertList(helps, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.http b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.http deleted file mode 100644 index 46cbe3c8ec..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.http +++ /dev/null @@ -1,9 +0,0 @@ -### /promotion/bargain-record/create 创建砍价记录 -POST {{appApi}}/promotion/bargain-record/create -Authorization: Bearer {{appToken}} -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "activityId": 1 -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java deleted file mode 100644 index 00f3def4c2..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java +++ /dev/null @@ -1,162 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordSummaryRespVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainRecordConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 砍价记录") -@RestController -@RequestMapping("/promotion/bargain-record") -@Validated -public class AppBargainRecordController { - - @Resource - private BargainHelpService bargainHelpService; - @Resource - private BargainRecordService bargainRecordService; - @Resource - private BargainActivityService bargainActivityService; - - @Resource - private TradeOrderApi tradeOrderApi; - @Resource - private MemberUserApi memberUserApi; - @Resource - private ProductSpuApi productSpuApi; - - @GetMapping("/get-summary") - @Operation(summary = "获得砍价记录的概要信息", description = "用于小程序首页") - public CommonResult getBargainRecordSummary() { - // 砍价成功的用户数量 - Integer successUserCount = bargainRecordService.getBargainRecordUserCount( - BargainRecordStatusEnum.SUCCESS.getStatus()); - if (successUserCount == 0) { - return success(new AppBargainRecordSummaryRespVO().setSuccessUserCount(0) - .setSuccessList(Collections.emptyList())); - } - // 砍价成功的用户列表 - List successList = bargainRecordService.getBargainRecordList( - BargainRecordStatusEnum.SUCCESS.getStatus(), 7); - List activityList = bargainActivityService.getBargainActivityList( - convertSet(successList, BargainRecordDO::getActivityId)); - Map userMap = memberUserApi.getUserMap( - convertSet(successList, BargainRecordDO::getUserId)); - // 拼接返回 - return success(BargainRecordConvert.INSTANCE.convert(successUserCount, successList, activityList, userMap)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得砍价记录的明细") - @Parameters({ - @Parameter(name = "id", description = "砍价记录编号", example = "111"), // 场景一:查看指定的砍价记录 - @Parameter(name = "activityId", description = "砍价活动编号", example = "222") // 场景二:查看指定的砍价活动 - }) - public CommonResult getBargainRecordDetail( - @RequestParam(value = "id", required = false) Long id, - @RequestParam(value = "activityId", required = false) Long activityId) { - // 1. 查询砍价记录 + 砍价活动 - Assert.isTrue(id != null || activityId != null, "砍价记录编号和活动编号不能同时为空"); - BargainRecordDO record = id != null ? bargainRecordService.getBargainRecord(id) - : bargainRecordService.getLastBargainRecord(getLoginUserId(), activityId); - if (activityId == null || record != null) { - activityId = record.getActivityId(); - } - // 2. 查询助力记录 - Long userId = getLoginUserId(); - Integer helpAction = getHelpAction(userId, record, activityId); - // 3. 如果是自己的订单,则查询订单信息 - TradeOrderRespDTO order = record != null && record.getOrderId() != null && record.getUserId().equals(getLoginUserId()) - ? tradeOrderApi.getOrder(record.getOrderId()) : null; - // TODO 继续查询别的字段 - - // 拼接返回 - return success(BargainRecordConvert.INSTANCE.convert02(record, helpAction, order)); - } - - private Integer getHelpAction(Long userId, BargainRecordDO record, Long activityId) { - // 0.1 如果没有活动,无法帮砍 - if (activityId == null) { - return null; - } - // 0.2 如果是自己的砍价记录,无法帮砍 - if (record != null && record.getUserId().equals(userId)) { - return null; - } - - // 1. 判断是否已经助力 - if (record != null - && bargainHelpService.getBargainHelp(record.getId(), userId) != null) { - return AppBargainRecordDetailRespVO.HELP_ACTION_SUCCESS; - } - // 2. 判断是否满助力 - BargainActivityDO activity = bargainActivityService.getBargainActivity(activityId); - if (activity != null - && bargainHelpService.getBargainHelpCountByActivity(activityId, userId) >= activity.getBargainCount()) { - return AppBargainRecordDetailRespVO.HELP_ACTION_FULL; - } - // 3. 允许助力 - return AppBargainRecordDetailRespVO.HELP_ACTION_NONE; - } - - @GetMapping("/page") - @Operation(summary = "获得砍价记录的分页") - public CommonResult> getBargainRecordPage(PageParam pageParam) { - PageResult pageResult = bargainRecordService.getBargainRecordPage(getLoginUserId(), pageParam); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - List activityList = bargainActivityService.getBargainActivityList( - convertSet(pageResult.getList(), BargainRecordDO::getActivityId)); - List spuList = productSpuApi.getSpuList( - convertSet(pageResult.getList(), BargainRecordDO::getSpuId)); - List orderList = tradeOrderApi.getOrderList( - convertSet(pageResult.getList(), BargainRecordDO::getOrderId)); - return success(BargainRecordConvert.INSTANCE.convertPage02(pageResult, activityList, spuList, orderList)); - } - - @PostMapping("/create") - @Operation(summary = "创建砍价记录", description = "参与砍价活动") - @PreAuthenticated - public CommonResult createBargainRecord(@RequestBody AppBargainRecordCreateReqVO reqVO) { - Long recordId = bargainRecordService.createBargainRecord(getLoginUserId(), reqVO); - return success(recordId); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java deleted file mode 100644 index 4a1f845041..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 砍价活动的明细 Response VO") -@Data -public class AppBargainActivityDetailRespVO { - - @Schema(description = "砍价活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大砍价") - private String name; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long skuId; - - @Schema(description = "商品价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - - @Schema(description = "商品描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "我要吃西红柿") - private String description; - - @Schema(description = "砍价库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") - private Integer stock; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") // 从 SPU 的 picUrl 读取 - private String picUrl; - - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") // 从 SPU 的 marketPrice 读取 - private Integer marketPrice; - - @Schema(description = "商品单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") // 从 SPU 的 unit 读取,然后转换 - private String unitName; - - @Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer bargainFirstPrice; - - @Schema(description = "砍价最低金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer bargainMinPrice; - - @Schema(description = "砍价成功数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer successUserCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java deleted file mode 100644 index f6e0193a57..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 砍价活动 Response VO") -@Data -public class AppBargainActivityRespVO { - - @Schema(description = "砍价活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大砍价") - private String name; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long skuId; - - @Schema(description = "砍价库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") - private Integer stock; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "4096") - private String picUrl; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - - @Schema(description = "砍价最低金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer bargainMinPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpCreateReqVO.java deleted file mode 100644 index 858b022c61..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpCreateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 App - 砍价助力的创建 Request VO") -@Data -public class AppBargainHelpCreateReqVO { - - @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "砍价记录编号不能为空") - private Long recordId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpRespVO.java deleted file mode 100644 index c7bb20feaa..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 砍价助力 Response VO") -@Data -public class AppBargainHelpRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userId; - - @Schema(description = "助力用户的昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String nickname; - - @Schema(description = "助力用户的头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String avatar; - - @Schema(description = "助力用户的砍价金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer reducePrice; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordCreateReqVO.java deleted file mode 100644 index c1b93a5711..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordCreateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 App - 砍价记录的创建 Request VO") -@Data -public class AppBargainRecordCreateReqVO { - - @Schema(description = "砍价活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "砍价活动编号不能为空") - private Long activityId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordDetailRespVO.java deleted file mode 100644 index 2f408b2c42..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordDetailRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 砍价记录的明细 Response VO") -@Data -public class AppBargainRecordDetailRespVO { - - public static final int HELP_ACTION_NONE = 1; // 帮砍动作 - 未帮砍,可以帮砍 - public static final int HELP_ACTION_FULL = 2; // 帮砍动作 - 未帮砍,无法帮砍(可帮砍次数已满) - public static final int HELP_ACTION_SUCCESS = 3; // 帮砍动作 - 已帮砍 - - // ========== 砍价记录 ========== - - @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") - private Long userId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long skuId; - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private Long activityId; - - @Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - private Integer bargainFirstPrice; - - @Schema(description = "当前砍价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - private Integer bargainPrice; - - @Schema(description = "砍价记录状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - // ========== 订单相关 ========== 注意:只有是自己的砍价记录,才会返回,保证隐私性 - - @Schema(description = "订单编号", example = "1024") - private Long orderId; - - @Schema(description = "支付状态", example = "true") - private Boolean payStatus; - - @Schema(description = "支付订单编号", example = "1024") - private Long payOrderId; - - // ========== 助力记录 ========== - - private Integer helpAction; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java deleted file mode 100644 index 6aa6cd909f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 砍价记录的 Response VO") -@Data -public class AppBargainRecordRespVO { - - @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long skuId; - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long activityId; - - @Schema(description = "砍价记录状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "当前价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "102") - private Integer bargainPrice; - - // ========== 活动相关 ========== - - @Schema(description = "活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private String activityName; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - // ========== 订单相关 ========== - - @Schema(description = "订单编号", example = "1024") - private Long orderId; - - @Schema(description = "支付状态", example = "true") - private Boolean payStatus; - - @Schema(description = "支付订单编号", example = "1024") - private Long payOrderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java deleted file mode 100644 index 8523e00a02..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 砍价记录的简要概括 Response VO") -@Data -public class AppBargainRecordSummaryRespVO { - - @Schema(description = "砍价用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer successUserCount; - - @Schema(description = "成功砍价的记录", requiredMode = Schema.RequiredMode.REQUIRED) // 只返回最近的 7 个 - private List successList; - - @Schema(description = "成功砍价记录") - @Data - public static class Record { - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王**") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "天蚕土豆") - private String activityName; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java deleted file mode 100644 index 867c2d4b83..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "用户 APP - 拼团活动") -@RestController -@RequestMapping("/promotion/combination-activity") -@Validated -public class AppCombinationActivityController { - - /** - * {@link AppCombinationActivityRespVO} 缓存,通过它异步刷新 {@link #getCombinationActivityList0(Integer)} 所要的首页数据 - */ - private final LoadingCache> combinationActivityListCache = buildAsyncReloadingCache(Duration.ofSeconds(10L), - new CacheLoader>() { - - @Override - public List load(Integer count) { - return getCombinationActivityList0(count); - } - - }); - - @Resource - private CombinationActivityService activityService; - - @Resource - private ProductSpuApi spuApi; - - @GetMapping("/list") - @Operation(summary = "获得拼团活动列表", description = "用于小程序首页") - @Parameter(name = "count", description = "需要展示的数量", example = "6") - public CommonResult> getCombinationActivityList( - @RequestParam(name = "count", defaultValue = "6") Integer count) { - return success(combinationActivityListCache.getUnchecked(count)); - } - - private List getCombinationActivityList0(Integer count) { - List activityList = activityService.getCombinationActivityListByCount(count); - if (CollUtil.isEmpty(activityList)) { - return Collections.emptyList(); - } - // 拼接返回 - List productList = activityService.getCombinationProductListByActivityIds( - convertList(activityList, CombinationActivityDO::getId)); - List spuList = spuApi.getSpuList(convertList(activityList, CombinationActivityDO::getSpuId)); - return CombinationActivityConvert.INSTANCE.convertAppList(activityList, productList, spuList); - } - - @GetMapping("/page") - @Operation(summary = "获得拼团活动分页") - public CommonResult> getCombinationActivityPage(PageParam pageParam) { - PageResult pageResult = activityService.getCombinationActivityPage(pageParam); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - // 拼接返回 - List productList = activityService.getCombinationProductListByActivityIds( - convertList(pageResult.getList(), CombinationActivityDO::getId)); - List spuList = spuApi.getSpuList(convertList(pageResult.getList(), CombinationActivityDO::getSpuId)); - return success(CombinationActivityConvert.INSTANCE.convertAppPage(pageResult, productList, spuList)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得拼团活动明细") - @Parameter(name = "id", description = "活动编号", required = true, example = "1024") - public CommonResult getCombinationActivityDetail(@RequestParam("id") Long id) { - // 1. 获取活动 - CombinationActivityDO activity = activityService.getCombinationActivity(id); - if (activity == null - || ObjectUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - return success(null); - } - - // 2. 获取活动商品 - List products = activityService.getCombinationProductsByActivityId(activity.getId()); - return success(CombinationActivityConvert.INSTANCE.convert3(activity, products)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java deleted file mode 100644 index 550c468c68..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.context.annotation.Lazy; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.constraints.Max; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 拼团活动") -@RestController -@RequestMapping("/promotion/combination-record") -@Validated -public class AppCombinationRecordController { - - @Resource - private CombinationRecordService combinationRecordService; - @Resource - @Lazy - private TradeOrderApi tradeOrderApi; - - @GetMapping("/get-summary") - @Operation(summary = "获得拼团记录的概要信息", description = "用于小程序首页") - public CommonResult getCombinationRecordSummary() { - AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO(); - // 1. 获得拼团参与用户数量 - Long userCount = combinationRecordService.getCombinationUserCount(); - if (userCount == 0) { - summary.setAvatars(Collections.emptyList()); - summary.setUserCount(userCount); - return success(summary); - } - summary.setUserCount(userCount); - - // 2. 获得拼团记录头像 - List records = combinationRecordService.getLatestCombinationRecordList( - AppCombinationRecordSummaryRespVO.AVATAR_COUNT); - summary.setAvatars(convertList(records, CombinationRecordDO::getAvatar)); - return success(summary); - } - - @GetMapping("/get-head-list") - @Operation(summary = "获得最近 n 条拼团记录(团长发起的)") - @Parameters({ - @Parameter(name = "activityId", description = "拼团活动编号"), - @Parameter(name = "status", description = "拼团状态"), // 对应 CombinationRecordStatusEnum 枚举 - @Parameter(name = "count", description = "数量") - }) - public CommonResult> getHeadCombinationRecordList( - @RequestParam(value = "activityId", required = false) Long activityId, - @RequestParam("status") Integer status, - @RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) { - return success(CombinationActivityConvert.INSTANCE.convertList3( - combinationRecordService.getHeadCombinationRecordList(activityId, status, count))); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得拼团记录明细") - @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024") - public CommonResult getCombinationRecordDetail(@RequestParam("id") Long id) { - // 1. 查找这条拼团记录 - CombinationRecordDO record = combinationRecordService.getCombinationRecordById(id); - if (record == null) { - return success(null); - } - - // 2. 查找该拼团的参团记录 - CombinationRecordDO headRecord; - List memberRecords; - if (Objects.equals(record.getHeadId(), CombinationRecordDO.HEAD_ID_GROUP)) { // 情况一:团长 - headRecord = record; - memberRecords = combinationRecordService.getCombinationRecordListByHeadId(record.getId()); - } else { // 情况二:团员 - headRecord = combinationRecordService.getCombinationRecordById(record.getHeadId()); - memberRecords = combinationRecordService.getCombinationRecordListByHeadId(headRecord.getId()); - } - - // 3. 拼接数据 - return success(CombinationActivityConvert.INSTANCE.convert(getLoginUserId(), headRecord, memberRecords)); - } - - @GetMapping("/cancel") - @Operation(summary = "取消拼团") - @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024") - public CommonResult cancelCombinationRecord(@RequestParam("id") Long id) { - Long userId = getLoginUserId(); - // 1、查找这条拼团记录 - CombinationRecordDO record = combinationRecordService.getCombinationRecordByIdAndUser(userId, id); - if (record == null) { - return success(Boolean.FALSE); - } - // 1.1、需要先校验拼团记录未完成; - if (!CombinationRecordStatusEnum.isInProgress(record.getStatus())) { - return success(Boolean.FALSE); - } - - // 2. 取消已支付的订单 - tradeOrderApi.cancelPaidOrder(userId, record.getOrderId()); - // 3. 取消拼团记录 - combinationRecordService.cancelCombinationRecord(userId, record.getId(), record.getHeadId()); - return success(Boolean.TRUE); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityDetailRespVO.java deleted file mode 100644 index e2996b89b9..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityDetailRespVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 拼团活动明细 Response VO") -@Data -public class AppCombinationActivityDetailRespVO { - - @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "拼团活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大拼团") - private String name; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "拼团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") - private Integer userSize; - - @Schema(description = "成功的拼团数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer successCount; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "总共限购数量", example = "10") - private Integer totalLimitCount; - - @Schema(description = "单次限购数量", example = "5") - private Integer singleLimitCount; - - @Schema(description = "商品信息数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - @Schema(description = "商品信息") - @Data - public static class Product { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") - private Long skuId; - - @Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer combinationPrice; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java deleted file mode 100644 index 64462a3771..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 拼团活动 Response VO") -@Data -public class AppCombinationActivityRespVO { - - @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "拼团活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大拼团") - private String name; - - @Schema(description = "拼团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") - private Integer userSize; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") - // 从 SPU 的 picUrl 读取 - private String picUrl; - - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - // 从 SPU 的 marketPrice 读取 - private Integer marketPrice; - - @Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordDetailRespVO.java deleted file mode 100644 index 7c310a6700..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordDetailRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 拼团记录详细 Response VO") -@Data -public class AppCombinationRecordDetailRespVO { - - @Schema(description = "团长的拼团记录", requiredMode = Schema.RequiredMode.REQUIRED) - private AppCombinationRecordRespVO headRecord; - - @Schema(description = "成员的拼团记录", requiredMode = Schema.RequiredMode.REQUIRED) - private List memberRecords; - - @Schema(description = "当前用户参团记录对应的订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordRespVO.java deleted file mode 100644 index 09d6ff3be8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordRespVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 拼团记录 Response VO") -@Data -public class AppCombinationRecordRespVO { - - @Schema(description = "拼团记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long activityId; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String avatar; - - @Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime expireTime; - - @Schema(description = "可参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer userSize; - - @Schema(description = "已参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer userCount; - - @Schema(description = "拼团状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "商品名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是大黄豆") - private String spuName; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordSummaryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordSummaryRespVO.java deleted file mode 100644 index d9ea03d6f7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordSummaryRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 拼团记录的简要概括 Response VO") -@Data -public class AppCombinationRecordSummaryRespVO { - - /** - * 加载 {@link #avatars} 的数量 - */ - public static final Integer AVATAR_COUNT = 7; - - @Schema(description = "拼团用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userCount; - - @Schema(description = "拼团用户头像列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List avatars; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java deleted file mode 100755 index d0199bdf2b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.*; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 优惠劵") -@RestController -@RequestMapping("/promotion/coupon") -@Validated -public class AppCouponController { - - @Resource - private CouponService couponService; - @Resource - private CouponTemplateService couponTemplateService; - - @PostMapping("/take") - @Operation(summary = "领取优惠劵") - @Parameter(name = "templateId", description = "优惠券模板编号", required = true, example = "1024") - @PreAuthenticated - public CommonResult takeCoupon(@Valid @RequestBody AppCouponTakeReqVO reqVO) { - // 1. 领取优惠劵 - Long userId = getLoginUserId(); - couponService.takeCoupon(reqVO.getTemplateId(), CollUtil.newHashSet(userId), CouponTakeTypeEnum.USER); - - // 2. 检查是否可以继续领取 - CouponTemplateDO couponTemplate = couponTemplateService.getCouponTemplate(reqVO.getTemplateId()); - boolean canTakeAgain = true; - if (couponTemplate.getTakeLimitCount() != null && couponTemplate.getTakeLimitCount() > 0) { - Integer takeCount = couponService.getTakeCount(reqVO.getTemplateId(), userId); - canTakeAgain = takeCount < couponTemplate.getTakeLimitCount(); - } - return success(canTakeAgain); - } - - @GetMapping("/match-list") - @Operation(summary = "获得匹配指定商品的优惠劵列表", description = "用于下单页,展示优惠劵列表") - public CommonResult> getMatchCouponList(AppCouponMatchReqVO matchReqVO) { - // todo: 优化:优惠金额倒序 - return success(CouponConvert.INSTANCE.convertList(couponService.getMatchCouponList(getLoginUserId(), matchReqVO))); - } - - @GetMapping("/page") - @Operation(summary = "我的优惠劵列表") - @PreAuthenticated - public CommonResult> getCouponPage(AppCouponPageReqVO pageReqVO) { - PageResult pageResult = couponService.getCouponPage( - CouponConvert.INSTANCE.convert(pageReqVO, Collections.singleton(getLoginUserId()))); - return success(CouponConvert.INSTANCE.convertAppPage(pageResult)); - } - - @GetMapping(value = "/get-unused-count") - @Operation(summary = "获得未使用的优惠劵数量") - @PreAuthenticated - public CommonResult getUnusedCouponCount() { - return success(couponService.getUnusedCouponCount(getLoginUserId())); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java deleted file mode 100755 index affb17262f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplateRespVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.util.*; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 优惠劵模板") -@RestController -@RequestMapping("/promotion/coupon-template") -@Validated -public class AppCouponTemplateController { - - @Resource - private CouponTemplateService couponTemplateService; - @Resource - private CouponService couponService; - - @Resource - private ProductSpuApi productSpuApi; - - @GetMapping("/list") - @Operation(summary = "获得优惠劵模版列表") - @Parameters({ - @Parameter(name = "spuId", description = "商品 SPU 编号"), // 目前主要给商品详情使用 - @Parameter(name = "useType", description = "使用类型"), - @Parameter(name = "count", description = "数量", required = true) - }) - public CommonResult> getCouponTemplateList( - @RequestParam(value = "spuId", required = false) Long spuId, - @RequestParam(value = "productScope", required = false) Integer productScope, - @RequestParam(value = "count", required = false, defaultValue = "10") Integer count) { - // 1.1 处理查询条件:商品范围编号 - Long productScopeValue = getProductScopeValue(productScope, spuId); - // 1.2 处理查询条件:领取方式 = 直接领取 - List canTakeTypes = Collections.singletonList(CouponTakeTypeEnum.USER.getValue()); - - // 2. 查询 - List list = couponTemplateService.getCouponTemplateList(canTakeTypes, productScope, - productScopeValue, count); - - // 3.1 领取数量 - Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), list); - // 3.2 拼接返回 - return success(CouponTemplateConvert.INSTANCE.convertAppList(list, canCanTakeMap)); - } - - @GetMapping("/list-by-ids") - @Operation(summary = "获得优惠劵模版列表") - @Parameter(name = "ids", description = "优惠券模板编号列表") - public CommonResult> getCouponTemplateList( - @RequestParam(value = "ids", required = false) Set ids) { - // 1. 查询 - List list = couponTemplateService.getCouponTemplateList(ids); - - // 2.1 领取数量 - Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), list); - // 2.2 拼接返回 - return success(CouponTemplateConvert.INSTANCE.convertAppList(list, canCanTakeMap)); - } - - @GetMapping("/page") - @Operation(summary = "获得优惠劵模版分页") - public CommonResult> getCouponTemplatePage(AppCouponTemplatePageReqVO pageReqVO) { - // 1.1 处理查询条件:商品范围编号 - Long productScopeValue = getProductScopeValue(pageReqVO.getProductScope(), pageReqVO.getSpuId()); - // 1.2 处理查询条件:领取方式 = 直接领取 - List canTakeTypes = Collections.singletonList(CouponTakeTypeEnum.USER.getValue()); - - // 2. 分页查询 - PageResult pageResult = couponTemplateService.getCouponTemplatePage( - CouponTemplateConvert.INSTANCE.convert(pageReqVO, canTakeTypes, pageReqVO.getProductScope(), productScopeValue)); - - // 3.1 领取数量 - Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), pageResult.getList()); - // 3.2 拼接返回 - return success(CouponTemplateConvert.INSTANCE.convertAppPage(pageResult, canCanTakeMap)); - } - - /** - * 获得商品的使用范围编号 - * - * @param productScope 商品范围 - * @param spuId 商品 SPU 编号 - * @return 商品范围编号 - */ - private Long getProductScopeValue(Integer productScope, Long spuId) { - // 通用券:没有商品范围 - if (ObjectUtils.equalsAny(productScope, PromotionProductScopeEnum.ALL.getScope(), null)) { - return null; - } - // 品类券:查询商品的品类编号 - if (Objects.equals(productScope, PromotionProductScopeEnum.CATEGORY.getScope()) && spuId != null) { - ProductSpuRespDTO spu = productSpuApi.getSpu(spuId); - return spu != null ? spu.getCategoryId() : null; - } - // 商品卷:直接返回 - return spuId; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchReqVO.java deleted file mode 100755 index 6dc287d988..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 优惠劵的匹配 Request VO") -@Data -public class AppCouponMatchReqVO { - - @Schema(description = "商品金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品金额不能为空") - private Integer price; - - @Schema(description = "商品 SPU 编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") - @NotEmpty(message = "商品 SPU 编号不能为空") - private List spuIds; - - @Schema(description = "商品 SKU 编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") - @NotEmpty(message = "商品 SKU 编号不能为空") - private List skuIds; - - @Schema(description = "分类编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[10, 20]") - @NotEmpty(message = "分类编号不能为空") - private List categoryIds; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchRespVO.java deleted file mode 100755 index da60390fe5..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 优惠劵 Response VO") -@Data -public class AppCouponMatchRespVO extends AppCouponRespVO { - - @Schema(description = "是否匹配", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean match; - - @Schema(description = "匹配条件的提示", example = "所结算商品没有符合条件的商品") - private String description; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponPageReqVO.java deleted file mode 100644 index 0c423959b6..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 App - 优惠劵分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppCouponPageReqVO extends PageParam { - - @Schema(description = "优惠劵状态", example = "1") - @InEnum(value = CouponStatusEnum.class, message = "优惠劵状态,必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java deleted file mode 100755 index b9107d9f26..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.Min; -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 优惠劵 Response VO") -@Data -public class AppCouponRespVO { - - @Schema(description = "优惠劵编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - private String name; - - @Schema(description = "优惠劵状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 参见 CouponStatusEnum 枚举 - private Integer status; - - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - // 单位:分;0 - 不限制 - private Integer usePrice; - - @Schema(description = "固定日期 - 生效开始时间") - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - private LocalDateTime validEndTime; - - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 - private Integer discountLimitPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponTakeReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponTakeReqVO.java deleted file mode 100644 index 6472145999..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponTakeReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 App - 优惠劵领取 Request VO") -@Data -public class AppCouponTakeReqVO { - - @Schema(description = "优惠劵模板编号", example = "1") - @NotNull(message = "优惠劵模板编号不能为空") - private Long templateId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplatePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplatePageReqVO.java deleted file mode 100644 index d98b2f161d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplatePageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 App - 优惠劵模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppCouponTemplatePageReqVO extends PageParam { - - @Schema(description = "商品范围", example = "1") - @InEnum(value = PromotionProductScopeEnum.class, message = "商品范围,必须是 {value}") - private Integer productScope; - - @Schema(description = "商品标号", example = "1") - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplateRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplateRespVO.java deleted file mode 100755 index eb4549ea75..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplateRespVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.Min; -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 优惠劵模板 Response VO") -@Data -public class AppCouponTemplateRespVO { - - @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - private String name; - - @Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制 - private Integer takeLimitCount; - - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - // 单位:分;0 - 不限制 - private Integer usePrice; - - @Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer validityType; - - @Schema(description = "固定日期 - 生效开始时间") - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - private LocalDateTime validEndTime; - - @Schema(description = "领取日期 - 开始天数") - @Min(value = 0L, message = "开始天数必须大于 0") - private Integer fixedStartTerm; - - @Schema(description = "领取日期 - 结束天数") - @Min(value = 1L, message = "开始天数必须大于 1") - private Integer fixedEndTerm; - - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 - private Integer discountLimitPrice; - - // ========== 用户相关字段 ========== - - @Schema(description = "是否可以领取", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean canTake; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/decorate/AppDecorateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/decorate/AppDecorateController.java deleted file mode 100644 index 36ae25b550..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/decorate/AppDecorateController.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.decorate; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.controller.app.decorate.vo.AppDecorateComponentRespVO; -import cn.iocoder.yudao.module.promotion.convert.decorate.DecorateComponentConvert; -import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; -import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 店铺装修") -@RestController -@RequestMapping("/promotion/decorate") -@Validated -public class AppDecorateController { - - @Resource - private DecorateComponentService decorateComponentService; - - @GetMapping("/list") - @Operation(summary = "获取指定页面的组件列表") - @Parameter(name = "page", description = "页面编号", required = true) - public CommonResult> getDecorateComponentListByPage( - @RequestParam("page") @InEnum(DecoratePageEnum.class) Integer page) { - return success(DecorateComponentConvert.INSTANCE.convertList( - decorateComponentService.getDecorateComponentListByPage(page, CommonStatusEnum.ENABLE.getStatus()))); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/decorate/vo/AppDecorateComponentRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/decorate/vo/AppDecorateComponentRespVO.java deleted file mode 100644 index 8926db26e3..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/decorate/vo/AppDecorateComponentRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.decorate.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 页面组件 Resp VO") -@Data -public class AppDecorateComponentRespVO { - - @Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu") - private String code; - - @Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO") - private String value; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java deleted file mode 100644 index fa1ea2d5b3..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.diy; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePropertyRespVO; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; -import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; - -@Tag(name = "用户 APP - 装修模板") -@RestController -@RequestMapping("/promotion/diy-template") -@Validated -public class AppDiyTemplateController { - - @Resource - private DiyTemplateService diyTemplateService; - @Resource - private DiyPageService diyPageService; - - @GetMapping("/used") - @Operation(summary = "使用中的装修模板") - public CommonResult getUsedDiyTemplate() { - DiyTemplateDO diyTemplate = diyTemplateService.getUsedDiyTemplate(); - return success(buildVo(diyTemplate)); - } - - @GetMapping("/get") - @Operation(summary = "获得装修模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getDiyTemplate(@RequestParam("id") Long id) { - DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id); - return success(buildVo(diyTemplate)); - } - - private AppDiyTemplatePropertyRespVO buildVo(DiyTemplateDO diyTemplate) { - if (diyTemplate == null) { - return null; - } - // 查询模板下的页面 - List pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId()); - String home = findFirst(pages, page -> "首页".equals(page.getName()), DiyPageDO::getProperty); - String user = findFirst(pages, page -> "我的".equals(page.getName()), DiyPageDO::getProperty); - // 拼接返回 - return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, home, user); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyPagePropertyRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyPagePropertyRespVO.java deleted file mode 100644 index 9d623f5d47..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyPagePropertyRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.diy.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "用户 App - 装修页面属性 Response VO") -@Data -@ToString(callSuper = true) -public class AppDiyPagePropertyRespVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "页面名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "页面属性", example = "[]") - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyTemplatePropertyRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyTemplatePropertyRespVO.java deleted file mode 100644 index aa237e088e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyTemplatePropertyRespVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.diy.vo; - -import com.fasterxml.jackson.annotation.JsonRawValue; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "用户 App - 装修模板属性 Response VO") -@Data -@ToString(callSuper = true) -public class AppDiyTemplatePropertyRespVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题") - private String name; - - @Schema(description = "模板属性", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @JsonRawValue - private String property; - - @Schema(description = "首页", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @JsonRawValue - private String home; - - @Schema(description = "我的", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @JsonRawValue - private String user; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java deleted file mode 100644 index c2da19e5d7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java +++ /dev/null @@ -1,152 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityNowRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityRespVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.context.annotation.Lazy; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween; - -@Tag(name = "用户 App - 秒杀活动") -@RestController -@RequestMapping("/promotion/seckill-activity") -@Validated -public class AppSeckillActivityController { - - /** - * {@link AppSeckillActivityNowRespVO} 缓存,通过它异步刷新 {@link #getNowSeckillActivity()} 所要的首页数据 - */ - private final LoadingCache nowSeckillActivityCache = buildAsyncReloadingCache(Duration.ofSeconds(10L), - new CacheLoader() { - - @Override - public AppSeckillActivityNowRespVO load(String key) { - return getNowSeckillActivity0(); - } - - }); - - @Resource - private SeckillActivityService activityService; - @Resource - @Lazy - private SeckillConfigService configService; - - @Resource - private ProductSpuApi spuApi; - - @GetMapping("/get-now") - @Operation(summary = "获得当前秒杀活动", description = "获取当前正在进行的活动,提供给首页使用") - public CommonResult getNowSeckillActivity() { - return success(nowSeckillActivityCache.getUnchecked("")); // 缓存 - } - - private AppSeckillActivityNowRespVO getNowSeckillActivity0() { - // 1. 获取当前时间处在哪个秒杀阶段 - SeckillConfigDO config = configService.getCurrentSeckillConfig(); - if (config == null) { // 时段不存在直接返回 null - return new AppSeckillActivityNowRespVO(); - } - - // 2.1 查询满足当前阶段的活动 - List activityList = activityService.getSeckillActivityListByConfigIdAndStatus(config.getId(), CommonStatusEnum.ENABLE.getStatus()); - List productList = activityService.getSeckillProductListByActivityId( - convertList(activityList, SeckillActivityDO::getId)); - // 2.2 获取 spu 信息 - List spuList = spuApi.getSpuList(convertList(activityList, SeckillActivityDO::getSpuId)); - return SeckillActivityConvert.INSTANCE.convert(config, activityList, productList, spuList); - } - - @GetMapping("/page") - @Operation(summary = "获得秒杀活动分页") - public CommonResult> getSeckillActivityPage(AppSeckillActivityPageReqVO pageReqVO) { - // 1. 查询满足当前阶段的活动 - PageResult pageResult = activityService.getSeckillActivityAppPageByConfigId(pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - List productList = activityService.getSeckillProductListByActivityId( - convertList(pageResult.getList(), SeckillActivityDO::getId)); - - // 2. 拼接数据 - List spuList = spuApi.getSpuList(convertList(pageResult.getList(), SeckillActivityDO::getSpuId)); - return success(SeckillActivityConvert.INSTANCE.convertPage02(pageResult, productList, spuList)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得秒杀活动明细") - @Parameter(name = "id", description = "活动编号", required = true, example = "1024") - public CommonResult getSeckillActivity(@RequestParam("id") Long id) { - // 1. 获取活动 - SeckillActivityDO activity = activityService.getSeckillActivity(id); - if (activity == null - || ObjectUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - return success(null); - } - - // 2. 获取时间段 - List configs = configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus()); - configs.removeIf(config -> !CollUtil.contains(activity.getConfigIds(), config.getId())); - // 2.1 优先使用当前时间段 - SeckillConfigDO config = findFirst(configs, config0 -> isBetween(config0.getStartTime(), config0.getEndTime())); - // 2.2 如果没有,则获取最后一个,因为倾向优先展示“未开始” > “已结束” - if (config == null) { - config = CollUtil.getLast(configs); - } - if (config == null) { - return null; - } - // 3. 计算开始时间、结束时间 - LocalDate nowDate; - // 3.1 如果在活动日期范围内,则以今天为 nowDate - if (LocalDateTimeUtils.isBetween(activity.getStartTime(), activity.getEndTime())) { - nowDate = LocalDate.now(); - } else { - // 3.2 如果不在活动时间范围内,则直接以活动的 endTime 作为 nowDate,因为还是倾向优先展示“未开始” > “已结束” - nowDate = activity.getEndTime().toLocalDate(); - } - LocalDateTime startTime = LocalDateTime.of(nowDate, LocalTime.parse(config.getStartTime())); - LocalDateTime endTime = LocalDateTime.of(nowDate, LocalTime.parse(config.getEndTime())); - - // 4. 拼接数据 - List productList = activityService.getSeckillProductListByActivityId(activity.getId()); - return success(SeckillActivityConvert.INSTANCE.convert3(activity, productList, startTime, endTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java deleted file mode 100644 index 19afdce030..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 秒杀时间段") -@RestController -@RequestMapping("/promotion/seckill-config") -@Validated -public class AppSeckillConfigController { - @Resource - private SeckillConfigService configService; - - @GetMapping("/list") - @Operation(summary = "获得秒杀时间段列表") - public CommonResult> getSeckillConfigList() { - List list = configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(SeckillConfigConvert.INSTANCE.convertList2(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityDetailRespVO.java deleted file mode 100644 index ebb5ac54d9..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityDetailRespVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 秒杀活动的详细 Response VO") -@Data -public class AppSeckillActivityDetailRespVO { - - @Schema(description = "秒杀活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晚九点限时秒杀") - private String name; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "总共限购数量", example = "10") - private Integer totalLimitCount; - - @Schema(description = "单次限购数量", example = "5") - private Integer singleLimitCount; - - @Schema(description = "秒杀库存(剩余)", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer stock; - - @Schema(description = "秒杀库存(总计)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer totalStock; - - @Schema(description = "商品信息数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - @Schema(description = "商品信息") - @Data - public static class Product { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") - private Long skuId; - - @Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer seckillPrice; - - @Schema(description = "秒杀限量库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer stock; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityNowRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityNowRespVO.java deleted file mode 100644 index 5dad129040..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityNowRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 当前秒杀活动 Response VO") -@Data -public class AppSeckillActivityNowRespVO { - - @Schema(description = "秒杀时间段", requiredMode = Schema.RequiredMode.REQUIRED) - private AppSeckillConfigRespVO config; - - @Schema(description = "秒杀活动数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List activities; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityPageReqVO.java deleted file mode 100644 index 158f11fd3a..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 App - 商品评价分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppSeckillActivityPageReqVO extends PageParam { - - @Schema(description = "秒杀配置编号", example = "1024") - private Long configId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java deleted file mode 100644 index 947a1122d5..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 秒杀活动 Response VO") -@Data -public class AppSeckillActivityRespVO { - - @Schema(description = "秒杀活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晚九点限时秒杀") - private String name; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - @Schema(description = "单位名", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") - private String unitName; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - - @Schema(description = "秒杀活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "秒杀库存(剩余)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer stock; - @Schema(description = "秒杀库存(总共)", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer totalStock; - - @Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer seckillPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/config/AppSeckillConfigRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/config/AppSeckillConfigRespVO.java deleted file mode 100644 index c981f8429b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/config/AppSeckillConfigRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 秒杀时间段 Response VO") -@Data -public class AppSeckillConfigRespVO { - - @Schema(description = "秒杀时间段编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "开始时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:00") - private String startTime; - @Schema(description = "结束时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:59") - private String endTime; - - @Schema(description = "轮播图", requiredMode = Schema.RequiredMode.REQUIRED) - private List sliderPicUrls; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java deleted file mode 100644 index b5ac4f4b34..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 文章分类 Convert - * - * @author HUIHUI - */ -@Mapper -public interface ArticleCategoryConvert { - - ArticleCategoryConvert INSTANCE = Mappers.getMapper(ArticleCategoryConvert.class); - - ArticleCategoryDO convert(ArticleCategoryCreateReqVO bean); - - ArticleCategoryDO convert(ArticleCategoryUpdateReqVO bean); - - ArticleCategoryRespVO convert(ArticleCategoryDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList03(List list); - - List convertList04(List categoryList); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java deleted file mode 100644 index 7f4867f5d6..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 文章管理 Convert - * - * @author HUIHUI - */ -@Mapper -public interface ArticleConvert { - - ArticleConvert INSTANCE = Mappers.getMapper(ArticleConvert.class); - - ArticleDO convert(ArticleCreateReqVO bean); - - ArticleDO convert(ArticleUpdateReqVO bean); - - ArticleRespVO convert(ArticleDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - AppArticleRespVO convert01(ArticleDO article); - - PageResult convertPage02(PageResult articlePage); - - List convertList03(List articleCategoryListByRecommendHotAndRecommendBanner); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/banner/BannerConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/banner/BannerConvert.java deleted file mode 100644 index d2d75362e5..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/banner/BannerConvert.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.banner.vo.AppBannerRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface BannerConvert { - - BannerConvert INSTANCE = Mappers.getMapper(BannerConvert.class); - - List convertList(List list); - - PageResult convertPage(PageResult pageResult); - - BannerRespVO convert(BannerDO banner); - - BannerDO convert(BannerCreateReqVO createReqVO); - - BannerDO convert(BannerUpdateReqVO updateReqVO); - - List convertList01(List bannerList); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java deleted file mode 100644 index 47448dfd38..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.enums.DictTypeConstants; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 拼团活动 Convert - * - * @author HUIHUI - */ -@Mapper -public interface BargainActivityConvert { - - BargainActivityConvert INSTANCE = Mappers.getMapper(BargainActivityConvert.class); - - BargainActivityDO convert(BargainActivityBaseVO bean); - - BargainActivityDO convert(BargainActivityUpdateReqVO bean); - - BargainActivityRespVO convert(BargainActivityDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, List spuList, - Map recordUserCountMap, Map recordSuccessUserCountMap, - Map helpUserCountMap) { - PageResult result = convertPage(page); - // 拼接关联属性 - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - result.getList().forEach(item -> { - findAndThen(spuMap, item.getSpuId(), spu -> { - item.setPicUrl(spu.getPicUrl()).setSpuName(spu.getName()); - }); - // 设置统计字段 - item.setRecordUserCount(recordUserCountMap.getOrDefault(item.getId(), 0)) - .setRecordSuccessUserCount(recordSuccessUserCountMap.getOrDefault(item.getId(), 0)) - .setHelpUserCount(helpUserCountMap.getOrDefault(item.getId(), 0)); - }); - return result; - } - - AppBargainActivityDetailRespVO convert1(BargainActivityDO bean); - - default AppBargainActivityDetailRespVO convert(BargainActivityDO bean, Integer successUserCount, ProductSpuRespDTO spu) { - AppBargainActivityDetailRespVO detail = convert1(bean).setSuccessUserCount(successUserCount); - if (spu != null) { - detail.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()) - .setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit())); - } - return detail; - } - - PageResult convertAppPage(PageResult page); - - default PageResult convertAppPage(PageResult page, List spuList) { - PageResult result = convertAppPage(page); - // 拼接关联属性 - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - List list = CollectionUtils.convertList(result.getList(), item -> { - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - result.setList(list); - return result; - } - - List convertAppList(List list); - - default List convertAppList(List list, List spuList) { - List activityList = convertAppList(list); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - return CollectionUtils.convertList(activityList, item -> { - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainHelpConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainHelpConvert.java deleted file mode 100644 index 6ec71ce7cf..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainHelpConvert.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 砍价助力 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BargainHelpConvert { - - BargainHelpConvert INSTANCE = Mappers.getMapper(BargainHelpConvert.class); - - default PageResult convertPage(PageResult page, - Map userMap) { - PageResult pageResult = convertPage(page); - // 拼接数据 - pageResult.getList().forEach(record -> - MapUtils.findAndThen(userMap, record.getUserId(), - user -> record.setNickname(user.getNickname()).setAvatar(user.getAvatar()))); - return pageResult; - } - PageResult convertPage(PageResult page); - - default List convertList(List helps, - Map userMap) { - List helpVOs = convertList02(helps); - helpVOs.forEach(help -> - MapUtils.findAndThen(userMap, help.getUserId(), - user -> help.setNickname(user.getNickname()).setAvatar(user.getAvatar()))); - return helpVOs; - } - List convertList02(List helps); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java deleted file mode 100644 index 5c1bf75a3b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordSummaryRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 砍价记录 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BargainRecordConvert { - - BargainRecordConvert INSTANCE = Mappers.getMapper(BargainRecordConvert.class); - - default PageResult convertPage(PageResult page, - Map helpCountMap, - List activityList, - Map userMap) { - PageResult pageResult = convertPage(page); - // 拼接数据 - Map activityMap = convertMap(activityList, BargainActivityDO::getId); - pageResult.getList().forEach(record -> { - MapUtils.findAndThen(userMap, record.getUserId(), - user -> record.setNickname(user.getNickname()).setAvatar(user.getAvatar())); - record.setActivity(BargainActivityConvert.INSTANCE.convert(activityMap.get(record.getActivityId()))) - .setHelpCount(helpCountMap.getOrDefault(record.getId(), 0)); - }); - return pageResult; - } - PageResult convertPage(PageResult page); - - default PageResult convertPage02(PageResult page, - List activityList, - List spuList, - List orderList) { - PageResult pageResult = convertPage02(page); - // 拼接数据 - Map activityMap = convertMap(activityList, BargainActivityDO::getId); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map orderMap = convertMap(orderList, TradeOrderRespDTO::getId); - pageResult.getList().forEach(record -> { - MapUtils.findAndThen(activityMap, record.getActivityId(), - activity -> record.setActivityName(activity.getName()).setEndTime(activity.getEndTime())); - MapUtils.findAndThen(spuMap, record.getSpuId(), - spu -> record.setPicUrl(record.getPicUrl())); - MapUtils.findAndThen(orderMap, record.getOrderId(), - order -> record.setPayStatus(order.getPayStatus()).setPayOrderId(order.getPayOrderId())); - }); - return pageResult; - } - PageResult convertPage02(PageResult page); - - default AppBargainRecordSummaryRespVO convert(Integer successUserCount, List successList, - List activityList, Map userMap) { - AppBargainRecordSummaryRespVO summary = new AppBargainRecordSummaryRespVO().setSuccessUserCount(successUserCount); - Map activityMap = convertMap(activityList, BargainActivityDO::getId); - summary.setSuccessList(CollectionUtils.convertList(successList, record -> { - AppBargainRecordSummaryRespVO.Record recordVO = new AppBargainRecordSummaryRespVO.Record(); - MapUtils.findAndThen(userMap, record.getUserId(), - user -> recordVO.setNickname(user.getNickname()).setAvatar(user.getAvatar())); - MapUtils.findAndThen(activityMap, record.getActivityId(), - activity -> recordVO.setActivityName(activity.getName())); - return recordVO; - })); - return summary; - } - - @Mapping(source = "record.id", target = "id") - @Mapping(source = "record.userId", target = "userId") - @Mapping(source = "record.status", target = "status") - AppBargainRecordDetailRespVO convert02(BargainRecordDO record, Integer helpAction, TradeOrderRespDTO order); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java deleted file mode 100644 index 1e4405b0db..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java +++ /dev/null @@ -1,229 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.combination; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 拼团活动 Convert - * - * @author HUIHUI - */ -@Mapper -public interface CombinationActivityConvert { - - CombinationActivityConvert INSTANCE = Mappers.getMapper(CombinationActivityConvert.class); - - CombinationActivityDO convert(CombinationActivityCreateReqVO bean); - - CombinationActivityDO convert(CombinationActivityUpdateReqVO bean); - - CombinationActivityRespVO convert(CombinationActivityDO bean); - - CombinationProductRespVO convert(CombinationProductDO bean); - - default CombinationActivityRespVO convert(CombinationActivityDO activity, List products) { - return convert(activity).setProducts(convertList2(products)); - } - - List convertList(List list); - - - default PageResult convertPage(PageResult page, - List productList, - Map groupCountMap, - Map groupSuccessCountMap, - Map recordCountMap, - List spuList) { - PageResult pageResult = convertPage(page); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - pageResult.getList().forEach(item -> { - MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()) - .setMarketPrice(spu.getMarketPrice())); - item.setProducts(convertList2(productList)); - // 设置统计字段 - item.setGroupCount(groupCountMap.getOrDefault(item.getId(), 0)) - .setGroupSuccessCount(groupSuccessCountMap.getOrDefault(item.getId(), 0)) - .setRecordCount(recordCountMap.getOrDefault(item.getId(), 0)); - }); - return pageResult; - } - - PageResult convertPage(PageResult page); - - List convertList2(List productDOs); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(target = "activityId", source = "activity.id"), - @Mapping(target = "spuId", source = "activity.spuId"), - @Mapping(target = "skuId", source = "product.skuId"), - @Mapping(target = "combinationPrice", source = "product.combinationPrice"), - @Mapping(target = "activityStartTime", source = "activity.startTime"), - @Mapping(target = "activityEndTime", source = "activity.endTime") - }) - CombinationProductDO convert(CombinationActivityDO activity, CombinationProductBaseVO product); - - default List convertList(List products, CombinationActivityDO activity) { - return CollectionUtils.convertList(products, item -> convert(activity, item).setActivityStatus(activity.getStatus())); - } - - default List convertList(List updateProductVOs, - List products, CombinationActivityDO activity) { - Map productMap = convertMap(products, CombinationProductDO::getSkuId, CombinationProductDO::getId); - return CollectionUtils.convertList(updateProductVOs, updateProductVO -> convert(activity, updateProductVO) - .setId(productMap.get(updateProductVO.getSkuId())) - .setActivityStatus(activity.getStatus())); - } - - CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO); - - default CombinationRecordCreateRespDTO convert4(CombinationRecordDO combinationRecord) { - return new CombinationRecordCreateRespDTO().setCombinationActivityId(combinationRecord.getActivityId()) - .setCombinationRecordId(combinationRecord.getId()).setCombinationHeadId(combinationRecord.getHeadId()); - } - - default CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO, - CombinationActivityDO activity, MemberUserRespDTO user, - ProductSpuRespDTO spu, ProductSkuRespDTO sku) { - return convert(reqDTO).setVirtualGroup(false) - .setStatus(CombinationRecordStatusEnum.IN_PROGRESS.getStatus()) // 创建后默认状态为进行中 - .setUserSize(activity.getUserSize()).setUserCount(1) // 默认就是 1 插入后会接着更新一次所有的拼团记录 - // 用户信息 - .setNickname(user.getNickname()).setAvatar(user.getAvatar()) - // 商品信息 - .setSpuName(spu.getName()).setPicUrl(sku.getPicUrl()); - - } - - List convertAppList(List list); - - default List convertAppList(List list, - List productList, - List spuList) { - List activityList = convertAppList(list); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map> productMap = convertMultiMap(productList, CombinationProductDO::getActivityId); - return CollectionUtils.convertList(activityList, item -> { - // 设置 product 信息 - item.setCombinationPrice(getMinValue(productMap.get(item.getId()), CombinationProductDO::getCombinationPrice)); - // 设置 SPU 信息 - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - } - - PageResult convertAppPage(PageResult result); - - default PageResult convertAppPage(PageResult result, - List productList, - List spuList) { - PageResult appPage = convertAppPage(result); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map> productMap = convertMultiMap(productList, CombinationProductDO::getActivityId); - List list = CollectionUtils.convertList(appPage.getList(), item -> { - // 设置 product 信息 - item.setCombinationPrice(getMinValue(productMap.get(item.getId()), CombinationProductDO::getCombinationPrice)); - // 设置 SPU 信息 - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - appPage.setList(list); - return appPage; - } - - AppCombinationActivityDetailRespVO convert2(CombinationActivityDO combinationActivity); - - List convertList1(List products); - - default AppCombinationActivityDetailRespVO convert3(CombinationActivityDO combinationActivity, List products) { - return convert2(combinationActivity).setProducts(convertList1(products)); - } - - List convertList3(List records); - - AppCombinationRecordRespVO convert(CombinationRecordDO record); - - PageResult convert(PageResult result); - - default PageResult convert(PageResult recordPage, List activities, List products) { - PageResult result = convert(recordPage); - // 拼接关联属性 - Map activityMap = convertMap(activities, CombinationActivityDO::getId); - Map> productsMap = convertMultiMap(products, CombinationProductDO::getActivityId); - result.setList(CollectionUtils.convertList(result.getList(), item -> { - findAndThen(activityMap, item.getActivityId(), activity -> { - item.setActivity(convert(activity).setProducts(convertList2(productsMap.get(item.getActivityId())))); - }); - return item; - })); - return result; - } - - default AppCombinationRecordDetailRespVO convert(Long userId, CombinationRecordDO headRecord, List memberRecords) { - AppCombinationRecordDetailRespVO respVO = new AppCombinationRecordDetailRespVO() - .setHeadRecord(convert(headRecord)).setMemberRecords(convertList3(memberRecords)); - // 处理自己参与拼团的 orderId - CombinationRecordDO userRecord = CollectionUtils.findFirst(memberRecords, r -> ObjectUtil.equal(r.getUserId(), userId)); - if (userRecord == null && ObjectUtil.equal(headRecord.getUserId(), userId)) { - userRecord = headRecord; - } - respVO.setOrderId(userRecord == null ? null : userRecord.getOrderId()); - return respVO; - } - - /** - * 转换生成虚拟成团虚拟记录 - * - * @param headRecord 虚拟成团团长记录 - * @return 虚拟记录列表 - */ - default List convertVirtualRecordList(CombinationRecordDO headRecord) { - int count = headRecord.getUserSize() - headRecord.getUserCount(); - List createRecords = new ArrayList<>(count); - for (int i = 0; i < count; i++) { - // 基础信息和团长保持一致 - CombinationRecordDO newRecord = convert5(headRecord); - // 虚拟信息 - newRecord.setCount(0) // 会单独更新下,在后续的 Service 逻辑里 - .setUserId(0L).setNickname("").setAvatar("").setOrderId(0L); - createRecords.add(newRecord); - } - return createRecords; - } - @Mapping(target = "id", ignore = true) - CombinationRecordDO convert5(CombinationRecordDO headRecord); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java deleted file mode 100755 index f036c90c9e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 优惠劵 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface CouponConvert { - - CouponConvert INSTANCE = Mappers.getMapper(CouponConvert.class); - - PageResult convertPage(PageResult page); - - CouponRespDTO convert(CouponDO bean); - - default CouponDO convert(CouponTemplateDO template, Long userId) { - CouponDO couponDO = new CouponDO() - .setTemplateId(template.getId()) - .setName(template.getName()) - .setTakeType(template.getTakeType()) - .setUsePrice(template.getUsePrice()) - .setProductScope(template.getProductScope()) - .setProductScopeValues(template.getProductScopeValues()) - .setDiscountType(template.getDiscountType()) - .setDiscountPercent(template.getDiscountPercent()) - .setDiscountPrice(template.getDiscountPrice()) - .setDiscountLimitPrice(template.getDiscountLimitPrice()) - .setStatus(CouponStatusEnum.UNUSED.getStatus()) - .setUserId(userId); - if (CouponTemplateValidityTypeEnum.DATE.getType().equals(template.getValidityType())) { - couponDO.setValidStartTime(template.getValidStartTime()); - couponDO.setValidEndTime(template.getValidEndTime()); - } else if (CouponTemplateValidityTypeEnum.TERM.getType().equals(template.getValidityType())) { - couponDO.setValidStartTime(LocalDateTime.now().plusDays(template.getFixedStartTerm())); - couponDO.setValidEndTime(LocalDateTime.now().plusDays(template.getFixedEndTerm())); - } - return couponDO; - } - - CouponPageReqVO convert(AppCouponPageReqVO pageReqVO, Collection userIds); - - PageResult convertAppPage(PageResult pageResult); - - List convertList(List list); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java deleted file mode 100755 index c6b86da38f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.coupon; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplateRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 优惠劵模板 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface CouponTemplateConvert { - - CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class); - - CouponTemplateDO convert(CouponTemplateCreateReqVO bean); - - CouponTemplateDO convert(CouponTemplateUpdateReqVO bean); - - CouponTemplateRespVO convert(CouponTemplateDO bean); - - PageResult convertPage(PageResult page); - - CouponTemplatePageReqVO convert(AppCouponTemplatePageReqVO pageReqVO, List canTakeTypes, Integer productScope, Long productScopeValue); - - PageResult convertAppPage(PageResult pageResult); - - List convertAppList(List list); - - default PageResult convertAppPage(PageResult pageResult, Map userCanTakeMap) { - PageResult result = convertAppPage(pageResult); - copyTo(result.getList(), userCanTakeMap); - return result; - } - - default List convertAppList(List list, Map userCanTakeMap) { - List result = convertAppList(list); - copyTo(result, userCanTakeMap); - return result; - } - - default void copyTo(List list, Map userCanTakeMap) { - for (AppCouponTemplateRespVO template : list) { - // 检查已领取数量是否超过限领数量 - template.setCanTake(MapUtil.getBool(userCanTakeMap, template.getId(), false)); - } - } - - List convertList(List list); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/decorate/DecorateComponentConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/decorate/DecorateComponentConvert.java deleted file mode 100644 index df6613b97a..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/decorate/DecorateComponentConvert.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.decorate; - -import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.decorate.vo.AppDecorateComponentRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface DecorateComponentConvert { - - DecorateComponentConvert INSTANCE = Mappers.getMapper(DecorateComponentConvert.class); - - List convertList02(List list); - - DecorateComponentDO convert(DecorateComponentSaveReqVO bean); - - List convertList(List list); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java deleted file mode 100755 index 0ecbd92efe..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.discount; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.*; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 限时折扣活动 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface DiscountActivityConvert { - - DiscountActivityConvert INSTANCE = Mappers.getMapper(DiscountActivityConvert.class); - - DiscountActivityDO convert(DiscountActivityCreateReqVO bean); - - DiscountActivityDO convert(DiscountActivityUpdateReqVO bean); - - DiscountActivityRespVO convert(DiscountActivityDO bean); - - List convertList(List list); - List convertList2(List list); - - List convertList02(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, - List discountProductDOList, - List spuList) { - PageResult pageResult = convertPage(page); - - // 拼接商品 TODO @zhangshuai:类似空行的问题,也可以看看 - Map discountActivityMap = CollectionUtils.convertMap(discountProductDOList, DiscountProductDO::getActivityId); - Map spuMap = CollectionUtils.convertMap(spuList, ProductSpuRespDTO::getId); - pageResult.getList().forEach(item -> { - item.setProducts(convertList2(discountProductDOList)); - item.setSpuId(discountActivityMap.get(item.getId())==null?null: discountActivityMap.get(item.getId()).getSpuId()); - if (item.getSpuId() != null) { - MapUtils.findAndThen(spuMap, item.getSpuId(), - spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - } - - }); - return pageResult; - } - - DiscountProductDO convert(DiscountActivityBaseVO.Product bean); - - default DiscountActivityDetailRespVO convert(DiscountActivityDO activity, List products){ - if ( activity == null && products == null ) { - return null; - } - - DiscountActivityDetailRespVO discountActivityDetailRespVO = new DiscountActivityDetailRespVO(); - - if ( activity != null ) { - discountActivityDetailRespVO.setName( activity.getName() ); - discountActivityDetailRespVO.setStartTime( activity.getStartTime() ); - discountActivityDetailRespVO.setEndTime( activity.getEndTime() ); - discountActivityDetailRespVO.setRemark( activity.getRemark() ); - discountActivityDetailRespVO.setId( activity.getId() ); - discountActivityDetailRespVO.setStatus( activity.getStatus() ); - discountActivityDetailRespVO.setCreateTime( activity.getCreateTime() ); - } - if (!products.isEmpty()) { - discountActivityDetailRespVO.setSpuId(products.get(0).getSpuId()); - } - discountActivityDetailRespVO.setProducts( convertList2( products ) ); - - return discountActivityDetailRespVO; - } - - // =========== 比较是否相等 ========== - /** - * 比较两个限时折扣商品是否相等 - * - * @param productDO 数据库中的商品 - * @param productVO 前端传入的商品 - * @return 是否匹配 - */ - @SuppressWarnings("DuplicatedCode") - default boolean isEquals(DiscountProductDO productDO, DiscountActivityBaseVO.Product productVO) { - if (ObjectUtil.notEqual(productDO.getSpuId(), productVO.getSpuId()) - || ObjectUtil.notEqual(productDO.getSkuId(), productVO.getSkuId()) - || ObjectUtil.notEqual(productDO.getDiscountType(), productVO.getDiscountType())) { - return false; - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PRICE.getType())) { - return ObjectUtil.equal(productDO.getDiscountPrice(), productVO.getDiscountPrice()); - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PERCENT.getType())) { - return ObjectUtil.equal(productDO.getDiscountPercent(), productVO.getDiscountPercent()); - } - return true; - } - - /** - * 比较两个限时折扣商品是否相等 - * 注意,比较时忽略 id 编号 - * - * @param productDO 商品 1 - * @param productVO 商品 2 - * @return 是否匹配 - */ - @SuppressWarnings("DuplicatedCode") - default boolean isEquals(DiscountProductDO productDO, DiscountProductDO productVO) { - if (ObjectUtil.notEqual(productDO.getSpuId(), productVO.getSpuId()) - || ObjectUtil.notEqual(productDO.getSkuId(), productVO.getSkuId()) - || ObjectUtil.notEqual(productDO.getDiscountType(), productVO.getDiscountType())) { - return false; - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PRICE.getType())) { - return ObjectUtil.equal(productDO.getDiscountPrice(), productVO.getDiscountPrice()); - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PERCENT.getType())) { - return ObjectUtil.equal(productDO.getDiscountPercent(), productVO.getDiscountPercent()); - } - return true; - } - - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyPageConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyPageConvert.java deleted file mode 100644 index 3443fd8627..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyPageConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.*; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 装修页面 Convert - * - * @author owen - */ -@Mapper -public interface DiyPageConvert { - - DiyPageConvert INSTANCE = Mappers.getMapper(DiyPageConvert.class); - - DiyPageDO convert(DiyPageCreateReqVO bean); - - DiyPageDO convert(DiyPageUpdateReqVO bean); - - DiyPageRespVO convert(DiyPageDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - DiyPageCreateReqVO convertCreateVo(Long templateId, String name, String remark); - - DiyPagePropertyRespVO convertPropertyVo(DiyPageDO diyPage); - - DiyPageDO convert(DiyPagePropertyUpdateRequestVO updateReqVO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java deleted file mode 100644 index a579c60873..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.*; -import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePropertyRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 装修模板 Convert - * - * @author owen - */ -@Mapper -public interface DiyTemplateConvert { - - DiyTemplateConvert INSTANCE = Mappers.getMapper(DiyTemplateConvert.class); - - DiyTemplateDO convert(DiyTemplateCreateReqVO bean); - - DiyTemplateDO convert(DiyTemplateUpdateReqVO bean); - - DiyTemplateRespVO convert(DiyTemplateDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - DiyTemplatePropertyRespVO convertPropertyVo(DiyTemplateDO diyTemplate, List pages); - - AppDiyTemplatePropertyRespVO convertPropertyVo2(DiyTemplateDO diyTemplate, String home, String user); - - DiyTemplateDO convert(DiyTemplatePropertyUpdateRequestVO updateReqVO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/reward/RewardActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/reward/RewardActivityConvert.java deleted file mode 100755 index 5343656ed9..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/reward/RewardActivityConvert.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.reward; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 满减送活动 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface RewardActivityConvert { - - RewardActivityConvert INSTANCE = Mappers.getMapper(RewardActivityConvert.class); - - RewardActivityDO convert(RewardActivityCreateReqVO bean); - - RewardActivityDO convert(RewardActivityUpdateReqVO bean); - - RewardActivityRespVO convert(RewardActivityDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java deleted file mode 100644 index 271a0340fa..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.enums.DictTypeConstants; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityNowRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityRespVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 秒杀活动 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface SeckillActivityConvert { - - SeckillActivityConvert INSTANCE = Mappers.getMapper(SeckillActivityConvert.class); - - SeckillActivityDO convert(SeckillActivityCreateReqVO bean); - - SeckillActivityDO convert(SeckillActivityUpdateReqVO bean); - - SeckillActivityRespVO convert(SeckillActivityDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, - List seckillProducts, - List spuList) { - PageResult pageResult = convertPage(page); - // 拼接商品 - Map spuMap = CollectionUtils.convertMap(spuList, ProductSpuRespDTO::getId); - pageResult.getList().forEach(item -> { - item.setProducts(convertList2(seckillProducts)); - MapUtils.findAndThen(spuMap, item.getSpuId(), - spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - }); - return pageResult; - } - - SeckillActivityDetailRespVO convert1(SeckillActivityDO activity); - - default SeckillActivityDetailRespVO convert(SeckillActivityDO activity, List products) { - return convert1(activity).setProducts(convertList2(products)); - } - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(target = "activityId", source = "activity.id"), - @Mapping(target = "configIds", source = "activity.configIds"), - @Mapping(target = "spuId", source = "activity.spuId"), - @Mapping(target = "skuId", source = "product.skuId"), - @Mapping(target = "seckillPrice", source = "product.seckillPrice"), - @Mapping(target = "stock", source = "product.stock"), - @Mapping(target = "activityStartTime", source = "activity.startTime"), - @Mapping(target = "activityEndTime", source = "activity.endTime") - }) - SeckillProductDO convert(SeckillActivityDO activity, SeckillProductBaseVO product); - - default List convertList(List products, SeckillActivityDO activity) { - return CollectionUtils.convertList(products, item -> convert(activity, item).setActivityStatus(activity.getStatus())); - } - - List convertList2(List list); - - List convertList3(List activityList); - - default AppSeckillActivityNowRespVO convert(SeckillConfigDO filteredConfig, List activityList, - List productList, List spuList) { - AppSeckillActivityNowRespVO respVO = new AppSeckillActivityNowRespVO(); - respVO.setConfig(SeckillConfigConvert.INSTANCE.convert1(filteredConfig)); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map> productMap = convertMultiMap(productList, SeckillProductDO::getActivityId); - respVO.setActivities(CollectionUtils.convertList(convertList3(activityList), item -> { - // product 信息 - item.setSeckillPrice(getMinValue(productMap.get(item.getId()), SeckillProductDO::getSeckillPrice)); - // spu 信息 - findAndThen(spuMap, item.getSpuId(), spu -> - item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()) - .setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()))); - return item; - })); - return respVO; - } - - PageResult convertPage1(PageResult pageResult); - - default PageResult convertPage02(PageResult pageResult, List productList, List spuList) { - PageResult result = convertPage1(pageResult); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map> productMap = convertMultiMap(productList, SeckillProductDO::getActivityId); - List list = CollectionUtils.convertList(result.getList(), item -> { - // product 信息 - item.setSeckillPrice(getMinValue(productMap.get(item.getId()), SeckillProductDO::getSeckillPrice)); - // spu 信息 - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()) - .setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()))); - return item; - }); - result.setList(list); - return result; - } - - AppSeckillActivityDetailRespVO convert2(SeckillActivityDO seckillActivity); - - List convertList1(List products); - - default AppSeckillActivityDetailRespVO convert3(SeckillActivityDO activity, List products, - LocalDateTime startTime, LocalDateTime endTime) { - return convert2(activity) - .setProducts(convertList1(products)) - .setStartTime(startTime).setEndTime(endTime); - } - - SeckillValidateJoinRespDTO convert02(SeckillActivityDO activity, SeckillProductDO product); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillconfig/SeckillConfigConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillconfig/SeckillConfigConvert.java deleted file mode 100644 index f8dd77440b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillconfig/SeckillConfigConvert.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigSimpleRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 秒杀时段 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface SeckillConfigConvert { - - SeckillConfigConvert INSTANCE = Mappers.getMapper(SeckillConfigConvert.class); - - SeckillConfigDO convert(SeckillConfigCreateReqVO bean); - - SeckillConfigDO convert(SeckillConfigUpdateReqVO bean); - - SeckillConfigRespVO convert(SeckillConfigDO bean); - - List convertList(List list); - - List convertList1(List list); - - PageResult convertPage(PageResult page); - - List convertList2(List list); - - AppSeckillConfigRespVO convert1(SeckillConfigDO filteredConfig); -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleCategoryDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleCategoryDO.java deleted file mode 100644 index c79b86d660..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleCategoryDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.article; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 文章分类 DO - * - * @author HUIHUI - */ -@TableName("promotion_article_category") -@KeySequence("promotion_article_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ArticleCategoryDO extends BaseDO { - - /** - * 文章分类编号 - */ - @TableId - private Long id; - /** - * 文章分类名称 - */ - private String name; - /** - * 图标地址 - */ - private String picUrl; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 排序 - */ - private Integer sort; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleDO.java deleted file mode 100644 index 426d9d9c7a..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleDO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.article; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 文章管理 DO - * - * @author HUIHUI - */ -@TableName("promotion_article") -@KeySequence("promotion_article_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ArticleDO extends BaseDO { - - /** - * 文章管理编号 - */ - @TableId - private Long id; - /** - * 分类编号 ArticleCategoryDO#id - */ - private Long categoryId; - /** - * 关联商品编号 ProductSpuDO#id - */ - private Long spuId; - /** - * 文章标题 - */ - private String title; - /** - * 文章作者 - */ - private String author; - /** - * 文章封面图片地址 - */ - private String picUrl; - /** - * 文章简介 - */ - private String introduction; - /** - * 浏览次数 - */ - private Integer browseCount; - /** - * 排序 - */ - private Integer sort; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 是否热门(小程序) - */ - private Boolean recommendHot; - /** - * 是否轮播图(小程序) - */ - private Boolean recommendBanner; - /** - * 文章内容 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java deleted file mode 100644 index fad9385b2b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.banner; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.banner.BannerPositionEnum; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * banner DO - * - * @author xia - */ -@TableName("promotion_banner") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BannerDO extends BaseDO { - - /** - * 编号 - */ - private Long id; - /** - * 标题 - */ - private String title; - /** - * 跳转链接 - */ - private String url; - /** - * 图片链接 - */ - private String picUrl; - /** - * 排序 - */ - private Integer sort; - - /** - * 状态 {@link CommonStatusEnum} - */ - private Integer status; - - /** - * 定位 {@link BannerPositionEnum} - */ - private Integer position; - - /** - * 备注 - */ - private String memo; - - /** - * 点击次数 - */ - private Integer browseCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java deleted file mode 100644 index 37259ebe67..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 砍价活动 DO - * - * @author HUIHUI - */ -@TableName("promotion_bargain_activity") -@KeySequence("promotion_bargain_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BargainActivityDO extends BaseDO { - - /** - * 砍价活动编号 - */ - @TableId - private Long id; - - /** - * 砍价活动名称 - */ - private String name; - - /** - * 活动开始时间 - */ - private LocalDateTime startTime; - /** - * 活动结束时间 - */ - private LocalDateTime endTime; - - /** - * 活动状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 砍价起始价格,单位:分 - */ - private Integer bargainFirstPrice; - /** - * 砍价底价,单位:分 - */ - private Integer bargainMinPrice; - - /** - * 砍价库存(剩余库存砍价时扣减) - */ - private Integer stock; - /** - * 砍价总库存 - */ - private Integer totalStock; - - /** - * 砍价人数 - * - * 需要多少人,砍价才能成功,即 {@link BargainRecordDO#getStatus()} 更新为 {@link BargainRecordDO#getStatus()} 成功状态 - */ - private Integer helpMaxCount; - /** - * 帮砍次数 - * - * 单个活动,用户可以帮砍的次数。 - * 例如说:帮砍次数为 1 时,A 和 B 同时将该活动链接发给 C,C 只能帮其中一个人砍价。 - */ - private Integer bargainCount; - - /** - * 总限购数量 - */ - private Integer totalLimitCount; - /** - * 用户每次砍价的最小金额,单位:分 - */ - private Integer randomMinPrice; - /** - * 用户每次砍价的最大金额,单位:分 - */ - private Integer randomMaxPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainHelpDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainHelpDO.java deleted file mode 100644 index 8419f3436e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainHelpDO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 砍价助力 DO - * - * @author HUIHUI - */ -@TableName("promotion_bargain_help") -@KeySequence("promotion_bargain_help_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BargainHelpDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 砍价活动编号 - * - * 关联 {@link BargainActivityDO#getId()} 字段 - */ - private Long activityId; - /** - * 砍价记录编号 - * - * 关联 {@link BargainRecordDO#getId()} 字段 - */ - private Long recordId; - - /** - * 用户编号 - */ - private Long userId; - /** - * 减少价格,单位:分 - */ - private Integer reducePrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainRecordDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainRecordDO.java deleted file mode 100644 index ff46cb6658..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainRecordDO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 砍价记录 DO TODO - * - * @author HUIHUI - */ -@TableName("promotion_bargain_record") -@KeySequence("promotion_bargain_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BargainRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - */ - private Long userId; - - /** - * 砍价活动编号 - * - * 关联 {@link BargainActivityDO#getId()} 字段 - */ - private Long activityId; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - - /** - * 砍价起始价格,单位:分 - */ - private Integer bargainFirstPrice; - /** - * 当前砍价,单位:分 - */ - private Integer bargainPrice; - - /** - * 砍价状态 - * - * 砍价成功的条件是:(2 选 1) - * 1. 砍价到 {@link BargainActivityDO#getBargainMinPrice()} 底价 - * 2. 助力人数到达 {@link BargainActivityDO#getUserSize()} 人 - * - * 枚举 {@link BargainRecordStatusEnum} - */ - private Integer status; - /** - * 结束时间 - */ - private LocalDateTime endTime; - - /** - * 订单编号 - */ - private Long orderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationActivityDO.java deleted file mode 100644 index 5236b303a8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationActivityDO.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.combination; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 拼团活动 DO - * - * @author HUIHUI - */ -@TableName("promotion_combination_activity") -@KeySequence("promotion_combination_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CombinationActivityDO extends BaseDO { - - /** - * 活动编号 - */ - @TableId - private Long id; - /** - * 拼团名称 - */ - private String name; - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id - */ - private Long spuId; - /** - * 总限购数量 - */ - private Integer totalLimitCount; - /** - * 单次限购数量 - */ - private Integer singleLimitCount; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 几人团 - */ - private Integer userSize; - /** - * 虚拟成团 - */ - private Boolean virtualGroup; - /** - * 活动状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 限制时长(小时) - */ - private Integer limitDuration; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationProductDO.java deleted file mode 100644 index d793bb63e7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationProductDO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.combination; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 拼团商品 DO - * - * @author HUIHUI - */ -@TableName("promotion_combination_product") -@KeySequence("promotion_combination_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CombinationProductDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 拼团活动编号 - */ - private Long activityId; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 拼团价格,单位分 - */ - private Integer combinationPrice; - - /** - * 拼团商品状态 - * - * 关联 {@link CombinationActivityDO#getStatus()} - */ - private Integer activityStatus; - /** - * 活动开始时间点 - * - * 冗余 {@link CombinationActivityDO#getStartTime()} - */ - private LocalDateTime activityStartTime; - /** - * 活动结束时间点 - * - * 冗余 {@link CombinationActivityDO#getEndTime()} - */ - private LocalDateTime activityEndTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java deleted file mode 100644 index e1ba90bf17..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java +++ /dev/null @@ -1,140 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.combination; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -// TODO 芋艿:把字段的顺序,和 do 顺序对齐下 -/** - * 拼团记录 DO - * - * 1. 用户参与拼团时,会创建一条记录 - * 2. 团长的拼团记录,和参团人的拼团记录,通过 {@link #headId} 关联 - * - * @author HUIHUI - */ -@TableName("promotion_combination_record") -@KeySequence("promotion_combination_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CombinationRecordDO extends BaseDO { - - /** - * 团长编号 - 团长 - */ - public static final Long HEAD_ID_GROUP = 0L; - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 拼团活动编号 - * - * 关联 {@link CombinationActivityDO#getId()} - */ - private Long activityId; - /** - * 拼团商品单价 - * - * 冗余 {@link CombinationProductDO#getCombinationPrice()} - */ - private Integer combinationPrice; - /** - * SPU 编号 - */ - private Long spuId; - /** - * 商品名字 - */ - private String spuName; - /** - * 商品图片 - */ - private String picUrl; - /** - * SKU 编号 - */ - private Long skuId; - /** - * 购买的商品数量 - */ - private Integer count; - - /** - * 用户编号 - */ - private Long userId; - - /** - * 用户昵称 - */ - private String nickname; - /** - * 用户头像 - */ - private String avatar; - - /** - * 团长编号 - * - * 关联 {@link CombinationRecordDO#getId()} - * - * 如果是团长,则它的值是 {@link #HEAD_ID_GROUP} - */ - private Long headId; - /** - * 开团状态 - * - * 关联 {@link CombinationRecordStatusEnum} - */ - private Integer status; - /** - * 订单编号 - */ - private Long orderId; - /** - * 开团需要人数 - * - * 关联 {@link CombinationActivityDO#getUserSize()} - */ - private Integer userSize; - /** - * 已加入拼团人数 - */ - private Integer userCount; - /** - * 是否虚拟成团 - * - * 默认为 false。 - * 拼团过期都还没有成功,如果 {@link CombinationActivityDO#getVirtualGroup()} 为 true,则执行虚拟成团的逻辑,才会更新该字段为 true - */ - private Boolean virtualGroup; - - /** - * 过期时间 - * - * 基于 {@link CombinationRecordDO#getStartTime()} + {@link CombinationActivityDO#getLimitDuration()} 计算 - */ - private LocalDateTime expireTime; - /** - * 开始时间 (订单付款后开始的时间) - */ - private LocalDateTime startTime; - /** - * 结束时间(成团时间/失败时间) - */ - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java deleted file mode 100644 index b986150936..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java +++ /dev/null @@ -1,139 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.coupon; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 优惠劵 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_coupon", autoResultMap = true) -@KeySequence("promotion_coupon_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class CouponDO extends BaseDO { - - // ========== 基本信息 BEGIN ========== - /** - * 优惠劵编号 - */ - private Long id; - /** - * 优惠劵模板编号 - * - * 关联 {@link CouponTemplateDO#getId()} - */ - private Long templateId; - /** - * 优惠劵名 - * - * 冗余 {@link CouponTemplateDO#getName()} - */ - private String name; - /** - * 优惠码状态 - * - * 枚举 {@link CouponStatusEnum} - */ - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取情况 BEGIN ========== - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 领取类型 - * - * 枚举 {@link CouponTakeTypeEnum} - */ - private Integer takeType; - // ========== 领取情况 END ========== - - // ========== 使用规则 BEGIN ========== - /** - * 是否设置满多少金额可用,单位:分 - * - * 冗余 {@link CouponTemplateDO#getUsePrice()} - */ - private Integer usePrice; - /** - * 生效开始时间 - */ - private LocalDateTime validStartTime; - /** - * 生效结束时间 - */ - private LocalDateTime validEndTime; - /** - * 商品范围 - * - * 枚举 {@link PromotionProductScopeEnum} - */ - private Integer productScope; - /** - * 商品范围编号的数组 - * - * 冗余 {@link CouponTemplateDO#getProductScopeValues()} - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List productScopeValues; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - /** - * 折扣类型 - * - * 冗余 {@link CouponTemplateDO#getDiscountType()} - */ - private Integer discountType; - /** - * 折扣百分比 - * - * 冗余 {@link CouponTemplateDO#getDiscountPercent()} - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - * - * 冗余 {@link CouponTemplateDO#getDiscountPrice()} - */ - private Integer discountPrice; - /** - * 折扣上限,仅在 {@link #discountType} 等于 {@link PromotionDiscountTypeEnum#PERCENT} 时生效 - * - * 冗余 {@link CouponTemplateDO#getDiscountLimitPrice()} - */ - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 使用情况 BEGIN ========== - /** - * 使用订单号 - */ - private Long useOrderId; - /** - * 使用时间 - */ - private LocalDateTime useTime; - - // ========== 使用情况 END ========== - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java deleted file mode 100644 index 6cab9c58c3..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java +++ /dev/null @@ -1,162 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.coupon; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 优惠劵模板 DO - * - * 当用户领取时,会生成 {@link CouponDO} 优惠劵 - * - * @author 芋道源码 - */ -@TableName(value = "promotion_coupon_template", autoResultMap = true) -@KeySequence("promotion_coupon_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class CouponTemplateDO extends BaseDO { - - // ========== 基本信息 BEGIN ========== - /** - * 模板编号,自增唯一 - */ - @TableId - private Long id; - /** - * 优惠劵名 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取规则 BEGIN ========== - /** - * 发放数量 - * - * -1 - 则表示不限制发放数量 - */ - private Integer totalCount; - /** - * 每人限领个数 - * - * -1 - 则表示不限制 - */ - private Integer takeLimitCount; - /** - * 领取方式 - * - * 枚举 {@link CouponTakeTypeEnum} - */ - private Integer takeType; - // ========== 领取规则 END ========== - - // ========== 使用规则 BEGIN ========== - /** - * 是否设置满多少金额可用,单位:分 - * - * 0 - 不限制 - * 大于 0 - 多少金额可用 - */ - private Integer usePrice; - /** - * 商品范围 - * - * 枚举 {@link PromotionProductScopeEnum} - */ - private Integer productScope; - /** - * 商品范围编号的数组 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List productScopeValues; - /** - * 生效日期类型 - * - * 枚举 {@link CouponTemplateValidityTypeEnum} - */ - private Integer validityType; - /** - * 固定日期 - 生效开始时间 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#DATE} - */ - private LocalDateTime validStartTime; - /** - * 固定日期 - 生效结束时间 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#DATE} - */ - private LocalDateTime validEndTime; - /** - * 领取日期 - 开始天数 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#TERM} - */ - private Integer fixedStartTerm; - /** - * 领取日期 - 结束天数 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#TERM} - */ - private Integer fixedEndTerm; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - /** - * 折扣类型 - * - * 枚举 {@link PromotionDiscountTypeEnum} - */ - private Integer discountType; - /** - * 折扣百分比 - * - * 例如,80% 为 80 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - * - * 当 {@link #discountType} 为 {@link PromotionDiscountTypeEnum#PRICE} 生效 - */ - private Integer discountPrice; - /** - * 折扣上限,仅在 {@link #discountType} 等于 {@link PromotionDiscountTypeEnum#PERCENT} 时生效 - * - * 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。 - */ - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 统计信息 BEGIN ========== - /** - * 领取优惠券的数量 - */ - private Integer takeCount; - /** - * 使用优惠券的次数 - */ - private Integer useCount; - // ========== 统计信息 END ========== - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/decorate/DecorateComponentDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/decorate/DecorateComponentDO.java deleted file mode 100644 index 8764317722..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/decorate/DecorateComponentDO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.decorate; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; -import cn.iocoder.yudao.module.promotion.enums.decorate.DecorateComponentEnum; -import com.baomidou.mybatisplus.annotation.*; - -import lombok.Data; - -/** - * 页面装修组件 DO, 一个页面由多个组件构成 - * - * @author jason - */ -@TableName(value ="promotion_decorate_component") -@KeySequence("promotion_decorate_component_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DecorateComponentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 所属页面 id - * - * 枚举 {@link DecoratePageEnum#getPage()} - */ - private Integer page; - - /** - * 组件编码 - * 枚举 {@link DecorateComponentEnum#getCode()} - */ - private String code; - - /** - * 组件值:json 格式。包含配置和数据 - */ - private String value; - - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountActivityDO.java deleted file mode 100644 index 956a223be1..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountActivityDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.discount; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; - -/** - * 限时折扣活动 DO - * - * 一个活动下,可以有 {@link DiscountProductDO} 商品; - * 一个商品,在指定时间段内,只能属于一个活动; - * - * @author 芋道源码 - */ -@TableName(value = "promotion_discount_activity", autoResultMap = true) -@KeySequence("promotion_discount_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class DiscountActivityDO extends BaseDO { - - /** - * 活动编号,主键自增 - */ - @TableId - private Long id; - /** - * 活动标题 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - * - * 活动被关闭后,不允许再次开启。 - */ - private Integer status; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java deleted file mode 100644 index 12b6822d65..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.discount; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; - -/** - * 限时折扣商品 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_discount_product", autoResultMap = true) -@KeySequence("promotion_discount_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class DiscountProductDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 限时折扣活动的编号 - * - * 关联 {@link DiscountActivityDO#getId()} - */ - private Long activityId; - - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的 id 编号 - */ - private Long skuId; - - /** - * 折扣类型 - * - * 枚举 {@link PromotionDiscountTypeEnum} - */ - private Integer discountType; - /** - * 折扣百分比 - * - * 例如,80% 为 80 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - * - * 当 {@link #discountType} 为 {@link PromotionDiscountTypeEnum#PRICE} 生效 - */ - private Integer discountPrice; - - /** - * 活动状态 - * - * 关联 {@link DiscountActivityDO#getStatus()} - */ - private Integer activityStatus; - /** - * 活动开始时间点 - * - * 冗余 {@link DiscountActivityDO#getStartTime()} - */ - private LocalDateTime activityStartTime; - /** - * 活动结束时间点 - * - * 冗余 {@link DiscountActivityDO#getEndTime()} - */ - private LocalDateTime activityEndTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java deleted file mode 100644 index 7e1044104b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.diy; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.StringListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.List; - -/** - * 装修页面 DO - * - * @author owen - */ -@TableName(value = "promotion_diy_page", autoResultMap = true) -@KeySequence("promotion_diy_page_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class DiyPageDO extends BaseDO { - - /** - * 装修页面编号 - */ - @TableId - private Long id; - /** - * 装修模板编号 - * - * 关联 {@link DiyTemplateDO#getId()} - */ - private Long templateId; - /** - * 页面名称 - */ - private String name; - /** - * 备注 - */ - private String remark; - /** - * 预览图,多个逗号分隔 - */ - @TableField(typeHandler = StringListTypeHandler.class) - private List previewImageUrls; - /** - * 页面属性,JSON 格式 - */ - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java deleted file mode 100644 index 684a6f9cb8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.diy; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.StringListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 装修模板 DO - * - * 1. 新建一个模版,下面可以包含多个 {@link DiyPageDO} 页面,例如说首页、我的 - * 2. 如果需要使用某个模版,则将 {@link #used} 设置为 true,表示已使用,有且仅有一个 - * - * @author owen - */ -@TableName(value = "promotion_diy_template", autoResultMap = true) -@KeySequence("promotion_diy_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class DiyTemplateDO extends BaseDO { - - /** - * 装修模板编号 - */ - @TableId - private Long id; - /** - * 模板名称 - */ - private String name; - /** - * 是否使用 - */ - private Boolean used; - /** - * 使用时间 - */ - private LocalDateTime usedTime; - /** - * 备注 - */ - private String remark; - /** - * 预览图 - */ - @TableField(typeHandler = StringListTypeHandler.class) - private List previewImageUrls; - /** - * 底部导航属性,JSON 格式 - */ - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java deleted file mode 100644 index 0c0b477efc..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.reward; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; -import java.time.LocalDateTime; -import java.util.List; - -/** - * 满减送活动 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_reward_activity", autoResultMap = true) -@KeySequence("promotion_reward_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class RewardActivityDO extends BaseDO { - - /** - * 活动编号,主键自增 - */ - @TableId - private Long id; - /** - * 活动标题 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link PromotionActivityStatusEnum} - */ - private Integer status; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 备注 - */ - private String remark; - /** - * 条件类型 - * - * 枚举 {@link PromotionConditionTypeEnum} - */ - private Integer conditionType; - /** - * 商品范围 - * - * 枚举 {@link PromotionProductScopeEnum} - */ - private Integer productScope; - /** - * 商品 SPU 编号的数组 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List productSpuIds; - /** - * 优惠规则的数组 - */ - @TableField(typeHandler = RuleTypeHandler.class) - private List rules; - - /** - * 优惠规则 - */ - @Data - public static class Rule implements Serializable { - - /** - * 优惠门槛 - * - * 1. 满 N 元,单位:分 - * 2. 满 N 件 - */ - private Integer limit; - /** - * 优惠价格,单位:分 - */ - private Integer discountPrice; - /** - * 是否包邮 - */ - private Boolean freeDelivery; - /** - * 赠送的积分 - */ - private Integer point; - /** - * 赠送的优惠劵编号的数组 - */ - private List couponIds; - /** - * 赠送的优惠券数量的数组 - */ - private List couponCounts; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class RuleTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List parse(String json) { - return JsonUtils.parseArray(json, Rule.class); - } - - @Override - protected String toJson(List obj) { - return JsonUtils.toJsonString(obj); - } - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillActivityDO.java deleted file mode 100644 index 76a08ac707..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillActivityDO.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 秒杀活动 DO - * - * @author halfninety - */ -@TableName(value = "promotion_seckill_activity", autoResultMap = true) -@KeySequence("promotion_seckill_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityDO extends BaseDO { - - /** - * 秒杀活动编号 - */ - @TableId - private Long id; - /** - * 秒杀活动商品 - */ - private Long spuId; - /** - * 秒杀活动名称 - */ - private String name; - /** - * 活动状态 - * - * 枚举 {@link CommonStatusEnum 对应的类} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 活动开始时间 - */ - private LocalDateTime startTime; - /** - * 活动结束时间 - */ - private LocalDateTime endTime; - /** - * 排序 - */ - private Integer sort; - /** - * 秒杀时段 id - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List configIds; - - /** - * 总限购数量 - */ - private Integer totalLimitCount; - /** - * 单次限够数量 - */ - private Integer singleLimitCount; - - /** - * 秒杀库存(剩余库存秒杀时扣减) - */ - private Integer stock; - /** - * 秒杀总库存 - */ - private Integer totalStock; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillConfigDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillConfigDO.java deleted file mode 100644 index 73efb7ad4f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillConfigDO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 秒杀时段 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_seckill_config", autoResultMap = true) -@KeySequence("promotion_seckill_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SeckillConfigDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 秒杀时段名称 - */ - private String name; - /** - * 开始时间点 - */ - private String startTime; - /** - * 结束时间点 - */ - private String endTime; - /** - * 秒杀轮播图 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List sliderPicUrls; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum 对应的类} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillProductDO.java deleted file mode 100644 index 45a2d9e937..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillProductDO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 秒杀参与商品 DO - * - * @author HUIHUI - */ -@TableName("promotion_seckill_product") -@KeySequence("promotion_seckill_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SeckillProductDO extends BaseDO { - - /** - * 秒杀参与商品编号 - */ - @TableId - private Long id; - /** - * 秒杀活动 id - * - * 关联 {@link SeckillActivityDO#getId()} - */ - private Long activityId; - /** - * 秒杀时段 id - * - * 关联 {@link SeckillConfigDO#getId()} - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List configIds; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 秒杀金额,单位:分 - */ - private Integer seckillPrice; - /** - * 秒杀库存 - */ - private Integer stock; - - /** - * 秒杀商品状态 - * - * 枚举 {@link CommonStatusEnum 对应的类} - */ - private Integer activityStatus; - /** - * 活动开始时间点 - */ - private LocalDateTime activityStartTime; - /** - * 活动结束时间点 - */ - private LocalDateTime activityEndTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleCategoryMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleCategoryMapper.java deleted file mode 100644 index d39264b6a5..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleCategoryMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 文章分类 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface ArticleCategoryMapper extends BaseMapperX { - - default PageResult selectPage(ArticleCategoryPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ArticleCategoryDO::getName, reqVO.getName()) - .eqIfPresent(ArticleCategoryDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(ArticleCategoryDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ArticleCategoryDO::getSort)); - } - - default List selectListByStatus(Integer status) { - return selectList(ArticleCategoryDO::getStatus, status); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java deleted file mode 100644 index 6f05b9a9b6..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 文章管理 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface ArticleMapper extends BaseMapperX { - - default PageResult selectPage(ArticlePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ArticleDO::getCategoryId, reqVO.getCategoryId()) - .eqIfPresent(ArticleDO::getTitle, reqVO.getTitle()) - .eqIfPresent(ArticleDO::getAuthor, reqVO.getAuthor()) - .eqIfPresent(ArticleDO::getStatus, reqVO.getStatus()) - .eqIfPresent(ArticleDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(ArticleDO::getRecommendHot, reqVO.getRecommendHot()) - .eqIfPresent(ArticleDO::getRecommendBanner, reqVO.getRecommendBanner()) - .betweenIfPresent(ArticleDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ArticleDO::getId)); - } - - default List selectList(Boolean recommendHot, Boolean recommendBanner) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(ArticleDO::getRecommendHot, recommendHot) - .eqIfPresent(ArticleDO::getRecommendBanner, recommendBanner)); - } - - default PageResult selectPage(AppArticlePageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eqIfPresent(ArticleDO::getCategoryId, pageReqVO.getCategoryId())); - } - - default void updateBrowseCount(Long id) { - update(null, new LambdaUpdateWrapper() - .eq(ArticleDO::getId, id) - .setSql("browse_count = browse_count + 1")); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/banner/BannerMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/banner/BannerMapper.java deleted file mode 100644 index 74bd3c7da3..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/banner/BannerMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * Banner Mapper - * - * @author xia - */ -@Mapper -public interface BannerMapper extends BaseMapperX { - - default PageResult selectPage(BannerPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BannerDO::getTitle, reqVO.getTitle()) - .eqIfPresent(BannerDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BannerDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BannerDO::getSort)); - } - - default void updateBrowseCount(Long id) { - update(null, new LambdaUpdateWrapper() - .eq(BannerDO::getId, id) - .setSql("browse_count = browse_count + 1")); - } - - default List selectBannerListByPosition(Integer position) { - return selectList(new LambdaQueryWrapperX().eq(BannerDO::getPosition, position)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java deleted file mode 100644 index 72d604e77f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 砍价活动 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface BargainActivityMapper extends BaseMapperX { - - default PageResult selectPage(BargainActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BargainActivityDO::getName, reqVO.getName()) - .eqIfPresent(BargainActivityDO::getStatus, reqVO.getStatus()) - .orderByDesc(BargainActivityDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(BargainActivityDO::getStatus, status); - } - - /** - * 更新活动库存 - * - * @param id 活动编号 - * @param count 扣减的库存数量 - * @return 影响的行数 - */ - default int updateStock(Long id, int count) { - // 情况一:增加库存 - if (count > 0) { - return update(null, new LambdaUpdateWrapper() - .eq(BargainActivityDO::getId, id) - .setSql("stock = stock + " + count)); - } - // 情况二:扣减库存 - count = -count; // 取正 - return update(null, new LambdaUpdateWrapper() - .eq(BargainActivityDO::getId, id) - .ge(BargainActivityDO::getStock, count) - .setSql("stock = stock - " + count)); - } - - /** - * 查询处在 now 日期时间且是 status 状态的活动分页 - * - * @param pageReqVO 分页参数 - * @param status 状态 - * @param now 当前日期时间 - * @return 活动分页 - */ - default PageResult selectPage(PageParam pageReqVO, Integer status, LocalDateTime now) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(BargainActivityDO::getStatus, status) - .le(BargainActivityDO::getStartTime, now) - .ge(BargainActivityDO::getEndTime, now)); - } - - /** - * 查询处在 now 日期时间且是 status 状态的活动分页 - * - * @param status 状态 - * @param now 当前日期时间 - * @return 活动分页 - */ - default List selectList(Integer count, Integer status, LocalDateTime now) { - return selectList(new LambdaQueryWrapperX() - .eq(BargainActivityDO::getStatus, status) - .le(BargainActivityDO::getStartTime, now) - .ge(BargainActivityDO::getEndTime, now) - .last("LIMIT " + count)); - } - - /** - * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - * - * @param spuIds spu 编号 - * @param status 状态 - * @return 包含 spuId 和 activityId 的 map 对象列表 - */ - default List> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(Collection spuIds, Integer status) { - return selectMaps(new QueryWrapper() - .select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id - .in("spu_id", spuIds) - .eq("status", status) - .groupBy("spu_id")); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(BargainActivityDO::getId, ids) - .lt(BargainActivityDO::getStartTime, dateTime) - .gt(BargainActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(BargainActivityDO::getCreateTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java deleted file mode 100644 index 8d01ba3615..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -@Mapper -public interface BargainHelpMapper extends BaseMapperX { - - default Long selectCountByUserIdAndActivityId(Long userId, Long activityId) { - return selectCount(new LambdaQueryWrapper<>(BargainHelpDO.class) - .eq(BargainHelpDO::getUserId, userId) - .eq(BargainHelpDO::getActivityId, activityId)); - } - - default Long selectUserCountMapByRecordId(Long recordId) { - return selectCount(BargainHelpDO::getRecordId, recordId); - } - - default BargainHelpDO selectByUserIdAndRecordId(Long userId, Long recordId) { - return selectOne(new LambdaQueryWrapper<>(BargainHelpDO.class) - .eq(BargainHelpDO::getUserId, userId) - .eq(BargainHelpDO::getRecordId, recordId)); - } - - default Map selectUserCountMapByActivityId(Collection activityIds) { - // SQL count 查询 - List> result = selectMaps(new QueryWrapper() - .select("COUNT(DISTINCT(user_id)) AS userCount, activity_id AS activityId") - .in("activity_id", activityIds) - .groupBy("activity_id")); - if (CollUtil.isEmpty(result)) { - return Collections.emptyMap(); - } - // 转换数据 - return CollectionUtils.convertMap(result, - record -> MapUtil.getLong(record, "activityId"), - record -> MapUtil.getInt(record, "userCount" )); - } - - default Map selectUserCountMapByRecordId(Collection recordIds) { - // SQL count 查询 - List> result = selectMaps(new QueryWrapper() - .select("COUNT(1) AS userCount, record_id AS recordId") - .in("record_id", recordIds) - .groupBy("record_id")); - if (CollUtil.isEmpty(result)) { - return Collections.emptyMap(); - } - // 转换数据 - return CollectionUtils.convertMap(result, - record -> MapUtil.getLong(record, "recordId"), - record -> MapUtil.getInt(record, "userCount" )); - } - - default PageResult selectPage(BargainHelpPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BargainHelpDO::getRecordId, reqVO.getRecordId()) - .orderByDesc(BargainHelpDO::getId)); - } - - default List selectListByRecordId(Long recordId) { - return selectList(new LambdaQueryWrapperX() - .eq(BargainHelpDO::getRecordId, recordId)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java deleted file mode 100644 index 17560db82d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * 砍价记录 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface BargainRecordMapper extends BaseMapperX { - - default BargainRecordDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(BargainRecordDO::getId, id, - BargainRecordDO::getUserId, userId); - } - - default List selectListByUserIdAndActivityIdAndStatus( - Long userId, Long activityId, Integer status) { - return selectList(new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getUserId, userId) - .eq(BargainRecordDO::getActivityId, activityId) - .eq(BargainRecordDO::getStatus, status)); - } - - default BargainRecordDO selectLastByUserIdAndActivityId(Long userId, Long activityId) { - return selectOne(new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getUserId, userId) - .eq(BargainRecordDO::getActivityId, activityId) - .orderByDesc(BargainRecordDO::getId) - .last("LIMIT 1")); - } - - default Long selectCountByUserIdAndActivityIdAndStatus( - Long userId, Long activityId, Integer status) { - return selectCount(new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getUserId, userId) - .eq(BargainRecordDO::getActivityId, activityId) - .eq(BargainRecordDO::getStatus, status)); - } - - default int updateByIdAndBargainPrice(Long id, Integer whereBargainPrice, BargainRecordDO updateObj) { - return update(updateObj, new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getId, id) - .eq(BargainRecordDO::getBargainPrice, whereBargainPrice)); - } - - default Map selectUserCountByActivityIdsAndStatus(Collection activityIds, Integer status) { - // SQL count 查询 - List> result = selectMaps(new QueryWrapper() - .select("COUNT(DISTINCT(user_id)) AS userCount, activity_id AS activityId") - .in("activity_id", activityIds) - .eq(status != null, "status", status) - .groupBy("activity_id")); - if (CollUtil.isEmpty(result)) { - return Collections.emptyMap(); - } - // 转换数据 - return CollectionUtils.convertMap(result, - record -> MapUtil.getLong(record, "activityId"), - record -> MapUtil.getInt(record, "userCount" )); - } - - @Select("SELECT COUNT(DISTINCT(user_id)) FROM promotion_bargain_record " + - "WHERE status = #{status}") - Integer selectUserCountByStatus(@Param("status") Integer status); - - @Select("SELECT COUNT(DISTINCT(user_id)) FROM promotion_bargain_record " + - "WHERE activity_id = #{activityId} " + - "AND status = #{status}") - Integer selectUserCountByActivityIdAndStatus(@Param("activityId") Long activityId, - @Param("status") Integer status); - - default PageResult selectPage(BargainRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BargainRecordDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BargainRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BargainRecordDO::getId)); - } - - default PageResult selectBargainRecordPage(Long userId, PageParam pageParam) { - return selectPage(pageParam, new LambdaQueryWrapperX() - .eq(BargainRecordDO::getUserId, userId) - .orderByDesc(BargainRecordDO::getId)); - } - - default List selectListByStatusAndCount(Integer status, Integer count) { - return selectList(new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getStatus, status) - .last("LIMIT " + count)); - } - - /** - * 更新砍价的订单编号,前提是 orderId 原本是空的 - * - * @param id 砍价记录编号 - * @param orderId 订单编号 - * @return 更新数量 - */ - default int updateOrderIdById(Long id, Long orderId) { - return update(new BargainRecordDO().setOrderId(orderId).setEndTime(LocalDateTime.now()), - new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getId, id) - .isNull(BargainRecordDO::getOrderId)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java deleted file mode 100644 index 55e975c450..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.combination; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 拼团活动 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CombinationActivityMapper extends BaseMapperX { - - default PageResult selectPage(CombinationActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(CombinationActivityDO::getName, reqVO.getName()) - .eqIfPresent(CombinationActivityDO::getStatus, reqVO.getStatus()) - .orderByDesc(CombinationActivityDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(CombinationActivityDO::getStatus, status); - } - - default PageResult selectPage(PageParam pageParam, Integer status) { - return selectPage(pageParam, new LambdaQueryWrapperX() - .eq(CombinationActivityDO::getStatus, status)); - } - - default List selectListByStatus(Integer status, Integer count) { - return selectList(new LambdaQueryWrapperX() - .eq(CombinationActivityDO::getStatus, status) - .last("LIMIT " + count)); - } - - /** - * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - * @param spuIds spu 编号 - * @param status 状态 - * @return 包含 spuId 和 activityId 的 map 对象列表 - */ - default List> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(@Param("spuIds") Collection spuIds, @Param("status") Integer status) { - return selectMaps(new QueryWrapper() - .select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id - .in("spu_id", spuIds) - .eq("status", status) - .groupBy("spu_id")); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(CombinationActivityDO::getId, ids) - .lt(CombinationActivityDO::getStartTime, dateTime) - .gt(CombinationActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(CombinationActivityDO::getCreateTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationProductMapper.java deleted file mode 100644 index 5d80b6d093..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationProductMapper.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.combination; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 拼团商品 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CombinationProductMapper extends BaseMapperX { - - default PageResult selectPage(CombinationProductPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CombinationProductDO::getActivityId, reqVO.getActivityId()) - .eqIfPresent(CombinationProductDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(CombinationProductDO::getSkuId, reqVO.getSkuId()) - .eqIfPresent(CombinationProductDO::getActivityStatus, reqVO.getActivityStatus()) - .betweenIfPresent(CombinationProductDO::getActivityStartTime, reqVO.getActivityStartTime()) - .betweenIfPresent(CombinationProductDO::getActivityEndTime, reqVO.getActivityEndTime()) - .eqIfPresent(CombinationProductDO::getCombinationPrice, reqVO.getActivePrice()) - .betweenIfPresent(CombinationProductDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(CombinationProductDO::getId)); - } - - default List selectListByActivityIds(Collection ids) { - return selectList(CombinationProductDO::getActivityId, ids); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java deleted file mode 100644 index 9dd31be2d0..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * 拼团记录 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CombinationRecordMapper extends BaseMapperX { - - default CombinationRecordDO selectByUserIdAndOrderId(Long userId, Long orderId) { - return selectOne(CombinationRecordDO::getUserId, userId, - CombinationRecordDO::getOrderId, orderId); - } - - /** - * 查询拼团记录 - * - * @param headId 团长编号 - * @return 拼团记录 - */ - default CombinationRecordDO selectByHeadId(Long headId, Integer status) { - return selectOne(new LambdaQueryWrapperX() - .eq(CombinationRecordDO::getId, headId) - .eq(CombinationRecordDO::getStatus, status)); - } - - /** - * 查询拼团记录 - * - * @param userId 用户 id - * @param activityId 活动 id - * @return 拼团记录 - */ - default List selectListByUserIdAndActivityId(Long userId, Long activityId) { - return selectList(new LambdaQueryWrapperX() - .eq(CombinationRecordDO::getUserId, userId) - .eq(CombinationRecordDO::getActivityId, activityId)); - } - - /** - * 获取最近的 count 条数据 - * - * @param count 数量 - * @return 拼团记录列表 - */ - default List selectLatestList(int count) { - return selectList(new LambdaQueryWrapperX() - .orderByDesc(CombinationRecordDO::getId) - .last("LIMIT " + count)); - } - - default List selectListByActivityIdAndStatusAndHeadId(Long activityId, Integer status, - Long headId, Integer count) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(CombinationRecordDO::getActivityId, activityId) - .eqIfPresent(CombinationRecordDO::getStatus, status) - .eq(CombinationRecordDO::getHeadId, headId) - .orderByDesc(CombinationRecordDO::getId) - .last("LIMIT " + count)); - } - - default Map selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(Collection activityIds, - Integer status, Long headId) { - // SQL count 查询 - List> result = selectMaps(new QueryWrapper() - .select("COUNT(DISTINCT(user_id)) AS recordCount, activity_id AS activityId") - .in("activity_id", activityIds) - .eq(status != null, "status", status) - .eq(headId != null, "head_id", headId) - .groupBy("activity_id")); - if (CollUtil.isEmpty(result)) { - return Collections.emptyMap(); - } - // 转换数据 - return CollectionUtils.convertMap(result, - record -> MapUtil.getLong(record, "activityId"), - record -> MapUtil.getInt(record, "recordCount")); - } - - default PageResult selectPage(CombinationRecordReqPageVO pageVO) { - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX() - .eqIfPresent(CombinationRecordDO::getStatus, pageVO.getStatus()) - .betweenIfPresent(CombinationRecordDO::getCreateTime, pageVO.getCreateTime()); - // 如果 headId 非空,说明查询指定团的团长 + 团员的拼团记录 - if (pageVO.getHeadId() != null) { - queryWrapper.eq(CombinationRecordDO::getId, pageVO.getHeadId()) // 团长 - .or().eq(CombinationRecordDO::getHeadId, pageVO.getHeadId()); // 团员 - } - return selectPage(pageVO, queryWrapper); - } - - /** - * 查询指定条件的记录数 - * - * @param status 状态,可为 null - * @param virtualGroup 是否虚拟成团,可为 null - * @param headId 团长编号,可为 null - * @return 记录数 - */ - default Long selectCountByHeadAndStatusAndVirtualGroup(Integer status, Boolean virtualGroup, Long headId) { - return selectCount(new LambdaQueryWrapperX() - .eqIfPresent(CombinationRecordDO::getStatus, status) - .eqIfPresent(CombinationRecordDO::getVirtualGroup, virtualGroup) - .eqIfPresent(CombinationRecordDO::getHeadId, headId)); - } - - /** - * 查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次 - * - * @return 参加过拼团的用户数 - */ - default Long selectUserCount() { - return selectCount(new QueryWrapper() - .select("DISTINCT (user_id)")); - } - - default List selectListByHeadIdAndStatusAndExpireTimeLt(Long headId, Integer status, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .eq(CombinationRecordDO::getHeadId, headId) - .eq(CombinationRecordDO::getStatus, status) - .lt(CombinationRecordDO::getExpireTime, dateTime)); - } - - default List selectListByHeadId(Long headId) { - return selectList(CombinationRecordDO::getHeadId, headId); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java deleted file mode 100755 index e5f1daf6cf..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.coupon; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.github.yulichang.toolkit.MPJWrappers; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 优惠劵 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CouponMapper extends BaseMapperX { - - default PageResult selectPage(CouponPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CouponDO::getTemplateId, reqVO.getTemplateId()) - .eqIfPresent(CouponDO::getStatus, reqVO.getStatus()) - .inIfPresent(CouponDO::getUserId, reqVO.getUserIds()) - .betweenIfPresent(CouponDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(CouponDO::getId)); - } - - default List selectListByUserIdAndStatus(Long userId, Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getUserId, userId).eq(CouponDO::getStatus, status)); - } - - default CouponDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(new LambdaQueryWrapperX() - .eq(CouponDO::getId, id).eq(CouponDO::getUserId, userId)); - } - - default int delete(Long id, Collection whereStatuses) { - return update(null, new LambdaUpdateWrapper() - .eq(CouponDO::getId, id).in(CouponDO::getStatus, whereStatuses) - .set(CouponDO::getDeleted, 1)); - } - - default int updateByIdAndStatus(Long id, Integer status, CouponDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(CouponDO::getId, id).eq(CouponDO::getStatus, status)); - } - - default Long selectCountByUserIdAndStatus(Long userId, Integer status) { - return selectCount(new LambdaQueryWrapperX() - .eq(CouponDO::getUserId, userId) - .eq(CouponDO::getStatus, status)); - } - - default List selectListByTemplateIdAndUserId(Long templateId, Collection userIds) { - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getTemplateId, templateId) - .in(CouponDO::getUserId, userIds) - ); - } - - default Map selectCountByUserIdAndTemplateIdIn(Long userId, Collection templateIds) { - String templateIdAlias = "templateId"; - String countAlias = "count"; - List> list = selectMaps(MPJWrappers.lambdaJoin(CouponDO.class) - .selectAs(CouponDO::getTemplateId, templateIdAlias) - .selectCount(CouponDO::getId, countAlias) - .eq(CouponDO::getUserId, userId) - .in(CouponDO::getTemplateId, templateIds) - .groupBy(CouponDO::getTemplateId)); - return convertMap(list, map -> MapUtil.getLong(map, templateIdAlias), map -> MapUtil.getInt(map, countAlias)); - } - - default List selectListByUserIdAndStatusAndUsePriceLeAndProductScope( - Long userId, Integer status, Integer usePrice, List spuIds, List categoryIds) { - Function, String> productScopeValuesFindInSetFunc = ids -> ids.stream() - .map(id -> StrUtil.format("FIND_IN_SET({}, product_scope_values) ", id)) - .collect(Collectors.joining(" OR ")); - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getUserId, userId) - .eq(CouponDO::getStatus, status) - .le(CouponDO::getUsePrice, usePrice) // 价格小于等于,满足价格使用条件 - .and(w -> w.eq(CouponDO::getProductScope, PromotionProductScopeEnum.ALL.getScope()) // 商品范围一:全部 - .or(ww -> ww.eq(CouponDO::getProductScope, PromotionProductScopeEnum.SPU.getScope()) // 商品范围二:满足指定商品 - .apply(productScopeValuesFindInSetFunc.apply(spuIds))) - .or(ww -> ww.eq(CouponDO::getProductScope, PromotionProductScopeEnum.CATEGORY.getScope()) // 商品范围三:满足指定分类 - .apply(productScopeValuesFindInSetFunc.apply(categoryIds))))); - } - - default List selectListByStatusAndValidEndTimeLe(Integer status, LocalDateTime validEndTime) { - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getStatus, status) - .le(CouponDO::getValidEndTime, validEndTime) - ); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java deleted file mode 100755 index dc703d881e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.function.Consumer; - -/** - * 优惠劵模板 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CouponTemplateMapper extends BaseMapperX { - - default PageResult selectPage(CouponTemplatePageReqVO reqVO) { - // 构建可领取的查询条件 - Consumer> canTakeConsumer = buildCanTakeQueryConsumer(reqVO.getCanTakeTypes()); - // 执行分页查询 - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(CouponTemplateDO::getName, reqVO.getName()) - .eqIfPresent(CouponTemplateDO::getStatus, reqVO.getStatus()) - .eqIfPresent(CouponTemplateDO::getDiscountType, reqVO.getDiscountType()) - .betweenIfPresent(CouponTemplateDO::getCreateTime, reqVO.getCreateTime()) - .eqIfPresent(CouponTemplateDO::getProductScope, reqVO.getProductScope()) - .and(reqVO.getProductScopeValue() != null, w -> w.apply("FIND_IN_SET({0}, product_scope_values)", - reqVO.getProductScopeValue())) - .and(canTakeConsumer != null, canTakeConsumer) - .orderByDesc(CouponTemplateDO::getId)); - } - - default void updateTakeCount(Long id, Integer incrCount) { - update(null, new LambdaUpdateWrapper() - .eq(CouponTemplateDO::getId, id) - .setSql("take_count = take_count + " + incrCount)); - } - - default List selectListByTakeType(Integer takeType) { - return selectList(CouponTemplateDO::getTakeType, takeType); - } - - default List selectList(List canTakeTypes, Integer productScope, Long productScopeValue, Integer count) { - // 构建可领取的查询条件 - Consumer> canTakeConsumer = buildCanTakeQueryConsumer(canTakeTypes); - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(CouponTemplateDO::getProductScope, productScope) - .and(productScopeValue != null, w -> w.apply("FIND_IN_SET({0}, product_scope_values)", - productScopeValue)) - .and(canTakeConsumer != null, canTakeConsumer) - .last(" LIMIT " + count) - .orderByDesc(CouponTemplateDO::getId)); - } - - static Consumer> buildCanTakeQueryConsumer(List canTakeTypes) { - Consumer> canTakeConsumer = null; - if (CollUtil.isNotEmpty(canTakeTypes)) { - canTakeConsumer = w -> - w.eq(CouponTemplateDO::getStatus, CommonStatusEnum.ENABLE.getStatus()) // 1. 状态为可用的 - .in(CouponTemplateDO::getTakeType, canTakeTypes) // 2. 领取方式一致 - .and(ww -> ww.isNull(CouponTemplateDO::getValidEndTime) // 3. 未过期 - .or().gt(CouponTemplateDO::getValidEndTime, LocalDateTime.now())) - .apply(" take_count < total_count "); // 4. 剩余数量大于 0 - } - return canTakeConsumer; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/decorate/DecorateComponentMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/decorate/DecorateComponentMapper.java deleted file mode 100644 index 38b448e8a4..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/decorate/DecorateComponentMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.decorate; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface DecorateComponentMapper extends BaseMapperX { - - default List selectListByPageAndStatus(Integer page, Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(DecorateComponentDO::getPage, page) - .eqIfPresent(DecorateComponentDO::getStatus, status)); - } - - default DecorateComponentDO selectByPageAndCode(Integer page, String code) { - return selectOne(DecorateComponentDO::getPage, page, - DecorateComponentDO::getCode, code); - } - -} - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java deleted file mode 100755 index 534ce627ab..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.discount; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; -import java.util.Set; - -/** - * 限时折扣活动 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface DiscountActivityMapper extends BaseMapperX { - - default PageResult selectPage(DiscountActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DiscountActivityDO::getName, reqVO.getName()) - .eqIfPresent(DiscountActivityDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DiscountActivityDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(DiscountActivityDO::getId)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java deleted file mode 100755 index 10df2ce3a7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.discount; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.Collection; -import java.util.List; - -/** - * 限时折扣商城 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface DiscountProductMapper extends BaseMapperX { - - default List selectListBySkuId(Collection skuIds) { - return selectList(DiscountProductDO::getSkuId, skuIds); - } - - default List selectListByActivityId(Long activityId) { - return selectList(DiscountProductDO::getActivityId, activityId); - } - - default List selectListByActivityId(Collection activityIds) { - return selectList(DiscountProductDO::getActivityId, activityIds); - } - - // TODO @zhangshuai:逻辑里,尽量避免写 join 语句哈,你可以看看这个查询,有什么办法优化?目前的一个思路,是分 2 次查询,性能也是 ok 的 - List getMatchDiscountProductList(@Param("skuIds") Collection skuIds); -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyPageMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyPageMapper.java deleted file mode 100644 index 979b93f25a..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyPageMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 装修页面 Mapper - * - * @author owen - */ -@Mapper -public interface DiyPageMapper extends BaseMapperX { - - default PageResult selectPage(DiyPagePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DiyPageDO::getName, reqVO.getName()) - .betweenIfPresent(DiyPageDO::getCreateTime, reqVO.getCreateTime()) - // 模板下面的页面,在模板中管理 - .isNull(DiyPageDO::getTemplateId) - .orderByDesc(DiyPageDO::getId)); - } - - default List selectListByTemplateId(Long templateId) { - return selectList(DiyPageDO::getTemplateId, templateId); - } - - default DiyPageDO selectByNameAndTemplateIdIsNull(String name) { - return selectOne(new LambdaQueryWrapperX() - .eq(DiyPageDO::getName, name) - .isNull(DiyPageDO::getTemplateId)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyTemplateMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyTemplateMapper.java deleted file mode 100644 index ca3c6284e7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyTemplateMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 装修模板 Mapper - * - * @author owen - */ -@Mapper -public interface DiyTemplateMapper extends BaseMapperX { - - default PageResult selectPage(DiyTemplatePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DiyTemplateDO::getName, reqVO.getName()) - .eqIfPresent(DiyTemplateDO::getUsed, reqVO.getUsed()) - .betweenIfPresent(DiyTemplateDO::getUsedTime, reqVO.getUsedTime()) - .betweenIfPresent(DiyTemplateDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(DiyTemplateDO::getUsed) // 排序规则1:已使用的排到最前面 - .orderByDesc(DiyTemplateDO::getId)); // 排序规则2:新创建的排到前面 - } - - default DiyTemplateDO selectByUsed(boolean used) { - return selectOne(DiyTemplateDO::getUsed, used); - } - - default DiyTemplateDO selectByName(String name) { - return selectOne(DiyTemplateDO::getName, name); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java deleted file mode 100755 index 2ee8798233..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.reward; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 满减送活动 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface RewardActivityMapper extends BaseMapperX { - - default PageResult selectPage(RewardActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(RewardActivityDO::getName, reqVO.getName()) - .eqIfPresent(RewardActivityDO::getStatus, reqVO.getStatus()) - .orderByDesc(RewardActivityDO::getId)); - } - - default List selectListByStatus(Collection statuses) { - return selectList(RewardActivityDO::getStatus, statuses); - } - - default List selectListByProductScopeAndStatus(Integer productScope, Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(RewardActivityDO::getProductScope, productScope) - .eq(RewardActivityDO::getStatus, status)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java deleted file mode 100644 index ca40e76029..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 秒杀活动 Mapper - * - * @author halfninety - */ -@Mapper -public interface SeckillActivityMapper extends BaseMapperX { - - default PageResult selectPage(SeckillActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(SeckillActivityDO::getName, reqVO.getName()) - .eqIfPresent(SeckillActivityDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(SeckillActivityDO::getCreateTime, reqVO.getCreateTime()) - .apply(ObjectUtil.isNotNull(reqVO.getConfigId()), "FIND_IN_SET(" + reqVO.getConfigId() + ", config_ids) > 0") - .orderByDesc(SeckillActivityDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(SeckillActivityDO::getStatus, status)); - } - - /** - * 更新活动库存(减少) - * - * @param id 活动编号 - * @param count 扣减的库存数量(正数) - * @return 影响的行数 - */ - default int updateStockDecr(Long id, int count) { - Assert.isTrue(count > 0); - return update(null, new LambdaUpdateWrapper() - .eq(SeckillActivityDO::getId, id) - .gt(SeckillActivityDO::getStock, count) - .setSql("stock = stock - " + count)); - } - - /** - * 更新活动库存(增加) - * - * @param id 活动编号 - * @param count 增加的库存数量(正数) - * @return 影响的行数 - */ - default int updateStockIncr(Long id, int count) { - Assert.isTrue(count > 0); - return update(null, new LambdaUpdateWrapper() - .eq(SeckillActivityDO::getId, id) - .setSql("stock = stock + " + count)); - } - - default PageResult selectPage(AppSeckillActivityPageReqVO pageReqVO, Integer status) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eqIfPresent(SeckillActivityDO::getStatus, status) - // TODO 芋艿:对 find in set 的想法; - .apply(ObjectUtil.isNotNull(pageReqVO.getConfigId()), "FIND_IN_SET(" + pageReqVO.getConfigId() + ",config_ids) > 0")); - } - - /** - * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - * - * @param spuIds spu 编号 - * @param status 状态 - * @return 包含 spuId 和 activityId 的 map 对象列表 - */ - default List> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(@Param("spuIds") Collection spuIds, @Param("status") Integer status) { - return selectMaps(new QueryWrapper() - .select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id - .in("spu_id", spuIds) - .eq("status", status) - .groupBy("spu_id")); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(SeckillActivityDO::getId, ids) - .lt(SeckillActivityDO::getStartTime, dateTime) - .gt(SeckillActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(SeckillActivityDO::getCreateTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java deleted file mode 100644 index 8fb1401797..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 秒杀活动商品 Mapper - * - * @author halfninety - */ -@Mapper -public interface SeckillProductMapper extends BaseMapperX { - - default List selectListByActivityId(Long activityId) { - return selectList(SeckillProductDO::getActivityId, activityId); - } - - default SeckillProductDO selectByActivityIdAndSkuId(Long activityId, Long skuId) { - return selectOne(SeckillProductDO::getActivityId, activityId, - SeckillProductDO::getSkuId, skuId); - } - - default List selectListByActivityId(Collection ids) { - return selectList(SeckillProductDO::getActivityId, ids); - } - - /** - * 更新活动库存(减少) - * - * @param id 活动编号 - * @param count 扣减的库存数量(减少库存) - * @return 影响的行数 - */ - default int updateStockDecr(Long id, int count) { - Assert.isTrue(count > 0); - return update(null, new LambdaUpdateWrapper() - .eq(SeckillProductDO::getId, id) - .ge(SeckillProductDO::getStock, count) - .setSql("stock = stock - " + count)); - } - - /** - * 更新活动库存(增加) - * - * @param id 活动编号 - * @param count 需要增加的库存(增加库存) - * @return 影响的行数 - */ - default int updateStockIncr(Long id, int count) { - Assert.isTrue(count > 0); - return update(null, new LambdaUpdateWrapper() - .eq(SeckillProductDO::getId, id) - .setSql("stock = stock + " + count)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillconfig/SeckillConfigMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillconfig/SeckillConfigMapper.java deleted file mode 100644 index f1dcaca322..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillconfig/SeckillConfigMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillconfig; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface SeckillConfigMapper extends BaseMapperX { - - default PageResult selectPage(SeckillConfigPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(SeckillConfigDO::getName, reqVO.getName()) - .eqIfPresent(SeckillConfigDO::getStatus, reqVO.getStatus()) - .orderByAsc(SeckillConfigDO::getStartTime)); - } - - default List selectListByStatus(Integer status) { - return selectList(SeckillConfigDO::getStatus, status); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/package-info.java deleted file mode 100644 index b2131910d1..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 promotion 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.promotion.framework; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/web/config/PromotionWebConfiguration.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/web/config/PromotionWebConfiguration.java deleted file mode 100644 index b94a69dbe8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/web/config/PromotionWebConfiguration.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.framework.web.config; - -import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration; -import org.springdoc.core.models.GroupedOpenApi; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * promotion 模块的 web 组件的 Configuration - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -public class PromotionWebConfiguration { - - /** - * promotion 模块的 API 分组 - */ - @Bean - public GroupedOpenApi promotionGroupedOpenApi() { - return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("promotion"); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/web/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/web/package-info.java deleted file mode 100644 index 8359130d43..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/web/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * promotion 模块的 web 配置 - */ -package cn.iocoder.yudao.module.promotion.framework.web; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/combination/CombinationRecordExpireJob.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/combination/CombinationRecordExpireJob.java deleted file mode 100644 index ee44a79d8c..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/combination/CombinationRecordExpireJob.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.job.combination; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -/** - * 拼团过期 Job - * - * @author HUIHUI - */ -@Component -public class CombinationRecordExpireJob implements JobHandler { - - @Resource - private CombinationRecordService combinationRecordService; - - @Override - @TenantJob - public String execute(String param) { - KeyValue keyValue = combinationRecordService.expireCombinationRecord(); - return StrUtil.format("过期拼团 {} 个, 虚拟成团 {} 个", keyValue.getKey(), keyValue.getValue()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/coupon/CouponExpireJob.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/coupon/CouponExpireJob.java deleted file mode 100644 index c6e26af31d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/coupon/CouponExpireJob.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.job.coupon; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -// TODO 芋艿:配置一个 Job -/** - * 优惠券过期 Job - * - * @author owen - */ -@Component -public class CouponExpireJob implements JobHandler { - - @Resource - private CouponService couponService; - - @Override - @TenantJob - public String execute(String param) { - int count = couponService.expireCoupon(); - return StrUtil.format("过期优惠券 {} 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/package-info.java deleted file mode 100644 index 320b98aa21..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位,无具体含义 - */ -package cn.iocoder.yudao.module.promotion.job; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/coupon/CouponTakeByRegisterConsumer.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/coupon/CouponTakeByRegisterConsumer.java deleted file mode 100644 index 673e7dd9c3..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/coupon/CouponTakeByRegisterConsumer.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.mq.consumer.coupon; - -import cn.iocoder.yudao.module.member.message.user.MemberUserCreateMessage; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.event.EventListener; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -/** - * 用户注册时,发送优惠劵的消费者,基 {@link MemberUserCreateMessage} 消息 - * - * @author owen - */ -@Component -@Slf4j -public class CouponTakeByRegisterConsumer { - - @Resource - private CouponService couponService; - - @EventListener - @Async // Spring Event 默认在 Producer 发送的线程,通过 @Async 实现异步 - public void onMessage(MemberUserCreateMessage message) { - log.info("[onMessage][消息内容({})]", message); - couponService.takeCouponByRegister(message.getUserId()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/package-info.java deleted file mode 100644 index 95c23df74d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的消费者 - */ -package cn.iocoder.yudao.module.promotion.mq.consumer; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/message/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/message/package-info.java deleted file mode 100644 index 912504e764..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/message/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的消息 - */ -package cn.iocoder.yudao.module.promotion.mq.message; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/producer/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/producer/package-info.java deleted file mode 100644 index e7b8d1b4c2..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/producer/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的生产者 - */ -package cn.iocoder.yudao.module.promotion.mq.producer; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/package-info.java deleted file mode 100644 index c022c62766..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * promotion 模块,我们放营销业务。 - * 例如说:营销活动、banner、优惠券等等 - * - * 1. Controller URL:以 /promotion/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 promotion_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.promotion; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryService.java deleted file mode 100644 index 86d948500c..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryService.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * 文章分类 Service 接口 - * - * @author HUIHUI - */ -public interface ArticleCategoryService { - - /** - * 创建文章分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createArticleCategory(@Valid ArticleCategoryCreateReqVO createReqVO); - - /** - * 更新文章分类 - * - * @param updateReqVO 更新信息 - */ - void updateArticleCategory(@Valid ArticleCategoryUpdateReqVO updateReqVO); - - /** - * 删除文章分类 - * - * @param id 编号 - */ - void deleteArticleCategory(Long id); - - /** - * 获得文章分类 - * - * @param id 编号 - * @return 文章分类 - */ - ArticleCategoryDO getArticleCategory(Long id); - - /** - * 获得文章分类分页 - * - * @param pageReqVO 分页查询 - * @return 文章分类分页 - */ - PageResult getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO); - - /** - * 获得指定状态的文章分类列表 - * - * @param status 状态 - * @return 文章分类列表 - */ - List getArticleCategoryListByStatus(Integer status); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java deleted file mode 100644 index 588502dfd6..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; - -/** - * 文章分类 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class ArticleCategoryServiceImpl implements ArticleCategoryService { - - @Resource - private ArticleCategoryMapper articleCategoryMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖问题 - private ArticleService articleService; - - @Override - public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) { - // 插入 - ArticleCategoryDO category = ArticleCategoryConvert.INSTANCE.convert(createReqVO); - articleCategoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateArticleCategory(ArticleCategoryUpdateReqVO updateReqVO) { - // 校验存在 - validateArticleCategoryExists(updateReqVO.getId()); - // 更新 - ArticleCategoryDO updateObj = ArticleCategoryConvert.INSTANCE.convert(updateReqVO); - articleCategoryMapper.updateById(updateObj); - } - - @Override - public void deleteArticleCategory(Long id) { - // 校验存在 - validateArticleCategoryExists(id); - // 校验是不是存在关联文章 - Long count = articleService.getArticleCountByCategoryId(id); - if (count > 0) { - throw exception(ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES); - } - - // 删除 - articleCategoryMapper.deleteById(id); - } - - private void validateArticleCategoryExists(Long id) { - if (articleCategoryMapper.selectById(id) == null) { - throw exception(ARTICLE_CATEGORY_NOT_EXISTS); - } - } - - @Override - public ArticleCategoryDO getArticleCategory(Long id) { - return articleCategoryMapper.selectById(id); - } - - @Override - public PageResult getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO) { - return articleCategoryMapper.selectPage(pageReqVO); - } - - @Override - public List getArticleCategoryListByStatus(Integer status) { - return articleCategoryMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java deleted file mode 100644 index 7af9153f41..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * 文章详情 Service 接口 - * - * @author HUIHUI - */ -public interface ArticleService { - - /** - * 创建文章详情 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createArticle(@Valid ArticleCreateReqVO createReqVO); - - /** - * 更新文章详情 - * - * @param updateReqVO 更新信息 - */ - void updateArticle(@Valid ArticleUpdateReqVO updateReqVO); - - /** - * 删除文章详情 - * - * @param id 编号 - */ - void deleteArticle(Long id); - - /** - * 获得文章详情 - * - * @param id 编号 - * @return 文章详情 - */ - ArticleDO getArticle(Long id); - - /** - * 获得文章详情分页 - * - * @param pageReqVO 分页查询 - * @return 文章详情分页 - */ - PageResult getArticlePage(ArticlePageReqVO pageReqVO); - - /** - * 获得文章详情列表 - * - * @param recommendHot 是否热门 - * @param recommendBanner 是否轮播图 - * @return 文章详情列表 - */ - List getArticleCategoryListByRecommend(Boolean recommendHot, Boolean recommendBanner); - - /** - * 获得文章详情分页 - * - * @param pageReqVO 分页查询 - * @return 文章详情分页 - */ - PageResult getArticlePage(AppArticlePageReqVO pageReqVO); - - /** - * 获得指定分类的文章列表 - * - * @param categoryId 文章分类编号 - * @return 文章列表 - */ - List getArticleByCategoryId(Long categoryId); - - /** - * 获得指定分类的文章数量 - * - * @param categoryId 文章分类编号 - * @return 文章数量 - */ - Long getArticleCountByCategoryId(Long categoryId); - - /** - * 增加文章浏览量 - * - * @param id 文章编号 - */ - void addArticleBrowseCount(Long id); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java deleted file mode 100644 index 76e05f906d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS; - -/** - * 文章管理 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class ArticleServiceImpl implements ArticleService { - - @Resource - private ArticleMapper articleMapper; - - @Resource - private ArticleCategoryService articleCategoryService; - - @Override - public Long createArticle(ArticleCreateReqVO createReqVO) { - // 校验分类存在 - validateArticleCategoryExists(createReqVO.getCategoryId()); - - // 插入 - ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO); - article.setBrowseCount(0); // 初始浏览量 - articleMapper.insert(article); - // 返回 - return article.getId(); - } - - @Override - public void updateArticle(ArticleUpdateReqVO updateReqVO) { - // 校验存在 - validateArticleExists(updateReqVO.getId()); - // 校验分类存在 - validateArticleCategoryExists(updateReqVO.getCategoryId()); - - // 更新 - ArticleDO updateObj = ArticleConvert.INSTANCE.convert(updateReqVO); - articleMapper.updateById(updateObj); - } - - @Override - public void deleteArticle(Long id) { - // 校验存在 - validateArticleExists(id); - // 删除 - articleMapper.deleteById(id); - } - - private void validateArticleExists(Long id) { - if (articleMapper.selectById(id) == null) { - throw exception(ARTICLE_NOT_EXISTS); - } - } - - private void validateArticleCategoryExists(Long categoryId) { - ArticleCategoryDO articleCategory = articleCategoryService.getArticleCategory(categoryId); - if (articleCategory == null) { - throw exception(ARTICLE_CATEGORY_NOT_EXISTS); - } - } - - @Override - public ArticleDO getArticle(Long id) { - return articleMapper.selectById(id); - } - - @Override - public PageResult getArticlePage(ArticlePageReqVO pageReqVO) { - return articleMapper.selectPage(pageReqVO); - } - - @Override - public List getArticleCategoryListByRecommend(Boolean recommendHot, Boolean recommendBanner) { - return articleMapper.selectList(recommendHot, recommendBanner); - } - - @Override - public PageResult getArticlePage(AppArticlePageReqVO pageReqVO) { - return articleMapper.selectPage(pageReqVO); - } - - @Override - public List getArticleByCategoryId(Long categoryId) { - return articleMapper.selectList(ArticleDO::getCategoryId, categoryId); - } - - @Override - public Long getArticleCountByCategoryId(Long categoryId) { - return articleMapper.selectCount(ArticleDO::getCategoryId, categoryId); - } - - @Override - public void addArticleBrowseCount(Long id) { - // 校验文章是否存在 - validateArticleExists(id); - // 增加浏览次数 - articleMapper.updateBrowseCount(id); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerService.java deleted file mode 100644 index 5e6b481673..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerService.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * 首页 Banner Service 接口 - * - * @author xia - */ -public interface BannerService { - - /** - * 创建 Banner - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBanner(@Valid BannerCreateReqVO createReqVO); - - /** - * 更新 Banner - * - * @param updateReqVO 更新信息 - */ - void updateBanner(@Valid BannerUpdateReqVO updateReqVO); - - /** - * 删除 Banner - * - * @param id 编号 - */ - void deleteBanner(Long id); - - /** - * 获得 Banner - * - * @param id 编号 - * @return Banner - */ - BannerDO getBanner(Long id); - - /** - * 获得 Banner 分页 - * - * @param pageReqVO 分页查询 - * @return Banner分页 - */ - PageResult getBannerPage(BannerPageReqVO pageReqVO); - - /** - * 增加 Banner 点击量 - * - * @param id Banner编号 - */ - void addBannerBrowseCount(Long id); - - /** - * 获得 Banner 列表 - * - * @param position 定位 - * @return Banner 列表 - */ - List getBannerListByPosition(Integer position); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerServiceImpl.java deleted file mode 100644 index 2fe81051f9..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerServiceImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.banner.BannerMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.BANNER_NOT_EXISTS; - -/** - * 首页 banner 实现类 - * - * @author xia - */ -@Service -@Validated -public class BannerServiceImpl implements BannerService { - - @Resource - private BannerMapper bannerMapper; - - @Override - public Long createBanner(BannerCreateReqVO createReqVO) { - // 插入 - BannerDO banner = BannerConvert.INSTANCE.convert(createReqVO); - bannerMapper.insert(banner); - // 返回 - return banner.getId(); - } - - @Override - public void updateBanner(BannerUpdateReqVO updateReqVO) { - // 校验存在 - this.validateBannerExists(updateReqVO.getId()); - // 更新 - BannerDO updateObj = BannerConvert.INSTANCE.convert(updateReqVO); - bannerMapper.updateById(updateObj); - } - - @Override - public void deleteBanner(Long id) { - // 校验存在 - this.validateBannerExists(id); - // 删除 - bannerMapper.deleteById(id); - } - - private void validateBannerExists(Long id) { - if (bannerMapper.selectById(id) == null) { - throw exception(BANNER_NOT_EXISTS); - } - } - - @Override - public BannerDO getBanner(Long id) { - return bannerMapper.selectById(id); - } - - @Override - public PageResult getBannerPage(BannerPageReqVO pageReqVO) { - return bannerMapper.selectPage(pageReqVO); - } - - @Override - public void addBannerBrowseCount(Long id) { - // 校验 Banner 是否存在 - validateBannerExists(id); - // 增加点击次数 - bannerMapper.updateBrowseCount(id); - } - - @Override - public List getBannerListByPosition(Integer position) { - return bannerMapper.selectBannerListByPosition(position); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java deleted file mode 100644 index 789a3c520e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; - -import jakarta.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -/** - * 砍价活动 Service 接口 - * - * @author HUIHUI - */ -public interface BargainActivityService { - - /** - * 创建砍价活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBargainActivity(@Valid BargainActivityCreateReqVO createReqVO); - - /** - * 更新砍价活动 - * - * @param updateReqVO 更新信息 - */ - void updateBargainActivity(@Valid BargainActivityUpdateReqVO updateReqVO); - - /** - * 更新砍价活动库存 - * - * 如果更新失败(库存不足),则抛出业务异常 - * - * @param id 砍价活动编号 - * @param count 购买数量 - */ - void updateBargainActivityStock(Long id, Integer count); - - /** - * 关闭砍价活动 - * - * @param id 砍价活动编号 - */ - void closeBargainActivityById(Long id); - - /** - * 删除砍价活动 - * - * @param id 编号 - */ - void deleteBargainActivity(Long id); - - /** - * 获得砍价活动 - * - * @param id 编号 - * @return 砍价活动 - */ - BargainActivityDO getBargainActivity(Long id); - - /** - * 获得砍价活动列表 - * - * @param ids 编号数组 - * @return 砍价活动列表 - */ - List getBargainActivityList(Set ids); - - /** - * 校验砍价活动,是否可以参与(发起砍价、下单、帮好友砍价) - * - * @param id 编号 - * @return 砍价活动 - */ - BargainActivityDO validateBargainActivityCanJoin(Long id); - - /** - * 获得砍价活动分页 - * - * @param pageReqVO 分页查询 - * @return 砍价活动分页 - */ - PageResult getBargainActivityPage(BargainActivityPageReqVO pageReqVO); - - /** - * 获取正在进行的活动分页数据 - * - * @param pageReqVO 分页请求 - * @return 砍价活动分页 - */ - PageResult getBargainActivityPage(PageParam pageReqVO); - - /** - * 获取正在进行的活动分页数据 - * - * @param count 需要的数量 - * @return 砍价活动分页 - */ - List getBargainActivityListByCount(Integer count); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 日期时间 - * @return 砍价活动列表 - */ - List getBargainActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java deleted file mode 100644 index f145fc6657..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java +++ /dev/null @@ -1,208 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 砍价活动 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class BargainActivityServiceImpl implements BargainActivityService { - - @Resource - private BargainActivityMapper bargainActivityMapper; - - @Resource - private ProductSkuApi productSkuApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createBargainActivity(BargainActivityCreateReqVO createReqVO) { - // 校验商品 SPU 是否存在是否参加的别的活动 - validateBargainConflict(createReqVO.getSpuId(), null); - // 校验商品 sku 是否存在 - validateSku(createReqVO.getSkuId()); - - // 插入砍价活动 - BargainActivityDO activityDO = BargainActivityConvert.INSTANCE.convert(createReqVO) - .setTotalStock(createReqVO.getStock()) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - bargainActivityMapper.insert(activityDO); - return activityDO.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateBargainActivity(BargainActivityUpdateReqVO updateReqVO) { - // 校验存在 - BargainActivityDO activity = validateBargainActivityExists(updateReqVO.getId()); - // 校验状态 - if (ObjectUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE); - } - // 校验商品冲突 - validateBargainConflict(updateReqVO.getSpuId(), updateReqVO.getId()); - // 校验商品 sku 是否存在 - validateSku(updateReqVO.getSkuId()); - - // 更新 - BargainActivityDO updateObj = BargainActivityConvert.INSTANCE.convert(updateReqVO); - if (updateObj.getStock() > activity.getTotalStock()) { // 如果更新的库存大于原来的库存,则更新总库存 - updateObj.setTotalStock(updateObj.getStock()); - } - bargainActivityMapper.updateById(updateObj); - } - - @Override - public void updateBargainActivityStock(Long id, Integer count) { - if (count < 0) { - // 更新库存。如果更新失败,则抛出异常 - int updateCount = bargainActivityMapper.updateStock(id, count); - if (updateCount == 0) { - throw exception(BARGAIN_ACTIVITY_STOCK_NOT_ENOUGH); - } - } else if (count > 0) { - bargainActivityMapper.updateStock(id, count); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void closeBargainActivityById(Long id) { - // 校验砍价活动是否存在 - BargainActivityDO activity = validateBargainActivityExists(id); - if (CommonStatusEnum.isDisable(activity.getStatus())) { - throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE); - } - - bargainActivityMapper.updateById(new BargainActivityDO().setId(id) - .setStatus(CommonStatusEnum.DISABLE.getStatus())); - } - - private void validateBargainConflict(Long spuId, Long activityId) { - // 查询所有开启的砍价活动 - List activityList = bargainActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - if (activityId != null) { // 更新时排除自己 - activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId)); - } - // 校验商品 spu 是否参加了其它活动 - if (anyMatch(activityList, activity -> ObjectUtil.equal(activity.getSpuId(), spuId))) { - throw exception(BARGAIN_ACTIVITY_SPU_CONFLICTS); - } - } - - private void validateSku(Long skuId) { - ProductSkuRespDTO sku = productSkuApi.getSku(skuId); - if (sku == null) { - throw exception(SKU_NOT_EXISTS); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteBargainActivity(Long id) { - // 校验存在 - BargainActivityDO activityDO = validateBargainActivityExists(id); - // 校验状态 - if (CommonStatusEnum.isEnable(activityDO.getStatus())) { - throw exception(BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); - } - - // 删除 - bargainActivityMapper.deleteById(id); - } - - private BargainActivityDO validateBargainActivityExists(Long id) { - BargainActivityDO activityDO = bargainActivityMapper.selectById(id); - if (activityDO == null) { - throw exception(BARGAIN_ACTIVITY_NOT_EXISTS); - } - return activityDO; - } - - @Override - public BargainActivityDO getBargainActivity(Long id) { - return bargainActivityMapper.selectById(id); - } - - @Override - public List getBargainActivityList(Set ids) { - return bargainActivityMapper.selectBatchIds(ids); - } - - @Override - public BargainActivityDO validateBargainActivityCanJoin(Long id) { - BargainActivityDO activity = bargainActivityMapper.selectById(id); - if (activity == null) { - throw exception(BARGAIN_ACTIVITY_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(activity.getStatus())) { - throw exception(BARGAIN_ACTIVITY_STATUS_CLOSED); - } - if (activity.getStock() <= 0) { - throw exception(BARGAIN_ACTIVITY_STOCK_NOT_ENOUGH); - } - if (!LocalDateTimeUtils.isBetween(activity.getStartTime(), activity.getEndTime())) { - throw exception(BARGAIN_ACTIVITY_TIME_END); - } - return activity; - } - - @Override - public PageResult getBargainActivityPage(BargainActivityPageReqVO pageReqVO) { - return bargainActivityMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getBargainActivityPage(PageParam pageReqVO) { - // 只查询进行中,且在时间范围内的 - return bargainActivityMapper.selectPage(pageReqVO, CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now()); - } - - @Override - public List getBargainActivityListByCount(Integer count) { - return bargainActivityMapper.selectList(count, CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now()); - } - - @Override - public List getBargainActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1. 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - List> spuIdAndActivityIdMaps = bargainActivityMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { - return Collections.emptyList(); - } - // 2. 查询活动详情 - return bargainActivityMapper.selectListByIdsAndDateTimeLt( - convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpService.java deleted file mode 100644 index 8aec48597f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpService.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpCreateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 砍价助力 Service 接口 - * - * @author 芋道源码 - */ -public interface BargainHelpService { - - /** - * 创建砍价助力(帮人砍价) - * - * @param userId 用户编号 - * @param reqVO 请求信息 - * @return 砍价助力记录 - */ - BargainHelpDO createBargainHelp(Long userId, AppBargainHelpCreateReqVO reqVO); - - /** - * 【砍价活动】获得助力人数 Map - * - * @param activityIds 活动编号 - * @return 助力人数 Map - */ - Map getBargainHelpUserCountMapByActivity(Collection activityIds); - - /** - * 【砍价记录】获得助力人数 Map - * - * @param recordIds 记录编号 - * @return 助力人数 Map - */ - Map getBargainHelpUserCountMapByRecord(Collection recordIds); - - /** - * 【砍价活动】获得用户的助力次数 - * - * @param activityId 活动编号 - * @param userId 用户编号 - * @return 助力次数 - */ - Long getBargainHelpCountByActivity(Long activityId, Long userId); - - /** - * 获得砍价助力分页 - * - * @param pageReqVO 分页查询 - * @return 砍价助力分页 - */ - PageResult getBargainHelpPage(BargainHelpPageReqVO pageReqVO); - - /** - * 获得指定砍价记录编号,对应的砍价助力列表 - * - * @param recordId 砍价记录编号 - * @return 砍价助力列表 - */ - List getBargainHelpListByRecordId(Long recordId); - - /** - * 获得助力记录 - * - * @param recordId 砍价记录编号 - * @param userId 用户编号 - * @return 助力记录 - */ - BargainHelpDO getBargainHelp(Long recordId, Long userId); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java deleted file mode 100644 index 5b98f8564b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpCreateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainHelpMapper; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import jodd.util.MathUtil; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 砍价助力 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BargainHelpServiceImpl implements BargainHelpService { - - @Resource - private BargainHelpMapper bargainHelpMapper; - - @Resource - private BargainRecordService bargainRecordService; - @Resource - private BargainActivityService bargainActivityService; - - @Override - @Transactional(rollbackFor = Exception.class) - public BargainHelpDO createBargainHelp(Long userId, AppBargainHelpCreateReqVO reqVO) { - // 1.1 校验砍价记录存在,并且处于进行中 - BargainRecordDO record = bargainRecordService.getBargainRecord(reqVO.getRecordId()); - if (record == null) { - throw exception(BARGAIN_RECORD_NOT_EXISTS); - } - if (ObjUtil.notEqual(record.getStatus(), BargainRecordStatusEnum.IN_PROGRESS.getStatus())) { - throw exception(BARGAIN_HELP_CREATE_FAIL_RECORD_NOT_IN_PROCESS); - } - // 1.2 不能自己给自己砍价 - if (ObjUtil.equal(record.getUserId(), userId)) { - throw exception(BARGAIN_HELP_CREATE_FAIL_RECORD_SELF); - } - - // 2.1 校验砍价活动 - BargainActivityDO activity = bargainActivityService.getBargainActivity(record.getActivityId()); - // 2.2 校验自己是否助力次数上限 - if (bargainHelpMapper.selectCountByUserIdAndActivityId(userId, activity.getId()) - >= activity.getBargainCount()) { - throw exception(BARGAIN_HELP_CREATE_FAIL_LIMIT); - } - // 2.3 特殊情况:砍价已经砍到最低价,不能再砍了 - if (record.getBargainPrice() <= activity.getBargainMinPrice()) { - throw exception(BARGAIN_HELP_CREATE_FAIL_RECORD_NOT_IN_PROCESS); - } - - // 3. 已经助力 - if (bargainHelpMapper.selectByUserIdAndRecordId(userId, record.getId()) != null) { - throw exception(BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS); - } - - // 4.1 计算砍价金额 - Integer reducePrice = calculateReducePrice(activity, record); - Assert.isTrue(reducePrice > 0, "砍价金额必须大于 0 元"); - // 4.2 创建助力记录 - BargainHelpDO help = BargainHelpDO.builder().userId(userId).activityId(activity.getId()) - .recordId(record.getId()).reducePrice(reducePrice).build(); - bargainHelpMapper.insert(help); - - // 5. 判断砍价记录是否完成 - Boolean success = record.getBargainPrice() - reducePrice <= activity.getBargainMinPrice() // 情况一:砍价已经砍到最低价 - || bargainHelpMapper.selectUserCountMapByRecordId(reqVO.getRecordId()) >= activity.getHelpMaxCount(); // 情况二:砍价助力已经达到上限 - if (!bargainRecordService.updateBargainRecordBargainPrice( - record.getId(), record.getBargainPrice(), reducePrice, success)) { - // 多人一起砍价,需要重试 - throw exception(BARGAIN_HELP_CREATE_FAIL_CONFLICT); - } - return help; - } - - // TODO 芋艿:优化点:实现一个更随机的逻辑,可以按照你自己的业务; - private Integer calculateReducePrice(BargainActivityDO activity, BargainRecordDO record) { - // 1. 随机金额 - Integer reducePrice = MathUtil.randomInt(activity.getBargainMinPrice(), - activity.getRandomMaxPrice() + 1); // + 1 的原因是,randomInt 默认不包含第二个参数 - // 2. 校验是否超过砍价上限 - if (record.getBargainPrice() - reducePrice < activity.getBargainMinPrice()) { - reducePrice = record.getBargainPrice() - activity.getBargainMinPrice(); - } - return reducePrice; - } - - @Override - public Map getBargainHelpUserCountMapByActivity(Collection activityIds) { - return bargainHelpMapper.selectUserCountMapByActivityId(activityIds); - } - - @Override - public Map getBargainHelpUserCountMapByRecord(Collection recordIds) { - return bargainHelpMapper.selectUserCountMapByRecordId(recordIds); - } - - @Override - public Long getBargainHelpCountByActivity(Long activityId, Long userId) { - return bargainHelpMapper.selectCountByUserIdAndActivityId(userId, activityId); - } - - @Override - public PageResult getBargainHelpPage(BargainHelpPageReqVO pageReqVO) { - return bargainHelpMapper.selectPage(pageReqVO); - } - - @Override - public List getBargainHelpListByRecordId(Long recordId) { - return bargainHelpMapper.selectListByRecordId(recordId); - } - - @Override - public BargainHelpDO getBargainHelp(Long recordId, Long userId) { - return bargainHelpMapper.selectByUserIdAndRecordId(userId, recordId); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java deleted file mode 100644 index 15862b0f24..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; - -import jakarta.annotation.Nullable; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 砍价记录 service 接口 - * - * @author HUIHUI - */ -public interface BargainRecordService { - - /** - * 【会员】创建砍价记录(参与参加活动) - * - * @param userId 用户编号 - * @param reqVO 创建信息 - * @return 砍价记录编号 - */ - Long createBargainRecord(Long userId, AppBargainRecordCreateReqVO reqVO); - - /** - * 更新砍价记录的砍价金额 - * - * 如果满足砍价成功的条件,则更新砍价记录的状态为成功 - * - * @param id 砍价记录编号 - * @param whereBargainPrice 当前的砍价金额 - * @param reducePrice 减少的砍价金额 - * @param success 是否砍价成功 - * @return 是否更新成功。注意,如果并发更新时,会更新失败 - */ - Boolean updateBargainRecordBargainPrice(Long id, Integer whereBargainPrice, - Integer reducePrice, Boolean success); - - /** - * 【下单前】校验是否参与砍价活动 - *

- * 如果校验失败,则抛出业务异常 - * - * @param userId 用户编号 - * @param bargainRecordId 砍价活动编号 - * @param skuId SKU 编号 - * @return 砍价信息 - */ - BargainValidateJoinRespDTO validateJoinBargain(Long userId, Long bargainRecordId, Long skuId); - - /** - * 更新砍价记录的订单编号 - * - * 在砍价成功后,用户发起订单后,会记录该订单编号 - * - * @param id 砍价记录编号 - * @param orderId 订单编号 - */ - void updateBargainRecordOrderId(Long id, Long orderId); - - /** - * 获得砍价记录 - * - * @param id 砍价记录编号 - * @return 砍价记录 - */ - BargainRecordDO getBargainRecord(Long id); - - /** - * 获得用户在当前砍价活动中的最后一条砍价记录 - * - * @param userId 用户编号 - * @param activityId 砍价记录编号 - * @return 砍价记录 - */ - BargainRecordDO getLastBargainRecord(Long userId, Long activityId); - - /** - * 获得砍价人数 Map - * - * @param activityIds 活动编号 - * @param status 砍价记录状态 - * @return 砍价人数 Map - */ - Map getBargainRecordUserCountMap(Collection activityIds, @Nullable Integer status); - - /** - * 获得砍价人数 - * - * @param status 砍价记录状态 - * @return 砍价人数 - */ - Integer getBargainRecordUserCount(Integer status); - - /** - * 获得砍价人数 - * - * @param activityId 砍价活动编号 - * @param status 砍价记录状态 - * @return 砍价人数 - */ - Integer getBargainRecordUserCount(Long activityId, Integer status); - - /** - * 【管理员】获得砍价记录分页 - * - * @param pageReqVO 分页查询 - * @return 砍价记录分页 - */ - PageResult getBargainRecordPage(BargainRecordPageReqVO pageReqVO); - - /** - * 【会员】获得砍价记录分页 - * - * @param userId 用户编号 - * @param pageParam 分页查询 - * @return 砍价记录分页 - */ - PageResult getBargainRecordPage(Long userId, PageParam pageParam); - - /** - * 获得砍价记录列表 - * - * @param status 砍价记录状态 - * @param count 条数 - * @return 砍价记录列表 - */ - List getBargainRecordList(Integer status, Integer count); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java deleted file mode 100644 index 5e2862ac0b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java +++ /dev/null @@ -1,152 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainRecordMapper; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Nullable; -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 砍价记录 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class BargainRecordServiceImpl implements BargainRecordService { - - @Resource - private BargainActivityService bargainActivityService; - - @Resource - private BargainRecordMapper bargainRecordMapper; - - @Override - public Long createBargainRecord(Long userId, AppBargainRecordCreateReqVO reqVO) { - // 1. 校验砍价活动(包括库存) - BargainActivityDO activity = bargainActivityService.validateBargainActivityCanJoin(reqVO.getActivityId()); - - // 2.1 校验当前是否已经有参与中的砍价活动 - if (CollUtil.isNotEmpty(bargainRecordMapper.selectListByUserIdAndActivityIdAndStatus( - userId, reqVO.getActivityId(), BargainRecordStatusEnum.IN_PROGRESS.getStatus()))) { - throw exception(BARGAIN_RECORD_CREATE_FAIL_EXISTS); - } - // 2.2 是否超过参与的上限 - if (bargainRecordMapper.selectCountByUserIdAndActivityIdAndStatus( - userId, reqVO.getActivityId(), BargainRecordStatusEnum.SUCCESS.getStatus()) >= activity.getTotalLimitCount()) { - throw exception(BARGAIN_RECORD_CREATE_FAIL_LIMIT); - } - - // 3. 创建砍价记录 - BargainRecordDO record = BargainRecordDO.builder().userId(userId) - .activityId(reqVO.getActivityId()).spuId(activity.getSpuId()).skuId(activity.getSkuId()) - .bargainFirstPrice(activity.getBargainFirstPrice()).bargainPrice(activity.getBargainFirstPrice()) - .status(BargainRecordStatusEnum.IN_PROGRESS.getStatus()).build(); - bargainRecordMapper.insert(record); - return record.getId(); - } - - @Override - public Boolean updateBargainRecordBargainPrice(Long id, Integer whereBargainPrice, - Integer reducePrice, Boolean success) { - BargainRecordDO updateObj = new BargainRecordDO().setBargainPrice(whereBargainPrice - reducePrice); - if (success) { - updateObj.setStatus(BargainRecordStatusEnum.SUCCESS.getStatus()); - } - return bargainRecordMapper.updateByIdAndBargainPrice(id, whereBargainPrice, updateObj) > 0; - } - - @Override - public BargainValidateJoinRespDTO validateJoinBargain(Long userId, Long bargainRecordId, Long skuId) { - // 1.1 砍价记录不存在 - BargainRecordDO record = bargainRecordMapper.selectByIdAndUserId(bargainRecordId, userId); - if (record == null) { - throw exception(BARGAIN_RECORD_NOT_EXISTS); - } - // 1.2 砍价记录未在进行中 - if (ObjUtil.notEqual(record.getStatus(), BargainRecordStatusEnum.SUCCESS.getStatus())) { - throw exception(BARGAIN_JOIN_RECORD_NOT_SUCCESS); - } - // 1.3 砍价记录已经下单 - if (record.getOrderId() != null) { - throw exception(BARGAIN_JOIN_RECORD_ALREADY_ORDER); - } - - // 2.1 校验砍价活动(包括库存) - BargainActivityDO activity = bargainActivityService.validateBargainActivityCanJoin(record.getActivityId()); - Assert.isTrue(Objects.equals(skuId, activity.getSkuId()), "砍价商品不匹配"); // 防御性校验 - return new BargainValidateJoinRespDTO().setActivityId(activity.getId()).setName(activity.getName()) - .setBargainPrice(record.getBargainPrice()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateBargainRecordOrderId(Long id, Long orderId) { - // 更新失败,说明已经下单 - int updateCount = bargainRecordMapper.updateOrderIdById(id, orderId); - if (updateCount == 0) { - throw exception(BARGAIN_JOIN_RECORD_ALREADY_ORDER); - } - } - - @Override - public BargainRecordDO getBargainRecord(Long id) { - return bargainRecordMapper.selectById(id); - } - - @Override - public BargainRecordDO getLastBargainRecord(Long userId, Long activityId) { - return bargainRecordMapper.selectLastByUserIdAndActivityId(userId, activityId); - } - - @Override - public Map getBargainRecordUserCountMap(Collection activityIds, @Nullable Integer status) { - return bargainRecordMapper.selectUserCountByActivityIdsAndStatus(activityIds, status); - } - - @Override - public Integer getBargainRecordUserCount(Integer status) { - return bargainRecordMapper.selectUserCountByStatus(status); - } - - @Override - public Integer getBargainRecordUserCount(Long activityId, Integer status) { - return bargainRecordMapper.selectUserCountByActivityIdAndStatus(activityId, status); - } - - @Override - public PageResult getBargainRecordPage(BargainRecordPageReqVO pageReqVO) { - return bargainRecordMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getBargainRecordPage(Long userId, PageParam pageParam) { - return bargainRecordMapper.selectBargainRecordPage(userId, pageParam); - } - - @Override - public List getBargainRecordList(Integer status, Integer count) { - return bargainRecordMapper.selectListByStatusAndCount(status, count); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java deleted file mode 100644 index 8637a96071..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; - -import jakarta.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * 拼团活动 Service 接口 - * - * @author HUIHUI - */ -public interface CombinationActivityService { - - /** - * 创建拼团活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCombinationActivity(@Valid CombinationActivityCreateReqVO createReqVO); - - /** - * 更新拼团活动 - * - * @param updateReqVO 更新信息 - */ - void updateCombinationActivity(@Valid CombinationActivityUpdateReqVO updateReqVO); - - /** - * 关闭拼团活动 - * - * @param id 拼团活动编号 - */ - void closeCombinationActivityById(Long id); - - /** - * 删除拼团活动 - * - * @param id 编号 - */ - void deleteCombinationActivity(Long id); - - /** - * 校验拼团活动是否存在 - * - * @param id 编号 - * @return 拼团活动 - */ - CombinationActivityDO validateCombinationActivityExists(Long id); - - /** - * 获得拼团活动 - * - * @param id 编号 - * @return 拼团活动 - */ - CombinationActivityDO getCombinationActivity(Long id); - - /** - * 获得拼团活动分页 - * - * @param pageReqVO 分页查询 - * @return 拼团活动分页 - */ - PageResult getCombinationActivityPage(CombinationActivityPageReqVO pageReqVO); - - /** - * 获得拼团活动商品列表 - * - * @param activityId 拼团活动 id - * @return 拼团活动的商品列表 - */ - default List getCombinationProductsByActivityId(Long activityId) { - return getCombinationProductListByActivityIds(Collections.singletonList(activityId)); - } - - /** - * 获得拼团活动商品列表 - * - * @param activityIds 拼团活动 ids - * @return 拼团活动的商品列表 - */ - List getCombinationProductListByActivityIds(Collection activityIds); - - /** - * 获得拼团活动列表 - * - * @param ids 拼团活动 ids - * @return 拼团活动的列表 - */ - List getCombinationActivityListByIds(Collection ids); - - /** - * 获取正在进行的活动分页数据 - * - * @param count 需要的数量 - * @return 拼团活动分页 - */ - List getCombinationActivityListByCount(Integer count); - - /** - * 获取正在进行的活动分页数据 - * - * @param pageParam 分页请求 - * @return 拼团活动分页 - */ - PageResult getCombinationActivityPage(PageParam pageParam); - - /** - * 获取指定活动、指定 sku 编号的商品 - * - * @param activityId 活动编号 - * @param skuId sku 编号 - * @return 活动商品信息 - */ - CombinationProductDO selectByActivityIdAndSkuId(Long activityId, Long skuId); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 日期时间 - * @return 拼团活动列表 - */ - List getCombinationActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java deleted file mode 100644 index 6d51bde6c1..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java +++ /dev/null @@ -1,257 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationProductMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; - -/** - * 拼团活动 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class CombinationActivityServiceImpl implements CombinationActivityService { - - @Resource - private CombinationActivityMapper combinationActivityMapper; - @Resource - private CombinationProductMapper combinationProductMapper; - - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createCombinationActivity(CombinationActivityCreateReqVO createReqVO) { - // 校验商品 SPU 是否存在是否参加的别的活动 - validateProductConflict(createReqVO.getSpuId(), null); - // 校验商品是否存在 - validateProductExists(createReqVO.getSpuId(), createReqVO.getProducts()); - - // 插入拼团活动 - CombinationActivityDO activity = CombinationActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - combinationActivityMapper.insert(activity); - // 插入商品 - List products = CombinationActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), activity); - combinationProductMapper.insertBatch(products); - return activity.getId(); - } - - /** - * 校验拼团商品参与的活动是否存在冲突 - * - * @param spuId 商品 SPU 编号 - * @param activityId 拼团活动编号 - */ - private void validateProductConflict(Long spuId, Long activityId) { - // 查询所有开启的拼团活动 - List activityList = combinationActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - if (activityId != null) { // 时排除自己 - activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId)); - } - // 查找是否有其它活动,选择了该产品 - List matchActivityList = filterList(activityList, activity -> ObjectUtil.equal(activity.getId(), spuId)); - if (CollUtil.isNotEmpty(matchActivityList)) { - throw exception(COMBINATION_ACTIVITY_SPU_CONFLICTS); - } - } - - /** - * 校验拼团商品是否都存在 - * - * @param spuId 商品 SPU 编号 - * @param products 拼团商品 - */ - private void validateProductExists(Long spuId, List products) { - // 1. 校验商品 spu 是否存在 - ProductSpuRespDTO spu = productSpuApi.getSpu(spuId); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - - // 2. 校验商品 sku 都存在 - List skus = productSkuApi.getSkuListBySpuId(singletonList(spuId)); - Map skuMap = convertMap(skus, ProductSkuRespDTO::getId); - products.forEach(product -> { - if (!skuMap.containsKey(product.getSkuId())) { - throw exception(SKU_NOT_EXISTS); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateCombinationActivity(CombinationActivityUpdateReqVO updateReqVO) { - // 校验存在 - CombinationActivityDO activityDO = validateCombinationActivityExists(updateReqVO.getId()); - // 校验状态 - if (ObjectUtil.equal(activityDO.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE_NOT_UPDATE); - } - // 校验商品冲突 - validateProductConflict(updateReqVO.getSpuId(), updateReqVO.getId()); - // 校验商品是否存在 - validateProductExists(updateReqVO.getSpuId(), updateReqVO.getProducts()); - - // 更新活动 - CombinationActivityDO updateObj = CombinationActivityConvert.INSTANCE.convert(updateReqVO); - combinationActivityMapper.updateById(updateObj); - // 更新商品 - updateCombinationProduct(updateObj, updateReqVO.getProducts()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void closeCombinationActivityById(Long id) { - // 校验活动是否存在 - CombinationActivityDO activity = validateCombinationActivityExists(id); - if (CommonStatusEnum.isDisable(activity.getStatus())) { - throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE_NOT_UPDATE); - } - - // 关闭活动 - combinationActivityMapper.updateById(new CombinationActivityDO().setId(id) - .setStatus(CommonStatusEnum.DISABLE.getStatus())); - } - - /** - * 更新拼团商品 - * - * @param activity 拼团活动 - * @param products 该活动的最新商品配置 - */ - private void updateCombinationProduct(CombinationActivityDO activity, List products) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List newList = CombinationActivityConvert.INSTANCE.convertList(products, activity); - List oldList = combinationProductMapper.selectListByActivityIds(CollUtil.newArrayList(activity.getId())); - List> diffList = CollectionUtils.diffList(oldList, newList, (oldVal, newVal) -> { - boolean same = ObjectUtil.equal(oldVal.getSkuId(), newVal.getSkuId()); - if (same) { - newVal.setId(oldVal.getId()); - } - return same; - }); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - combinationProductMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - combinationProductMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - combinationProductMapper.deleteBatchIds(CollectionUtils.convertList(diffList.get(2), CombinationProductDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteCombinationActivity(Long id) { - // 校验存在 - CombinationActivityDO activity = validateCombinationActivityExists(id); - // 校验状态 - if (CommonStatusEnum.isEnable(activity.getStatus())) { - throw exception(COMBINATION_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); - } - - // 删除 - combinationActivityMapper.deleteById(id); - } - - @Override - public CombinationActivityDO validateCombinationActivityExists(Long id) { - CombinationActivityDO activityDO = combinationActivityMapper.selectById(id); - if (activityDO == null) { - throw exception(COMBINATION_ACTIVITY_NOT_EXISTS); - } - return activityDO; - } - - @Override - public CombinationActivityDO getCombinationActivity(Long id) { - return validateCombinationActivityExists(id); - } - - @Override - public PageResult getCombinationActivityPage(CombinationActivityPageReqVO pageReqVO) { - return combinationActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getCombinationProductListByActivityIds(Collection activityIds) { - return combinationProductMapper.selectListByActivityIds(activityIds); - } - - @Override - public List getCombinationActivityListByIds(Collection ids) { - return combinationActivityMapper.selectList(CombinationActivityDO::getId, ids); - } - - @Override - public List getCombinationActivityListByCount(Integer count) { - return combinationActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus(), count); - } - - @Override - public PageResult getCombinationActivityPage(PageParam pageParam) { - return combinationActivityMapper.selectPage(pageParam, CommonStatusEnum.ENABLE.getStatus()); - } - - @Override - public CombinationProductDO selectByActivityIdAndSkuId(Long activityId, Long skuId) { - return combinationProductMapper.selectOne( - CombinationProductDO::getActivityId, activityId, - CombinationProductDO::getSkuId, skuId); - } - - @Override - public List getCombinationActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1.查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - List> spuIdAndActivityIdMaps = combinationActivityMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { - return Collections.emptyList(); - } - // 2.查询活动详情 - return combinationActivityMapper.selectListByIdsAndDateTimeLt( - convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java deleted file mode 100644 index 3541149a1f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java +++ /dev/null @@ -1,166 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; - -import jakarta.annotation.Nullable; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 拼团记录 Service 接口 - * - * @author HUIHUI - */ -public interface CombinationRecordService { - - /** - * 【下单前】校验是否满足拼团活动条件 - * - * 如果校验失败,则抛出业务异常 - * - * @param userId 用户编号 - * @param activityId 活动编号 - * @param headId 团长编号 - * @param skuId sku 编号 - * @param count 数量 - * @return 拼团信息 - */ - KeyValue validateCombinationRecord(Long userId, Long activityId, Long headId, - Long skuId, Integer count); - - /** - * 创建拼团记录 - * - * @param reqDTO 创建信息 - * @return 团信息 - */ - CombinationRecordDO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO); - - /** - * 获得拼团记录 - * - * @param userId 用户编号 - * @param orderId 订单编号 - * @return 拼团记录 - */ - CombinationRecordDO getCombinationRecord(Long userId, Long orderId); - - /** - * 【下单前】校验是否满足拼团活动条件 - * - * 如果校验失败,则抛出业务异常 - * - * @param userId 用户编号 - * @param activityId 活动编号 - * @param headId 团长编号 - * @param skuId sku 编号 - * @param count 数量 - * @return 拼团信息 - */ - CombinationValidateJoinRespDTO validateJoinCombination(Long userId, Long activityId, Long headId, Long skuId, Integer count); - - /** - * 获取拼团记录数 - * - * @param status 状态-允许为空 - * @param virtualGroup 是否虚拟成团-允许为空 - * @param headId 团长编号,允许空。目的 headId 设置为 {@link CombinationRecordDO#HEAD_ID_GROUP} 时,可以设置 - * @return 记录数 - */ - Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup, Long headId); - - /** - * 查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次 - * - * @return 参加过拼团的用户数 - */ - Long getCombinationUserCount(); - - /** - * 获取最近的 count 条拼团记录 - * - * @param count 限制数量 - * @return 拼团记录列表 - */ - List getLatestCombinationRecordList(int count); - - /** - * 获得最近 n 条拼团记录(团长发起的) - * - * @param activityId 拼团活动编号 - * @param status 状态 - * @param count 数量 - * @return 拼团记录列表 - */ - List getHeadCombinationRecordList(Long activityId, Integer status, Integer count); - - /** - * 获取指定编号的拼团记录 - * - * @param id 拼团记录编号 - * @return 拼团记录 - */ - CombinationRecordDO getCombinationRecordById(Long id); - - /** - * 获取指定团长编号的拼团记录 - * - * @param headId 团长编号 - * @return 拼团记录列表 - */ - List getCombinationRecordListByHeadId(Long headId); - - /** - * 获取拼团记录分页数据 - * - * @param pageVO 分页请求 - * @return 拼团记录分页数据 - */ - PageResult getCombinationRecordPage(CombinationRecordReqPageVO pageVO); - - /** - * 【拼团活动】获得拼团记录数量 Map - * - * @param activityIds 活动记录编号数组 - * @param status 拼团状态,允许空 - * @param headId 团长编号,允许空。目的 headId 设置为 {@link CombinationRecordDO#HEAD_ID_GROUP} 时,可以设置 - * @return 拼团记录数量 Map - */ - Map getCombinationRecordCountMapByActivity(Collection activityIds, - @Nullable Integer status, - @Nullable Long headId); - - /** - * 获取拼团记录 - * - * @param userId 用户编号 - * @param id 拼团记录编号 - * @return 拼团记录 - */ - CombinationRecordDO getCombinationRecordByIdAndUser(Long userId, Long id); - - /** - * 取消拼团 - * - * @param userId 用户编号 - * @param id 拼团记录编号 - * @param headId 团长编号 - */ - void cancelCombinationRecord(Long userId, Long id, Long headId); - - /** - * 处理过期拼团 - * - * @return key 过期拼团数量, value 虚拟成团数量 - */ - KeyValue expireCombinationRecord(); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java deleted file mode 100644 index a3b61759da..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java +++ /dev/null @@ -1,420 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Nullable; -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.afterNow; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.beforeNow; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -// TODO 芋艿:等拼团记录做完,完整 review 下 - -/** - * 拼团记录 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Slf4j -@Validated -public class CombinationRecordServiceImpl implements CombinationRecordService { - - @Resource - private CombinationActivityService combinationActivityService; - @Resource - private CombinationRecordMapper combinationRecordMapper; - - @Resource - private MemberUserApi memberUserApi; - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Resource - @Lazy - private TradeOrderApi tradeOrderApi; - - // TODO @芋艿:在详细预览下; - @Override - public KeyValue validateCombinationRecord( - Long userId, Long activityId, Long headId, Long skuId, Integer count) { - // 1. 校验拼团活动是否存在 - CombinationActivityDO activity = combinationActivityService.validateCombinationActivityExists(activityId); - // 1.1 校验活动是否开启 - if (ObjUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE); - } - // 1.2. 校验活动开始时间 - if (afterNow(activity.getStartTime())) { - throw exception(COMBINATION_RECORD_FAILED_TIME_NOT_START); - } - // 1.3 校验是否超出单次限购数量 - if (count > activity.getSingleLimitCount()) { - throw exception(COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED); - } - - // 2. 父拼团是否存在,是否已经满了 - if (headId != null) { - // 2.1. 查询进行中的父拼团 - CombinationRecordDO record = combinationRecordMapper.selectByHeadId(headId, CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); - if (record == null) { - throw exception(COMBINATION_RECORD_HEAD_NOT_EXISTS); - } - // 2.2. 校验拼团是否已满 - if (ObjUtil.equal(record.getUserCount(), record.getUserSize())) { - throw exception(COMBINATION_RECORD_USER_FULL); - } - // 2.3 校验拼团是否过期(有父拼团的时候只校验父拼团的过期时间) - if (beforeNow(record.getExpireTime())) { - throw exception(COMBINATION_RECORD_FAILED_TIME_END); - } - } else { - // 3. 校验当前活动是否结束(自己是父拼团的时候才校验活动是否结束) - if (beforeNow(activity.getEndTime())) { - throw exception(COMBINATION_RECORD_FAILED_TIME_END); - } - } - - // 4.1 校验活动商品是否存在 - CombinationProductDO product = combinationActivityService.selectByActivityIdAndSkuId(activityId, skuId); - if (product == null) { - throw exception(COMBINATION_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS); - } - // 4.2 校验 sku 是否存在 - ProductSkuRespDTO sku = productSkuApi.getSku(skuId); - if (sku == null) { - throw exception(COMBINATION_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS); - } - // 4.3 校验库存是否充足 - if (count > sku.getStock()) { - throw exception(COMBINATION_ACTIVITY_UPDATE_STOCK_FAIL); - } - - // 6.1 校验是否有拼团记录 - List recordList = combinationRecordMapper.selectListByUserIdAndActivityId(userId, activityId); - recordList.removeIf(record -> CombinationRecordStatusEnum.isFailed(record.getStatus())); // 取消的订单,不算数 - if (CollUtil.isEmpty(recordList)) { // 如果为空,说明可以参与,直接返回 - return new KeyValue<>(activity, product); - } - // 6.2 校验用户是否有该活动正在进行的拼团 - CombinationRecordDO inProgressRecord = findFirst(recordList, - record -> CombinationRecordStatusEnum.isInProgress(record.getStatus())); - if (inProgressRecord != null) { - throw exception(COMBINATION_RECORD_FAILED_HAVE_JOINED); - } - // 6.3 校验是否超出总限购数量 - Integer sumValue = getSumValue(recordList, CombinationRecordDO::getCount, Integer::sum); - if (sumValue != null && sumValue + count > activity.getTotalLimitCount()) { - throw exception(COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED); - } - return new KeyValue<>(activity, product); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public CombinationRecordDO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { - // 1. 校验拼团活动 - KeyValue keyValue = validateCombinationRecord(reqDTO.getUserId(), - reqDTO.getActivityId(), reqDTO.getHeadId(), reqDTO.getSkuId(), reqDTO.getCount()); - - // 2. 组合数据创建拼团记录 - MemberUserRespDTO user = memberUserApi.getUser(reqDTO.getUserId()); - ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId()); - ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId()); - CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO, keyValue.getKey(), user, spu, sku); - // 2.1. 如果是团长需要设置 headId 为 CombinationRecordDO#HEAD_ID_GROUP - if (record.getHeadId() == null) { - record.setStartTime(LocalDateTime.now()) - .setExpireTime(keyValue.getKey().getStartTime().plusHours(keyValue.getKey().getLimitDuration())) - .setHeadId(CombinationRecordDO.HEAD_ID_GROUP); - } else { - // 2.2.有团长的情况下需要设置开始时间和过期时间为团长的 - CombinationRecordDO headRecord = combinationRecordMapper.selectByHeadId(record.getHeadId(), - CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); // 查询进行中的父拼团 - record.setStartTime(headRecord.getStartTime()).setExpireTime(headRecord.getExpireTime()); - } - combinationRecordMapper.insert(record); - - // 3. 更新拼团记录 - if (ObjUtil.notEqual(CombinationRecordDO.HEAD_ID_GROUP, record.getHeadId())) { - updateCombinationRecordWhenCreate(reqDTO.getHeadId(), keyValue.getKey()); - } - return record; - } - - /** - * 当新增拼团时,更新拼团记录的进展 - * - * @param headId 团长编号 - * @param activity 活动 - */ - private void updateCombinationRecordWhenCreate(Long headId, CombinationActivityDO activity) { - // 1. 团长 + 团员 - List records = getCombinationRecordListByHeadId(headId); - if (CollUtil.isEmpty(records)) { - return; - } - CombinationRecordDO headRecord = combinationRecordMapper.selectById(headId); - - // 2. 批量更新记录 - List updateRecords = new ArrayList<>(); - records.add(headRecord); // 加入团长,团长也需要更新 - boolean isFull = records.size() >= activity.getUserSize(); - LocalDateTime now = LocalDateTime.now(); - records.forEach(item -> { - CombinationRecordDO updateRecord = new CombinationRecordDO(); - updateRecord.setId(item.getId()).setUserCount(records.size()); - if (isFull) { - updateRecord.setStatus(CombinationRecordStatusEnum.SUCCESS.getStatus()); - updateRecord.setEndTime(now); - } - updateRecords.add(updateRecord); - }); - combinationRecordMapper.updateBatch(updateRecords); - } - - @Override - public CombinationRecordDO getCombinationRecord(Long userId, Long orderId) { - return combinationRecordMapper.selectByUserIdAndOrderId(userId, orderId); - } - - @Override - public CombinationValidateJoinRespDTO validateJoinCombination(Long userId, Long activityId, Long headId, - Long skuId, Integer count) { - KeyValue keyValue = validateCombinationRecord(userId, activityId, - headId, skuId, count); - return new CombinationValidateJoinRespDTO().setActivityId(keyValue.getKey().getId()) - .setName(keyValue.getKey().getName()).setCombinationPrice(keyValue.getValue().getCombinationPrice()); - } - - @Override - public Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup, @Nullable Long headId) { - return combinationRecordMapper.selectCountByHeadAndStatusAndVirtualGroup(status, virtualGroup, headId); - } - - @Override - public Long getCombinationUserCount() { - return combinationRecordMapper.selectUserCount(); - } - - @Override - public List getLatestCombinationRecordList(int count) { - return combinationRecordMapper.selectLatestList(count); - } - - @Override - public List getHeadCombinationRecordList(Long activityId, Integer status, Integer count) { - return combinationRecordMapper.selectListByActivityIdAndStatusAndHeadId(activityId, status, - CombinationRecordDO.HEAD_ID_GROUP, count); - } - - @Override - public CombinationRecordDO getCombinationRecordById(Long id) { - return combinationRecordMapper.selectById(id); - } - - @Override - public List getCombinationRecordListByHeadId(Long headId) { - return combinationRecordMapper.selectList(CombinationRecordDO::getHeadId, headId); - } - - @Override - public PageResult getCombinationRecordPage(CombinationRecordReqPageVO pageVO) { - return combinationRecordMapper.selectPage(pageVO); - } - - @Override - public Map getCombinationRecordCountMapByActivity(Collection activityIds, - @Nullable Integer status, @Nullable Long headId) { - return combinationRecordMapper.selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(activityIds, status, headId); - } - - @Override - public CombinationRecordDO getCombinationRecordByIdAndUser(Long userId, Long id) { - return combinationRecordMapper.selectOne(CombinationRecordDO::getUserId, userId, CombinationRecordDO::getId, id); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void cancelCombinationRecord(Long userId, Long id, Long headId) { - // 删除记录 - combinationRecordMapper.deleteById(id); - - // 需要更新的记录 - List updateRecords = new ArrayList<>(); - // 如果它是团长,则顺序(下单时间)继承 - if (Objects.equals(headId, CombinationRecordDO.HEAD_ID_GROUP)) { // 情况一:团长 - // 团员 - List list = getCombinationRecordListByHeadId(id); - if (CollUtil.isEmpty(list)) { - return; - } - // 按照创建时间升序排序 - list.sort(Comparator.comparing(CombinationRecordDO::getCreateTime)); // 影响原 list - CombinationRecordDO newHead = list.get(0); // 新团长继位 - list.forEach(item -> { - CombinationRecordDO recordDO = new CombinationRecordDO(); - recordDO.setId(item.getId()); - if (ObjUtil.equal(item.getId(), newHead.getId())) { // 新团长 - recordDO.setHeadId(CombinationRecordDO.HEAD_ID_GROUP); - } else { - recordDO.setHeadId(newHead.getId()); - } - recordDO.setUserCount(list.size()); - updateRecords.add(recordDO); - }); - } else { // 情况二:团员 - // 团长 - CombinationRecordDO recordHead = combinationRecordMapper.selectById(headId); - // 团员 - List records = getCombinationRecordListByHeadId(headId); - if (CollUtil.isEmpty(records)) { - return; - } - records.add(recordHead); // 加入团长,团长数据也需要更新 - records.forEach(item -> { - CombinationRecordDO recordDO = new CombinationRecordDO(); - recordDO.setId(item.getId()); - recordDO.setUserCount(records.size()); - updateRecords.add(recordDO); - }); - } - - // 更新拼团记录 - combinationRecordMapper.updateBatch(updateRecords); - } - - @Override - public KeyValue expireCombinationRecord() { - // 1. 获取所有正在进行中的过期的父拼团 - List headExpireRecords = combinationRecordMapper.selectListByHeadIdAndStatusAndExpireTimeLt( - CombinationRecordDO.HEAD_ID_GROUP, CombinationRecordStatusEnum.IN_PROGRESS.getStatus(), LocalDateTime.now()); - if (CollUtil.isEmpty(headExpireRecords)) { - return new KeyValue<>(0, 0); - } - - // 2. 获取拼团活动 - List activities = combinationActivityService.getCombinationActivityListByIds( - convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); - Map activityMap = convertMap(activities, CombinationActivityDO::getId); - - // 3. 逐个处理拼团,过期 or 虚拟成团 - KeyValue keyValue = new KeyValue<>(0, 0); // 统计过期拼团和虚拟成团 - for (CombinationRecordDO record : headExpireRecords) { - try { - CombinationActivityDO activity = activityMap.get(record.getActivityId()); - if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 - // 3.1. 处理过期的拼团 - getSelf().handleExpireRecord(record); - keyValue.setKey(keyValue.getKey() + 1); - } else { - // 3.2. 处理虚拟成团 - getSelf().handleVirtualGroupRecord(record); - keyValue.setValue(keyValue.getValue() + 1); - } - } catch (Exception ignored) { // 处理异常继续循环 - log.error("[expireCombinationRecord][record({}) 处理异常,请进行处理!record 数据是:{}]", - record.getId(), JsonUtils.toJsonString(record)); - } - } - return keyValue; - } - - /** - * 处理过期拼团 - * - * @param headRecord 过期拼团团长记录 - */ - @Transactional(rollbackFor = Exception.class) - public void handleExpireRecord(CombinationRecordDO headRecord) { - // 1. 更新拼团记录 - List headAndRecords = updateBatchCombinationRecords(headRecord, - CombinationRecordStatusEnum.FAILED); - // 2. 订单取消 - headAndRecords.forEach(item -> tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId())); - } - - /** - * 处理虚拟拼团 - * - * @param headRecord 虚拟成团团长记录 - */ - @Transactional(rollbackFor = Exception.class) - public void handleVirtualGroupRecord(CombinationRecordDO headRecord) { - // 1. 团员补齐 - combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualRecordList(headRecord)); - // 2. 更新拼团记录 - updateBatchCombinationRecords(headRecord, CombinationRecordStatusEnum.SUCCESS); - } - - /** - * 更新拼团记录 - * - * @param headRecord 团长记录 - * @param status 状态-拼团失败 FAILED 成功 SUCCESS - * @return 整团记录(包含团长和团成员) - */ - private List updateBatchCombinationRecords(CombinationRecordDO headRecord, CombinationRecordStatusEnum status) { - // 1. 查询团成员(包含团长) - List records = combinationRecordMapper.selectListByHeadId(headRecord.getId()); - records.add(headRecord);// 把团长加进去 - - // 2. 批量更新拼团记录 status 和 endTime - List updateRecords = new ArrayList<>(records.size()); - LocalDateTime now = LocalDateTime.now(); - records.forEach(item -> { - CombinationRecordDO updateRecord = new CombinationRecordDO().setId(item.getId()) - .setStatus(status.getStatus()).setEndTime(now); - if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数 - updateRecord.setUserCount(updateRecord.getUserSize()); - } - updateRecords.add(updateRecord); - }); - combinationRecordMapper.updateBatch(updateRecords); - return records; - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private CombinationRecordServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java deleted file mode 100644 index 7cc13e2ce7..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java +++ /dev/null @@ -1,171 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; - -import java.util.*; - -/** - * 优惠劵 Service 接口 - * - * @author 芋道源码 - */ -public interface CouponService { - - /** - * 校验优惠劵,包括状态、有限期 - *

- * 1. 如果校验通过,则返回优惠劵信息 - * 2. 如果校验不通过,则直接抛出业务异常 - * - * @param id 优惠劵编号 - * @param userId 用户编号 - * @return 优惠劵信息 - */ - CouponDO validCoupon(Long id, Long userId); - - /** - * 校验优惠劵,包括状态、有限期 - * - * @param coupon 优惠劵 - * @see #validCoupon(Long, Long) 逻辑相同,只是入参不同 - */ - void validCoupon(CouponDO coupon); - - /** - * 获得优惠劵分页 - * - * @param pageReqVO 分页查询 - * @return 优惠劵分页 - */ - PageResult getCouponPage(CouponPageReqVO pageReqVO); - - /** - * 使用优惠劵 - * - * @param id 优惠劵编号 - * @param userId 用户编号 - * @param orderId 订单编号 - */ - void useCoupon(Long id, Long userId, Long orderId); - - /** - * 退还已使用的优惠券 - * - * @param id 优惠券编号 - */ - void returnUsedCoupon(Long id); - - /** - * 回收优惠劵 - * - * @param id 优惠劵编号 - */ - void deleteCoupon(Long id); - - /** - * 获得用户的优惠劵列表 - * - * @param userId 用户编号 - * @param status 优惠劵状态 - * @return 优惠劵列表 - */ - List getCouponList(Long userId, Integer status); - - /** - * 获得未使用的优惠劵数量 - * - * @param userId 用户编号 - * @return 未使用的优惠劵数量 - */ - Long getUnusedCouponCount(Long userId); - - /** - * 领取优惠券 - * - * @param templateId 优惠券模板编号 - * @param userIds 用户编号列表 - * @param takeType 领取方式 - */ - void takeCoupon(Long templateId, Set userIds, CouponTakeTypeEnum takeType); - - /** - * 【管理员】给用户发送优惠券 - * - * @param templateId 优惠券模板编号 - * @param userIds 用户编号列表 - */ - default void takeCouponByAdmin(Long templateId, Set userIds) { - takeCoupon(templateId, userIds, CouponTakeTypeEnum.ADMIN); - } - - /** - * 【会员】领取优惠券 - * - * @param templateId 优惠券模板编号 - * @param userId 用户编号 - */ - default void takeCouponByUser(Long templateId, Long userId) { - takeCoupon(templateId, CollUtil.newHashSet(userId), CouponTakeTypeEnum.USER); - } - - /** - * 【系统】给用户发送新人券 - * - * @param userId 用户编号 - */ - void takeCouponByRegister(Long userId); - - /** - * 获取会员领取指定优惠券的数量 - * - * @param templateId 优惠券模板编号 - * @param userId 用户编号 - * @return 领取优惠券的数量 - */ - default Integer getTakeCount(Long templateId, Long userId) { - Map map = getTakeCountMapByTemplateIds(Collections.singleton(templateId), userId); - return MapUtil.getInt(map, templateId, 0); - } - - /** - * 统计会员领取优惠券的数量 - * - * @param templateIds 优惠券模板编号列表 - * @param userId 用户编号 - * @return 领取优惠券的数量 - */ - Map getTakeCountMapByTemplateIds(Collection templateIds, Long userId); - - /** - * 获取用户匹配的优惠券列表 - * - * @param userId 用户编号 - * @param matchReqVO 匹配参数 - * @return 优惠券列表 - */ - List getMatchCouponList(Long userId, AppCouponMatchReqVO matchReqVO); - - /** - * 过期优惠券 - * - * @return 过期数量 - */ - int expireCoupon(); - - /** - * 获取用户是否可以领取优惠券 - * - * @param userId 用户编号 - * @param templates 优惠券列表 - * @return 是否可以领取 - */ - Map getUserCanCanTakeMap(Long userId, List templates); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java deleted file mode 100644 index 1c22971074..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java +++ /dev/null @@ -1,326 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.hutool.core.collection.CollStreamUtil; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchReqVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponMapper; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; - -/** - * 优惠劵 Service 实现类 - * - * @author 芋道源码 - */ -@Slf4j -@Service -@Validated -public class CouponServiceImpl implements CouponService { - - @Resource - private CouponTemplateService couponTemplateService; - - @Resource - private CouponMapper couponMapper; - - @Resource - private MemberUserApi memberUserApi; - - @Override - public CouponDO validCoupon(Long id, Long userId) { - CouponDO coupon = couponMapper.selectByIdAndUserId(id, userId); - if (coupon == null) { - throw exception(COUPON_NOT_EXISTS); - } - validCoupon(coupon); - return coupon; - } - - @Override - public void validCoupon(CouponDO coupon) { - // 校验状态 - if (ObjectUtil.notEqual(coupon.getStatus(), CouponStatusEnum.UNUSED.getStatus())) { - throw exception(COUPON_STATUS_NOT_UNUSED); - } - // 校验有效期;为避免定时器没跑,实际优惠劵已经过期 - if (LocalDateTimeUtils.isBetween(coupon.getValidStartTime(), coupon.getValidEndTime())) { - throw exception(COUPON_VALID_TIME_NOT_NOW); - } - } - - @Override - public PageResult getCouponPage(CouponPageReqVO pageReqVO) { - // 获得用户编号 - if (StrUtil.isNotEmpty(pageReqVO.getNickname())) { - List users = memberUserApi.getUserListByNickname(pageReqVO.getNickname()); - if (CollUtil.isEmpty(users)) { - return PageResult.empty(); - } - pageReqVO.setUserIds(convertSet(users, MemberUserRespDTO::getId)); - } - // 分页查询 - return couponMapper.selectPage(pageReqVO); - } - - @Override - public void useCoupon(Long id, Long userId, Long orderId) { - // 校验优惠劵 - validCoupon(id, userId); - - // 更新状态 - int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(), - new CouponDO().setStatus(CouponStatusEnum.USED.getStatus()) - .setUseOrderId(orderId).setUseTime(LocalDateTime.now())); - if (updateCount == 0) { - throw exception(COUPON_STATUS_NOT_UNUSED); - } - } - - @Override - public void returnUsedCoupon(Long id) { - // 校验存在 - CouponDO coupon = couponMapper.selectById(id); - if (coupon == null) { - throw exception(COUPON_NOT_EXISTS); - } - // 校验状态 - if (ObjectUtil.notEqual(coupon.getStatus(), CouponStatusEnum.USED.getStatus())) { - throw exception(COUPON_STATUS_NOT_USED); - } - - // 退还 - Integer status = LocalDateTimeUtils.beforeNow(coupon.getValidEndTime()) - ? CouponStatusEnum.EXPIRE.getStatus() // 退还时可能已经过期了 - : CouponStatusEnum.UNUSED.getStatus(); - int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(), - new CouponDO().setStatus(status)); - if (updateCount == 0) { - throw exception(COUPON_STATUS_NOT_USED); - } - - // TODO 增加优惠券变动记录? - } - - @Override - @Transactional - public void deleteCoupon(Long id) { - // 校验存在 - validateCouponExists(id); - - // 更新优惠劵 - int deleteCount = couponMapper.delete(id, - asList(CouponStatusEnum.UNUSED.getStatus(), CouponStatusEnum.EXPIRE.getStatus())); - if (deleteCount == 0) { - throw exception(COUPON_DELETE_FAIL_USED); - } - // 减少优惠劵模板的领取数量 -1 - couponTemplateService.updateCouponTemplateTakeCount(id, -1); - } - - @Override - public List getCouponList(Long userId, Integer status) { - return couponMapper.selectListByUserIdAndStatus(userId, status); - } - - private void validateCouponExists(Long id) { - if (couponMapper.selectById(id) == null) { - throw exception(COUPON_NOT_EXISTS); - } - } - - @Override - public Long getUnusedCouponCount(Long userId) { - return couponMapper.selectCountByUserIdAndStatus(userId, CouponStatusEnum.UNUSED.getStatus()); - } - - @Override - public void takeCoupon(Long templateId, Set userIds, CouponTakeTypeEnum takeType) { - CouponTemplateDO template = couponTemplateService.getCouponTemplate(templateId); - // 1. 过滤掉达到领取限制的用户 - removeTakeLimitUser(userIds, template); - // 2. 校验优惠劵是否可以领取 - validateCouponTemplateCanTake(template, userIds, takeType); - - // 3. 批量保存优惠劵 - couponMapper.insertBatch(convertList(userIds, userId -> CouponConvert.INSTANCE.convert(template, userId))); - - // 3. 增加优惠劵模板的领取数量 - couponTemplateService.updateCouponTemplateTakeCount(templateId, userIds.size()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void takeCouponByRegister(Long userId) { - List templates = couponTemplateService.getCouponTemplateListByTakeType(CouponTakeTypeEnum.REGISTER); - for (CouponTemplateDO template : templates) { - takeCoupon(template.getId(), CollUtil.newHashSet(userId), CouponTakeTypeEnum.REGISTER); - } - } - - @Override - public Map getTakeCountMapByTemplateIds(Collection templateIds, Long userId) { - if (CollUtil.isEmpty(templateIds)) { - return Collections.emptyMap(); - } - return couponMapper.selectCountByUserIdAndTemplateIdIn(userId, templateIds); - } - - @Override - public List getMatchCouponList(Long userId, AppCouponMatchReqVO matchReqVO) { - return couponMapper.selectListByUserIdAndStatusAndUsePriceLeAndProductScope(userId, - CouponStatusEnum.UNUSED.getStatus(), - matchReqVO.getPrice(), matchReqVO.getSpuIds(), matchReqVO.getCategoryIds()); - } - - @Override - public int expireCoupon() { - // 1. 查询待过期的优惠券 - List list = couponMapper.selectListByStatusAndValidEndTimeLe( - CouponStatusEnum.UNUSED.getStatus(), LocalDateTime.now()); - if (CollUtil.isEmpty(list)) { - return 0; - } - - // 2. 遍历执行 - int count = 0; - for (CouponDO coupon : list) { - try { - boolean success = getSelf().expireCoupon(coupon); - if (success) { - count++; - } - } catch (Exception e) { - log.error("[expireCoupon][coupon({}) 更新为已过期失败]", coupon.getId(), e); - } - } - return count; - } - - @Override - public Map getUserCanCanTakeMap(Long userId, List templates) { - // 1. 未登录时,都显示可以领取 - Map userCanTakeMap = convertMap(templates, CouponTemplateDO::getId, templateId -> true); - if (userId == null) { - return userCanTakeMap; - } - - // 2.1 过滤领取数量无限制的 - Set templateIds = convertSet(templates, CouponTemplateDO::getId, template -> template.getTakeLimitCount() != -1); - // 2.2 检查用户领取的数量是否超过限制 - if (CollUtil.isNotEmpty(templateIds)) { - Map couponTakeCountMap = this.getTakeCountMapByTemplateIds(templateIds, userId); - for (CouponTemplateDO template : templates) { - Integer takeCount = couponTakeCountMap.get(template.getId()); - userCanTakeMap.put(template.getId(), takeCount == null || takeCount < template.getTakeLimitCount()); - } - } - return userCanTakeMap; - } - - /** - * 过期单个优惠劵 - * - * @param coupon 优惠劵 - * @return 是否过期成功 - */ - private boolean expireCoupon(CouponDO coupon) { - // 更新记录状态 - int updateRows = couponMapper.updateByIdAndStatus(coupon.getId(), CouponStatusEnum.UNUSED.getStatus(), - new CouponDO().setStatus(CouponStatusEnum.EXPIRE.getStatus())); - if (updateRows == 0) { - log.error("[expireCoupon][coupon({}) 更新为已过期失败]", coupon.getId()); - return false; - } - log.info("[expireCoupon][coupon({}) 更新为已过期成功]", coupon.getId()); - return true; - } - - /** - * 校验优惠券是否可以领取 - * - * @param couponTemplate 优惠券模板 - * @param userIds 领取人列表 - * @param takeType 领取方式 - */ - private void validateCouponTemplateCanTake(CouponTemplateDO couponTemplate, Set userIds, CouponTakeTypeEnum takeType) { - // 如果所有用户都领取过,则抛出异常 - if (CollUtil.isEmpty(userIds)) { - throw exception(COUPON_TEMPLATE_USER_ALREADY_TAKE); - } - - // 校验模板 - if (couponTemplate == null) { - throw exception(COUPON_TEMPLATE_NOT_EXISTS); - } - // 校验剩余数量 - if (couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) { - throw exception(COUPON_TEMPLATE_NOT_ENOUGH); - } - // 校验"固定日期"的有效期类型是否过期 - if (CouponTemplateValidityTypeEnum.DATE.getType().equals(couponTemplate.getValidityType())) { - if (LocalDateTimeUtils.beforeNow(couponTemplate.getValidEndTime())) { - throw exception(COUPON_TEMPLATE_EXPIRED); - } - } - // 校验领取方式 - if (ObjectUtil.notEqual(couponTemplate.getTakeType(), takeType.getValue())) { - throw exception(COUPON_TEMPLATE_CANNOT_TAKE); - } - } - - /** - * 过滤掉达到领取上线的用户 - * - * @param userIds 用户编号数组 - * @param couponTemplate 优惠劵模版 - */ - private void removeTakeLimitUser(Set userIds, CouponTemplateDO couponTemplate) { - if (couponTemplate.getTakeLimitCount() <= 0) { - return; - } - // 查询已领过券的用户 - List alreadyTakeCoupons = couponMapper.selectListByTemplateIdAndUserId(couponTemplate.getId(), userIds); - if (CollUtil.isEmpty(alreadyTakeCoupons)) { - return; - } - // 移除达到领取限制的用户 - Map userTakeCountMap = CollStreamUtil.groupBy(alreadyTakeCoupons, CouponDO::getUserId, Collectors.summingInt(c -> 1)); - userIds.removeIf(userId -> MapUtil.getInt(userTakeCountMap, userId, 0) >= couponTemplate.getTakeLimitCount()); - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private CouponServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java deleted file mode 100755 index 085979ef02..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 优惠劵模板 Service 接口 - * - * @author 芋道源码 - */ -public interface CouponTemplateService { - - /** - * 创建优惠劵模板 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCouponTemplate(@Valid CouponTemplateCreateReqVO createReqVO); - - /** - * 更新优惠劵模板 - * - * @param updateReqVO 更新信息 - */ - void updateCouponTemplate(@Valid CouponTemplateUpdateReqVO updateReqVO); - - /** - * 更新优惠劵模板的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateCouponTemplateStatus(Long id, Integer status); - - /** - * 删除优惠劵模板 - * - * @param id 编号 - */ - void deleteCouponTemplate(Long id); - - /** - * 获得优惠劵模板 - * - * @param id 编号 - * @return 优惠劵模板 - */ - CouponTemplateDO getCouponTemplate(Long id); - - /** - * 获得优惠劵模板分页 - * - * @param pageReqVO 分页查询 - * @return 优惠劵模板分页 - */ - PageResult getCouponTemplatePage(CouponTemplatePageReqVO pageReqVO); - - /** - * 更新优惠劵模板的领取数量 - * - * @param id 优惠劵模板编号 - * @param incrCount 增加数量 - */ - void updateCouponTemplateTakeCount(Long id, int incrCount); - - /** - * 获得指定领取方式的优惠券模板 - * - * @param takeType 领取方式 - * @return 优惠券模板列表 - */ - List getCouponTemplateListByTakeType(CouponTakeTypeEnum takeType); - - /** - * 获得优惠券模板列表 - * - * @param canTakeTypes 可领取的类型列表 - * @param productScope 商品使用范围类型 - * @param productScopeValue 商品使用范围编号 - * @param count 查询数量 - * @return 优惠券模板列表 - */ - List getCouponTemplateList(List canTakeTypes, Integer productScope, - Long productScopeValue, Integer count); - - /** - * 获得优惠券模版列表 - * - * @param ids 优惠券模版编号 - * @return 优惠券模版列表 - */ - List getCouponTemplateList(Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java deleted file mode 100755 index 923ee5904e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.category.ProductCategoryApi; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponTemplateMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL; - -/** - * 优惠劵模板 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CouponTemplateServiceImpl implements CouponTemplateService { - - @Resource - private CouponTemplateMapper couponTemplateMapper; - - @Resource - private ProductCategoryApi productCategoryApi; - @Resource - private ProductSpuApi productSpuApi; - - @Override - public Long createCouponTemplate(CouponTemplateCreateReqVO createReqVO) { - // 校验商品范围 - validateProductScope(createReqVO.getProductScope(), createReqVO.getProductScopeValues()); - // 插入 - CouponTemplateDO couponTemplate = CouponTemplateConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - couponTemplateMapper.insert(couponTemplate); - // 返回 - return couponTemplate.getId(); - } - - @Override - public void updateCouponTemplate(CouponTemplateUpdateReqVO updateReqVO) { - // 校验存在 - CouponTemplateDO couponTemplate = validateCouponTemplateExists(updateReqVO.getId()); - // 校验发放数量不能过小 - if (updateReqVO.getTotalCount() < couponTemplate.getTakeCount()) { - throw exception(COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL, couponTemplate.getTakeCount()); - } - // 校验商品范围 - validateProductScope(updateReqVO.getProductScope(), updateReqVO.getProductScopeValues()); - - // 更新 - CouponTemplateDO updateObj = CouponTemplateConvert.INSTANCE.convert(updateReqVO); - couponTemplateMapper.updateById(updateObj); - } - - @Override - public void updateCouponTemplateStatus(Long id, Integer status) { - // 校验存在 - validateCouponTemplateExists(id); - // 更新 - couponTemplateMapper.updateById(new CouponTemplateDO().setId(id).setStatus(status)); - } - - @Override - public void deleteCouponTemplate(Long id) { - // 校验存在 - validateCouponTemplateExists(id); - // 删除 - couponTemplateMapper.deleteById(id); - } - - private CouponTemplateDO validateCouponTemplateExists(Long id) { - CouponTemplateDO couponTemplate = couponTemplateMapper.selectById(id); - if (couponTemplate == null) { - throw exception(COUPON_TEMPLATE_NOT_EXISTS); - } - return couponTemplate; - } - - private void validateProductScope(Integer productScope, List productScopeValues) { - if (Objects.equals(PromotionProductScopeEnum.SPU.getScope(), productScope)) { - productSpuApi.validateSpuList(productScopeValues); - } else if (Objects.equals(PromotionProductScopeEnum.CATEGORY.getScope(), productScope)) { - productCategoryApi.validateCategoryList(productScopeValues); - } - } - - @Override - public CouponTemplateDO getCouponTemplate(Long id) { - return couponTemplateMapper.selectById(id); - } - - @Override - public PageResult getCouponTemplatePage(CouponTemplatePageReqVO pageReqVO) { - return couponTemplateMapper.selectPage(pageReqVO); - } - - @Override - public void updateCouponTemplateTakeCount(Long id, int incrCount) { - couponTemplateMapper.updateTakeCount(id, incrCount); - } - - @Override - public List getCouponTemplateListByTakeType(CouponTakeTypeEnum takeType) { - return couponTemplateMapper.selectListByTakeType(takeType.getValue()); - } - - @Override - public List getCouponTemplateList(List canTakeTypes, Integer productScope, - Long productScopeValue, Integer count) { - return couponTemplateMapper.selectList(canTakeTypes, productScope, productScopeValue, count); - } - - @Override - public List getCouponTemplateList(Collection ids) { - return couponTemplateMapper.selectBatchIds(ids); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentService.java deleted file mode 100644 index 82f0b0f5b9..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentService.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.decorate; - -import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO; -import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum; - -import java.util.List; - -/** - * 装修组件 Service 接口 - * - * @author jason - */ -public interface DecorateComponentService { - - /** - * 保存页面的组件信息 - * - * @param reqVO 请求 VO - */ - void saveDecorateComponent(DecorateComponentSaveReqVO reqVO); - - /** - * 根据页面 id,获取页面的组件信息 - * - * @param page 页面编号 {@link DecoratePageEnum#getPage()} - * @param status 状态 - */ - List getDecorateComponentListByPage(Integer page, Integer status); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImpl.java deleted file mode 100644 index 46353a1eed..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.decorate; - -import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO; -import cn.iocoder.yudao.module.promotion.convert.decorate.DecorateComponentConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.decorate.DecorateComponentMapper; -import org.springframework.stereotype.Service; - -import jakarta.annotation.Resource; -import java.util.List; - -/** - * 装修组件 Service 实现 - * - * @author jason - */ -@Service -public class DecorateComponentServiceImpl implements DecorateComponentService { - - @Resource - private DecorateComponentMapper decorateComponentMapper; - - @Override - public void saveDecorateComponent(DecorateComponentSaveReqVO reqVO) { - // 1. 如果存在,则进行更新 - DecorateComponentDO dbComponent = decorateComponentMapper.selectByPageAndCode(reqVO.getPage(), reqVO.getCode()); - if (dbComponent != null) { - decorateComponentMapper.updateById(DecorateComponentConvert.INSTANCE.convert(reqVO).setId(dbComponent.getId())); - return; - } - // 2. 不存在,则进行新增 - decorateComponentMapper.insert(DecorateComponentConvert.INSTANCE.convert(reqVO)); - } - - @Override - public List getDecorateComponentListByPage(Integer page, Integer status) { - return decorateComponentMapper.selectListByPageAndStatus(page, status); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java deleted file mode 100644 index 05ad13eed9..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.discount; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 限时折扣 Service 接口 - * - * @author 芋道源码 - */ -public interface DiscountActivityService { - - /** - * 基于指定 SKU 编号数组,获得匹配的限时折扣商品 - * - * 注意,匹配的条件,仅仅是日期符合,并且处于开启状态 - * - * @param skuIds SKU 编号数组 - * @return 匹配的限时折扣商品 - */ - List getMatchDiscountProductList(Collection skuIds); - - /** - * 创建限时折扣活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDiscountActivity(@Valid DiscountActivityCreateReqVO createReqVO); - - /** - * 更新限时折扣活动 - * - * @param updateReqVO 更新信息 - */ - void updateDiscountActivity(@Valid DiscountActivityUpdateReqVO updateReqVO); - - /** - * 关闭限时折扣活动 - * - * @param id 编号 - */ - void closeDiscountActivity(Long id); - - /** - * 删除限时折扣活动 - * - * @param id 编号 - */ - void deleteDiscountActivity(Long id); - - /** - * 获得限时折扣活动 - * - * @param id 编号 - * @return 限时折扣活动 - */ - DiscountActivityDO getDiscountActivity(Long id); - - /** - * 获得限时折扣活动分页 - * - * @param pageReqVO 分页查询 - * @return 限时折扣活动分页 - */ - PageResult getDiscountActivityPage(DiscountActivityPageReqVO pageReqVO); - - /** - * 获得活动编号,对应对应的商品列表 - * - * @param activityId 活动编号 - * @return 活动的商品列表 - */ - List getDiscountProductsByActivityId(Long activityId); - - /** - * 获得活动编号,对应对应的商品列表 - * - * @param activityIds 活动编号 - * @return 活动的商品列表 - */ - List getDiscountProductsByActivityId(Collection activityIds); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java deleted file mode 100644 index b8b496fdb1..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java +++ /dev/null @@ -1,187 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.discount; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountProductMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.util.PromotionUtils; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 限时折扣 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class DiscountActivityServiceImpl implements DiscountActivityService { - - @Resource - private DiscountActivityMapper discountActivityMapper; - @Resource - private DiscountProductMapper discountProductMapper; - - @Override - public List getMatchDiscountProductList(Collection skuIds) { - // TODO @zhangshuai:这里是不是可以直接 return discountProductMapper.getMatchDiscountProductList(skuIds); 一般来说,如果 idea 报“黄色”的警告,尽量都处理下哈;原则是,一切警告,皆为异常(错误),这样可以写出更好的代码。 - List matchDiscountProductList = discountProductMapper.getMatchDiscountProductList(skuIds); - return matchDiscountProductList; - } - - @Override - public Long createDiscountActivity(DiscountActivityCreateReqVO createReqVO) { - // 校验商品是否冲突 - validateDiscountActivityProductConflicts(null, createReqVO.getProducts()); - - // 插入活动 - DiscountActivityDO discountActivity = DiscountActivityConvert.INSTANCE.convert(createReqVO) - // TODO @zhangshuai:这里的调用去掉哈,强制就是开启的; - .setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getEndTime())); - discountActivityMapper.insert(discountActivity); - // 插入商品 - // TODO @zhangshuai:activityStatus 最好代码里,也做下设置噢。 - List discountProducts = convertList(createReqVO.getProducts(), - product -> DiscountActivityConvert.INSTANCE.convert(product).setActivityId(discountActivity.getId())); - discountProductMapper.insertBatch(discountProducts); - // 返回 - return discountActivity.getId(); - } - - @Override - public void updateDiscountActivity(DiscountActivityUpdateReqVO updateReqVO) { - // 校验存在 - DiscountActivityDO discountActivity = validateDiscountActivityExists(updateReqVO.getId()); - if (discountActivity.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { // 已关闭的活动,不能修改噢 - throw exception(DISCOUNT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); - } - // 校验商品是否冲突 - validateDiscountActivityProductConflicts(updateReqVO.getId(), updateReqVO.getProducts()); - - // 更新活动 - DiscountActivityDO updateObj = DiscountActivityConvert.INSTANCE.convert(updateReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getEndTime())); - discountActivityMapper.updateById(updateObj); - // 更新商品 - updateDiscountProduct(updateReqVO); - } - - private void updateDiscountProduct(DiscountActivityUpdateReqVO updateReqVO) { - // TODO @zhangshuai:这里的逻辑,可以优化下哈;参考 CombinationActivityServiceImpl 的 updateCombinationProduct,主要是 CollectionUtils.diffList 的使用哈; - // 然后原先是使用 DiscountActivityConvert.INSTANCE.isEquals 对比,现在看看是不是简化就基于 skuId 对比就完事了;之前写的太精细,意义不大; - List dbDiscountProducts = discountProductMapper.selectListByActivityId(updateReqVO.getId()); - // 计算要删除的记录 - List deleteIds = convertList(dbDiscountProducts, DiscountProductDO::getId, - discountProductDO -> updateReqVO.getProducts().stream() - .noneMatch(product -> DiscountActivityConvert.INSTANCE.isEquals(discountProductDO, product))); - if (CollUtil.isNotEmpty(deleteIds)) { - discountProductMapper.deleteBatchIds(deleteIds); - } - // 计算新增的记录 - List newDiscountProducts = convertList(updateReqVO.getProducts(), - product -> DiscountActivityConvert.INSTANCE.convert(product).setActivityId(updateReqVO.getId())); - newDiscountProducts.removeIf(product -> dbDiscountProducts.stream().anyMatch( - dbProduct -> DiscountActivityConvert.INSTANCE.isEquals(dbProduct, product))); // 如果匹配到,说明是更新的 - if (CollectionUtil.isNotEmpty(newDiscountProducts)) { - discountProductMapper.insertBatch(newDiscountProducts); - } - } - - /** - * 校验商品是否冲突 - * - * @param id 编号 - * @param products 商品列表 - */ - private void validateDiscountActivityProductConflicts(Long id, List products) { - if (CollUtil.isEmpty(products)) { - return; - } - // 查询商品参加的活动 - // TODO @zhangshuai:下面 121 这个查询,是不是不用做呀;直接 convert 出 skuId 集合就 ok 啦; - List list = discountProductMapper.selectListByActivityId(id); - // TODO @zhangshuai:一般简单的 stream 方法,建议是使用 CollectionUtils,例如说这里是 convertList 对把。 - List skuIds = list.stream().map(item -> item.getSkuId()).collect(Collectors.toList()); - List matchDiscountProductList = getMatchDiscountProductList(skuIds); - if (id != null) { // 排除自己这个活动 - matchDiscountProductList.removeIf(product -> id.equals(product.getActivityId())); - } - // 如果非空,则说明冲突 - if (CollUtil.isNotEmpty(matchDiscountProductList)) { - throw exception(DISCOUNT_ACTIVITY_SPU_CONFLICTS); - } - } - - @Override - public void closeDiscountActivity(Long id) { - // 校验存在 - DiscountActivityDO activity = validateDiscountActivityExists(id); - if (activity.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); - } - - // 更新 - DiscountActivityDO updateObj = new DiscountActivityDO().setId(id).setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - discountActivityMapper.updateById(updateObj); - } - - @Override - public void deleteDiscountActivity(Long id) { - // 校验存在 - DiscountActivityDO activity = validateDiscountActivityExists(id); - if (CommonStatusEnum.isEnable(activity.getStatus())) { // 未关闭的活动,不能删除噢 - throw exception(DISCOUNT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED); - } - - // 删除 - discountActivityMapper.deleteById(id); - } - - private DiscountActivityDO validateDiscountActivityExists(Long id) { - DiscountActivityDO discountActivity = discountActivityMapper.selectById(id); - if (discountActivity == null) { - throw exception(DISCOUNT_ACTIVITY_NOT_EXISTS); - } - return discountActivity; - } - - @Override - public DiscountActivityDO getDiscountActivity(Long id) { - return discountActivityMapper.selectById(id); - } - - @Override - public PageResult getDiscountActivityPage(DiscountActivityPageReqVO pageReqVO) { - return discountActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getDiscountProductsByActivityId(Long activityId) { - return discountProductMapper.selectListByActivityId(activityId); - } - - @Override - public List getDiscountProductsByActivityId(Collection activityIds) { - return discountProductMapper.selectList("activity_id", activityIds); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageService.java deleted file mode 100644 index da8ed2a41f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyUpdateRequestVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 装修页面 Service 接口 - * - * @author owen - */ -public interface DiyPageService { - - /** - * 创建装修页面 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDiyPage(@Valid DiyPageCreateReqVO createReqVO); - - /** - * 更新装修页面 - * - * @param updateReqVO 更新信息 - */ - void updateDiyPage(@Valid DiyPageUpdateReqVO updateReqVO); - - /** - * 删除装修页面 - * - * @param id 编号 - */ - void deleteDiyPage(Long id); - - /** - * 获得装修页面 - * - * @param id 编号 - * @return 装修页面 - */ - DiyPageDO getDiyPage(Long id); - - /** - * 获得装修页面列表 - * - * @param ids 编号 - * @return 装修页面列表 - */ - List getDiyPageList(Collection ids); - - /** - * 获得装修页面分页 - * - * @param pageReqVO 分页查询 - * @return 装修页面分页 - */ - PageResult getDiyPagePage(DiyPagePageReqVO pageReqVO); - - /** - * 更新装修页面属性 - * - * @param updateReqVO 更新信息 - */ - void updateDiyPageProperty(DiyPagePropertyUpdateRequestVO updateReqVO); - - /** - * 获得模板所属的页面列表 - * - * @param templateId 模板编号 - * @return 装修页面列表 - */ - List getDiyPageByTemplateId(Long templateId); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java deleted file mode 100644 index 9ad016a2fb..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyUpdateRequestVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyPageMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_PAGE_NAME_USED; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_PAGE_NOT_EXISTS; - -/** - * 装修页面 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class DiyPageServiceImpl implements DiyPageService { - - @Resource - private DiyPageMapper diyPageMapper; - - @Override - public Long createDiyPage(DiyPageCreateReqVO createReqVO) { - // 校验名称唯一 - validateNameUnique(null, createReqVO.getTemplateId(), createReqVO.getName()); - // 插入 - DiyPageDO diyPage = DiyPageConvert.INSTANCE.convert(createReqVO); - diyPage.setProperty("{}"); - diyPageMapper.insert(diyPage); - return diyPage.getId(); - } - - @Override - public void updateDiyPage(DiyPageUpdateReqVO updateReqVO) { - // 校验存在 - validateDiyPageExists(updateReqVO.getId()); - // 校验名称唯一 - validateNameUnique(updateReqVO.getId(), updateReqVO.getTemplateId(), updateReqVO.getName()); - // 更新 - DiyPageDO updateObj = DiyPageConvert.INSTANCE.convert(updateReqVO); - diyPageMapper.updateById(updateObj); - } - - /** - * 校验 Page 页面,在一个 template 模版下的名字是唯一的 - * - * @param id Page 编号 - * @param templateId 模版编号 - * @param name Page 名字 - */ - void validateNameUnique(Long id, Long templateId, String name) { - if (templateId != null || StrUtil.isBlank(name)) { - return; - } - DiyPageDO page = diyPageMapper.selectByNameAndTemplateIdIsNull(name); - if (page == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的页面 - if (id == null) { - throw exception(DIY_PAGE_NAME_USED, name); - } - if (!page.getId().equals(id)) { - throw exception(DIY_PAGE_NAME_USED, name); - } - } - - @Override - public void deleteDiyPage(Long id) { - // 校验存在 - validateDiyPageExists(id); - // 删除 - diyPageMapper.deleteById(id); - } - - private void validateDiyPageExists(Long id) { - if (diyPageMapper.selectById(id) == null) { - throw exception(DIY_PAGE_NOT_EXISTS); - } - } - - @Override - public DiyPageDO getDiyPage(Long id) { - return diyPageMapper.selectById(id); - } - - @Override - public List getDiyPageList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return diyPageMapper.selectBatchIds(ids); - } - - @Override - public PageResult getDiyPagePage(DiyPagePageReqVO pageReqVO) { - return diyPageMapper.selectPage(pageReqVO); - } - - @Override - public List getDiyPageByTemplateId(Long templateId) { - return diyPageMapper.selectListByTemplateId(templateId); - } - - @Override - public void updateDiyPageProperty(DiyPagePropertyUpdateRequestVO updateReqVO) { - // 校验存在 - validateDiyPageExists(updateReqVO.getId()); - // 更新 - DiyPageDO updateObj = DiyPageConvert.INSTANCE.convert(updateReqVO); - diyPageMapper.updateById(updateObj); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java deleted file mode 100644 index 64320e4f94..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePropertyUpdateRequestVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; - -import jakarta.validation.Valid; - -/** - * 装修模板 Service 接口 - * - * @author owen - */ -public interface DiyTemplateService { - - /** - * 创建装修模板 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDiyTemplate(@Valid DiyTemplateCreateReqVO createReqVO); - - /** - * 更新装修模板 - * - * @param updateReqVO 更新信息 - */ - void updateDiyTemplate(@Valid DiyTemplateUpdateReqVO updateReqVO); - - /** - * 删除装修模板 - * - * @param id 编号 - */ - void deleteDiyTemplate(Long id); - - /** - * 获得装修模板 - * - * @param id 编号 - * @return 装修模板 - */ - DiyTemplateDO getDiyTemplate(Long id); - - /** - * 获得装修模板分页 - * - * @param pageReqVO 分页查询 - * @return 装修模板分页 - */ - PageResult getDiyTemplatePage(DiyTemplatePageReqVO pageReqVO); - - /** - * 使用装修模板 - * - * @param id 编号 - */ - void useDiyTemplate(Long id); - - /** - * 更新装修模板属性 - * - * @param updateReqVO 更新信息 - */ - void updateDiyTemplateProperty(DiyTemplatePropertyUpdateRequestVO updateReqVO); - - /** - * 获取使用中的装修模板 - * - * @return 装修模板 - */ - DiyTemplateDO getUsedDiyTemplate(); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java deleted file mode 100644 index bc005b9400..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java +++ /dev/null @@ -1,172 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePropertyUpdateRequestVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 装修模板 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class DiyTemplateServiceImpl implements DiyTemplateService { - - @Resource - private DiyTemplateMapper diyTemplateMapper; - - @Resource - private DiyPageService diyPageService; - - // TODO @疯狂:事务; - @Override - public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) { - // 校验名称唯一 - validateNameUnique(null, createReqVO.getName()); - // 插入 - DiyTemplateDO diyTemplate = DiyTemplateConvert.INSTANCE.convert(createReqVO); - diyTemplate.setProperty("{}"); - diyTemplateMapper.insert(diyTemplate); - // 创建默认页面 - createDefaultPage(diyTemplate); - // 返回 - return diyTemplate.getId(); - } - - /** - * 创建模板下面的默认页面 - * 默认创建两个页面:首页、我的 - * - * @param diyTemplate 模板对象 - */ - private void createDefaultPage(DiyTemplateDO diyTemplate) { - String remark = String.format("模板【%s】自动创建", diyTemplate.getName()); - diyPageService.createDiyPage(DiyPageConvert.INSTANCE.convertCreateVo(diyTemplate.getId(), "首页", remark)); - diyPageService.createDiyPage(DiyPageConvert.INSTANCE.convertCreateVo(diyTemplate.getId(), "我的", remark)); - } - - @Override - public void updateDiyTemplate(DiyTemplateUpdateReqVO updateReqVO) { - // 校验存在 - validateDiyTemplateExists(updateReqVO.getId()); - // 校验名称唯一 - validateNameUnique(updateReqVO.getId(), updateReqVO.getName()); - // 更新 - DiyTemplateDO updateObj = DiyTemplateConvert.INSTANCE.convert(updateReqVO); - diyTemplateMapper.updateById(updateObj); - } - - void validateNameUnique(Long id, String name) { - if (StrUtil.isBlank(name)) { - return; - } - DiyTemplateDO template = diyTemplateMapper.selectByName(name); - if (template == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的模板 - if (id == null) { - throw exception(DIY_TEMPLATE_NAME_USED, name); - } - if (!template.getId().equals(id)) { - throw exception(DIY_TEMPLATE_NAME_USED, name); - } - } - - @Override - public void deleteDiyTemplate(Long id) { - // 校验存在 - DiyTemplateDO diyTemplateDO = validateDiyTemplateExists(id); - // 校验使用中 - if (BooleanUtil.isTrue(diyTemplateDO.getUsed())) { - throw exception(DIY_TEMPLATE_USED_CANNOT_DELETE); - } - // 删除 - diyTemplateMapper.deleteById(id); - } - - private DiyTemplateDO validateDiyTemplateExists(Long id) { - DiyTemplateDO diyTemplateDO = diyTemplateMapper.selectById(id); - if (diyTemplateDO == null) { - throw exception(DIY_TEMPLATE_NOT_EXISTS); - } - return diyTemplateDO; - } - - @Override - public DiyTemplateDO getDiyTemplate(Long id) { - return diyTemplateMapper.selectById(id); - } - - @Override - public PageResult getDiyTemplatePage(DiyTemplatePageReqVO pageReqVO) { - return diyTemplateMapper.selectPage(pageReqVO); - } - - @Override - // TODO @疯狂:事务; - public void useDiyTemplate(Long id) { - // 校验存在 - validateDiyTemplateExists(id); - // TODO @疯狂:要不已使用的情况,抛个业务异常? - // 已使用的更新为未使用 - DiyTemplateDO used = diyTemplateMapper.selectByUsed(true); - if (used != null) { - // 如果 id 相同,说明未发生变化 - if (used.getId().equals(id)) { - return; - } - this.updateUsed(used.getId(), false, null); - } - // 更新为已使用 - this.updateUsed(id, true, LocalDateTime.now()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateDiyTemplateProperty(DiyTemplatePropertyUpdateRequestVO updateReqVO) { - // 校验存在 - validateDiyTemplateExists(updateReqVO.getId()); - // 更新模板属性 - DiyTemplateDO updateObj = DiyTemplateConvert.INSTANCE.convert(updateReqVO); - diyTemplateMapper.updateById(updateObj); - } - - @Override - public DiyTemplateDO getUsedDiyTemplate() { - return diyTemplateMapper.selectByUsed(true); - } - - // TODO @疯狂:挪到 useDiyTemplate 下面,改名 updateTemplateUsed 会不会好点哈; - /** - * 更新模板是否使用 - * - * @param id 模板编号 - * @param used 是否使用 - * @param usedTime 使用时间 - */ - private void updateUsed(Long id, Boolean used, LocalDateTime usedTime) { - DiyTemplateDO updateObj = new DiyTemplateDO().setId(id) - .setUsed(used).setUsedTime(usedTime); - diyTemplateMapper.updateById(updateObj); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java deleted file mode 100755 index 7176e980b3..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.reward; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 满减送活动 Service 接口 - * - * @author 芋道源码 - */ -public interface RewardActivityService { - - /** - * 创建满减送活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createRewardActivity(@Valid RewardActivityCreateReqVO createReqVO); - - /** - * 更新满减送活动 - * - * @param updateReqVO 更新信息 - */ - void updateRewardActivity(@Valid RewardActivityUpdateReqVO updateReqVO); - - /** - * 关闭满减送活动 - * - * @param id 活动编号 - */ - void closeRewardActivity(Long id); - - /** - * 删除满减送活动 - * - * @param id 编号 - */ - void deleteRewardActivity(Long id); - - /** - * 获得满减送活动 - * - * @param id 编号 - * @return 满减送活动 - */ - RewardActivityDO getRewardActivity(Long id); - - /** - * 获得满减送活动分页 - * - * @param pageReqVO 分页查询 - * @return 满减送活动分页 - */ - PageResult getRewardActivityPage(RewardActivityPageReqVO pageReqVO); - - /** - * 基于指定的 SPU 编号数组,获得它们匹配的满减送活动 - * - * @param spuIds SPU 编号数组 - * @return 满减送活动列表 - */ - List getMatchRewardActivityList(Collection spuIds); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java deleted file mode 100755 index 723dda9336..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java +++ /dev/null @@ -1,166 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.reward; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.reward.RewardActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.reward.RewardActivityMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.util.PromotionUtils; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; - -/** - * 满减送活动 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class RewardActivityServiceImpl implements RewardActivityService { - - @Resource - private RewardActivityMapper rewardActivityMapper; - - @Override - public Long createRewardActivity(RewardActivityCreateReqVO createReqVO) { - // 校验商品是否冲突 - validateRewardActivitySpuConflicts(null, createReqVO.getProductSpuIds()); - - // 插入 - RewardActivityDO rewardActivity = RewardActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getEndTime())); - rewardActivityMapper.insert(rewardActivity); - // 返回 - return rewardActivity.getId(); - } - - @Override - public void updateRewardActivity(RewardActivityUpdateReqVO updateReqVO) { - // 校验存在 - RewardActivityDO dbRewardActivity = validateRewardActivityExists(updateReqVO.getId()); - if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能修改噢 - throw exception(REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); - } - // 校验商品是否冲突 - validateRewardActivitySpuConflicts(updateReqVO.getId(), updateReqVO.getProductSpuIds()); - - // 更新 - RewardActivityDO updateObj = RewardActivityConvert.INSTANCE.convert(updateReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getEndTime())); - rewardActivityMapper.updateById(updateObj); - } - - @Override - public void closeRewardActivity(Long id) { - // 校验存在 - RewardActivityDO dbRewardActivity = validateRewardActivityExists(id); - if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); - } - if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.END.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_END); - } - - // 更新 - RewardActivityDO updateObj = new RewardActivityDO().setId(id).setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - rewardActivityMapper.updateById(updateObj); - } - - @Override - public void deleteRewardActivity(Long id) { - // 校验存在 - RewardActivityDO dbRewardActivity = validateRewardActivityExists(id); - if (!dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 未关闭的活动,不能删除噢 - throw exception(REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED); - } - - // 删除 - rewardActivityMapper.deleteById(id); - } - - private RewardActivityDO validateRewardActivityExists(Long id) { - RewardActivityDO activity = rewardActivityMapper.selectById(id); - if (activity == null) { - throw exception(REWARD_ACTIVITY_NOT_EXISTS); - } - return activity; - } - - // TODO @芋艿:逻辑有问题,需要优化;要分成全场、和指定来校验; - /** - * 校验商品参加的活动是否冲突 - * - * @param id 活动编号 - * @param spuIds 商品 SPU 编号数组 - */ - private void validateRewardActivitySpuConflicts(Long id, Collection spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return; - } - // 查询商品参加的活动 - List rewardActivityList = getRewardActivityListBySpuIds(spuIds, - asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus())); - if (id != null) { // 排除自己这个活动 - rewardActivityList.removeIf(activity -> id.equals(activity.getId())); - } - // 如果非空,则说明冲突 - if (CollUtil.isNotEmpty(rewardActivityList)) { - throw exception(REWARD_ACTIVITY_SPU_CONFLICTS); - } - } - - /** - * 获得商品参加的满减送活动的数组 - * - * @param spuIds 商品 SPU 编号数组 - * @param statuses 活动状态数组 - * @return 商品参加的满减送活动的数组 - */ - private List getRewardActivityListBySpuIds(Collection spuIds, - Collection statuses) { - List list = rewardActivityMapper.selectListByStatus(statuses); - return CollUtil.filter(list, activity -> CollUtil.containsAny(activity.getProductSpuIds(), spuIds)); - } - - @Override - public RewardActivityDO getRewardActivity(Long id) { - return rewardActivityMapper.selectById(id); - } - - @Override - public PageResult getRewardActivityPage(RewardActivityPageReqVO pageReqVO) { - return rewardActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getMatchRewardActivityList(Collection spuIds) { - // TODO 芋艿:待实现;先指定,然后再全局的; -// // 如果有全局活动,则直接选择它 -// List allActivities = rewardActivityMapper.selectListByProductScopeAndStatus( -// PromotionProductScopeEnum.ALL.getScope(), PromotionActivityStatusEnum.RUN.getStatus()); -// if (CollUtil.isNotEmpty(allActivities)) { -// return MapUtil.builder(allActivities.get(0), spuIds).build(); -// } -// -// // 查询某个活动参加的活动 -// List productActivityList = getRewardActivityListBySpuIds(spuIds, -// singleton(PromotionActivityStatusEnum.RUN.getStatus())); -// return convertMap(productActivityList, activity -> activity, -// rewardActivityDO -> intersectionDistinct(rewardActivityDO.getProductSpuIds(), spuIds)); // 求交集返回 - return null; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java deleted file mode 100644 index a47bbec7cb..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; - -import jakarta.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 秒杀活动 Service 接口 - * - * @author halfninety - */ -public interface SeckillActivityService { - - /** - * 创建秒杀活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSeckillActivity(@Valid SeckillActivityCreateReqVO createReqVO); - - /** - * 更新秒杀活动 - * - * @param updateReqVO 更新信息 - */ - void updateSeckillActivity(@Valid SeckillActivityUpdateReqVO updateReqVO); - - /** - * 更新秒杀库存(减少) - * - * @param id 活动编号 - * @param skuId sku 编号 - * @param count 数量(正数) - */ - void updateSeckillStockDecr(Long id, Long skuId, Integer count); - - /** - * 更新秒杀库存(增加) - * - * @param id 活动编号 - * @param skuId sku 编号 - * @param count 数量(正数) - */ - void updateSeckillStockIncr(Long id, Long skuId, Integer count); - - /** - * 关闭秒杀活动 - * - * @param id 编号 - */ - void closeSeckillActivity(Long id); - - /** - * 删除秒杀活动 - * - * @param id 编号 - */ - void deleteSeckillActivity(Long id); - - /** - * 获得秒杀活动 - * - * @param id 编号 - * @return 秒杀活动 - */ - SeckillActivityDO getSeckillActivity(Long id); - - /** - * 获得秒杀活动分页 - * - * @param pageReqVO 分页查询 - * @return 秒杀活动分页 - */ - PageResult getSeckillActivityPage(SeckillActivityPageReqVO pageReqVO); - - /** - * 通过活动编号获取活动商品 - * - * @param activityId 活动编号 - * @return 活动商品列表 - */ - List getSeckillProductListByActivityId(Long activityId); - - /** - * 通过活动编号获取活动商品 - * - * @param activityIds 活动编号 - * @return 活动商品列表 - */ - List getSeckillProductListByActivityId(Collection activityIds); - - /** - * 通过活动时段编号获取指定 status 的秒杀活动 - * - * @param configId 时段配置编号 - * @param status 状态 - * @return 秒杀活动列表 - */ - List getSeckillActivityListByConfigIdAndStatus(Long configId, Integer status); - - /** - * 通过活动时段获取秒杀活动 - * - * @param pageReqVO 请求 - * @return 秒杀活动列表 - */ - PageResult getSeckillActivityAppPageByConfigId(AppSeckillActivityPageReqVO pageReqVO); - - /** - * 校验是否参与秒杀商品 - * - * 如果校验失败,则抛出业务异常 - * - * @param activityId 活动编号 - * @param skuId SKU 编号 - * @param count 数量 - * @return 秒杀信息 - */ - SeckillValidateJoinRespDTO validateJoinSeckill(Long activityId, Long skuId, Integer count); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 日期时间 - * @return 秒杀活动列表 - */ - List getSeckillActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java deleted file mode 100644 index b65afcbad9..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java +++ /dev/null @@ -1,339 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillProductMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.hutool.core.collection.CollUtil.isNotEmpty; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; - -/** - * 秒杀活动 Service 实现类 - * - * @author halfninety - */ -@Service -@Validated -public class SeckillActivityServiceImpl implements SeckillActivityService { - - @Resource - private SeckillActivityMapper seckillActivityMapper; - @Resource - private SeckillProductMapper seckillProductMapper; - @Resource - private SeckillConfigService seckillConfigService; - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSeckillActivity(SeckillActivityCreateReqVO createReqVO) { - // 1.1 校验商品秒杀时段是否冲突 - validateProductConflict(createReqVO.getConfigIds(), createReqVO.getSpuId(), null); - // 1.2 校验商品是否存在 - validateProductExists(createReqVO.getSpuId(), createReqVO.getProducts()); - - // 2.1 插入秒杀活动 - SeckillActivityDO activity = SeckillActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setStock(getSumValue(createReqVO.getProducts(), SeckillProductBaseVO::getStock, Integer::sum)); - activity.setTotalStock(activity.getStock()); - seckillActivityMapper.insert(activity); - // 2.2 插入商品 - List products = SeckillActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), activity); - seckillProductMapper.insertBatch(products); - return activity.getId(); - } - - /** - * 校验秒杀商品参与的活动是否存在冲突 - * - * 1. 校验秒杀时段是否存在 - * 2. 秒杀商品是否参加其它活动 - * - * @param configIds 秒杀时段数组 - * @param spuId 商品 SPU 编号 - * @param activityId 秒杀活动编号 - */ - private void validateProductConflict(List configIds, Long spuId, Long activityId) { - // 1. 校验秒杀时段是否存在 - seckillConfigService.validateSeckillConfigExists(configIds); - - // 2.1 查询所有开启的秒杀活动 - List activityList = seckillActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - if (activityId != null) { // 排除自己 - activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId)); - } - // 2.2 过滤出所有 configIds 有交集的活动,判断是否存在重叠 - List conflictActivityList = filterList(activityList, s -> containsAny(s.getConfigIds(), configIds)); - if (isNotEmpty(conflictActivityList)) { - throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS); - } - } - - /** - * 校验秒杀商品是否都存在 - * - * @param spuId 商品 SPU 编号 - * @param products 秒杀商品 - */ - private void validateProductExists(Long spuId, List products) { - // 1. 校验商品 spu 是否存在 - ProductSpuRespDTO spu = productSpuApi.getSpu(spuId); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - - // 2. 校验商品 sku 都存在 - List skus = productSkuApi.getSkuListBySpuId(singletonList(spuId)); - Map skuMap = convertMap(skus, ProductSkuRespDTO::getId); - products.forEach(product -> { - if (!skuMap.containsKey(product.getSkuId())) { - throw exception(SKU_NOT_EXISTS); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSeckillActivity(SeckillActivityUpdateReqVO updateReqVO) { - // 1.1 校验存在 - SeckillActivityDO activity = validateSeckillActivityExists(updateReqVO.getId()); - if (CommonStatusEnum.DISABLE.getStatus().equals(activity.getStatus())) { - throw exception(SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); - } - // 1.2 校验商品是否冲突 - validateProductConflict(updateReqVO.getConfigIds(), updateReqVO.getSpuId(), updateReqVO.getId()); - // 1.3 校验商品是否存在 - validateProductExists(updateReqVO.getSpuId(), updateReqVO.getProducts()); - - // 2.1 更新活动 - SeckillActivityDO updateObj = SeckillActivityConvert.INSTANCE.convert(updateReqVO) - .setStock(getSumValue(updateReqVO.getProducts(), SeckillProductBaseVO::getStock, Integer::sum)); - if (updateObj.getStock() > activity.getTotalStock()) { // 如果更新的库存大于原来的库存,则更新总库存 - updateObj.setTotalStock(updateObj.getStock()); - } - seckillActivityMapper.updateById(updateObj); - // 2.2 更新商品 - updateSeckillProduct(updateObj, updateReqVO.getProducts()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSeckillStockDecr(Long id, Long skuId, Integer count) { - // 1.1 校验活动库存是否充足 - SeckillActivityDO seckillActivity = validateSeckillActivityExists(id); - if (count > seckillActivity.getTotalStock()) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - // 1.2 校验商品库存是否充足 - SeckillProductDO product = seckillProductMapper.selectByActivityIdAndSkuId(id, skuId); - if (product == null || count > product.getStock()) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - - // 2.1 更新活动商品库存 - int updateCount = seckillProductMapper.updateStockDecr(product.getId(), count); - if (updateCount == 0) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - - // 2.2 更新活动库存 - updateCount = seckillActivityMapper.updateStockDecr(seckillActivity.getId(), count); - if (updateCount == 0) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSeckillStockIncr(Long id, Long skuId, Integer count) { - SeckillProductDO product = seckillProductMapper.selectByActivityIdAndSkuId(id, skuId); - // 更新活动商品库存 - seckillProductMapper.updateStockIncr(product.getId(), count); - // 更新活动库存 - seckillActivityMapper.updateStockIncr(id, count); - } - - /** - * 更新秒杀商品 - * - * @param activity 秒杀活动 - * @param products 该活动的最新商品配置 - */ - private void updateSeckillProduct(SeckillActivityDO activity, List products) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List newList = SeckillActivityConvert.INSTANCE.convertList(products, activity); - List oldList = seckillProductMapper.selectListByActivityId(activity.getId()); - List> diffList = diffList(oldList, newList, (oldVal, newVal) -> { - boolean same = ObjectUtil.equal(oldVal.getSkuId(), newVal.getSkuId()); - if (same) { - newVal.setId(oldVal.getId()); - } - return same; - }); - - // 第二步,批量添加、修改、删除 - if (isNotEmpty(diffList.get(0))) { - seckillProductMapper.insertBatch(diffList.get(0)); - } - if (isNotEmpty(diffList.get(1))) { - seckillProductMapper.updateBatch(diffList.get(1)); - } - if (isNotEmpty(diffList.get(2))) { - seckillProductMapper.deleteBatchIds(convertList(diffList.get(2), SeckillProductDO::getId)); - } - } - - @Override - public void closeSeckillActivity(Long id) { - // 校验存在 - SeckillActivityDO activity = validateSeckillActivityExists(id); - if (CommonStatusEnum.DISABLE.getStatus().equals(activity.getStatus())) { - throw exception(SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); - } - - // 更新 - SeckillActivityDO updateObj = new SeckillActivityDO().setId(id).setStatus(CommonStatusEnum.DISABLE.getStatus()); - seckillActivityMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSeckillActivity(Long id) { - // 校验存在 - SeckillActivityDO seckillActivity = this.validateSeckillActivityExists(id); - if (CommonStatusEnum.ENABLE.getStatus().equals(seckillActivity.getStatus())) { - throw exception(SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); - } - - // 删除活动 - seckillActivityMapper.deleteById(id); - // 删除活动商品 - List products = seckillProductMapper.selectListByActivityId(id); - seckillProductMapper.deleteBatchIds(convertSet(products, SeckillProductDO::getId)); - } - - private SeckillActivityDO validateSeckillActivityExists(Long id) { - SeckillActivityDO seckillActivity = seckillActivityMapper.selectById(id); - if (seckillActivity == null) { - throw exception(SECKILL_ACTIVITY_NOT_EXISTS); - } - return seckillActivity; - } - - @Override - public SeckillActivityDO getSeckillActivity(Long id) { - return seckillActivityMapper.selectById(id); - } - - @Override - public PageResult getSeckillActivityPage(SeckillActivityPageReqVO pageReqVO) { - return seckillActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getSeckillProductListByActivityId(Long activityId) { - return seckillProductMapper.selectListByActivityId(activityId); - } - - @Override - public List getSeckillProductListByActivityId(Collection activityIds) { - return seckillProductMapper.selectListByActivityId(activityIds); - } - - @Override - public List getSeckillActivityListByConfigIdAndStatus(Long configId, Integer status) { - return filterList(seckillActivityMapper.selectList(SeckillActivityDO::getStatus, status), - item -> anyMatch(item.getConfigIds(), id -> ObjectUtil.equal(id, configId)) // 校验时段 - && isBetween(item.getStartTime(), item.getEndTime())); // 追加当前日期是否处在活动日期之间的校验条件 - } - - @Override - public PageResult getSeckillActivityAppPageByConfigId(AppSeckillActivityPageReqVO pageReqVO) { - return seckillActivityMapper.selectPage(pageReqVO, CommonStatusEnum.ENABLE.getStatus()); - } - - @Override - public SeckillValidateJoinRespDTO validateJoinSeckill(Long activityId, Long skuId, Integer count) { - // 1.1 校验秒杀活动是否存在 - SeckillActivityDO activity = validateSeckillActivityExists(activityId); - if (CommonStatusEnum.isDisable(activity.getStatus())) { - throw exception(SECKILL_JOIN_ACTIVITY_STATUS_CLOSED); - } - // 1.2 是否在活动时间范围内 - if (!LocalDateTimeUtils.isBetween(activity.getStartTime(), activity.getEndTime())) { - throw exception(SECKILL_JOIN_ACTIVITY_TIME_ERROR); - } - SeckillConfigDO config = seckillConfigService.getCurrentSeckillConfig(); - if (config == null || !CollectionUtil.contains(activity.getConfigIds(), config.getId())) { - throw exception(SECKILL_JOIN_ACTIVITY_TIME_ERROR); - } - // 1.3 超过单次购买限制 - if (count > activity.getSingleLimitCount()) { - throw exception(SECKILL_JOIN_ACTIVITY_SINGLE_LIMIT_COUNT_EXCEED); - } - - // 2.1 校验秒杀商品是否存在 - SeckillProductDO product = seckillProductMapper.selectByActivityIdAndSkuId(activityId, skuId); - if (product == null) { - throw exception(SECKILL_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS); - } - // 2.2 校验库存是否充足 - if (count > product.getStock()) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - return SeckillActivityConvert.INSTANCE.convert02(activity, product); - } - - @Override - public List getSeckillActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1.查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - List> spuIdAndActivityIdMaps = seckillActivityMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { - return Collections.emptyList(); - } - // 2.查询活动详情 - return seckillActivityMapper.selectListByIdsAndDateTimeLt( - convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java deleted file mode 100644 index de598ac16b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 秒杀时段 Service 接口 - * - * @author halfninety - */ -public interface SeckillConfigService { - - /** - * 创建秒杀时段 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSeckillConfig(@Valid SeckillConfigCreateReqVO createReqVO); - - /** - * 更新秒杀时段 - * - * @param updateReqVO 更新信息 - */ - void updateSeckillConfig(@Valid SeckillConfigUpdateReqVO updateReqVO); - - /** - * 删除秒杀时段 - * - * @param id 编号 - */ - void deleteSeckillConfig(Long id); - - /** - * 获得秒杀时段 - * - * @param id 编号 - * @return 秒杀时段 - */ - SeckillConfigDO getSeckillConfig(Long id); - - /** - * 获得所有秒杀时段列表 - * - * @return 所有秒杀时段列表 - */ - List getSeckillConfigList(); - - /** - * 校验秒杀时段是否存在 - * - * @param ids 秒杀时段 id 集合 - */ - void validateSeckillConfigExists(Collection ids); - - /** - * 获得秒杀时间段配置分页数据 - * - * @param pageVO 分页请求参数 - * @return 秒杀时段分页列表 - */ - PageResult getSeckillConfigPage(SeckillConfigPageReqVO pageVO); - - /** - * 获得所有正常状态的时段配置列表 - * - * @param status 状态 - * @return 秒杀时段列表 - */ - List getSeckillConfigListByStatus(Integer status); - - /** - * 更新秒杀时段配置状态 - * - * @param id id - * @param status 状态 - */ - void updateSeckillConfigStatus(Long id, Integer status); - - /** - * 获得当前的秒杀时段 - * - * 要求必须处于开启状态、且在当前时间段内 - * - * @return 时段 - */ - SeckillConfigDO getCurrentSeckillConfig(); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java deleted file mode 100644 index 525343911b..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java +++ /dev/null @@ -1,160 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillconfig.SeckillConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalTime; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 秒杀时段 Service 实现类 - * - * @author halfninety - */ -@Service -@Validated -public class SeckillConfigServiceImpl implements SeckillConfigService { - - @Resource - private SeckillConfigMapper seckillConfigMapper; - - @Override - public Long createSeckillConfig(SeckillConfigCreateReqVO createReqVO) { - // 校验时间段是否冲突 - validateSeckillConfigConflict(createReqVO.getStartTime(), createReqVO.getEndTime(), null); - - // 插入 - SeckillConfigDO seckillConfig = SeckillConfigConvert.INSTANCE.convert(createReqVO); - seckillConfigMapper.insert(seckillConfig); - // 返回 - return seckillConfig.getId(); - } - - @Override - public void updateSeckillConfig(SeckillConfigUpdateReqVO updateReqVO) { - // 校验存在 - validateSeckillConfigExists(updateReqVO.getId()); - // 校验时间段是否冲突 - validateSeckillConfigConflict(updateReqVO.getStartTime(), updateReqVO.getEndTime(), updateReqVO.getId()); - - // 更新 - SeckillConfigDO updateObj = SeckillConfigConvert.INSTANCE.convert(updateReqVO); - seckillConfigMapper.updateById(updateObj); - } - - @Override - public void updateSeckillConfigStatus(Long id, Integer status) { - // 校验秒杀时段是否存在 - validateSeckillConfigExists(id); - - // 更新状态 - seckillConfigMapper.updateById(new SeckillConfigDO().setId(id).setStatus(status)); - } - - @Override - public SeckillConfigDO getCurrentSeckillConfig() { - List list = seckillConfigMapper.selectList(SeckillConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus()); - return findFirst(list, config -> isBetween(config.getStartTime(), config.getEndTime())); - } - - @Override - public void deleteSeckillConfig(Long id) { - // 校验存在 - validateSeckillConfigExists(id); - - // 删除 - seckillConfigMapper.deleteById(id); - } - - private void validateSeckillConfigExists(Long id) { - if (seckillConfigMapper.selectById(id) == null) { - throw exception(SECKILL_CONFIG_NOT_EXISTS); - } - } - - /** - * 校验时间是否存在冲突 - * - * @param startTimeStr 开始时间 - * @param endTimeStr 结束时间 - */ - private void validateSeckillConfigConflict(String startTimeStr, String endTimeStr, Long id) { - // 1. 查询出所有的时段配置 - LocalTime startTime = LocalTime.parse(startTimeStr); - LocalTime endTime = LocalTime.parse(endTimeStr); - List configs = seckillConfigMapper.selectList(); - // 更新时排除自己 - if (id != null) { - configs.removeIf(item -> ObjectUtil.equal(item.getId(), id)); - } - - // 2. 判断是否有重叠的时间 - boolean hasConflict = configs.stream().anyMatch(config -> LocalDateTimeUtils.isOverlap(startTime, endTime, - LocalTime.parse(config.getStartTime()), LocalTime.parse(config.getEndTime()))); - if (hasConflict) { - throw exception(SECKILL_CONFIG_TIME_CONFLICTS); - } - } - - - @Override - public SeckillConfigDO getSeckillConfig(Long id) { - return seckillConfigMapper.selectById(id); - } - - @Override - public List getSeckillConfigList() { - return seckillConfigMapper.selectList(); - } - - @Override - public void validateSeckillConfigExists(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - // 1. 如果有数量不匹配,说明有不存在的,则抛出 SECKILL_CONFIG_NOT_EXISTS 业务异常 - List configs = seckillConfigMapper.selectBatchIds(ids); - if (configs.size() != ids.size()) { - throw exception(SECKILL_CONFIG_NOT_EXISTS); - } - - // 2. 如果存在关闭,则抛出 SECKILL_CONFIG_DISABLE 业务异常 - configs.forEach(config -> { - if (ObjectUtil.equal(config.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(SECKILL_CONFIG_DISABLE); - } - }); - } - - @Override - public PageResult getSeckillConfigPage(SeckillConfigPageReqVO pageVO) { - return seckillConfigMapper.selectPage(pageVO); - } - - @Override - public List getSeckillConfigListByStatus(Integer status) { - List list = seckillConfigMapper.selectListByStatus(status); - list.sort(Comparator.comparing(SeckillConfigDO::getStartTime)); - return list; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java deleted file mode 100644 index 2ad362fe26..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.util; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; - -import java.time.LocalDateTime; - -/** - * 活动工具类 - * - * @author 芋道源码 - */ -public class PromotionUtils { - - /** - * 根据时间,计算活动状态 - * - * @param endTime 结束时间 - * @return 活动状态 - */ - public static Integer calculateActivityStatus(LocalDateTime endTime) { - return LocalDateTimeUtils.beforeNow(endTime) ? CommonStatusEnum.DISABLE.getStatus() : CommonStatusEnum.ENABLE.getStatus(); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/discount/DiscountProductMapper.xml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/discount/DiscountProductMapper.xml deleted file mode 100644 index 76af37db2e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/discount/DiscountProductMapper.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImplTest.java deleted file mode 100644 index 9fdab66168..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImplTest.java +++ /dev/null @@ -1,140 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -// TODO 芋艿:review 单测 -/** - * {@link ArticleCategoryServiceImpl} 的单元测试类 - * - * @author HUIHUI - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(ArticleCategoryServiceImpl.class) -public class ArticleCategoryServiceImplTest extends BaseDbUnitTest { - - @Resource - private ArticleCategoryServiceImpl articleCategoryService; - - @Resource - private ArticleCategoryMapper articleCategoryMapper; - - @Test - public void testCreateArticleCategory_success() { - // 准备参数 - ArticleCategoryCreateReqVO reqVO = randomPojo(ArticleCategoryCreateReqVO.class); - - // 调用 - Long articleCategoryId = articleCategoryService.createArticleCategory(reqVO); - // 断言 - assertNotNull(articleCategoryId); - // 校验记录的属性是否正确 - ArticleCategoryDO articleCategory = articleCategoryMapper.selectById(articleCategoryId); - assertPojoEquals(reqVO, articleCategory); - } - - @Test - public void testUpdateArticleCategory_success() { - // mock 数据 - ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class); - articleCategoryMapper.insert(dbArticleCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - ArticleCategoryUpdateReqVO reqVO = randomPojo(ArticleCategoryUpdateReqVO.class, o -> { - o.setId(dbArticleCategory.getId()); // 设置更新的 ID - }); - - // 调用 - articleCategoryService.updateArticleCategory(reqVO); - // 校验是否更新正确 - ArticleCategoryDO articleCategory = articleCategoryMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, articleCategory); - } - - @Test - public void testUpdateArticleCategory_notExists() { - // 准备参数 - ArticleCategoryUpdateReqVO reqVO = randomPojo(ArticleCategoryUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> articleCategoryService.updateArticleCategory(reqVO), ARTICLE_CATEGORY_NOT_EXISTS); - } - - @Test - public void testDeleteArticleCategory_success() { - // mock 数据 - ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class); - articleCategoryMapper.insert(dbArticleCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbArticleCategory.getId(); - - // 调用 - articleCategoryService.deleteArticleCategory(id); - // 校验数据不存在了 - assertNull(articleCategoryMapper.selectById(id)); - } - - @Test - public void testDeleteArticleCategory_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> articleCategoryService.deleteArticleCategory(id), ARTICLE_CATEGORY_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetArticleCategoryPage() { - // mock 数据 - ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class, o -> { // 等会查询到 - o.setName(null); - o.setPicUrl(null); - o.setStatus(null); - o.setSort(null); - o.setCreateTime(null); - }); - articleCategoryMapper.insert(dbArticleCategory); - // 测试 name 不匹配 - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setName(null))); - // 测试 picUrl 不匹配 - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setPicUrl(null))); - // 测试 status 不匹配 - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setStatus(null))); - // 测试 sort 不匹配 - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setSort(null))); - // 测试 createTime 不匹配 - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setCreateTime(null))); - // 准备参数 - ArticleCategoryPageReqVO reqVO = new ArticleCategoryPageReqVO(); - reqVO.setName(null); - reqVO.setStatus(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = articleCategoryService.getArticleCategoryPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbArticleCategory, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java deleted file mode 100644 index 4438f4b8ef..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java +++ /dev/null @@ -1,168 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link ArticleServiceImpl} 的单元测试类 - * - * @author HUIHUI - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(ArticleServiceImpl.class) -public class ArticleServiceImplTest extends BaseDbUnitTest { - - @Resource - private ArticleServiceImpl articleService; - - @Resource - private ArticleMapper articleMapper; - - @Test - public void testCreateArticle_success() { - // 准备参数 - ArticleCreateReqVO reqVO = randomPojo(ArticleCreateReqVO.class); - - // 调用 - Long articleId = articleService.createArticle(reqVO); - // 断言 - assertNotNull(articleId); - // 校验记录的属性是否正确 - ArticleDO article = articleMapper.selectById(articleId); - assertPojoEquals(reqVO, article); - } - - @Test - public void testUpdateArticle_success() { - // mock 数据 - ArticleDO dbArticle = randomPojo(ArticleDO.class); - articleMapper.insert(dbArticle);// @Sql: 先插入出一条存在的数据 - // 准备参数 - ArticleUpdateReqVO reqVO = randomPojo(ArticleUpdateReqVO.class, o -> { - o.setId(dbArticle.getId()); // 设置更新的 ID - }); - - // 调用 - articleService.updateArticle(reqVO); - // 校验是否更新正确 - ArticleDO article = articleMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, article); - } - - @Test - public void testUpdateArticle_notExists() { - // 准备参数 - ArticleUpdateReqVO reqVO = randomPojo(ArticleUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> articleService.updateArticle(reqVO), ARTICLE_NOT_EXISTS); - } - - @Test - public void testDeleteArticle_success() { - // mock 数据 - ArticleDO dbArticle = randomPojo(ArticleDO.class); - articleMapper.insert(dbArticle);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbArticle.getId(); - - // 调用 - articleService.deleteArticle(id); - // 校验数据不存在了 - assertNull(articleMapper.selectById(id)); - } - - @Test - public void testDeleteArticle_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> articleService.deleteArticle(id), ARTICLE_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetArticlePage() { - // mock 数据 - ArticleDO dbArticle = randomPojo(ArticleDO.class, o -> { // 等会查询到 - o.setCategoryId(null); - o.setTitle(null); - o.setAuthor(null); - o.setPicUrl(null); - o.setIntroduction(null); - o.setBrowseCount(null); - o.setSort(null); - o.setStatus(null); - o.setSpuId(null); - o.setRecommendHot(null); - o.setRecommendBanner(null); - o.setContent(null); - o.setCreateTime(null); - }); - articleMapper.insert(dbArticle); - // 测试 categoryId 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCategoryId(null))); - // 测试 title 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setTitle(null))); - // 测试 author 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setAuthor(null))); - // 测试 picUrl 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setPicUrl(null))); - // 测试 introduction 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setIntroduction(null))); - // 测试 browseCount 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setBrowseCount(null))); - // 测试 sort 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSort(null))); - // 测试 status 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setStatus(null))); - // 测试 spuId 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSpuId(null))); - // 测试 recommendHot 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendHot(null))); - // 测试 recommendBanner 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendBanner(null))); - // 测试 content 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setContent(null))); - // 测试 createTime 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCreateTime(null))); - // 准备参数 - ArticlePageReqVO reqVO = new ArticlePageReqVO(); - reqVO.setCategoryId(null); - reqVO.setTitle(null); - reqVO.setAuthor(null); - reqVO.setStatus(null); - reqVO.setSpuId(null); - reqVO.setRecommendHot(null); - reqVO.setRecommendBanner(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = articleService.getArticlePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbArticle, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImplTest.java deleted file mode 100644 index 5572812786..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImplTest.java +++ /dev/null @@ -1,199 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationActivityMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COMBINATION_ACTIVITY_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -// TODO 芋艿:等完成后,在补全单测 -/** - * {@link CombinationActivityServiceImpl} 的单元测试类 - * - * @author HUIHUI - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(CombinationActivityServiceImpl.class) -public class CombinationActivityServiceImplTest extends BaseDbUnitTest { - - @Resource - private CombinationActivityServiceImpl combinationActivityService; - - @Resource - private CombinationActivityMapper combinationActivityMapper; - - @Test - public void testCreateCombinationActivity_success() { - // 准备参数 - CombinationActivityCreateReqVO reqVO = randomPojo(CombinationActivityCreateReqVO.class); - - // 调用 - Long combinationActivityId = combinationActivityService.createCombinationActivity(reqVO); - // 断言 - assertNotNull(combinationActivityId); - // 校验记录的属性是否正确 - CombinationActivityDO combinationActivity = combinationActivityMapper.selectById(combinationActivityId); - assertPojoEquals(reqVO, combinationActivity); - } - - @Test - public void testUpdateCombinationActivity_success() { - // mock 数据 - CombinationActivityDO dbCombinationActivity = randomPojo(CombinationActivityDO.class); - combinationActivityMapper.insert(dbCombinationActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - CombinationActivityUpdateReqVO reqVO = randomPojo(CombinationActivityUpdateReqVO.class, o -> { - o.setId(dbCombinationActivity.getId()); // 设置更新的 ID - }); - - // 调用 - combinationActivityService.updateCombinationActivity(reqVO); - // 校验是否更新正确 - CombinationActivityDO combinationActivity = combinationActivityMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, combinationActivity); - } - - @Test - public void testUpdateCombinationActivity_notExists() { - // 准备参数 - CombinationActivityUpdateReqVO reqVO = randomPojo(CombinationActivityUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> combinationActivityService.updateCombinationActivity(reqVO), COMBINATION_ACTIVITY_NOT_EXISTS); - } - - @Test - public void testDeleteCombinationActivity_success() { - // mock 数据 - CombinationActivityDO dbCombinationActivity = randomPojo(CombinationActivityDO.class); - combinationActivityMapper.insert(dbCombinationActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCombinationActivity.getId(); - - // 调用 - combinationActivityService.deleteCombinationActivity(id); - // 校验数据不存在了 - assertNull(combinationActivityMapper.selectById(id)); - } - - @Test - public void testDeleteCombinationActivity_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> combinationActivityService.deleteCombinationActivity(id), COMBINATION_ACTIVITY_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetCombinationActivityPage() { - // mock 数据 - CombinationActivityDO dbCombinationActivity = randomPojo(CombinationActivityDO.class, o -> { // 等会查询到 - o.setName(null); - //o.setSpuId(null); - o.setTotalLimitCount(null); - o.setSingleLimitCount(null); - o.setStartTime(null); - o.setEndTime(null); - o.setUserSize(null); - o.setVirtualGroup(null); - o.setStatus(null); - o.setLimitDuration(null); - o.setCreateTime(null); - }); - combinationActivityMapper.insert(dbCombinationActivity); - // 测试 name 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setName(null))); - // 测试 spuId 不匹配 - //combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setSpuId(null))); - // 测试 totalLimitCount 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setTotalLimitCount(null))); - // 测试 singleLimitCount 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setSingleLimitCount(null))); - // 测试 startTime 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setStartTime(null))); - // 测试 endTime 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null))); - // 测试 userSize 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setUserSize(null))); - // 测试 virtualGroup 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null))); - // 测试 status 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setStatus(null))); - // 测试 limitDuration 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setLimitDuration(null))); - // 测试 createTime 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setCreateTime(null))); - // 准备参数 - CombinationActivityPageReqVO reqVO = new CombinationActivityPageReqVO(); - reqVO.setName(null); - reqVO.setStatus(null); - - // 调用 - PageResult pageResult = combinationActivityService.getCombinationActivityPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbCombinationActivity, pageResult.getList().get(0)); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetCombinationActivityList() { - // mock 数据 - CombinationActivityDO dbCombinationActivity = randomPojo(CombinationActivityDO.class, o -> { // 等会查询到 - o.setName(null); - //o.setSpuId(null); - o.setTotalLimitCount(null); - o.setSingleLimitCount(null); - o.setStartTime(null); - o.setEndTime(null); - o.setUserSize(null); - o.setVirtualGroup(null); - o.setStatus(null); - o.setLimitDuration(null); - o.setCreateTime(null); - }); - combinationActivityMapper.insert(dbCombinationActivity); - // 测试 name 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setName(null))); - // 测试 spuId 不匹配 - //combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setSpuId(null))); - // 测试 totalLimitCount 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setTotalLimitCount(null))); - // 测试 singleLimitCount 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setSingleLimitCount(null))); - // 测试 startTime 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setStartTime(null))); - // 测试 endTime 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setEndTime(null))); - // 测试 userSize 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setUserSize(null))); - // 测试 virtualGroup 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setVirtualGroup(null))); - // 测试 status 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setStatus(null))); - // 测试 limitDuration 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setLimitDuration(null))); - // 测试 createTime 不匹配 - combinationActivityMapper.insert(cloneIgnoreId(dbCombinationActivity, o -> o.setCreateTime(null))); - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImplTest.java deleted file mode 100755 index 2f3862849a..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImplTest.java +++ /dev/null @@ -1,149 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponTemplateMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link CouponTemplateServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(CouponTemplateServiceImpl.class) -public class CouponTemplateServiceImplTest extends BaseDbUnitTest { - - @Resource - private CouponTemplateServiceImpl couponTemplateService; - - @Resource - private CouponTemplateMapper couponTemplateMapper; - - @Test - public void testCreateCouponTemplate_success() { - // 准备参数 - CouponTemplateCreateReqVO reqVO = randomPojo(CouponTemplateCreateReqVO.class, - o -> o.setProductScope(randomEle(PromotionProductScopeEnum.values()).getScope()) - .setValidityType(randomEle(CouponTemplateValidityTypeEnum.values()).getType()) - .setDiscountType(randomEle(PromotionDiscountTypeEnum.values()).getType())); - - // 调用 - Long couponTemplateId = couponTemplateService.createCouponTemplate(reqVO); - // 断言 - assertNotNull(couponTemplateId); - // 校验记录的属性是否正确 - CouponTemplateDO couponTemplate = couponTemplateMapper.selectById(couponTemplateId); - assertPojoEquals(reqVO, couponTemplate); - } - - @Test - public void testUpdateCouponTemplate_success() { - // mock 数据 - CouponTemplateDO dbCouponTemplate = randomPojo(CouponTemplateDO.class); - couponTemplateMapper.insert(dbCouponTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - CouponTemplateUpdateReqVO reqVO = randomPojo(CouponTemplateUpdateReqVO.class, o -> { - o.setId(dbCouponTemplate.getId()); // 设置更新的 ID - // 其它通用字段 - o.setProductScope(randomEle(PromotionProductScopeEnum.values()).getScope()) - .setValidityType(randomEle(CouponTemplateValidityTypeEnum.values()).getType()) - .setDiscountType(randomEle(PromotionDiscountTypeEnum.values()).getType()); - }); - - // 调用 - couponTemplateService.updateCouponTemplate(reqVO); - // 校验是否更新正确 - CouponTemplateDO couponTemplate = couponTemplateMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, couponTemplate); - } - - @Test - public void testUpdateCouponTemplate_notExists() { - // 准备参数 - CouponTemplateUpdateReqVO reqVO = randomPojo(CouponTemplateUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> couponTemplateService.updateCouponTemplate(reqVO), COUPON_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testDeleteCouponTemplate_success() { - // mock 数据 - CouponTemplateDO dbCouponTemplate = randomPojo(CouponTemplateDO.class); - couponTemplateMapper.insert(dbCouponTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCouponTemplate.getId(); - - // 调用 - couponTemplateService.deleteCouponTemplate(id); - // 校验数据不存在了 - assertNull(couponTemplateMapper.selectById(id)); - } - - @Test - public void testDeleteCouponTemplate_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> couponTemplateService.deleteCouponTemplate(id), COUPON_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testGetCouponTemplatePage() { - // mock 数据 - CouponTemplateDO dbCouponTemplate = randomPojo(CouponTemplateDO.class, o -> { // 等会查询到 - o.setName("芋艿"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()); - o.setCreateTime(buildTime(2022, 2, 2)); - }); - couponTemplateMapper.insert(dbCouponTemplate); - // 测试 name 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setName("土豆"))); - // 测试 status 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 type 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setDiscountType(PromotionDiscountTypeEnum.PRICE.getType()))); - // 测试 createTime 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setCreateTime(buildTime(2022, 1, 1)))); - // 准备参数 - CouponTemplatePageReqVO reqVO = new CouponTemplatePageReqVO(); - reqVO.setName("芋艿"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2022, 2, 1), buildTime(2022, 2, 3)})); - - // 调用 - PageResult pageResult = couponTemplateService.getCouponTemplatePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbCouponTemplate, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImplTest.java deleted file mode 100644 index 95c542b67a..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImplTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.decorate; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.promotion.dal.mysql.decorate.DecorateComponentMapper; -import org.junit.jupiter.api.BeforeEach; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -// TODO @芋艿:后续 review 下 -/** - * @author jason - */ -public class DecorateComponentServiceImplTest extends BaseMockitoUnitTest { - - @InjectMocks - private DecorateComponentServiceImpl decoratePageService; - - @Mock - private DecorateComponentMapper decorateComponentMapper; - - @BeforeEach - public void init(){ - - } - -// @Test -// void testResp(){ -// List list = new ArrayList<>(1); -// DecorateComponentDO decorateDO = new DecorateComponentDO() -// .setPage(INDEX.getPage()).setValue("") -// .setCode(ROLLING_NEWS.getCode()).setId(1L); -// list.add(decorateDO); -// //mock 方法 -// Mockito.when(decorateComponentMapper.selectListByPageAndStatus(eq(1))).thenReturn(list); -// } -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImplTest.java deleted file mode 100755 index 5b4292e28e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImplTest.java +++ /dev/null @@ -1,211 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.discount; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountProductMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DISCOUNT_ACTIVITY_NOT_EXISTS; -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link DiscountActivityServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(DiscountActivityServiceImpl.class) -public class DiscountActivityServiceImplTest extends BaseDbUnitTest { - - @Resource - private DiscountActivityServiceImpl discountActivityService; - - @Resource - private DiscountActivityMapper discountActivityMapper; - @Resource - private DiscountProductMapper discountProductMapper; - - @Test - public void testCreateDiscountActivity_success() { - // 准备参数 - DiscountActivityCreateReqVO reqVO = randomPojo(DiscountActivityCreateReqVO.class, o -> { - // 用于触发进行中的状态 - o.setStartTime(addTime(Duration.ofDays(1))).setEndTime(addTime(Duration.ofDays(2))); - // 设置商品 - o.setProducts(asList(new DiscountActivityBaseVO.Product().setSpuId(1L).setSkuId(2L) - .setDiscountType(PromotionDiscountTypeEnum.PRICE.getType()).setDiscountPrice(3), - new DiscountActivityBaseVO.Product().setSpuId(10L).setSkuId(20L) - .setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()).setDiscountPercent(30))); - }); - - // 调用 - Long discountActivityId = discountActivityService.createDiscountActivity(reqVO); - // 断言 - assertNotNull(discountActivityId); - // 校验活动 - DiscountActivityDO discountActivity = discountActivityMapper.selectById(discountActivityId); - assertPojoEquals(reqVO, discountActivity); - assertEquals(discountActivity.getStatus(), PromotionActivityStatusEnum.WAIT.getStatus()); - // 校验商品 - List discountProducts = discountProductMapper.selectList(DiscountProductDO::getActivityId, discountActivity.getId()); - assertEquals(discountProducts.size(), reqVO.getProducts().size()); - for (int i = 0; i < reqVO.getProducts().size(); i++) { - DiscountActivityBaseVO.Product product = reqVO.getProducts().get(i); - DiscountProductDO discountProduct = discountProducts.get(i); - assertEquals(discountProduct.getActivityId(), discountActivity.getId()); - assertEquals(discountProduct.getSpuId(), product.getSpuId()); - assertEquals(discountProduct.getSkuId(), product.getSkuId()); - assertEquals(discountProduct.getDiscountType(), product.getDiscountType()); - assertEquals(discountProduct.getDiscountPrice(), product.getDiscountPrice()); - assertEquals(discountProduct.getDiscountPercent(), product.getDiscountPercent()); - } - } - - @Test - public void testUpdateDiscountActivity_success() { - // mock 数据(商品) - DiscountActivityDO dbDiscountActivity = randomPojo(DiscountActivityDO.class); - discountActivityMapper.insert(dbDiscountActivity);// @Sql: 先插入出一条存在的数据 - // mock 数据(活动) - DiscountProductDO dbDiscountProduct01 = randomPojo(DiscountProductDO.class, o -> o.setActivityId(dbDiscountActivity.getId()) - .setSpuId(1L).setSkuId(2L).setDiscountType(PromotionDiscountTypeEnum.PRICE.getType()).setDiscountPrice(3).setDiscountPercent(null)); - DiscountProductDO dbDiscountProduct02 = randomPojo(DiscountProductDO.class, o -> o.setActivityId(dbDiscountActivity.getId()) - .setSpuId(10L).setSkuId(20L).setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()).setDiscountPercent(30).setDiscountPrice(null)); - discountProductMapper.insert(dbDiscountProduct01); - discountProductMapper.insert(dbDiscountProduct02); - // 准备参数 - DiscountActivityUpdateReqVO reqVO = randomPojo(DiscountActivityUpdateReqVO.class, o -> { - o.setId(dbDiscountActivity.getId()); // 设置更新的 ID - // 用于触发进行中的状态 - o.setStartTime(addTime(Duration.ofDays(1))).setEndTime(addTime(Duration.ofDays(2))); - // 设置商品 - o.setProducts(asList(new DiscountActivityBaseVO.Product().setSpuId(1L).setSkuId(2L) - .setDiscountType(PromotionDiscountTypeEnum.PRICE.getType()).setDiscountPrice(3).setDiscountPercent(null), - new DiscountActivityBaseVO.Product().setSpuId(100L).setSkuId(200L) - .setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()).setDiscountPercent(30).setDiscountPrice(null))); - }); - - // 调用 - discountActivityService.updateDiscountActivity(reqVO); - // 校验活动 - DiscountActivityDO discountActivity = discountActivityMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, discountActivity); - assertEquals(discountActivity.getStatus(), PromotionActivityStatusEnum.WAIT.getStatus()); - // 校验商品 - List discountProducts = discountProductMapper.selectList(DiscountProductDO::getActivityId, discountActivity.getId()); - assertEquals(discountProducts.size(), reqVO.getProducts().size()); - for (int i = 0; i < reqVO.getProducts().size(); i++) { - DiscountActivityBaseVO.Product product = reqVO.getProducts().get(i); - DiscountProductDO discountProduct = discountProducts.get(i); - assertEquals(discountProduct.getActivityId(), discountActivity.getId()); - assertEquals(discountProduct.getSpuId(), product.getSpuId()); - assertEquals(discountProduct.getSkuId(), product.getSkuId()); - assertEquals(discountProduct.getDiscountType(), product.getDiscountType()); - assertEquals(discountProduct.getDiscountPrice(), product.getDiscountPrice()); - assertEquals(discountProduct.getDiscountPercent(), product.getDiscountPercent()); - } - } - - @Test - public void testCloseDiscountActivity() { - // mock 数据 - DiscountActivityDO dbDiscountActivity = randomPojo(DiscountActivityDO.class, - o -> o.setStatus(PromotionActivityStatusEnum.WAIT.getStatus())); - discountActivityMapper.insert(dbDiscountActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDiscountActivity.getId(); - - // 调用 - discountActivityService.closeDiscountActivity(id); - // 校验状态 - DiscountActivityDO discountActivity = discountActivityMapper.selectById(id); - assertEquals(discountActivity.getStatus(), PromotionActivityStatusEnum.CLOSE.getStatus()); - } - - @Test - public void testUpdateDiscountActivity_notExists() { - // 准备参数 - DiscountActivityUpdateReqVO reqVO = randomPojo(DiscountActivityUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> discountActivityService.updateDiscountActivity(reqVO), DISCOUNT_ACTIVITY_NOT_EXISTS); - } - - @Test - public void testDeleteDiscountActivity_success() { - // mock 数据 - DiscountActivityDO dbDiscountActivity = randomPojo(DiscountActivityDO.class, - o -> o.setStatus(PromotionActivityStatusEnum.CLOSE.getStatus())); - discountActivityMapper.insert(dbDiscountActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDiscountActivity.getId(); - - // 调用 - discountActivityService.deleteDiscountActivity(id); - // 校验数据不存在了 - assertNull(discountActivityMapper.selectById(id)); - } - - @Test - public void testDeleteDiscountActivity_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> discountActivityService.deleteDiscountActivity(id), DISCOUNT_ACTIVITY_NOT_EXISTS); - } - - @Test - public void testGetDiscountActivityPage() { - // mock 数据 - DiscountActivityDO dbDiscountActivity = randomPojo(DiscountActivityDO.class, o -> { // 等会查询到 - o.setName("芋艿"); - o.setStatus(PromotionActivityStatusEnum.WAIT.getStatus()); - o.setCreateTime(buildTime(2021, 1, 15)); - }); - discountActivityMapper.insert(dbDiscountActivity); - // 测试 name 不匹配 - discountActivityMapper.insert(cloneIgnoreId(dbDiscountActivity, o -> o.setName("土豆"))); - // 测试 status 不匹配 - discountActivityMapper.insert(cloneIgnoreId(dbDiscountActivity, o -> o.setStatus(PromotionActivityStatusEnum.END.getStatus()))); - // 测试 createTime 不匹配 - discountActivityMapper.insert(cloneIgnoreId(dbDiscountActivity, o -> o.setCreateTime(buildTime(2021, 2, 10)))); - // 准备参数 - DiscountActivityPageReqVO reqVO = new DiscountActivityPageReqVO(); - reqVO.setName("芋艿"); - reqVO.setStatus(PromotionActivityStatusEnum.WAIT.getStatus()); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 1, 1), buildTime(2021, 1, 31)})); - - // 调用 - PageResult pageResult = discountActivityService.getDiscountActivityPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbDiscountActivity, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImplTest.java deleted file mode 100644 index 52c9e92acc..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImplTest.java +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyPageMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_PAGE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link DiyPageServiceImpl} 的单元测试类 - * - * @author owen - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(DiyPageServiceImpl.class) -public class DiyPageServiceImplTest extends BaseDbUnitTest { - - @Resource - private DiyPageServiceImpl diyPageService; - - @Resource - private DiyPageMapper diyPageMapper; - - @Test - public void testCreateDiyPage_success() { - // 准备参数 - DiyPageCreateReqVO reqVO = randomPojo(DiyPageCreateReqVO.class); - - // 调用 - Long diyPageId = diyPageService.createDiyPage(reqVO); - // 断言 - assertNotNull(diyPageId); - // 校验记录的属性是否正确 - DiyPageDO diyPage = diyPageMapper.selectById(diyPageId); - assertPojoEquals(reqVO, diyPage); - } - - @Test - public void testUpdateDiyPage_success() { - // mock 数据 - DiyPageDO dbDiyPage = randomPojo(DiyPageDO.class); - diyPageMapper.insert(dbDiyPage);// @Sql: 先插入出一条存在的数据 - // 准备参数 - DiyPageUpdateReqVO reqVO = randomPojo(DiyPageUpdateReqVO.class, o -> { - o.setId(dbDiyPage.getId()); // 设置更新的 ID - }); - - // 调用 - diyPageService.updateDiyPage(reqVO); - // 校验是否更新正确 - DiyPageDO diyPage = diyPageMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, diyPage); - } - - @Test - public void testUpdateDiyPage_notExists() { - // 准备参数 - DiyPageUpdateReqVO reqVO = randomPojo(DiyPageUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> diyPageService.updateDiyPage(reqVO), DIY_PAGE_NOT_EXISTS); - } - - @Test - public void testDeleteDiyPage_success() { - // mock 数据 - DiyPageDO dbDiyPage = randomPojo(DiyPageDO.class); - diyPageMapper.insert(dbDiyPage);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDiyPage.getId(); - - // 调用 - diyPageService.deleteDiyPage(id); - // 校验数据不存在了 - assertNull(diyPageMapper.selectById(id)); - } - - @Test - public void testDeleteDiyPage_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> diyPageService.deleteDiyPage(id), DIY_PAGE_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetDiyPagePage() { - // mock 数据 - DiyPageDO dbDiyPage = randomPojo(DiyPageDO.class, o -> { // 等会查询到 - o.setName(null); - o.setCreateTime(null); - }); - diyPageMapper.insert(dbDiyPage); - // 测试 name 不匹配 - diyPageMapper.insert(cloneIgnoreId(dbDiyPage, o -> o.setName(null))); - // 测试 createTime 不匹配 - diyPageMapper.insert(cloneIgnoreId(dbDiyPage, o -> o.setCreateTime(null))); - // 准备参数 - DiyPagePageReqVO reqVO = new DiyPagePageReqVO(); - reqVO.setName(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = diyPageService.getDiyPagePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbDiyPage, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImplTest.java deleted file mode 100644 index c9c6d0bdcc..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImplTest.java +++ /dev/null @@ -1,176 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_TEMPLATE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link DiyTemplateServiceImpl} 的单元测试类 - * - * @author owen - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(DiyTemplateServiceImpl.class) -public class DiyTemplateServiceImplTest extends BaseDbUnitTest { - - @Resource - private DiyTemplateServiceImpl diyTemplateService; - - @Resource - private DiyTemplateMapper diyTemplateMapper; - - @Test - public void testCreateDiyTemplate_success() { - // 准备参数 - DiyTemplateCreateReqVO reqVO = randomPojo(DiyTemplateCreateReqVO.class); - - // 调用 - Long diyTemplateId = diyTemplateService.createDiyTemplate(reqVO); - // 断言 - assertNotNull(diyTemplateId); - // 校验记录的属性是否正确 - DiyTemplateDO diyTemplate = diyTemplateMapper.selectById(diyTemplateId); - assertPojoEquals(reqVO, diyTemplate); - } - - @Test - public void testUpdateDiyTemplate_success() { - // mock 数据 - DiyTemplateDO dbDiyTemplate = randomPojo(DiyTemplateDO.class); - diyTemplateMapper.insert(dbDiyTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - DiyTemplateUpdateReqVO reqVO = randomPojo(DiyTemplateUpdateReqVO.class, o -> { - o.setId(dbDiyTemplate.getId()); // 设置更新的 ID - }); - - // 调用 - diyTemplateService.updateDiyTemplate(reqVO); - // 校验是否更新正确 - DiyTemplateDO diyTemplate = diyTemplateMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, diyTemplate); - } - - @Test - public void testUpdateDiyTemplate_notExists() { - // 准备参数 - DiyTemplateUpdateReqVO reqVO = randomPojo(DiyTemplateUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> diyTemplateService.updateDiyTemplate(reqVO), DIY_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testDeleteDiyTemplate_success() { - // mock 数据 - DiyTemplateDO dbDiyTemplate = randomPojo(DiyTemplateDO.class); - diyTemplateMapper.insert(dbDiyTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDiyTemplate.getId(); - - // 调用 - diyTemplateService.deleteDiyTemplate(id); - // 校验数据不存在了 - assertNull(diyTemplateMapper.selectById(id)); - } - - @Test - public void testDeleteDiyTemplate_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> diyTemplateService.deleteDiyTemplate(id), DIY_TEMPLATE_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetDiyTemplatePage() { - // mock 数据 - DiyTemplateDO dbDiyTemplate = randomPojo(DiyTemplateDO.class, o -> { // 等会查询到 - o.setName(null); - o.setUsed(null); - o.setUsedTime(null); - o.setRemark(null); - o.setPreviewImageUrls(null); - o.setProperty(null); - o.setCreateTime(null); - }); - diyTemplateMapper.insert(dbDiyTemplate); - // 测试 name 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setName(null))); - // 测试 used 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsed(null))); - // 测试 usedTime 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null))); - // 测试 remark 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setRemark(null))); - // 测试 previewImageUrls 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setPreviewImageUrls(null))); - // 测试 property 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null))); - // 测试 createTime 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setCreateTime(null))); - // 准备参数 - DiyTemplatePageReqVO reqVO = new DiyTemplatePageReqVO(); - reqVO.setName(null); - reqVO.setUsed(null); - reqVO.setUsedTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = diyTemplateService.getDiyTemplatePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbDiyTemplate, pageResult.getList().get(0)); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetDiyTemplateList() { - // mock 数据 - DiyTemplateDO dbDiyTemplate = randomPojo(DiyTemplateDO.class, o -> { // 等会查询到 - o.setName(null); - o.setUsed(null); - o.setUsedTime(null); - o.setRemark(null); - o.setPreviewImageUrls(null); - o.setProperty(null); - o.setCreateTime(null); - }); - diyTemplateMapper.insert(dbDiyTemplate); - // 测试 name 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setName(null))); - // 测试 used 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsed(null))); - // 测试 usedTime 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setUsedTime(null))); - // 测试 remark 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setRemark(null))); - // 测试 previewImageUrls 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setPreviewImageUrls(null))); - // 测试 property 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setProperty(null))); - // 测试 createTime 不匹配 - diyTemplateMapper.insert(cloneIgnoreId(dbDiyTemplate, o -> o.setCreateTime(null))); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImplTest.java deleted file mode 100755 index f2297abf6d..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImplTest.java +++ /dev/null @@ -1,219 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.reward; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.reward.RewardActivityMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.util.Set; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.REWARD_ACTIVITY_NOT_EXISTS; -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link RewardActivityServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(RewardActivityServiceImpl.class) -public class RewardActivityServiceImplTest extends BaseDbUnitTest { - - @Resource - private RewardActivityServiceImpl rewardActivityService; - - @Resource - private RewardActivityMapper rewardActivityMapper; - - @Test - public void testCreateRewardActivity_success() { - // 准备参数 - RewardActivityCreateReqVO reqVO = randomPojo(RewardActivityCreateReqVO.class, o -> { - o.setConditionType(randomEle(PromotionConditionTypeEnum.values()).getType()); - o.setProductScope(randomEle(PromotionProductScopeEnum.values()).getScope()); - // 用于触发进行中的状态 - o.setStartTime(addTime(Duration.ofDays(1))).setEndTime(addTime(Duration.ofDays(2))); - }); - - // 调用 - Long rewardActivityId = rewardActivityService.createRewardActivity(reqVO); - // 断言 - assertNotNull(rewardActivityId); - // 校验记录的属性是否正确 - RewardActivityDO rewardActivity = rewardActivityMapper.selectById(rewardActivityId); - assertPojoEquals(reqVO, rewardActivity, "rules"); - assertEquals(rewardActivity.getStatus(), PromotionActivityStatusEnum.WAIT.getStatus()); - for (int i = 0; i < reqVO.getRules().size(); i++) { - assertPojoEquals(reqVO.getRules().get(i), rewardActivity.getRules().get(i)); - } - } - - @Test - public void testUpdateRewardActivity_success() { - // mock 数据 - RewardActivityDO dbRewardActivity = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.WAIT.getStatus())); - rewardActivityMapper.insert(dbRewardActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - RewardActivityUpdateReqVO reqVO = randomPojo(RewardActivityUpdateReqVO.class, o -> { - o.setId(dbRewardActivity.getId()); // 设置更新的 ID - o.setConditionType(randomEle(PromotionConditionTypeEnum.values()).getType()); - o.setProductScope(randomEle(PromotionProductScopeEnum.values()).getScope()); - // 用于触发进行中的状态 - o.setStartTime(addTime(Duration.ofDays(1))).setEndTime(addTime(Duration.ofDays(2))); - }); - - // 调用 - rewardActivityService.updateRewardActivity(reqVO); - // 校验是否更新正确 - RewardActivityDO rewardActivity = rewardActivityMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, rewardActivity, "rules"); - assertEquals(rewardActivity.getStatus(), PromotionActivityStatusEnum.WAIT.getStatus()); - for (int i = 0; i < reqVO.getRules().size(); i++) { - assertPojoEquals(reqVO.getRules().get(i), rewardActivity.getRules().get(i)); - } - } - - @Test - public void testCloseRewardActivity() { - // mock 数据 - RewardActivityDO dbRewardActivity = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.WAIT.getStatus())); - rewardActivityMapper.insert(dbRewardActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbRewardActivity.getId(); - - // 调用 - rewardActivityService.closeRewardActivity(id); - // 校验状态 - RewardActivityDO rewardActivity = rewardActivityMapper.selectById(id); - assertEquals(rewardActivity.getStatus(), PromotionActivityStatusEnum.CLOSE.getStatus()); - } - - @Test - public void testUpdateRewardActivity_notExists() { - // 准备参数 - RewardActivityUpdateReqVO reqVO = randomPojo(RewardActivityUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> rewardActivityService.updateRewardActivity(reqVO), REWARD_ACTIVITY_NOT_EXISTS); - } - - @Test - public void testDeleteRewardActivity_success() { - // mock 数据 - RewardActivityDO dbRewardActivity = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.CLOSE.getStatus())); - rewardActivityMapper.insert(dbRewardActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbRewardActivity.getId(); - - // 调用 - rewardActivityService.deleteRewardActivity(id); - // 校验数据不存在了 - assertNull(rewardActivityMapper.selectById(id)); - } - - @Test - public void testDeleteRewardActivity_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> rewardActivityService.deleteRewardActivity(id), REWARD_ACTIVITY_NOT_EXISTS); - } - - @Test - public void testGetRewardActivityPage() { - // mock 数据 - RewardActivityDO dbRewardActivity = randomPojo(RewardActivityDO.class, o -> { // 等会查询到 - o.setName("芋艿"); - o.setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - }); - rewardActivityMapper.insert(dbRewardActivity); - // 测试 name 不匹配 - rewardActivityMapper.insert(cloneIgnoreId(dbRewardActivity, o -> o.setName("土豆"))); - // 测试 status 不匹配 - rewardActivityMapper.insert(cloneIgnoreId(dbRewardActivity, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus()))); - // 准备参数 - RewardActivityPageReqVO reqVO = new RewardActivityPageReqVO(); - reqVO.setName("芋艿"); - reqVO.setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - - // 调用 - PageResult pageResult = rewardActivityService.getRewardActivityPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbRewardActivity, pageResult.getList().get(0), "rules"); - } - - @Test - public void testGetRewardActivities_all() { - // mock 数据 - RewardActivityDO allActivity = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus()) - .setProductScope(PromotionProductScopeEnum.ALL.getScope())); - rewardActivityMapper.insert(allActivity); - RewardActivityDO productActivity = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus()) - .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(asList(1L, 2L))); - rewardActivityMapper.insert(productActivity); - // 准备参数 - Set spuIds = asSet(1L, 2L); - - // 调用 TODO getMatchRewardActivities 没有这个方法,但是找到了 getMatchRewardActivityList - //Map> matchRewardActivities = rewardActivityService.getMatchRewardActivities(spuIds); - // 断言 - //assertEquals(matchRewardActivities.size(), 1); - //Map.Entry> next = matchRewardActivities.entrySet().iterator().next(); - //assertPojoEquals(next.getKey(), allActivity); - //assertEquals(next.getValue(), spuIds); - } - - @Test - public void testGetRewardActivities_product() { - // mock 数据 - RewardActivityDO productActivity01 = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus()) - .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(asList(1L, 2L))); - rewardActivityMapper.insert(productActivity01); - RewardActivityDO productActivity02 = randomPojo(RewardActivityDO.class, o -> o.setStatus(PromotionActivityStatusEnum.RUN.getStatus()) - .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(singletonList(3L))); - rewardActivityMapper.insert(productActivity02); - // 准备参数 - Set spuIds = asSet(1L, 2L, 3L); - - // 调用 TODO getMatchRewardActivities 没有这个方法,但是找到了 getMatchRewardActivityList - //Map> matchRewardActivities = rewardActivityService.getMatchRewardActivities(spuIds); - // 断言 - //assertEquals(matchRewardActivities.size(), 2); - //matchRewardActivities.forEach((activity, activitySpuIds) -> { - // if (activity.getId().equals(productActivity01.getId())) { - // assertPojoEquals(activity, productActivity01); - // assertEquals(activitySpuIds, asSet(1L, 2L)); - // } else if (activity.getId().equals(productActivity02.getId())) { - // assertPojoEquals(activity, productActivity02); - // assertEquals(activitySpuIds, asSet(3L)); - // } else { - // fail(); - // } - //}); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillactivity/SeckillActivityServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillactivity/SeckillActivityServiceImplTest.java deleted file mode 100644 index ad837f508f..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillactivity/SeckillActivityServiceImplTest.java +++ /dev/null @@ -1,171 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckillactivity; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityServiceImpl; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL_ACTIVITY_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link SeckillActivityServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Import(SeckillActivityServiceImpl.class) -@Disabled // TODO 芋艿:未来开启 -public class SeckillActivityServiceImplTest extends BaseDbUnitTest { - - @Resource - private SeckillActivityServiceImpl seckillActivityService; - - @Resource - private SeckillActivityMapper seckillActivityMapper; - - @Test - public void testCreateSeckillActivity_success() { - // 准备参数 - SeckillActivityCreateReqVO reqVO = randomPojo(SeckillActivityCreateReqVO.class); - - // 调用 - Long seckillActivityId = seckillActivityService.createSeckillActivity(reqVO); - // 断言 - assertNotNull(seckillActivityId); - // 校验记录的属性是否正确 - SeckillActivityDO seckillActivity = seckillActivityMapper.selectById(seckillActivityId); - assertPojoEquals(reqVO, seckillActivity); - } - - @Test - public void testUpdateSeckillActivity_success() { - // mock 数据 - SeckillActivityDO dbSeckillActivity = randomPojo(SeckillActivityDO.class); - seckillActivityMapper.insert(dbSeckillActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - SeckillActivityUpdateReqVO reqVO = randomPojo(SeckillActivityUpdateReqVO.class, o -> { - o.setId(dbSeckillActivity.getId()); // 设置更新的 ID - }); - - // 调用 - seckillActivityService.updateSeckillActivity(reqVO); - // 校验是否更新正确 - SeckillActivityDO seckillActivity = seckillActivityMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, seckillActivity); - } - - @Test - public void testUpdateSeckillActivity_notExists() { - // 准备参数 - SeckillActivityUpdateReqVO reqVO = randomPojo(SeckillActivityUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> seckillActivityService.updateSeckillActivity(reqVO), SECKILL_ACTIVITY_NOT_EXISTS); - } - - @Test - public void testDeleteSeckillActivity_success() { - // mock 数据 - SeckillActivityDO dbSeckillActivity = randomPojo(SeckillActivityDO.class); - seckillActivityMapper.insert(dbSeckillActivity);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSeckillActivity.getId(); - - // 调用 - seckillActivityService.deleteSeckillActivity(id); - // 校验数据不存在了 - assertNull(seckillActivityMapper.selectById(id)); - } - - @Test - public void testDeleteSeckillActivity_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> seckillActivityService.deleteSeckillActivity(id), SECKILL_ACTIVITY_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetSeckillActivityPage() { - // mock 数据 - SeckillActivityDO dbSeckillActivity = randomPojo(SeckillActivityDO.class, o -> { // 等会查询到 - o.setName(null); - o.setStatus(null); - o.setConfigIds(null); - o.setCreateTime(null); - }); - seckillActivityMapper.insert(dbSeckillActivity); - // 测试 name 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setName(null))); - // 测试 status 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setStatus(null))); - // 测试 timeId 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setConfigIds(null))); - // 测试 createTime 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setCreateTime(null))); - // 准备参数 - SeckillActivityPageReqVO reqVO = new SeckillActivityPageReqVO(); - reqVO.setName(null); - reqVO.setStatus(null); - reqVO.setConfigId(null); - reqVO.setCreateTime((new LocalDateTime[]{})); - - // 调用 - PageResult pageResult = seckillActivityService.getSeckillActivityPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSeckillActivity, pageResult.getList().get(0)); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetSeckillActivityList() { - // mock 数据 - SeckillActivityDO dbSeckillActivity = randomPojo(SeckillActivityDO.class, o -> { // 等会查询到 - o.setName(null); - o.setStatus(null); - o.setConfigIds(null); - o.setCreateTime(null); - }); - seckillActivityMapper.insert(dbSeckillActivity); - // 测试 name 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setName(null))); - // 测试 status 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setStatus(null))); - // 测试 timeId 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setConfigIds(null))); - // 测试 createTime 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setCreateTime(null))); - // 准备参数 -// SeckillActivityExportReqVO reqVO = new SeckillActivityExportReqVO(); -// reqVO.setName(null); -// reqVO.setStatus(null); -// reqVO.setTimeId(null); -// reqVO.setCreateTime((new Date[]{})); -// -// // 调用 -// List list = seckillActivityService.getSeckillActivityList(reqVO); -// // 断言 -// assertEquals(1, list.size()); -// assertPojoEquals(dbSeckillActivity, list.get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillconfig/SeckillConfigServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillconfig/SeckillConfigServiceImplTest.java deleted file mode 100644 index 3b422b5c39..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillconfig/SeckillConfigServiceImplTest.java +++ /dev/null @@ -1,190 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckillconfig; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillconfig.SeckillConfigMapper; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigServiceImpl; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL_CONFIG_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; - -/** - * {@link SeckillConfigServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(SeckillConfigServiceImpl.class) -@Disabled // TODO 芋艿:未来开启;后续要 review 下 -public class SeckillConfigServiceImplTest extends BaseDbUnitTest { - - @Resource - private SeckillConfigServiceImpl SeckillConfigService; - - @Resource - private SeckillConfigMapper seckillConfigMapper; - - @Resource - private ObjectMapper objectMapper; - - @Test - public void testJacksonSerializ() { - - // 准备参数 - SeckillConfigCreateReqVO reqVO = randomPojo(SeckillConfigCreateReqVO.class); -// ObjectMapper objectMapper = new ObjectMapper(); - try { - String string = objectMapper.writeValueAsString(reqVO); - System.out.println(string); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - - - } - - @Test - public void testCreateSeckillConfig_success() { - // 准备参数 - SeckillConfigCreateReqVO reqVO = randomPojo(SeckillConfigCreateReqVO.class); - - // 调用 - Long SeckillConfigId = SeckillConfigService.createSeckillConfig(reqVO); - // 断言 - assertNotNull(SeckillConfigId); - // 校验记录的属性是否正确 - SeckillConfigDO SeckillConfig = seckillConfigMapper.selectById(SeckillConfigId); - assertPojoEquals(reqVO, SeckillConfig); - } - - @Test - public void testUpdateSeckillConfig_success() { - // mock 数据 - SeckillConfigDO dbSeckillConfig = randomPojo(SeckillConfigDO.class); - seckillConfigMapper.insert(dbSeckillConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - SeckillConfigUpdateReqVO reqVO = randomPojo(SeckillConfigUpdateReqVO.class, o -> { - o.setId(dbSeckillConfig.getId()); // 设置更新的 ID - }); - - // 调用 - SeckillConfigService.updateSeckillConfig(reqVO); - // 校验是否更新正确 - SeckillConfigDO SeckillConfig = seckillConfigMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, SeckillConfig); - } - - @Test - public void testUpdateSeckillConfig_notExists() { - // 准备参数 - SeckillConfigUpdateReqVO reqVO = randomPojo(SeckillConfigUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> SeckillConfigService.updateSeckillConfig(reqVO), SECKILL_CONFIG_NOT_EXISTS); - } - - @Test - public void testDeleteSeckillConfig_success() { - // mock 数据 - SeckillConfigDO dbSeckillConfig = randomPojo(SeckillConfigDO.class); - seckillConfigMapper.insert(dbSeckillConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSeckillConfig.getId(); - - // 调用 - SeckillConfigService.deleteSeckillConfig(id); - // 校验数据不存在了 - assertNull(seckillConfigMapper.selectById(id)); - } - - @Test - public void testDeleteSeckillConfig_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> SeckillConfigService.deleteSeckillConfig(id), SECKILL_CONFIG_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetSeckillConfigPage() { - // mock 数据 -// SeckillConfigDO dbSeckillConfig = randomPojo(SeckillConfigDO.class, o -> { // 等会查询到 -// o.setName(null); -// o.setStartTime(null); -// o.setEndTime(null); -// o.setCreateTime(null); -// }); -// seckillConfigMapper.insert(dbSeckillConfig); -// // 测试 name 不匹配 -// seckillConfigMapper.insert(cloneIgnoreId(dbSeckillConfig, o -> o.setName(null))); -// // 测试 startTime 不匹配 -// seckillConfigMapper.insert(cloneIgnoreId(dbSeckillConfig, o -> o.setStartTime(null))); -// // 测试 endTime 不匹配 -// seckillConfigMapper.insert(cloneIgnoreId(dbSeckillConfig, o -> o.setEndTime(null))); -// // 测试 createTime 不匹配 -// seckillConfigMapper.insert(cloneIgnoreId(dbSeckillConfig, o -> o.setCreateTime(null))); -// // 准备参数 -// SeckillConfigPageReqVO reqVO = new SeckillConfigPageReqVO(); -// reqVO.setName(null); -//// reqVO.setStartTime((new LocalTime())); -//// reqVO.setEndTime((new LocalTime[]{})); -//// reqVO.setCreateTime((new Date[]{})); -// -// // 调用 -// PageResult pageResult = SeckillConfigService.getSeckillConfigPage(reqVO); -// // 断言 -// assertEquals(1, pageResult.getTotal()); -// assertEquals(1, pageResult.getList().size()); -// assertPojoEquals(dbSeckillConfig, pageResult.getList().get(0)); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetSeckillConfigList() { - // mock 数据 - SeckillConfigDO dbSeckillConfig = randomPojo(SeckillConfigDO.class, o -> { // 等会查询到 - o.setName(null); - o.setStartTime(null); - o.setEndTime(null); - o.setCreateTime(null); - }); - seckillConfigMapper.insert(dbSeckillConfig); - // 测试 name 不匹配 - seckillConfigMapper.insert(cloneIgnoreId(dbSeckillConfig, o -> o.setName(null))); - // 测试 startTime 不匹配 - seckillConfigMapper.insert(cloneIgnoreId(dbSeckillConfig, o -> o.setStartTime(null))); - // 测试 endTime 不匹配 - seckillConfigMapper.insert(cloneIgnoreId(dbSeckillConfig, o -> o.setEndTime(null))); - // 测试 createTime 不匹配 - seckillConfigMapper.insert(cloneIgnoreId(dbSeckillConfig, o -> o.setCreateTime(null))); - // 准备参数 -// SeckillConfigExportReqVO reqVO = new SeckillConfigExportReqVO(); -// reqVO.setName(null); -// reqVO.setStartTime((new LocalTime[]{})); -// reqVO.setEndTime((new LocalTime[]{})); -// reqVO.setCreateTime((new Date[]{})); -// -// // 调用 -// List list = SeckillConfigService.getSeckillConfigList(reqVO); -// // 断言 -// assertEquals(1, list.size()); -// assertPojoEquals(dbSeckillConfig, list.get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 7b76570fd8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,50 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/logback.xml b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff0..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index 6a1a24252e..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,12 +0,0 @@ -DELETE FROM "market_activity"; -DELETE FROM "promotion_coupon_template"; -DELETE FROM "promotion_coupon"; -DELETE FROM "promotion_reward_activity"; -DELETE FROM "promotion_discount_activity"; -DELETE FROM "promotion_discount_product"; -DELETE FROM "promotion_seckill_config"; -DELETE FROM "promotion_combination_activity"; -DELETE FROM "promotion_article_category"; -DELETE FROM "promotion_article"; -DELETE FROM "promotion_diy_template"; -DELETE FROM "promotion_diy_page"; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index dc651301c8..0000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,256 +0,0 @@ -CREATE TABLE IF NOT EXISTS "market_activity" -( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "title" varchar(50) NOT NULL, - "activity_type" tinyint(4) NOT NULL, - "status" tinyint(4) NOT NULL, - "start_time" datetime NOT NULL, - "end_time" datetime NOT NULL, - "invalid_time" datetime, - "delete_time" datetime, - "time_limited_discount" varchar(2000), - "full_privilege" varchar(2000), - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint(20) NOT NULL, - PRIMARY KEY ("id") -) COMMENT '促销活动'; - -CREATE TABLE IF NOT EXISTS "promotion_coupon_template" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "total_count" int NOT NULL, - "take_limit_count" int NOT NULL, - "take_type" int NOT NULL, - "use_price" int NOT NULL, - "product_scope" int NOT NULL, - "product_spu_ids" varchar, - "validity_type" int NOT NULL, - "valid_start_time" datetime, - "valid_end_time" datetime, - "fixed_start_term" int, - "fixed_end_term" int, - "discount_type" int NOT NULL, - "discount_percent" int, - "discount_price" int, - "discount_limit_price" int, - "take_count" int NOT NULL DEFAULT 0, - "use_count" int NOT NULL DEFAULT 0, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '优惠劵模板'; - -CREATE TABLE IF NOT EXISTS "promotion_coupon" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "template_id" bigint NOT NULL, - "name" varchar NOT NULL, - "status" int NOT NULL, - "user_id" bigint NOT NULL, - "take_type" int NOT NULL, - "useprice" int NOT NULL, - "valid_start_time" datetime NOT NULL, - "valid_end_time" datetime NOT NULL, - "product_scope" int NOT NULL, - "product_spu_ids" varchar, - "discount_type" int NOT NULL, - "discount_percent" int, - "discount_price" int, - "discount_limit_price" int, - "use_order_id" bigint, - "use_time" datetime, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '优惠劵'; - -CREATE TABLE IF NOT EXISTS "promotion_reward_activity" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "start_time" datetime NOT NULL, - "end_time" datetime NOT NULL, - "remark" varchar, - "condition_type" int NOT NULL, - "product_scope" int NOT NULL, - "product_spu_ids" varchar, - "rules" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '满减送活动'; - -CREATE TABLE IF NOT EXISTS "promotion_discount_activity" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "start_time" datetime NOT NULL, - "end_time" datetime NOT NULL, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '限时折扣活动'; - -CREATE TABLE IF NOT EXISTS "promotion_seckill_activity" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "spu_id" bigint NOT NULL, - "name" varchar NOT NULL, - "status" int NOT NULL, - "remark" varchar, - "start_time" varchar NOT NULL, - "end_time" varchar NOT NULL, - "sort" int NOT NULL, - "config_ids" varchar NOT NULL, - "order_count" int NOT NULL, - "user_count" int NOT NULL, - "total_price" int NOT NULL, - "total_limit_count" int, - "single_limit_count" int, - "stock" int, - "total_stock" int, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '秒杀活动'; - -CREATE TABLE IF NOT EXISTS "promotion_seckill_config" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "start_time" varchar NOT NULL, - "end_time" varchar NOT NULL, - "pic_url" varchar NOT NULL, - "status" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '秒杀时段配置'; - -CREATE TABLE IF NOT EXISTS "promotion_combination_activity" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "spu_id" bigint, - "total_limit_count" int NOT NULL, - "single_limit_count" int NOT NULL, - "start_time" varchar NOT NULL, - "end_time" varchar NOT NULL, - "user_size" int NOT NULL, - "total_num" int NOT NULL, - "success_num" int NOT NULL, - "order_user_count" int NOT NULL, - "virtual_group" int NOT NULL, - "status" int NOT NULL, - "limit_duration" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '拼团活动'; - -CREATE TABLE IF NOT EXISTS "promotion_article_category" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "pic_url" varchar, - "status" int NOT NULL, - "sort" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '文章分类表'; - -CREATE TABLE IF NOT EXISTS "promotion_article" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "category_id" bigint NOT NULL, - "title" varchar NOT NULL, - "author" varchar, - "pic_url" varchar NOT NULL, - "introduction" varchar, - "browse_count" varchar, - "sort" int NOT NULL, - "status" int NOT NULL, - "spu_id" bigint NOT NULL, - "recommend_hot" bit NOT NULL, - "recommend_banner" bit NOT NULL, - "content" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '文章管理表'; - -CREATE TABLE IF NOT EXISTS "promotion_diy_template" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "used" bit NOT NULL, - "used_time" varchar, - "remark" varchar, - "preview_image_urls" varchar, - "property" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL DEFAULT 0, - PRIMARY KEY ("id") -) COMMENT '装修模板'; -CREATE TABLE IF NOT EXISTS "promotion_diy_page" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "template_id" bigint NOT NULL, - "name" varchar NOT NULL, - "remark" varchar, - "preview_image_urls" varchar, - "property" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '装修页面'; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-api/pom.xml b/yudao-module-mall/yudao-module-statistics-api/pom.xml deleted file mode 100644 index 7c838fecc7..0000000000 --- a/yudao-module-mall/yudao-module-statistics-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-statistics-api - jar - - ${project.artifactId} - - statistics 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - diff --git a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/api/package-info.java b/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/api/package-info.java deleted file mode 100644 index 2963c120a0..0000000000 --- a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位,无特殊含义 - */ -package cn.iocoder.yudao.module.statistics.api; diff --git a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java b/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java deleted file mode 100644 index 5f3c8fe228..0000000000 --- a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.statistics.enums; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 时间范围类型的枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum TimeRangeTypeEnum implements IntArrayValuable { - - /** - * 天 - */ - DAY(1), - /** - * 周 - */ - WEEK(7), - /** - * 月 - */ - MONTH(30), - /** - * 年 - */ - YEAR(365), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TimeRangeTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/package-info.java b/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/package-info.java deleted file mode 100644 index f885ae076a..0000000000 --- a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位,无特殊含义 - */ -package cn.iocoder.yudao.module.statistics.enums; diff --git a/yudao-module-mall/yudao-module-statistics-biz/pom.xml b/yudao-module-mall/yudao-module-statistics-biz/pom.xml deleted file mode 100644 index f77037aed9..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-statistics-biz - jar - - ${project.artifactId} - - statistics 模块,主要实现统计相关功能 - 例如:统计商品、会员、交易等功能。 - - - - - cn.iocoder.boot - yudao-module-statistics-api - ${revision} - - - cn.iocoder.boot - yudao-module-promotion-api - ${revision} - - - cn.iocoder.boot - yudao-module-product-api - ${revision} - - - cn.iocoder.boot - yudao-module-trade-api - ${revision} - - - cn.iocoder.boot - yudao-module-member-api - ${revision} - - - cn.iocoder.boot - yudao-module-pay-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-tenant - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-ip - - - - - cn.iocoder.boot - yudao-spring-boot-starter-web - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - - - - - cn.iocoder.boot - yudao-spring-boot-starter-excel - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-dict - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/common/vo/DataComparisonRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/common/vo/DataComparisonRespVO.java deleted file mode 100644 index efd889a87a..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/common/vo/DataComparisonRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.common.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - 数据对照 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DataComparisonRespVO { - - @Schema(description = "当前数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private T value; - - @Schema(description = "参照数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private T reference; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java deleted file mode 100644 index ec21926083..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java +++ /dev/null @@ -1,121 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member; - -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.NumberUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; -import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; -import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService; -import cn.iocoder.yudao.module.statistics.service.member.MemberStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员统计") -@RestController -@RequestMapping("/statistics/member") -@Validated -@Slf4j -public class MemberStatisticsController { - - @Resource - private MemberStatisticsService memberStatisticsService; - @Resource - private TradeOrderStatisticsService tradeOrderStatisticsService; - @Resource - private ApiAccessLogStatisticsService apiAccessLogStatisticsService; - - // TODO 芋艿:已经 review - @GetMapping("/summary") - @Operation(summary = "获得会员统计(实时统计)") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult getMemberSummary() { - return success(memberStatisticsService.getMemberSummary()); - } - - // TODO 芋艿:已经 review - @GetMapping("/analyse") - @Operation(summary = "获得会员分析数据") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult getMemberAnalyse(MemberAnalyseReqVO reqVO) { - // 1. 查询数据 - LocalDateTime beginTime = ArrayUtil.get(reqVO.getTimes(), 0); - LocalDateTime endTime = ArrayUtil.get(reqVO.getTimes(), 1); - // 1.1 查询分析对照数据 - DataComparisonRespVO comparisonData = memberStatisticsService.getMemberAnalyseComparisonData(beginTime, endTime); - // TODO @疯狂:这个可能有点特殊,要按照 create_time 来查询;不然它的漏斗就不统一;因为是访问数量 > 今日下单人 > 今日支付人;是一个统一的维度; - // 1.2 查询成交用户数量 - Integer payUserCount = tradeOrderStatisticsService.getPayUserCount(beginTime, endTime); - // 1.3 计算客单价 - int atv = 0; - if (payUserCount != null && payUserCount > 0) { - // TODO @疯狂:类似上面的 payUserCount - Integer payPrice = tradeOrderStatisticsService.getOrderPayPrice(beginTime, endTime); - atv = NumberUtil.div(payPrice, payUserCount).intValue(); - } - // 1.4 查询访客数量 - Integer visitUserCount = apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime); - // 1.5 下单用户数量 - Integer orderUserCount = tradeOrderStatisticsService.getOrderUserCount(beginTime, endTime); - - // 2. 拼接返回 - return success(MemberStatisticsConvert.INSTANCE.convert(visitUserCount, orderUserCount, payUserCount, atv, comparisonData)); - } - - // TODO 芋艿:已经 review - @GetMapping("/area-statistics-list") - @Operation(summary = "按照省份,获得会员统计列表") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getMemberAreaStatisticsList() { - return success(memberStatisticsService.getMemberAreaStatisticsList()); - } - - // TODO 芋艿:已经 review - @GetMapping("/sex-statistics-list") - @Operation(summary = "按照性别,获得会员统计列表") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getMemberSexStatisticsList() { - return success(memberStatisticsService.getMemberSexStatisticsList()); - } - - // TODO 芋艿:已经 review - @GetMapping("/terminal-statistics-list") - @Operation(summary = "按照终端,获得会员统计列表") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getMemberTerminalStatisticsList() { - return success(memberStatisticsService.getMemberTerminalStatisticsList()); - } - - // TODO 芋艿:已经 review - // TODO @疯狂:要注意 date 的排序; - @GetMapping("/user-count-comparison") - @Operation(summary = "获得用户数量对照") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getUserCountComparison() { - return success(memberStatisticsService.getUserCountComparison()); - } - - // TODO 芋艿:已经 review - @GetMapping("/register-count-list") - @Operation(summary = "获得会员注册数量列表") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getMemberRegisterCountList(MemberAnalyseReqVO reqVO) { - return success(memberStatisticsService.getMemberRegisterCountList( - ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1))); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseDataRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseDataRespVO.java deleted file mode 100644 index d2dd3e4839..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseDataRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员分析数据 Response VO") -@Data -public class MemberAnalyseDataRespVO { - - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer registerUserCount; - - @Schema(description = "活跃用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer visitUserCount; - - @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") - private Integer rechargeUserCount; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseReqVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseReqVO.java deleted file mode 100644 index e0106b4e82..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员分析 Request VO") -@Data -public class MemberAnalyseReqVO { - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "时间范围") - private LocalDateTime[] times; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseRespVO.java deleted file mode 100644 index e1c46547be..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员分析 Response VO") -@Data -public class MemberAnalyseRespVO { - - @Schema(description = "访客数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer visitUserCount; - - @Schema(description = "下单用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderUserCount; - - @Schema(description = "成交用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer payUserCount; - - @Schema(description = "客单价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer atv; - - @Schema(description = "对照数据", requiredMode = Schema.RequiredMode.REQUIRED) - private DataComparisonRespVO comparison; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java deleted file mode 100644 index 1024d04ef7..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员地区统计 Response VO") -@Data -public class MemberAreaStatisticsRespVO { - - @Schema(description = "省份编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer areaId; - @Schema(description = "省份名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "浙江省") - private String areaName; - - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer userCount; - - @Schema(description = "下单的会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderCreateUserCount; - @Schema(description = "支付订单的会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") - private Integer orderPayUserCount; - - @Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622") - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java deleted file mode 100644 index ce81658cfd..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员数量统计 Response VO") -@Data -public class MemberCountRespVO { - - @Schema(description = "用户访问量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer visitUserCount; - - @Schema(description = "注册用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer registerUserCount; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java deleted file mode 100644 index fb7fc2ac4e..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDate; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -@Schema(description = "管理后台 - 会员注册数量 Response VO") -@Data -public class MemberRegisterCountRespVO { - - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY, timezone = TIME_ZONE_DEFAULT) - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private LocalDate date; - - @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java deleted file mode 100644 index eaf7ce5f5d..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员性别统计 Response VO") -@Data -public class MemberSexStatisticsRespVO { - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sex; - - // TODO @疯狂:要不还是其它字段,我们也补全,这样方便使用的用户,做定制化;就保持和 MemberAreaStatisticsRespVO 一致; - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer userCount; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java deleted file mode 100644 index 2a55e38976..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员统计 Response VO") -@Data -public class MemberSummaryRespVO { - - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer userCount; - - @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") - private Integer rechargeUserCount; - - @Schema(description = "充值金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer rechargePrice; - - // TODO @疯狂:要不干脆这个字段改成:orderPayPrice?? - @Schema(description = "支出金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer expensePrice; // 只计算 mall 交易订单的支付金额,不考虑退款 - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java deleted file mode 100644 index 3ecf0f8fe0..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员终端统计 Response VO") -@Data -public class MemberTerminalStatisticsRespVO { - - @Schema(description = "终端", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer terminal; - - // TODO @疯狂:要不 orderCreateUserCount 和 orderPayUserCount 貌似更统一一些; - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer userCount; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java deleted file mode 100644 index 5bc29ed854..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.pay; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO; -import cn.iocoder.yudao.module.statistics.convert.pay.PayStatisticsConvert; -import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 支付统计") -@RestController -@RequestMapping("/statistics/pay") -@Validated -@Slf4j -public class PayStatisticsController { - - @Resource - private PayWalletStatisticsService payWalletStatisticsService; - - @GetMapping("/summary") - @Operation(summary = "获取充值金额") - public CommonResult getWalletRechargePrice() { - Integer rechargePrice = payWalletStatisticsService.getRechargePriceSummary(); - return success(PayStatisticsConvert.INSTANCE.convert(rechargePrice)); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java deleted file mode 100644 index 01edc24cf9..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.pay.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 支付统计 Response VO") -@Data -public class PaySummaryRespVO { - - @Schema(description = "充值金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer rechargePrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/ProductStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/ProductStatisticsController.java deleted file mode 100644 index 4e5684fb9f..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/ProductStatisticsController.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.product; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.statistics.dal.mysql.product.ProductSpuStatisticsDO; -import cn.iocoder.yudao.module.statistics.dal.mysql.product.ProductStatisticsDO; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.time.LocalDateTime; -import java.util.List; - -@Tag(name = "管理后台 - 商品统计") -@RestController -@RequestMapping("/statistics/product") -@Validated -@Slf4j -public class ProductStatisticsController { - - // TODO @麦子:返回 ProductStatisticsComparisonResp, 里面有两个字段,一个是选择的时间范围的合计结果,一个是对比的时间范围的合计结果; - // 例如说,选择时间范围是 2023-10-01 ~ 2023-10-02,那么对比就是 2023-09-30,再倒推 2 天; - public CommonResult getProductStatisticsComparison() { - return null; - } - - // TODO @麦子:查询指定时间范围内的商品统计数据;DO 到时需要改成 VO 哈 - public CommonResult> getProductStatisticsList( - LocalDateTime[] times) { - return null; - } - - // TODO @麦子:查询指定时间范围内的商品 SPU 统计数据;DO 到时需要改成 VO 哈 - // 入参是分页参数 + 时间范围 + 排序字段 - public CommonResult> getProductSpuStatisticsPage() { - return null; - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java deleted file mode 100644 index 0b304e0a34..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; -import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.AfterSaleStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.BrokerageStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 交易统计") -@RestController -@RequestMapping("/statistics/trade") -@Validated -@Slf4j -public class TradeStatisticsController { - - @Resource - private TradeStatisticsService tradeStatisticsService; - @Resource - private TradeOrderStatisticsService tradeOrderStatisticsService; - @Resource - private AfterSaleStatisticsService afterSaleStatisticsService; - @Resource - private BrokerageStatisticsService brokerageStatisticsService; - - // TODO 芋艿:已经 review - @GetMapping("/summary") - @Operation(summary = "获得交易统计") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult> getTradeSummaryComparison() { - // 1.1 昨天的数据 - TradeSummaryRespBO yesterdayData = tradeStatisticsService.getTradeSummaryByDays(-1); - // 1.2 前天的数据(用于对照昨天的数据) - TradeSummaryRespBO beforeYesterdayData = tradeStatisticsService.getTradeSummaryByDays(-2); - - // 2.1 本月数据 - TradeSummaryRespBO monthData = tradeStatisticsService.getTradeSummaryByMonths(0); - // 2.2 上月数据(用于对照本月的数据) - TradeSummaryRespBO lastMonthData = tradeStatisticsService.getTradeSummaryByMonths(-1); - // 拼接数据 - return success(TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData)); - } - - // TODO @疯狂:【晚点再改和讨论;等首页的接口出来】这个要不还是叫 analyse,对比选中的时间段,和上一个时间段;类似 MemberStatisticsController 的 getMemberAnalyse - @GetMapping("/trend/summary") - @Operation(summary = "获得交易状况统计") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult> getTradeTrendSummaryComparison( - TradeTrendReqVO reqVO) { - return success(tradeStatisticsService.getTradeTrendSummaryComparison(ArrayUtil.get(reqVO.getTimes(), 0), - ArrayUtil.get(reqVO.getTimes(), 1))); - } - - // TODO 芋艿:已经 review - @GetMapping("/list") - @Operation(summary = "获得交易状况明细") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult> getTradeStatisticsList(TradeTrendReqVO reqVO) { - List list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), - ArrayUtil.get(reqVO.getTimes(), 1)); - return success(TradeStatisticsConvert.INSTANCE.convertList(list)); - } - - // TODO 芋艿:已经 review - @GetMapping("/export-excel") - @Operation(summary = "导出获得交易状况明细 Excel") - @PreAuthorize("@ss.hasPermission('statistics:trade:export')") - public void exportTradeStatisticsExcel(TradeTrendReqVO reqVO, HttpServletResponse response) throws IOException { - List list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), - ArrayUtil.get(reqVO.getTimes(), 1)); - // 导出 Excel - List voList = TradeStatisticsConvert.INSTANCE.convertList(list); - List data = TradeStatisticsConvert.INSTANCE.convertList02(voList); - ExcelUtils.write(response, "交易状况.xls", "数据", TradeTrendSummaryExcelVO.class, data); - } - - // TODO 芋艿:已经 review - @GetMapping("/order-count") - @Operation(summary = "获得交易订单数量") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult getOrderCount() { - // 订单统计 - Long undeliveredCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType( - TradeOrderStatusEnum.UNDELIVERED.getStatus(), DeliveryTypeEnum.EXPRESS.getType()); - // TODO @疯狂:订单支付后,如果是门店自提的,需要 update 成 DELIVERED;;目前还没搞~~突然反应过来 - Long pickUpCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType( - TradeOrderStatusEnum.DELIVERED.getStatus(), DeliveryTypeEnum.PICK_UP.getType()); - // 售后统计 - Long afterSaleApplyCount = afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY); - Long auditingWithdrawCount = brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING); - // 拼接返回 - return success(TradeStatisticsConvert.INSTANCE.convert(undeliveredCount, pickUpCount, afterSaleApplyCount, auditingWithdrawCount)); - } - - // TODO 芋艿:已经 review - @GetMapping("/order-comparison") - @Operation(summary = "获得交易订单数量") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult> getOrderComparison() { - return success(tradeOrderStatisticsService.getOrderComparison()); - } - - // TODO 芋艿:已经 review - @GetMapping("/order-count-trend") - @Operation(summary = "获得订单量趋势统计") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) { - // TODO @疯狂:要注意 date 的排序; - return success(tradeOrderStatisticsService.getOrderCountTrendComparison(reqVO)); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java deleted file mode 100644 index 1320a889ec..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 交易订单数量 Response VO") -@Data -public class TradeOrderCountRespVO { - - @Schema(description = "待发货", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long undelivered; - - @Schema(description = "待核销", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long pickUp; - - @Schema(description = "退款中", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long afterSaleApply; - - @Schema(description = "提现待审核", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long auditingWithdraw; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java deleted file mode 100644 index 22d8f4a14d..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 交易订单统计 Response VO") -@Data -public class TradeOrderSummaryRespVO { - - @Schema(description = "支付订单商品数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayCount; - - @Schema(description = "总支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java deleted file mode 100644 index 563f6b6c44..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 交易订单量趋势统计 Request VO") -@Data -public class TradeOrderTrendReqVO { - - @Schema(description = "日期范围类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "日期范围类型不能为空") - @InEnum(value = TimeRangeTypeEnum.class, message = "日期范围类型,必须是 {value}") - private Integer type; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "起始时间") - private LocalDateTime beginTime; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "截止时间") - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java deleted file mode 100644 index d69c343cba..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 订单量趋势统计 Response VO") -@Data -public class TradeOrderTrendRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String date; - - @Schema(description = "订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayCount; - - @Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java deleted file mode 100644 index 5e0e7c62db..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 交易统计 Response VO") -@Data -public class TradeSummaryRespVO { - - @Schema(description = "昨日订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer yesterdayOrderCount; - @Schema(description = "昨日支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer yesterdayPayPrice; - - @Schema(description = "本月订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer monthOrderCount; - @Schema(description = "本月支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer monthPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendReqVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendReqVO.java deleted file mode 100644 index 234b7a7854..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 交易状况 Request VO") -@Data -public class TradeTrendReqVO { - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "时间范围") - private LocalDateTime[] times; -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java deleted file mode 100644 index 5b14fa1d4e..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert; -import com.alibaba.excel.annotation.ExcelProperty; -import com.alibaba.excel.annotation.format.DateTimeFormat; -import lombok.Data; - -import java.time.LocalDate; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -/** - * 交易状况统计 Excel VO - * - * @author owen - */ -@Data -public class TradeTrendSummaryExcelVO { - - @ExcelProperty(value = "日期") - @DateTimeFormat(FORMAT_YEAR_MONTH_DAY) - private LocalDate date; - - @ExcelProperty(value = "营业额", converter = MoneyConvert.class) - private Integer turnoverPrice; - - @ExcelProperty(value = "商品支付金额", converter = MoneyConvert.class) - private Integer orderPayPrice; - - @ExcelProperty(value = "充值金额", converter = MoneyConvert.class) - private Integer rechargePrice; - - @ExcelProperty(value = "支出金额", converter = MoneyConvert.class) - private Integer expensePrice; - - @ExcelProperty(value = "余额支付金额", converter = MoneyConvert.class) - private Integer walletPayPrice; - - @ExcelProperty(value = "支付佣金金额", converter = MoneyConvert.class) - private Integer brokerageSettlementPrice; - - @ExcelProperty(value = "商品退款金额", converter = MoneyConvert.class) - private Integer afterSaleRefundPrice; -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java deleted file mode 100644 index f76d02e91d..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDate; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -@Schema(description = "管理后台 - 交易状况统计 Response VO") -@Data -public class TradeTrendSummaryRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY) - private LocalDate date; - - @Schema(description = "营业额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer turnoverPrice; // 营业额 = 商品支付金额 + 充值金额 - - @Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayPrice; - - @Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer walletPayPrice; - - @Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer afterSaleRefundPrice; - - @Schema(description = "支付佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer brokerageSettlementPrice; - - @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer rechargePrice; - - @Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer expensePrice; // 余额支付金额 + 支付佣金金额 + 商品退款金额 - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/app/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/app/package-info.java deleted file mode 100644 index 1384194b43..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/app/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占位 - */ -package cn.iocoder.yudao.module.statistics.controller.app; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java deleted file mode 100644 index 2d527b0a38..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.statistics.convert.member; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseDataRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 会员统计 Convert - * - * @author owen - */ -@Mapper -public interface MemberStatisticsConvert { - - MemberStatisticsConvert INSTANCE = Mappers.getMapper(MemberStatisticsConvert.class); - - default List convertList(List areaList, - Map userCountMap, - Map orderMap) { - return CollectionUtils.convertList(areaList, area -> { - MemberAreaStatisticsRespBO orderVo = Optional.ofNullable(orderMap.get(area.getId())) - .orElseGet(MemberAreaStatisticsRespBO::new); - return new MemberAreaStatisticsRespVO() - .setAreaId(area.getId()).setAreaName(area.getName()) - .setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0)) - .setOrderCreateUserCount(ObjUtil.defaultIfNull(orderVo.getOrderCreateUserCount(), 0)) - .setOrderPayUserCount(ObjUtil.defaultIfNull(orderVo.getOrderPayUserCount(), 0)) - .setOrderPayPrice(ObjUtil.defaultIfNull(orderVo.getOrderPayPrice(), 0)); - }); - } - - MemberSummaryRespVO convert(RechargeSummaryRespBO rechargeSummary, Integer expensePrice, Integer userCount); - - MemberAnalyseRespVO convert(Integer visitUserCount, Integer orderUserCount, Integer payUserCount, int atv, - DataComparisonRespVO comparison); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java deleted file mode 100644 index 08f38005f9..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.statistics.convert.pay; - -import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 支付统计 Convert - * - * @author owen - */ -@Mapper -public interface PayStatisticsConvert { - - PayStatisticsConvert INSTANCE = Mappers.getMapper(PayStatisticsConvert.class); - - PaySummaryRespVO convert(Integer rechargePrice); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java deleted file mode 100644 index 7c140628fd..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.statistics.convert.trade; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderCountRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; -import org.mapstruct.IterableMapping; -import org.mapstruct.Mapper; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易统计 Convert - * - * @author owen - */ -@Mapper -public interface TradeStatisticsConvert { - - TradeStatisticsConvert INSTANCE = Mappers.getMapper(TradeStatisticsConvert.class); - - default DataComparisonRespVO convert(TradeSummaryRespBO yesterdayData, - TradeSummaryRespBO beforeYesterdayData, - TradeSummaryRespBO monthData, - TradeSummaryRespBO lastMonthData) { - return convert(convert(yesterdayData, monthData), convert(beforeYesterdayData, lastMonthData)); - } - - - default TradeSummaryRespVO convert(TradeSummaryRespBO yesterdayData, TradeSummaryRespBO monthData) { - return new TradeSummaryRespVO() - .setYesterdayOrderCount(yesterdayData.getCount()).setYesterdayPayPrice(yesterdayData.getSummary()) - .setMonthOrderCount(monthData.getCount()).setMonthPayPrice(monthData.getSummary()); - } - - DataComparisonRespVO convert(TradeSummaryRespVO value, TradeSummaryRespVO reference); - - DataComparisonRespVO convert(TradeTrendSummaryRespVO value, - TradeTrendSummaryRespVO reference); - - List convertList02(List list); - - TradeStatisticsDO convert(LocalDateTime time, TradeOrderSummaryRespBO orderSummary, - AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice, - WalletSummaryRespBO walletSummary); - - @IterableMapping(qualifiedByName = "convert") - List convertList(List list); - - TradeTrendSummaryRespVO convertA(TradeStatisticsDO tradeStatistics); - - @Named("convert") - default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) { - TradeTrendSummaryRespVO vo = convertA(tradeStatistics); - return vo - .setDate(tradeStatistics.getTime().toLocalDate()) - // 营业额 = 商品支付金额 + 充值金额 - .setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice()) - // 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 - .setExpensePrice(tradeStatistics.getWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()); - } - - TradeOrderCountRespVO convert(Long undelivered, Long pickUp, Long afterSaleApply, Long auditingWithdraw); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/member/MemberStatisticsDO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/member/MemberStatisticsDO.java deleted file mode 100644 index af980b5c17..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/member/MemberStatisticsDO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.dataobject.member; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 会员统计 DO - *

- * 以天为维度,统计全部的数据 - * - * @author 芋道源码 - */ -@TableName("member_statistics") -@KeySequence("member_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberStatisticsDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 统计日期 - */ - private LocalDateTime time; - - /** - * 注册用户数量 - */ - private Integer userRegisterCount; - /** - * 访问用户数量(UV) - */ - private Integer userVisitCount; - /** - * 访问页面数量(PV) - */ - private Integer pageVisitCount; - - /** - * 充值用户数量 - */ - private Integer rechargeUserCount; - - /** - * 创建订单用户数 - */ - private Integer orderCreateUserCount; - /** - * 支付订单用户数 - */ - private Integer orderPayUserCount; - /** - * 总支付金额,单位:分 - */ - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/package-info.java deleted file mode 100644 index 80eca3b41b..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 todo - */ -package cn.iocoder.yudao.module.statistics.dal.dataobject; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java deleted file mode 100644 index 46e148aa4e..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.dataobject.trade; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 交易统计 DO - *

- * 以天为维度,统计全部的数据 - * - * @author 芋道源码 - */ -@TableName("trade_statistics") -@KeySequence("trade_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeStatisticsDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 统计日期 - */ - private LocalDateTime time; - - /** - * 创建订单数 - */ - private Integer orderCreateCount; - /** - * 支付订单商品数 - */ - private Integer orderPayCount; - /** - * 总支付金额,单位:分 - */ - private Integer orderPayPrice; - - /** - * 退款订单数 - */ - private Integer afterSaleCount; - /** - * 总退款金额,单位:分 - */ - private Integer afterSaleRefundPrice; - - /** - * 佣金金额(已结算),单位:分 - */ - private Integer brokerageSettlementPrice; - - /** - * 总支付金额(余额),单位:分 - */ - private Integer walletPayPrice; - /** - * 充值订单数 - *

- * 从 PayWalletRechargeDO 计算 - */ - private Integer rechargePayCount; - /** - * 充值金额,单位:分 - */ - private Integer rechargePayPrice; - /** - * 充值退款订单数 - */ - private Integer rechargeRefundCount; - /** - * 充值退款金额,单位:分 - */ - private Integer rechargeRefundPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java deleted file mode 100644 index cf7f98a0e0..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.infra; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; - -// TODO @芋艿:api 访问日志,现在会清理,可能要单独有个偏业务的访问表; -/** - * API 访问日志的统计 Mapper - * - * @author owen - */ -@Mapper -@SuppressWarnings("rawtypes") -public interface ApiAccessLogStatisticsMapper extends BaseMapperX { - - // TODO 芋艿:已经 review - Integer selectIpCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO 芋艿:已经 review - Integer selectUserCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java deleted file mode 100644 index 1d215b8189..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.member; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberRegisterCountRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 会员信息的统计 Mapper - * - * @author owen - */ -@Mapper -@SuppressWarnings("rawtypes") -public interface MemberStatisticsMapper extends BaseMapperX { - - // TODO @芋艿:已经 review - List selectSummaryListByAreaId(); - - // TODO @芋艿:已经 review - List selectSummaryListBySex(); - - // TODO @芋艿:已经 review - List selectSummaryListByRegisterTerminal(); - - // TODO @芋艿:已经 review - Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO @芋艿:已经 review - /** - * 获得用户的每天注册数量列表 - * - * @param beginTime 开始时间 - * @param endTime 结束时间 - * @return 每天注册数量列表 - */ - List selectListByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java deleted file mode 100644 index 90ab0e0c61..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.pay; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; - -/** - * 支付钱包的统计 Mapper - * - * @author owen - */ -@Mapper -@SuppressWarnings("rawtypes") -public interface PayWalletStatisticsMapper extends BaseMapperX { - - // TODO 芋艿:已经 review; - WalletSummaryRespBO selectRechargeSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime, - @Param("payStatus") Boolean payStatus); - - // TODO 芋艿:已经 review; - WalletSummaryRespBO selectRechargeSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime, - @Param("refundStatus") Integer refundStatus); - - // TODO 芋艿:已经 review; - Integer selectPriceSummaryByBizTypeAndCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime, - @Param("bizType") Integer bizType); - - // TODO 芋艿:已经 review; - RechargeSummaryRespBO selectRechargeSummaryGroupByWalletId(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime, - @Param("payStatus") Boolean payStatus); - - // TODO 芋艿:已经 review; - Integer selectRechargePriceSummary(@Param("payStatus") Integer payStatus); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductSpuStatisticsDO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductSpuStatisticsDO.java deleted file mode 100644 index d29d4332b3..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductSpuStatisticsDO.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 商品 SPU 统计 DO - * - * 以天为维度,统计商品 SPU 的数据 - * - * @author 芋道源码 - */ -@TableName("product_spu_statistics") -@KeySequence("product_spu_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductSpuStatisticsDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 字段 - */ - private Long spuId; - /** - * 统计日期 - */ - private LocalDateTime time; - - /** - * 浏览量 - */ - private Integer browseCount; - /** - * 收藏量 - */ - private Integer favoriteCount; - - /** - * 添加购物车次数 - * - * 以商品被添加到购物车的 createTime 计算,后续多次添加,不会增加该值。 - * 直到该次被下单、或者被删除,后续再次被添加到购物车。 - */ - private Integer addCartCount; - /** - * 创建订单商品数 - */ - private Integer createOrderCount; - /** - * 支付订单商品数 - */ - private Integer payOrderCount; - /** - * 总支付金额,单位:分 - */ - private Integer payPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductStatisticsDO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductStatisticsDO.java deleted file mode 100644 index 5937b41da2..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductStatisticsDO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 商品统计 DO - * - * 以天为维度,统计全部的数据 - * - * 和 {@link ProductSpuStatisticsDO} 的差异是,它是全局的统计 - * - * @author 芋道源码 - */ -@TableName("product_spu_statistics") -@KeySequence("product_spu_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductStatisticsDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 统计日期 - */ - private LocalDateTime time; - - /** - * 浏览量 - */ - private Integer browseCount; - /** - * 收藏量 - */ - private Integer favoriteCount; - - /** - * 添加购物车次数 - * - * 以商品被添加到购物车的 createTime 计算,后续多次添加,不会增加该值。 - * 直到该次被下单、或者被删除,后续再次被添加到购物车。 - */ - private Integer addCartCount; - /** - * 创建订单商品数 - */ - private Integer createOrderCount; - /** - * 支付订单商品数 - */ - private Integer payOrderCount; - /** - * 总支付金额,单位:分 - */ - private Integer payPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java deleted file mode 100644 index 1d2bb88144..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.trade; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; - -/** - * 售后订单的统计 Mapper - * - * @author owen - */ -@Mapper -public interface AfterSaleStatisticsMapper extends BaseMapperX { - - // TODO 芋艿:已 review - AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO 芋艿:已经 review - Long selectCountByStatus(@Param("status") Integer status); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java deleted file mode 100644 index 46d651a75f..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.trade; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; - -/** - * 订单分销的统计 Mapper - * - * @author owen - */ -@Mapper -public interface BrokerageStatisticsMapper extends BaseMapperX { - - // TODO 芋艿:已经 review - Integer selectSummaryPriceByStatusAndUnfreezeTimeBetween(@Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO 芋艿:已经 review - Long selectWithdrawCountByStatus(@Param("status") Integer status); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java deleted file mode 100644 index 43b4c4dfda..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.trade; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易订单的统计 Mapper - * - * @author owen - */ -@Mapper -public interface TradeOrderStatisticsMapper extends BaseMapperX { - - // TODO 芋艿:已经 review - List selectSummaryListByAreaId(); - - // TODO 芋艿:已经 review - Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO 芋艿:已经 review - Integer selectCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO 芋艿:已经 review - Integer selectSummaryPriceByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO 芋艿:已经 review - Integer selectUserCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO 芋艿:已经 review - Integer selectUserCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO 芋艿:已经 review - /** - * 按照支付时间统计订单(按天分组) - * - * @param beginTime 支付起始时间 - * @param endTime 支付截止时间 - * @return 订单统计列表 - */ - List selectListByPayTimeBetweenAndGroupByDay(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO 芋艿:已经 review - /** - * 按照支付时间统计订单(按月分组) - * - * @param beginTime 支付起始时间 - * @param endTime 支付截止时间 - * @return 订单统计列表 - */ - List selectListByPayTimeBetweenAndGroupByMonth(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO @芋艿:已经 review - Long selectCountByStatusAndDeliveryType(@Param("status") Integer status, @Param("deliveryType") Integer deliveryType); - - // TODO 芋艿:已经 review - TradeOrderSummaryRespVO selectPaySummaryByStatusAndPayTimeBetween(@Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java deleted file mode 100644 index d5ed54cec4..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.trade; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易统计 Mapper - * - * @author owen - */ -@Mapper -public interface TradeStatisticsMapper extends BaseMapperX { - - TradeSummaryRespBO selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - TradeTrendSummaryRespVO selectVoByTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO @芋艿:已经 review - default List selectListByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { - return selectList(new LambdaQueryWrapperX() - .between(TradeStatisticsDO::getTime, beginTime, endTime)); - } - - // TODO @芋艿:已经 review - Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO @芋艿:已经 review - default TradeStatisticsDO selectByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { - return selectOne(new LambdaQueryWrapperX() - .between(TradeStatisticsDO::getTime, beginTime, endTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/package-info.java deleted file mode 100644 index e8cf302e17..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿,占坑,无特殊含义 - */ -package cn.iocoder.yudao.module.statistics.job; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java deleted file mode 100644 index 74b65a1335..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.statistics.job.trade; - -import cn.hutool.core.convert.Convert; -import cn.hutool.core.util.NumberUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -// TODO 芋艿:缺个 Job 的配置;等和 Product 一起配置 -/** - * 交易统计 Job - * - * @author owen - */ -@Component -public class TradeStatisticsJob implements JobHandler { - - @Resource - private TradeStatisticsService tradeStatisticsService; - - /** - * 执行交易统计任务 - * - * @param param 要统计的天数,只能是正整数,1 代表昨日数据 - * @return 统计结果 - */ - @Override - @TenantJob - public String execute(String param) { - // 默认昨日 - param = ObjUtil.defaultIfBlank(param, "1"); - // 校验参数的合理性 - if (!NumberUtil.isInteger(param)) { - throw new RuntimeException("交易统计任务的参数只能为是正整数"); - } - Integer days = Convert.toInt(param, 0); - if (days < 1) { - throw new RuntimeException("交易统计任务的参数只能为是正整数"); - } - String result = tradeStatisticsService.statisticsTrade(days); - return StrUtil.format("交易统计:\n{}", result); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/package-info.java deleted file mode 100644 index 598e16c025..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * statistics 模块,主要实现统计相关功能。 - * 例如:统计商品、会员、交易等功能。 - * - * 1. Controller URL:以 /statistics/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 statistics_ 为后缀,方便在数据库中区分【特殊】 - */ -package cn.iocoder.yudao.module.statistics; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java deleted file mode 100644 index f4042730bc..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.infra; - -import java.time.LocalDateTime; - -/** - * API 访问日志的统计 Service 接口 - * - * @author owen - */ -public interface ApiAccessLogStatisticsService { - - // TODO 芋艿:已经 review - /** - * 获取活跃用户数量 - * - * @param userType 用户类型 - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 活跃用户数量 - */ - Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime); - - // TODO 芋艿:已经 review - /** - * 获取访问用户数量 - * - * @param userType 用户类型 - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 访问用户数量 - */ - Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java deleted file mode 100644 index 91062560d3..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.infra; - -import cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; - -/** - * API 访问日志的统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class ApiAccessLogStatisticsServiceImpl implements ApiAccessLogStatisticsService { - - @Resource - private ApiAccessLogStatisticsMapper apiAccessLogStatisticsMapper; - - @Override - public Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) { - return apiAccessLogStatisticsMapper.selectUserCountByUserTypeAndCreateTimeBetween(userType, beginTime, endTime); - } - - @Override - public Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) { - return apiAccessLogStatisticsMapper.selectIpCountByUserTypeAndCreateTimeBetween(userType, beginTime, endTime); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java deleted file mode 100644 index 324905e597..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.member; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 会员信息的统计 Service 接口 - * - * @author owen - */ -public interface MemberStatisticsService { - - // TODO 芋艿:已经 review - /** - * 获取会员统计(实时统计) - * - * @return 会员统计 - */ - MemberSummaryRespVO getMemberSummary(); - - // TODO 芋艿:已经 review - /** - * 获取会员分析对照数据 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 会员分析对照数据 - */ - DataComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, - LocalDateTime endTime); - - // TODO 芋艿:已经 review - /** - * 按照省份,获得会员统计列表 - * - * @return 会员统计列表 - */ - List getMemberAreaStatisticsList(); - - // TODO 芋艿:已经 review - /** - * 按照性别,获得会员统计列表 - * - * @return 会员统计列表 - */ - List getMemberSexStatisticsList(); - - /** - * 按照终端,获得会员统计列表 - * - * @return 会员统计列表 - */ - List getMemberTerminalStatisticsList(); - - // TODO 芋艿:已经 review - /** - * 获取用户注册数量列表 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 注册数量列表 - */ - List getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime); - - // TODO 芋艿:已经 review - /** - * 获得用户数量量统计对照 - * - * @return 用户数量量统计对照 - */ - DataComparisonRespVO getUserCountComparison(); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java deleted file mode 100644 index 6e3200b770..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.member; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; -import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; -import cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper; -import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 会员信息的统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class MemberStatisticsServiceImpl implements MemberStatisticsService { - - @Resource - private MemberStatisticsMapper memberStatisticsMapper; - - @Resource - private PayWalletStatisticsService payWalletStatisticsService; - @Resource - private TradeStatisticsService tradeStatisticsService; - @Resource - private TradeOrderStatisticsService tradeOrderStatisticsService; - @Resource - private ApiAccessLogStatisticsService apiAccessLogStatisticsService; - - @Override - public MemberSummaryRespVO getMemberSummary() { - RechargeSummaryRespBO rechargeSummary = payWalletStatisticsService.getUserRechargeSummary(null, null); - // TODO @疯狂:1)这里是实时统计,不好走走 TradeStatistics 表;2)因为这个放在商城下,所以只考虑订单数据,即按照 trade_order 的 pay_price 并且已支付来计算; - Integer expensePrice = tradeStatisticsService.getExpensePrice(null, null); - Integer userCount = memberStatisticsMapper.selectUserCount(null, null); - return MemberStatisticsConvert.INSTANCE.convert(rechargeSummary, expensePrice, userCount); - } - - @Override - public List getMemberAreaStatisticsList() { - // 统计用户 - // TODO @疯狂:可能得把每个省的用户,都查询出来,然后去 order 那边 in;因为要按照这些人为基础来计算;;用户规模量大可能不太好,但是暂时就先这样搞吧 = = - Map userCountMap = convertMap(memberStatisticsMapper.selectSummaryListByAreaId(), - vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), - MemberAreaStatisticsRespBO::getUserCount, Integer::sum); - // 统计订单 - Map orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(), - bo -> AreaUtils.getParentIdByType(bo.getAreaId(), AreaTypeEnum.PROVINCE), - bo -> bo, - (a, b) -> new MemberAreaStatisticsRespBO() - .setOrderCreateUserCount(a.getOrderCreateUserCount() + b.getOrderCreateUserCount()) - .setOrderPayUserCount(a.getOrderPayUserCount() + b.getOrderPayUserCount()) - .setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice())); - // 拼接数据 - List areaList = AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area); - areaList.add(new Area().setId(null).setName("未知")); - return MemberStatisticsConvert.INSTANCE.convertList(areaList, userCountMap, orderMap); - } - - @Override - public DataComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) { - // 当前数据 - MemberAnalyseDataRespVO vo = getMemberAnalyseData(beginTime, endTime); - // 对照数据 - LocalDateTime referenceEndDate = beginTime.minusDays(1); // 减少1天,防止出现时间重叠 - LocalDateTime referenceBeginDate = referenceEndDate.minus(Duration.between(beginTime, endTime)); - MemberAnalyseDataRespVO reference = getMemberAnalyseData( - LocalDateTimeUtil.beginOfDay(referenceBeginDate), LocalDateTimeUtil.endOfDay(referenceEndDate)); - return new DataComparisonRespVO<>(vo, reference); - } - - private MemberAnalyseDataRespVO getMemberAnalyseData(LocalDateTime beginTime, LocalDateTime endTime) { - Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime)) - .map(RechargeSummaryRespBO::getRechargeUserCount).orElse(0); - return new MemberAnalyseDataRespVO() - .setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) - .setVisitUserCount(apiAccessLogStatisticsService.getUserCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)) - .setRechargeUserCount(rechargeUserCount); - } - - @Override - public List getMemberSexStatisticsList() { - return memberStatisticsMapper.selectSummaryListBySex(); - } - - @Override - public List getMemberTerminalStatisticsList() { - return memberStatisticsMapper.selectSummaryListByRegisterTerminal(); - } - - @Override - public List getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime) { - return memberStatisticsMapper.selectListByCreateTimeBetween(beginTime, endTime); - } - - @Override - public DataComparisonRespVO getUserCountComparison() { - // 今日时间范围 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(beginOfToday); - // 昨日时间范围 - LocalDateTime beginOfYesterday = LocalDateTimeUtil.beginOfDay(beginOfToday.minusDays(1)); - LocalDateTime endOfYesterday = LocalDateTimeUtil.endOfDay(beginOfYesterday); - return new DataComparisonRespVO() - .setValue(getUserCount(beginOfToday, endOfToday)) - .setReference(getUserCount(beginOfYesterday, endOfYesterday)); - } - - private MemberCountRespVO getUserCount(LocalDateTime beginTime, LocalDateTime endTime) { - return new MemberCountRespVO() - .setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) - .setVisitUserCount(apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/bo/MemberAreaStatisticsRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/bo/MemberAreaStatisticsRespBO.java deleted file mode 100644 index 6b2d9ceab0..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/bo/MemberAreaStatisticsRespBO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.member.bo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员地区统计 Response BO") -@Data -public class MemberAreaStatisticsRespBO { - - /** - * 省份编号 - */ - private Integer areaId; - /** - * 省份名称 - */ - private String areaName; - - /** - * 会员数量 - */ - private Integer userCount; - - /** - * 下单的会员数量 - */ - private Integer orderCreateUserCount; - /** - * 支付订单的会员数量 - */ - private Integer orderPayUserCount; - - /** - * 订单支付金额,单位:分 - */ - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java deleted file mode 100644 index 4801ad186f..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.pay; - -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; - -import java.time.LocalDateTime; - -/** - * 钱包的统计 Service 接口 - * - * @author owen - */ -public interface PayWalletStatisticsService { - - // TODO 芋艿:已经 review - /** - * 获取钱包统计 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 钱包统计 - */ - WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime); - - // TODO 芋艿:已经 review - /** - * 获取钱包充值统计 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 钱包充值统计 - */ - RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime); - - // TODO 芋艿:已经 review - /** - * 获取充值金额合计 - * - * @return 充值金额合计 - */ - Integer getRechargePriceSummary(); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java deleted file mode 100644 index 4774a06589..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.pay; - -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper; -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; - -/** - * 钱包的统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsService { - - @Resource - private PayWalletStatisticsMapper payWalletStatisticsMapper; - - @Override - public WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) { - WalletSummaryRespBO paySummary = payWalletStatisticsMapper.selectRechargeSummaryByPayTimeBetween( - beginTime, endTime, true); - WalletSummaryRespBO refundSummary = payWalletStatisticsMapper.selectRechargeSummaryByRefundTimeBetween( - beginTime, endTime, PayRefundStatusEnum.SUCCESS.getStatus()); - Integer walletPayPrice = payWalletStatisticsMapper.selectPriceSummaryByBizTypeAndCreateTimeBetween( - beginTime, endTime, PayWalletBizTypeEnum.PAYMENT.getType()); - // 拼接 - paySummary.setWalletPayPrice(walletPayPrice) - .setRechargeRefundCount(refundSummary.getRechargeRefundCount()) - .setRechargeRefundPrice(refundSummary.getRechargeRefundPrice()); - return paySummary; - } - - @Override - public RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime) { - return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true); - } - - @Override - public Integer getRechargePriceSummary() { - return payWalletStatisticsMapper.selectRechargePriceSummary(PayOrderStatusEnum.SUCCESS.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/bo/RechargeSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/bo/RechargeSummaryRespBO.java deleted file mode 100644 index 05cfa11558..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/bo/RechargeSummaryRespBO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.pay.bo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 充值统计 Response BO - */ -@Data -public class RechargeSummaryRespBO { - - /** - * 充值会员数量 - */ - private Integer rechargeUserCount; - - /** - * 充值金额 - */ - private Integer rechargePrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java deleted file mode 100644 index 3904387d61..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; - -import java.time.LocalDateTime; - -/** - * 售后统计 Service 接口 - * - * @author owen - */ -public interface AfterSaleStatisticsService { - - // TODO 芋艿:已经 review - /** - * 获取售后单统计 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 售后统计结果 - */ - AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime); - - // TODO 芋艿:已经 review - /** - * 获取指定状态的售后订单数量 - * - * @param status 售后状态 - * @return 售后订单数量 - */ - Long getCountByStatus(AfterSaleStatusEnum status); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java deleted file mode 100644 index df733cc160..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.AfterSaleStatisticsMapper; -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; - -/** - * 售后统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class AfterSaleStatisticsServiceImpl implements AfterSaleStatisticsService { - - @Resource - private AfterSaleStatisticsMapper afterSaleStatisticsMapper; - - @Override - public AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime) { - return afterSaleStatisticsMapper.selectSummaryByRefundTimeBetween(beginTime, endTime); - } - - @Override - public Long getCountByStatus(AfterSaleStatusEnum status) { - return afterSaleStatisticsMapper.selectCountByStatus(status.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java deleted file mode 100644 index 5f856778db..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; - -import java.time.LocalDateTime; - -/** - * 分销统计 Service 接口 - * - * @author owen - */ -public interface BrokerageStatisticsService { - - // TODO 芋艿:已经 review - /** - * 获取已结算的佣金金额 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 已结算的佣金金额 - */ - Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); - - // TODO 芋艿:已经 review - /** - * 获取指定状态的提现记录数量 - * - * @param status 提现记录状态 - * @return 提现记录数量 - */ - Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java deleted file mode 100644 index f6ead15dfd..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.BrokerageStatisticsMapper; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; - -/** - * 分销统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class BrokerageStatisticsServiceImpl implements BrokerageStatisticsService { - - @Resource - private BrokerageStatisticsMapper brokerageStatisticsMapper; - - @Override - public Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime) { - return brokerageStatisticsMapper.selectSummaryPriceByStatusAndUnfreezeTimeBetween( - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), - beginTime, endTime); - } - - @Override - public Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status) { - return brokerageStatisticsMapper.selectWithdrawCountByStatus(status.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java deleted file mode 100644 index 982957e240..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易订单的统计 Service 接口 - * - * @author owen - */ -public interface TradeOrderStatisticsService { - - /** - * 获取订单统计 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 订单统计结果 - */ - TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime); - - // TODO 芋艿:已经 review - /** - * 获取地区订单统计 - * - * @return 订单统计结果 - */ - List getSummaryListByAreaId(); - - // TODO 芋艿:已经 review - /** - * 获取下单用户数量 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 下单用户数量 - */ - Integer getOrderUserCount(LocalDateTime beginTime, LocalDateTime endTime); - - // TODO 芋艿:已经 review - /** - * 获取支付用户数量 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 支付用户数量 - */ - Integer getPayUserCount(LocalDateTime beginTime, LocalDateTime endTime); - - // TODO 芋艿:已经 review - /** - * 获取支付金额 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 支付用户金额 - */ - Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 根据订单状态、物流类型,获得交易订单数量 - * - * @return 订单数量 - */ - Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType); - - // TODO 芋艿:已经 review - /** - * 交易订单销售额对照 - * - * @return 销售额对照 - */ - DataComparisonRespVO getOrderComparison(); - - // TODO 芋艿:已经 review - /** - * 获得订单量趋势统计 - * - * @param reqVO 统计参数 - * @return 订单量趋势统计 - */ - List> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java deleted file mode 100644 index 0aed979eee..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendReqVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper; -import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -/** - * 交易订单统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsService { - - @Resource - private TradeOrderStatisticsMapper tradeOrderStatisticsMapper; - - @Override - public TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) { - return new TradeOrderSummaryRespBO() - .setOrderCreateCount(tradeOrderStatisticsMapper.selectCountByCreateTimeBetween(beginTime, endTime)) - .setOrderPayCount(tradeOrderStatisticsMapper.selectCountByPayTimeBetween(beginTime, endTime)) - .setOrderPayPrice(tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime)); - } - - @Override - public List getSummaryListByAreaId() { - return tradeOrderStatisticsMapper.selectSummaryListByAreaId(); - } - - @Override - public Integer getOrderUserCount(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeOrderStatisticsMapper.selectUserCountByCreateTimeBetween(beginTime, endTime); - } - - @Override - public Integer getPayUserCount(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeOrderStatisticsMapper.selectUserCountByPayTimeBetween(beginTime, endTime); - } - - @Override - public Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime); - } - - @Override - public Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType) { - return tradeOrderStatisticsMapper.selectCountByStatusAndDeliveryType(status, deliveryType); - } - - @Override - public DataComparisonRespVO getOrderComparison() { - return new DataComparisonRespVO() - .setValue(getPayPriceSummary(LocalDateTime.now())) - .setReference(getPayPriceSummary(LocalDateTime.now().minusDays(1))); - } - - private TradeOrderSummaryRespVO getPayPriceSummary(LocalDateTime date) { - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); - LocalDateTime endTime = LocalDateTimeUtil.beginOfDay(date); - return tradeOrderStatisticsMapper.selectPaySummaryByStatusAndPayTimeBetween( - PayOrderStatusEnum.SUCCESS.getStatus(), beginTime, endTime); - } - - @Override - public List> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO) { - // 查询当前数据 - List value = getOrderCountTrend(reqVO.getType(), reqVO.getBeginTime(), reqVO.getEndTime()); - // 查询对照数据 - LocalDateTime referenceEndTime = reqVO.getBeginTime().minusDays(1); - LocalDateTime referenceBeginTime = referenceEndTime.minus(Duration.between(reqVO.getBeginTime(), reqVO.getEndTime())); - List reference = getOrderCountTrend(reqVO.getType(), referenceBeginTime, referenceEndTime); - // 顺序对比返回 - return IntStream.range(0, value.size()) - .mapToObj(index -> new DataComparisonRespVO() - .setValue(CollUtil.get(value, index)) - .setReference(CollUtil.get(reference, index))) - .collect(Collectors.toList()); - } - - private List getOrderCountTrend(Integer timeRangeType, LocalDateTime beginTime, LocalDateTime endTime) { - // 情况一:按年统计时,以月份分组 - if (TimeRangeTypeEnum.YEAR.getType().equals(timeRangeType)) { - return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByMonth(beginTime, endTime); - } - // 情况二:其它以天分组(天、周、月) - return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByDay(beginTime, endTime); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java deleted file mode 100644 index ec2e5bd5aa..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易统计 Service 接口 - * - * @author owen - */ -public interface TradeStatisticsService { - - /** - * 获得交易状况统计对照 - * - * @return 统计数据对照 - */ - DataComparisonRespVO getTradeTrendSummaryComparison( - LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获得交易状况统计 - * - * @param beginTime 开始时间 - * @param endTime 结束时间 - * @return 统计数据对照 - */ - Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获得交易状况明细 - * - * @param beginTime 开始时间 - * @param endTime 结束时间 - * @return 统计数据列表 - */ - List getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime); - - // TODO 芋艿:已经 review; - /** - * 统计指定天数的交易数据 - * - * @return 统计结果 - */ - String statisticsTrade(Integer days); - - // TODO 芋艿:已经 review - /** - * 统计指定日期的交易数据 - * - * @param days 增加的天数 - * @return 交易数据 - */ - TradeSummaryRespBO getTradeSummaryByDays(int days); - - // TODO 芋艿:已经 review - /** - * 统计指定月份的交易数据 - * - * @param months 增加的月数 - * @return 交易数据 - */ - TradeSummaryRespBO getTradeSummaryByMonths(int months); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java deleted file mode 100644 index a6b9b1633d..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; -import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper; -import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; -import org.springframework.stereotype.Service; -import org.springframework.util.StopWatch; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -/** - * 交易统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class TradeStatisticsServiceImpl implements TradeStatisticsService { - - @Resource - private TradeStatisticsMapper tradeStatisticsMapper; - - @Resource - private TradeOrderStatisticsService tradeOrderStatisticsService; - @Resource - private AfterSaleStatisticsService afterSaleStatisticsService; - @Resource - private BrokerageStatisticsService brokerageStatisticsService; - @Resource - private PayWalletStatisticsService payWalletStatisticsService; - - @Override - public TradeSummaryRespBO getTradeSummaryByDays(int days) { - LocalDateTime date = LocalDateTime.now().plusDays(days); - return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween( - LocalDateTimeUtil.beginOfDay(date), LocalDateTimeUtil.endOfDay(date)); - } - - @Override - public TradeSummaryRespBO getTradeSummaryByMonths(int months) { - LocalDateTime monthDate = LocalDateTime.now().plusMonths(months); - return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween( - LocalDateTimeUtils.beginOfMonth(monthDate), LocalDateTimeUtils.endOfMonth(monthDate)); - } - - @Override - public DataComparisonRespVO getTradeTrendSummaryComparison(LocalDateTime beginTime, - LocalDateTime endTime) { - // 统计数据 - TradeTrendSummaryRespVO value = tradeStatisticsMapper.selectVoByTimeBetween(beginTime, endTime); - // 对照数据 - LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime)); - TradeTrendSummaryRespVO reference = tradeStatisticsMapper.selectVoByTimeBetween(referenceBeginTime, beginTime); - return TradeStatisticsConvert.INSTANCE.convert(value, reference); - } - - @Override - public Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeStatisticsMapper.selectExpensePriceByTimeBetween(beginTime, endTime); - } - - @Override - public List getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime); - } - - @Override - public String statisticsTrade(Integer days) { - LocalDateTime today = LocalDateTime.now(); - return IntStream.rangeClosed(1, days) - .mapToObj(day -> statisticsTrade(today.minusDays(day))) - .sorted() - .collect(Collectors.joining("\n")); - } - - /** - * 统计交易数据 - * - * @param date 需要统计的日期 - * @return 统计结果 - */ - private String statisticsTrade(LocalDateTime date) { - // 1. 处理统计时间范围 - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); - LocalDateTime endTime = LocalDateTimeUtil.endOfDay(date); - String dateStr = DatePattern.NORM_DATE_FORMAT.format(date); - // 2. 检查该日是否已经统计过 - TradeStatisticsDO entity = tradeStatisticsMapper.selectByTimeBetween(beginTime, endTime); - if (entity != null) { - return dateStr + " 数据已存在,如果需要重新统计,请先删除对应的数据"; - } - - // 3. 从各个数据表,统计对应数据 - StopWatch stopWatch = new StopWatch(dateStr); - // 3.1 统计订单 - stopWatch.start("统计订单"); - TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime); - stopWatch.stop(); - // 3.2 统计售后 - stopWatch.start("统计售后"); - AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime); - stopWatch.stop(); - // 3.3 统计佣金 - stopWatch.start("统计佣金"); - Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime); - stopWatch.stop(); - // 3.4 统计充值 - stopWatch.start("统计充值"); - WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime); - stopWatch.stop(); - - // 4. 插入数据 - entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice, - walletSummary); - tradeStatisticsMapper.insert(entity); - return stopWatch.prettyPrint(); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/AfterSaleSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/AfterSaleSummaryRespBO.java deleted file mode 100644 index 985643636b..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/AfterSaleSummaryRespBO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 售后统计 Response DTO - * - * @author owen - */ -@Data -public class AfterSaleSummaryRespBO { - - /** - * 退款订单数 - */ - private Integer afterSaleCount; - /** - * 总退款金额,单位:分 - */ - private Integer afterSaleRefundPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java deleted file mode 100644 index 3d3572f90d..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 会员地区统计 Response BO - * - * @author owen - */ -@Data -public class MemberAreaStatisticsRespBO { - - /** - * 省份编号 - */ - private Integer areaId; - /** - * 省份名称 - */ - private String areaName; - - /** - * 会员数量 - */ - private Integer userCount; - - /** - * 下单的会员数量 - */ - private Integer orderCreateUserCount; - /** - * 支付订单的会员数量 - */ - private Integer orderPayUserCount; - - /** - * 订单支付金额,单位:分 - */ - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeOrderSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeOrderSummaryRespBO.java deleted file mode 100644 index bc4f3903b3..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeOrderSummaryRespBO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 订单统计 Response BO - * - * @author owen - */ -@Data -public class TradeOrderSummaryRespBO { - - /** - * 创建订单数 - */ - private Integer orderCreateCount; - /** - * 支付订单商品数 - */ - private Integer orderPayCount; - /** - * 总支付金额,单位:分 - */ - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeSummaryRespBO.java deleted file mode 100644 index 8937c809cc..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeSummaryRespBO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 交易统计 Resp BO - * - * @author owen - */ -@Data -public class TradeSummaryRespBO { - - /** - * 数量 - */ - private Integer count; - - /** - * 合计 - */ - private Integer summary; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java deleted file mode 100644 index 89371f6c1c..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 钱包统计 Response DTO - * - * @author owen - */ -@Data -public class WalletSummaryRespBO { - - /** - * 总支付金额(余额),单位:分 - */ - private Integer walletPayPrice; - - /** - * 充值订单数 - */ - private Integer rechargePayCount; - /** - * 充值金额,单位:分 - */ - private Integer rechargePayPrice; - /** - * 充值退款订单数 - */ - private Integer rechargeRefundCount; - /** - * 充值退款金额,单位:分 - */ - private Integer rechargeRefundPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml deleted file mode 100644 index e641615974..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml deleted file mode 100644 index 33500fb43a..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml deleted file mode 100644 index 0977808415..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml deleted file mode 100644 index 933c45610c..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml deleted file mode 100644 index dff7e444fb..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml deleted file mode 100644 index c79c639a43..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml deleted file mode 100644 index 2415f6d557..0000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-trade-api/pom.xml b/yudao-module-mall/yudao-module-trade-api/pom.xml deleted file mode 100644 index 6dd926b7bd..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-trade-api - jar - - ${project.artifactId} - - trade 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java deleted file mode 100644 index 744a7b8fde..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.trade.api.order; - -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; - -import java.util.Collection; -import java.util.List; - -/** - * 订单 API 接口 - * - * @author HUIHUI - */ -public interface TradeOrderApi { - - /** - * 获得订单列表 - * - * @param ids 订单编号数组 - * @return 订单列表 - */ - List getOrderList(Collection ids); - - /** - * 获得订单 - * - * @param id 订单编号 - * @return 订单 - */ - TradeOrderRespDTO getOrder(Long id); - - // TODO 芋艿:需要优化下; - /** - * 取消支付订单 - * - * @param userId 用户编号 - * @param orderId 订单编号 - */ - void cancelPaidOrder(Long userId, Long orderId); - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java deleted file mode 100644 index 52b167cd48..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.trade.api.order.dto; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderCancelTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 订单信息 Response DTO - * - * @author HUIHUI - */ -@Data -public class TradeOrderRespDTO { - - // ========== 订单基本信息 ========== - /** - * 订单编号,主键自增 - */ - private Long id; - /** - * 订单流水号 - * - * 例如说,1146347329394184195 - */ - private String no; - /** - * 订单类型 - * - * 枚举 {@link TradeOrderTypeEnum} - */ - private Integer type; - /** - * 订单来源 - * - * 枚举 {@link TerminalEnum} - */ - private Integer terminal; - /** - * 用户编号 - */ - private Long userId; - /** - * 用户 IP - */ - private String userIp; - /** - * 用户备注 - */ - private String userRemark; - /** - * 订单状态 - * - * 枚举 {@link TradeOrderStatusEnum} - */ - private Integer status; - /** - * 购买的商品数量 - */ - private Integer productCount; - /** - * 订单完成时间 - */ - private LocalDateTime finishTime; - /** - * 订单取消时间 - */ - private LocalDateTime cancelTime; - /** - * 取消类型 - * - * 枚举 {@link TradeOrderCancelTypeEnum} - */ - private Integer cancelType; - /** - * 商家备注 - */ - private String remark; - /** - * 是否评价 - */ - private Boolean commentStatus; - - // ========== 价格 + 支付基本信息 ========== - /** - * 支付订单编号 - */ - private Long payOrderId; - /** - * 是否已支付 - */ - private Boolean payStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java deleted file mode 100644 index 5b0e37dcc1..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.trade.api; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java deleted file mode 100644 index ff09e59d89..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums; - -/** - * Trade 字典类型的枚举类 - * - * @author owen - */ -public interface DictTypeConstants { - - String BROKERAGE_WITHDRAW_STATUS = "brokerage_withdraw_status"; // 佣金提现状态 - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java deleted file mode 100644 index 33081d4614..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Trade 错误码枚举类 - * trade 系统,使用 1-011-000-000 段 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface ErrorCodeConstants { - - // ========== Order 模块 1-011-000-000 ========== - ErrorCode ORDER_ITEM_NOT_FOUND = new ErrorCode(1_011_000_010, "交易订单项不存在"); - ErrorCode ORDER_NOT_FOUND = new ErrorCode(1_011_000_011, "交易订单不存在"); - ErrorCode ORDER_ITEM_UPDATE_AFTER_SALE_STATUS_FAIL = new ErrorCode(1_011_000_012, "交易订单项更新售后状态失败,请重试"); - ErrorCode ORDER_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_011_000_013, "交易订单更新支付状态失败,订单不是【未支付】状态"); - ErrorCode ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR = new ErrorCode(1_011_000_014, "交易订单更新支付状态失败,支付单编号不匹配"); - ErrorCode ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1_011_000_015, "交易订单更新支付状态失败,支付单状态不是【支付成功】状态"); - ErrorCode ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH = new ErrorCode(1_011_000_016, "交易订单更新支付状态失败,支付单金额不匹配"); - ErrorCode ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED = new ErrorCode(1_011_000_017, "交易订单发货失败,订单不是【待发货】状态"); - ErrorCode ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_018, "交易订单收货失败,订单不是【待收货】状态"); - ErrorCode ORDER_COMMENT_FAIL_STATUS_NOT_COMPLETED = new ErrorCode(1_011_000_019, "创建交易订单项的评价失败,订单不是【已完成】状态"); - ErrorCode ORDER_COMMENT_STATUS_NOT_FALSE = new ErrorCode(1_011_000_020, "创建交易订单项的评价失败,订单已评价"); - ErrorCode ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE = new ErrorCode(1_011_000_021, "交易订单发货失败,订单已退款或部分退款"); - ErrorCode ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1_011_000_022, "交易订单发货失败,拼团未成功"); - ErrorCode ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1_011_000_023, "交易订单发货失败,砍价未成功"); - ErrorCode ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS = new ErrorCode(1_011_000_024, "交易订单发货失败,发货类型不是快递"); - ErrorCode ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID = new ErrorCode(1_011_000_025, "交易订单取消失败,订单不是【待支付】状态"); - ErrorCode ORDER_UPDATE_PRICE_FAIL_PAID = new ErrorCode(1_011_000_026, "支付订单调价失败,原因:支付订单已付款,不能调价"); - ErrorCode ORDER_UPDATE_PRICE_FAIL_ALREADY = new ErrorCode(1_011_000_027, "支付订单调价失败,原因:已经修改过价格"); - ErrorCode ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR = new ErrorCode(1_011_000_028, "支付订单调价失败,原因:调整后支付价格不能小于 0.01 元"); - ErrorCode ORDER_DELETE_FAIL_STATUS_NOT_CANCEL = new ErrorCode(1_011_000_029, "交易订单删除失败,订单不是【已取消】状态"); - ErrorCode ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP = new ErrorCode(1_011_000_030, "交易订单自提失败,收货方式不是【用户自提】"); - ErrorCode ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_031, "交易订单修改收货地址失败,原因:订单不是【待发货】状态"); - ErrorCode ORDER_CREATE_FAIL_EXIST_UNPAID = new ErrorCode(1_011_000_032, "交易订单创建失败,原因:存在未付款订单"); - - // ========== After Sale 模块 1-011-000-100 ========== - ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在"); - ErrorCode AFTER_SALE_CREATE_FAIL_REFUND_PRICE_ERROR = new ErrorCode(1_011_000_101, "申请退款金额错误"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_CANCELED = new ErrorCode(1_011_000_102, "订单已关闭,无法申请售后"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_PAID = new ErrorCode(1_011_000_103, "订单未支付,无法申请售后"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_DELIVERED = new ErrorCode(1_011_000_104, "订单未发货,无法申请【退货退款】售后"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_ITEM_APPLIED = new ErrorCode(1_011_000_105, "订单项已申请售后,无法重复申请"); - ErrorCode AFTER_SALE_AUDIT_FAIL_STATUS_NOT_APPLY = new ErrorCode(1_011_000_106, "审批失败,售后状态不处于审批中"); - ErrorCode AFTER_SALE_UPDATE_STATUS_FAIL = new ErrorCode(1_011_000_107, "操作售后单失败,请刷新后重试"); - ErrorCode AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_SELLER_AGREE = new ErrorCode(1_011_000_108, "退货失败,售后单状态不处于【待买家退货】"); - ErrorCode AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_DELIVERY = new ErrorCode(1_011_000_109, "确认收货失败,售后单状态不处于【待确认收货】"); - ErrorCode AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND = new ErrorCode(1_011_000_110, "退款失败,售后单状态不是【待退款】"); - ErrorCode AFTER_SALE_CANCEL_FAIL_STATUS_NOT_APPLY_OR_AGREE_OR_BUYER_DELIVERY = - new ErrorCode(1_011_000_111, "取消售后单失败,售后单状态不是【待审核】或【卖家同意】或【商家待收货】"); - - // ========== Cart 模块 1-011-002-000 ========== - ErrorCode CARD_ITEM_NOT_FOUND = new ErrorCode(1_011_002_000, "购物车项不存在"); - - // ========== Price 相关 1-011-003-000 ============ - ErrorCode PRICE_CALCULATE_PAY_PRICE_ILLEGAL = new ErrorCode(1_011_003_000, "支付价格计算异常,原因:价格小于等于 0"); - ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_TEMPLATE_NOT_FOUND = new ErrorCode(1_011_003_002, "计算快递运费异常,找不到对应的运费模板"); - ErrorCode PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER = new ErrorCode(1_011_003_004, "参与秒杀、拼团、砍价的营销商品,无法使用优惠劵"); - ErrorCode PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT = new ErrorCode(1_011_003_005, "参与秒杀的商品,超过了秒杀总限购数量"); - - // ========== 物流 Express 模块 1-011-004-000 ========== - ErrorCode EXPRESS_NOT_EXISTS = new ErrorCode(1_011_004_000, "快递公司不存在"); - ErrorCode EXPRESS_CODE_DUPLICATE = new ErrorCode(1_011_004_001, "已经存在该编码的快递公司"); - ErrorCode EXPRESS_CLIENT_NOT_PROVIDE = new ErrorCode(1_011_004_002, "需要接入快递服务商,比如【快递100】"); - ErrorCode EXPRESS_STATUS_NOT_ENABLE = new ErrorCode(1_011_004_003, "快递公司未启用"); - - ErrorCode EXPRESS_API_QUERY_ERROR = new ErrorCode(1_011_004_101, "快递查询接口异常"); - ErrorCode EXPRESS_API_QUERY_FAILED = new ErrorCode(1_011_004_102, "快递查询返回失败,原因:{}"); - - // ========== 物流 Template 模块 1-011-005-000 ========== - ErrorCode EXPRESS_TEMPLATE_NAME_DUPLICATE = new ErrorCode(1_011_005_000, "已经存在该运费模板名"); - ErrorCode EXPRESS_TEMPLATE_NOT_EXISTS = new ErrorCode(1_011_005_001, "运费模板不存在"); - - // ========== 物流 PICK_UP 模块 1-011-006-000 ========== - ErrorCode PICK_UP_STORE_NOT_EXISTS = new ErrorCode(1_011_006_000, "自提门店不存在"); - - // ========== 分销用户 模块 1-011-007-000 ========== - ErrorCode BROKERAGE_USER_NOT_EXISTS = new ErrorCode(1_011_007_000, "分销用户不存在"); - ErrorCode BROKERAGE_USER_FROZEN_PRICE_NOT_ENOUGH = new ErrorCode(1_011_007_001, "用户冻结佣金({})数量不足"); - ErrorCode BROKERAGE_BIND_SELF = new ErrorCode(1_011_007_002, "不能绑定自己"); - ErrorCode BROKERAGE_BIND_USER_NOT_ENABLED = new ErrorCode(1_011_007_003, "绑定用户没有推广资格"); - ErrorCode BROKERAGE_BIND_CONDITION_ADMIN = new ErrorCode(1_011_007_004, "仅可在后台绑定推广员"); - ErrorCode BROKERAGE_BIND_MODE_REGISTER = new ErrorCode(1_011_007_005, "只有在注册时可以绑定"); - ErrorCode BROKERAGE_BIND_OVERRIDE = new ErrorCode(1_011_007_006, "已绑定了推广人"); - ErrorCode BROKERAGE_BIND_LOOP = new ErrorCode(1_011_007_007, "下级不能绑定自己的上级"); - ErrorCode BROKERAGE_USER_LEVEL_NOT_SUPPORT = new ErrorCode(1_011_007_008, "目前只支持 level 小于等于 2"); - - // ========== 分销提现 模块 1-011-008-000 ========== - ErrorCode BROKERAGE_WITHDRAW_NOT_EXISTS = new ErrorCode(1_011_008_000, "佣金提现记录不存在"); - ErrorCode BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING = new ErrorCode(1_011_008_001, "佣金提现记录状态不是审核中"); - ErrorCode BROKERAGE_WITHDRAW_MIN_PRICE = new ErrorCode(1_011_008_002, "提现金额不能低于 {} 元"); - ErrorCode BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH = new ErrorCode(1_011_008_003, "您当前最多可提现 {} 元"); - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java deleted file mode 100644 index 5041139b46..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums; - -// TODO @芋艿:枚举 -/** - * 通知模板枚举类 - * - * @author HUIHUI - */ -public interface MessageTemplateConstants { - - String ORDER_DELIVERY = "order_delivery"; // 短信模版编号 - - String BROKERAGE_WITHDRAW_AUDIT_APPROVE = "brokerage_withdraw_audit_approve"; // 佣金提现(审核通过) - String BROKERAGE_WITHDRAW_AUDIT_REJECT = "brokerage_withdraw_audit_reject"; // 佣金提现(审核不通过) - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java deleted file mode 100644 index db870c6375..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -/** - * 售后操作类型的枚举 - * - * @author 陈賝 - * @since 2023/6/13 13:53 - */ -@RequiredArgsConstructor -@Getter -public enum AfterSaleOperateTypeEnum { - - MEMBER_CREATE(10, "会员申请退款"), - ADMIN_AGREE_APPLY(11, "商家同意退款"), - ADMIN_DISAGREE_APPLY(12, "商家拒绝退款"), - MEMBER_DELIVERY(20, "会员填写退货物流信息,快递公司:{deliveryName},快递单号:{logisticsNo}"), - ADMIN_AGREE_RECEIVE(21, "商家收货"), - ADMIN_DISAGREE_RECEIVE(22, "商家拒绝收货,原因:{reason}"), - ADMIN_REFUND(30, "商家退款"), - MEMBER_CANCEL(40, "会员取消退款"), - ; - - /** - * 操作类型 - */ - private final Integer type; - /** - * 操作描述 - */ - private final String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleStatusEnum.java deleted file mode 100644 index 23c1b2efe0..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleStatusEnum.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; -import java.util.Collection; - -import static cn.hutool.core.util.ArrayUtil.firstMatch; - -/** - * 售后状态的枚举 - * - * 状态流转 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum AfterSaleStatusEnum implements IntArrayValuable { - - /** - * 【申请售后】 - */ - APPLY(10,"申请中", "会员申请退款"), // 有赞的状态提示:退款申请待商家处理 - /** - * 卖家通过售后;【商品待退货】 - */ - SELLER_AGREE(20, "卖家通过", "商家同意退款"), // 有赞的状态提示:请退货并填写物流信息 - /** - * 买家已退货,等待卖家收货;【商家待收货】 - */ - BUYER_DELIVERY(30,"待卖家收货", "会员填写退货物流信息"), // 有赞的状态提示:退货退款申请待商家处理 - /** - * 卖家已收货,等待平台退款;等待退款【等待退款】 - */ - WAIT_REFUND(40, "等待平台退款", "商家收货"), // 有赞的状态提示:无(有赞无该状态) - /** - * 完成退款【退款成功】 - */ - COMPLETE(50, "完成", "商家确认退款"), // 有赞的状态提示:退款成功 - /** - * 【买家取消】 - */ - BUYER_CANCEL(61, "买家取消售后", "会员取消退款"), // 有赞的状态提示:退款关闭 - /** - * 卖家拒绝售后;商家拒绝【商家拒绝】 - */ - SELLER_DISAGREE(62,"卖家拒绝", "商家拒绝退款"), // 有赞的状态提示:商家不同意退款申请 - /** - * 卖家拒绝收货,终止售后;【商家拒收货】 - */ - SELLER_REFUSE(63,"卖家拒绝收货", "商家拒绝收货"), // 有赞的状态提示:商家拒绝收货,不同意退款 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AfterSaleStatusEnum::getStatus).toArray(); - - /** - * 进行中的售后状态 - * - * 不包括已经结束的状态 - */ - public static final Collection APPLYING_STATUSES = Arrays.asList( - APPLY.getStatus(), - SELLER_AGREE.getStatus(), - BUYER_DELIVERY.getStatus(), - WAIT_REFUND.getStatus() - ); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - /** - * 操作内容 - * - * 目的:记录售后日志的内容 - */ - private final String content; - - @Override - public int[] array() { - return ARRAYS; - } - - public static AfterSaleStatusEnum valueOf(Integer status) { - return firstMatch(value -> value.getStatus().equals(status), values()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleTypeEnum.java deleted file mode 100644 index dfb32f7bee..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易售后 - 类型 - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum AfterSaleTypeEnum implements IntArrayValuable { - - IN_SALE(10, "售中退款"), // 交易完成前买家申请退款 - AFTER_SALE(20, "售后退款"); // 交易完成后买家申请退款 - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AfterSaleTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleWayEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleWayEnum.java deleted file mode 100644 index 1d608a1027..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleWayEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易售后 - 方式 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum AfterSaleWayEnum implements IntArrayValuable { - - REFUND(10, "仅退款"), - RETURN_AND_REFUND(20, "退货退款"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AfterSaleWayEnum::getWay).toArray(); - - /** - * 方式 - */ - private final Integer way; - /** - * 方式名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageBindModeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageBindModeEnum.java deleted file mode 100644 index 72ce100323..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageBindModeEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 分销关系绑定模式枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageBindModeEnum implements IntArrayValuable { - - /** - * 只要用户没有推广人,随时都可以绑定分销关系 - */ - ANYTIME(1, "首次绑定"), - /** - * 仅新用户注册时才能绑定推广关系 - */ - REGISTER(2, "注册绑定"), - /** - * 每次扫码都覆盖 - */ - OVERRIDE(3, "覆盖绑定"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageBindModeEnum::getMode).toArray(); - - /** - * 模式 - */ - private final Integer mode; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageEnabledConditionEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageEnabledConditionEnum.java deleted file mode 100644 index 990d10e160..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageEnabledConditionEnum.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 分佣模式枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageEnabledConditionEnum implements IntArrayValuable { - - /** - * 所有用户都可以分销 - */ - ALL(1, "人人分销"), - /** - * 仅可后台手动设置推广员 - */ - ADMIN(2, "指定分销"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageEnabledConditionEnum::getCondition).toArray(); - - /** - * 模式 - */ - private final Integer condition; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java deleted file mode 100644 index 546069465a..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 佣金记录业务类型枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageRecordBizTypeEnum implements IntArrayValuable { - - ORDER(1, "获得推广佣金", "获得推广佣金 {}", true), - WITHDRAW(2, "提现申请", "提现申请扣除佣金 {}", false), - WITHDRAW_REJECT(3, "提现申请驳回", "提现申请驳回,返还佣金 {}", true), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageRecordBizTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 标题 - */ - private final String title; - /** - * 描述 - */ - private final String description; - /** - * 是否为增加佣金 - */ - private final boolean add; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordStatusEnum.java deleted file mode 100644 index 827390998e..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 佣金记录状态枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageRecordStatusEnum implements IntArrayValuable { - - WAIT_SETTLEMENT(0, "待结算"), - SETTLEMENT(1, "已结算"), - CANCEL(2, "已取消"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageRecordStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java deleted file mode 100644 index b68db4a718..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -// TODO 芋艿:提现的打通,在纠结下; -/** - * 佣金提现状态枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageWithdrawStatusEnum implements IntArrayValuable { - - AUDITING(0, "审核中"), - AUDIT_SUCCESS(10, "审核通过"), - WITHDRAW_SUCCESS(11, "提现成功"), - AUDIT_FAIL(20, "审核不通过"), - WITHDRAW_FAIL(21, "提现失败"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java deleted file mode 100644 index 46edf010e9..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 佣金提现类型枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageWithdrawTypeEnum implements IntArrayValuable { - - WALLET(1, "钱包"), - BANK(2, "银行卡"), - WECHAT(3, "微信"), - ALIPAY(4, "支付宝"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java deleted file mode 100644 index 7503dd322b..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.delivery; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 快递配送计费方式枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum DeliveryExpressChargeModeEnum implements IntArrayValuable { - - COUNT(1, "按件"), - WEIGHT(2,"按重量"), - VOLUME(3, "按体积"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryExpressChargeModeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 描述 - */ - private final String desc; - - @Override - public int[] array() { - return ARRAYS; - } - - public static DeliveryExpressChargeModeEnum valueOf(Integer value) { - return ArrayUtil.firstMatch(chargeMode -> chargeMode.getType().equals(value), DeliveryExpressChargeModeEnum.values()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java deleted file mode 100644 index 27e11370cd..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.delivery; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 配送方式枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum DeliveryTypeEnum implements IntArrayValuable { - - EXPRESS(1, "快递发货"), - PICK_UP(2, "用户自提"),; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryTypeEnum::getType).toArray(); - - /** - * 配送方式 - */ - private final Integer type; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java deleted file mode 100644 index 74c6b23fe2..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java +++ /dev/null @@ -1,5 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.notify; - -// TODO @芋艿:这个枚举的作用? -public interface TradeNotifyEnums { -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderCancelTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderCancelTypeEnum.java deleted file mode 100644 index 8ec1e9b168..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderCancelTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 关闭类型 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderCancelTypeEnum implements IntArrayValuable { - - PAY_TIMEOUT(10, "超时未支付"), - AFTER_SALE_CLOSE(20, "退款关闭"), - MEMBER_CANCEL(30, "买家取消"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderCancelTypeEnum::getType).toArray(); - - /** - * 关闭类型 - */ - private final Integer type; - /** - * 关闭类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderItemAfterSaleStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderItemAfterSaleStatusEnum.java deleted file mode 100644 index 50640717e2..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderItemAfterSaleStatusEnum.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单项 - 售后状态 - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderItemAfterSaleStatusEnum implements IntArrayValuable { - - NONE(0, "未售后"), - APPLY(10, "售后中"), - SUCCESS(20, "售后成功"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderItemAfterSaleStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - /** - * 判断指定状态,是否正处于【未申请】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isNone(Integer status) { - return ObjectUtil.equals(status, NONE.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java deleted file mode 100644 index 8973ff9731..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -/** - * 订单操作类型的枚举 - * - * @author 陈賝 - * @since 2023/7/6 15:31 - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderOperateTypeEnum { - - MEMBER_CREATE(1, "用户下单"), - ADMIN_UPDATE_PRICE(2, "订单价格 {oldPayPrice} 修改,实际支付金额为 {newPayPrice} 元"), - MEMBER_PAY(10, "用户付款成功"), - ADMIN_UPDATE_ADDRESS(11, "收货地址修改"), - ADMIN_DELIVERY(20, "已发货,快递公司:{deliveryName},快递单号:{logisticsNo}"), - MEMBER_RECEIVE(30, "用户已收货"), - SYSTEM_RECEIVE(31, "到期未收货,系统自动确认收货"), - ADMIN_PICK_UP_RECEIVE(32, "管理员自提收货"), - MEMBER_COMMENT(33, "用户评价"), - SYSTEM_COMMENT(34, "到期未评价,系统自动评价"), - MEMBER_CANCEL(40, "取消订单"), - SYSTEM_CANCEL(41, "到期未支付,系统自动取消订单"), - // 42 预留:管理员取消订单 - ADMIN_CANCEL_AFTER_SALE(43, "订单全部售后,管理员自动取消订单"), - MEMBER_DELETE(49, "删除订单"), - ; - - /** - * 操作类型 - */ - private final Integer type; - /** - * 操作描述 - */ - private final String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderRefundStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderRefundStatusEnum.java deleted file mode 100644 index d0e4190bba..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderRefundStatusEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 退款状态 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderRefundStatusEnum implements IntArrayValuable { - - NONE(0, "未退款"), - PART(10, "部分退款"), - ALL(20, "全部退款"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderRefundStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java deleted file mode 100644 index 86d3d996f1..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 状态 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderStatusEnum implements IntArrayValuable { - - UNPAID(0, "待支付"), - UNDELIVERED(10, "待发货"), - DELIVERED(20, "已发货"), - COMPLETED(30, "已完成"), - CANCELED(40, "已取消"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - // ========== 问:为什么写了很多 isXXX 和 haveXXX 的判断逻辑呢? ========== - // ========== 答:方便找到某一类判断,哪些业务正在使用 ========== - - /** - * 判断指定状态,是否正处于【未付款】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isUnpaid(Integer status) { - return ObjectUtil.equal(UNPAID.getStatus(), status); - } - - /** - * 判断指定状态,是否正处于【待发货】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isUndelivered(Integer status) { - return ObjectUtil.equal(UNDELIVERED.getStatus(), status); - } - - /** - * 判断指定状态,是否正处于【已发货】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isDelivered(Integer status) { - return ObjectUtil.equals(status, DELIVERED.getStatus()); - } - - /** - * 判断指定状态,是否正处于【已取消】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isCanceled(Integer status) { - return ObjectUtil.equals(status, CANCELED.getStatus()); - } - - /** - * 判断指定状态,是否正处于【已完成】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isCompleted(Integer status) { - return ObjectUtil.equals(status, COMPLETED.getStatus()); - } - - /** - * 判断指定状态,是否有过【已付款】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean havePaid(Integer status) { - return ObjectUtils.equalsAny(status, UNDELIVERED.getStatus(), - DELIVERED.getStatus(), COMPLETED.getStatus()); - } - - /** - * 判断指定状态,是否有过【已发货】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean haveDelivered(Integer status) { - return ObjectUtils.equalsAny(status, DELIVERED.getStatus(), COMPLETED.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderTypeEnum.java deleted file mode 100644 index f820712068..0000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderTypeEnum.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 类型 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderTypeEnum implements IntArrayValuable { - - NORMAL(0, "普通订单"), - SECKILL(1, "秒杀订单"), - BARGAIN(2, "砍价订单"), - COMBINATION(3, "拼团订单"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static boolean isNormal(Integer type) { - return ObjectUtil.equal(type, NORMAL.getType()); - } - - public static boolean isSeckill(Integer type) { - return ObjectUtil.equal(type, SECKILL.getType()); - } - - public static boolean isBargain(Integer type) { - return ObjectUtil.equal(type, BARGAIN.getType()); - } - - public static boolean isCombination(Integer type) { - return ObjectUtil.equal(type, COMBINATION.getType()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/pom.xml b/yudao-module-mall/yudao-module-trade-biz/pom.xml deleted file mode 100644 index 912135eea5..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/pom.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-trade-biz - jar - - ${project.artifactId} - - trade 模块,主要实现交易相关功能 - 例如:订单、退款、购物车等功能。 - - - - - cn.iocoder.boot - yudao-module-trade-api - ${revision} - - - cn.iocoder.boot - yudao-module-product-api - ${revision} - - - cn.iocoder.boot - yudao-module-pay-api - ${revision} - - - cn.iocoder.boot - yudao-module-promotion-api - ${revision} - - - cn.iocoder.boot - yudao-module-member-api - ${revision} - - - cn.iocoder.boot - yudao-module-system-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-tenant - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-ip - - - - - cn.iocoder.boot - yudao-spring-boot-starter-web - - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-pay - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.boot - yudao-spring-boot-starter-redis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - - - - - cn.iocoder.boot - yudao-spring-boot-starter-excel - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-dict - - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java deleted file mode 100644 index 7426585d9c..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.trade.api.order; - -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -/** - * 订单 API 接口实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class TradeOrderApiImpl implements TradeOrderApi { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - - @Override - public List getOrderList(Collection ids) { - return TradeOrderConvert.INSTANCE.convertList04(tradeOrderQueryService.getOrderList(ids)); - } - - @Override - public TradeOrderRespDTO getOrder(Long id) { - return TradeOrderConvert.INSTANCE.convert(tradeOrderQueryService.getOrder(id)); - } - - @Override - public void cancelPaidOrder(Long userId, Long orderId) { - tradeOrderUpdateService.cancelPaidOrder(userId, orderId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java deleted file mode 100644 index 5b0e37dcc1..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.trade.api; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/AfterSaleController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/AfterSaleController.java deleted file mode 100644 index 6d20ba15af..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/AfterSaleController.java +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.*; -import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleLogService; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.annotation.security.PermitAll; -import jakarta.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 售后订单") -@RestController -@RequestMapping("/trade/after-sale") -@Validated -@Slf4j -public class AfterSaleController { - - @Resource - private AfterSaleService afterSaleService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - @Resource - private AfterSaleLogService afterSaleLogService; - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @Operation(summary = "获得售后订单分页") - @PreAuthorize("@ss.hasPermission('trade:after-sale:query')") - public CommonResult> getAfterSalePage(@Valid AfterSalePageReqVO pageVO) { - // 查询售后 - PageResult pageResult = afterSaleService.getAfterSalePage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 查询会员 - Map memberUsers = memberUserApi.getUserMap( - convertSet(pageResult.getList(), AfterSaleDO::getUserId)); - return success(AfterSaleConvert.INSTANCE.convertPage(pageResult, memberUsers)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得售后订单详情") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:query')") - public CommonResult getOrderDetail(@RequestParam("id") Long id) { - // 查询订单 - AfterSaleDO afterSale = afterSaleService.getAfterSale(id); - if (afterSale == null) { - return success(null); - } - - // 查询订单 - TradeOrderDO order = tradeOrderQueryService.getOrder(afterSale.getOrderId()); - // 查询订单项 - TradeOrderItemDO orderItem = tradeOrderQueryService.getOrderItem(afterSale.getOrderItemId()); - // 拼接数据 - MemberUserRespDTO user = memberUserApi.getUser(afterSale.getUserId()); - List logs = afterSaleLogService.getAfterSaleLogList(afterSale.getId()); - return success(AfterSaleConvert.INSTANCE.convert(afterSale, order, orderItem, user, logs)); - } - - @PutMapping("/agree") - @Operation(summary = "同意售后") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:agree')") - public CommonResult agreeAfterSale(@RequestParam("id") Long id) { - afterSaleService.agreeAfterSale(getLoginUserId(), id); - return success(true); - } - - @PutMapping("/disagree") - @Operation(summary = "拒绝售后") - @PreAuthorize("@ss.hasPermission('trade:after-sale:disagree')") - public CommonResult disagreeAfterSale(@RequestBody AfterSaleDisagreeReqVO confirmReqVO) { - afterSaleService.disagreeAfterSale(getLoginUserId(), confirmReqVO); - return success(true); - } - - @PutMapping("/receive") - @Operation(summary = "确认收货") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:receive')") - public CommonResult receiveAfterSale(@RequestParam("id") Long id) { - afterSaleService.receiveAfterSale(getLoginUserId(), id); - return success(true); - } - - @PutMapping("/refuse") - @Operation(summary = "拒绝收货") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:receive')") - public CommonResult refuseAfterSale(AfterSaleRefuseReqVO refuseReqVO) { - afterSaleService.refuseAfterSale(getLoginUserId(), refuseReqVO); - return success(true); - } - - @PutMapping("/refund") - @Operation(summary = "确认退款") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:refund')") - public CommonResult refundAfterSale(@RequestParam("id") Long id) { - afterSaleService.refundAfterSale(getLoginUserId(), getClientIP(), id); - return success(true); - } - - @PostMapping("/update-refunded") - @Operation(summary = "更新售后订单为已退款") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录,安全由 PayDemoOrderService 内部校验实现 - @OperateLog(enable = false) // 禁用操作日志,因为没有操作人 - public CommonResult updateAfterRefund(@RequestBody PayRefundNotifyReqDTO notifyReqDTO) { - // 目前业务逻辑,不需要做任何事情 - // 当然,退款会有小概率会失败的情况,可以监控失败状态,进行告警 - log.info("[updateAfterRefund][notifyReqDTO({})]", notifyReqDTO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http deleted file mode 100644 index 81cb35cbf0..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http +++ /dev/null @@ -1,33 +0,0 @@ -### 获得交易售后分页 => 成功 -GET {{baseUrl}}/trade/after-sale/page?pageNo=1&pageSize=10 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 同意售后 => 成功 -PUT {{baseUrl}}/trade/after-sale/agree?id=7 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json - -### 拒绝售后 => 成功 -PUT {{baseUrl}}/trade/after-sale/disagree -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json - -{ - "id": 6, - "auditReason": "阿巴巴" -} - -### 确认退款 => 成功 -PUT {{baseUrl}}/trade/after-sale/refund?id=6 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json - -### 确认收货 => 成功 -PUT {{baseUrl}}/trade/after-sale/receive?id=7 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleBaseVO.java deleted file mode 100644 index 89774aa7ad..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleBaseVO.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 交易售后 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class AfterSaleBaseVO { - - @Schema(description = "售后流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "202211190847450020500077") - @NotNull(message = "售后流水号不能为空") - private String no; - - @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "售后状态不能为空") - private Integer status; - - @Schema(description = "售后类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - @NotNull(message = "售后类型不能为空") - private Integer type; - - @Schema(description = "售后方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "售后方式不能为空") - private Integer way; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30337") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "申请原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "不喜欢") - @NotNull(message = "申请原因不能为空") - private String applyReason; - - @Schema(description = "补充描述", example = "你说的对") - private String applyDescription; - - @Schema(description = "补充凭证图片", example = "https://www.iocoder.cn/1.png") - private List applyPicUrls; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18078") - @NotNull(message = "订单编号不能为空") - private Long orderId; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022111917190001") - @NotNull(message = "订单流水号不能为空") - private String orderNo; - - @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "572") - @NotNull(message = "订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2888") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "商品 SPU 名称不能为空") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15657") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品图片", example = "https://www.iocoder.cn/2.png") - private String picUrl; - - @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20012") - @NotNull(message = "购买数量不能为空") - private Integer count; - - @Schema(description = "审批时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime auditTime; - - @Schema(description = "审批人", example = "30835") - private Long auditUserId; - - @Schema(description = "审批备注", example = "不香") - private String auditReason; - - @Schema(description = "退款金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "18077") - @NotNull(message = "退款金额,单位:分不能为空") - private Integer refundPrice; - - @Schema(description = "支付退款编号", example = "10271") - private Long payRefundId; - - @Schema(description = "退款时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime refundTime; - - @Schema(description = "退货物流公司编号", example = "10") - private Long logisticsId; - - @Schema(description = "退货物流单号", example = "610003952009") - private String logisticsNo; - - @Schema(description = "退货时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime deliveryTime; - - @Schema(description = "收货时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime receiveTime; - - @Schema(description = "收货备注", example = "不喜欢") - private String receiveReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDetailRespVO.java deleted file mode 100644 index 3f220770b4..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDetailRespVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.AfterSaleLogRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderBaseVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderItemBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - 售后订单的详情 Response VO") -@Data -public class AfterSaleDetailRespVO extends AfterSaleBaseVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - - - /** - * 订单基本信息 - */ - private TradeOrderBaseVO order; - /** - * 订单项列表 - */ - private OrderItem orderItem; - - /** - * 用户信息 - */ - private MemberUserRespVO user; - - /** - * 售后日志 - */ - private List logs; - - @Schema(description = "管理后台 - 交易订单的详情的订单项目") - @Data - public static class OrderItem extends TradeOrderItemBaseVO { - - /** - * 属性数组 - */ - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDisagreeReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDisagreeReqVO.java deleted file mode 100644 index ef9678650c..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDisagreeReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 交易售后拒绝 Request VO") -@Data -public class AfterSaleDisagreeReqVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "售后编号不能为空") - private Long id; - - @Schema(description = "审批备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - @NotEmpty(message = "审批备注不能为空") - private String auditReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSalePageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSalePageReqVO.java deleted file mode 100644 index f74c84b8fe..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSalePageReqVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 交易售后分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AfterSalePageReqVO extends PageParam { - - @Schema(description = "售后流水号", example = "202211190847450020500077") - private String no; - - @Schema(description = "售后状态", example = "10") - @InEnum(value = AfterSaleStatusEnum.class, message = "售后状态必须是 {value}") - private Integer status; - - @Schema(description = "售后类型", example = "20") - @InEnum(value = AfterSaleTypeEnum.class, message = "售后类型必须是 {value}") - private Integer type; - - @Schema(description = "售后方式", example = "10") - @InEnum(value = AfterSaleWayEnum.class, message = "售后方式必须是 {value}") - private Integer way; - - @Schema(description = "订单编号", example = "18078") - private String orderNo; - - @Schema(description = "商品 SPU 名称", example = "李四") - private String spuName; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRefuseReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRefuseReqVO.java deleted file mode 100644 index 36e52e842c..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRefuseReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 交易售后拒绝收货 Request VO") -@Data -public class AfterSaleRefuseReqVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "售后编号不能为空") - private Long id; - - @Schema(description = "收货备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - @NotNull(message = "收货备注不能为空") - private String refuseMemo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRespPageItemVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRespPageItemVO.java deleted file mode 100644 index 3e76405e9d..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRespPageItemVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 交易售后分页的每一条记录 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AfterSaleRespPageItemVO extends AfterSaleBaseVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27630") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - /** - * 商品属性数组 - */ - private List properties; - - /** - * 用户信息 - */ - private MemberUserRespVO user; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/log/AfterSaleLogRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/log/AfterSaleLogRespVO.java deleted file mode 100644 index c2ab475893..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/log/AfterSaleLogRespVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 交易售后日志 Response VO") -@Data -public class AfterSaleLogRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20669") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22634") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "用户类型不能为空") - private Integer userType; - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3023") - @NotNull(message = "售后编号不能为空") - private Long afterSaleId; - - @Schema(description = "售后状态(之前)", example = "2") - private Integer beforeStatus; - - @Schema(description = "售后状态(之后)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "售后状态(之后)不能为空") - private Integer afterStatus; - - @Schema(description = "操作明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "维权完成,退款金额:¥37776.00") - @NotNull(message = "操作明细不能为空") - private String content; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/package-info.java deleted file mode 100644 index f874e482db..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,可忽略 - */ -package cn.iocoder.yudao.module.trade.controller.admin.base.member; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/user/MemberUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/user/MemberUserRespVO.java deleted file mode 100644 index 2d7c3512d8..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/user/MemberUserRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.base.member.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员用户 Response VO") -@Data -public class MemberUserRespVO { - - @Schema(description = "用户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String nickname; - - @Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png") - private String avatar; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/package-info.java deleted file mode 100644 index 0baa83e49a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 放置该模块通用的 VO 类 - */ -package cn.iocoder.yudao.module.trade.controller.admin.base; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/product/property/ProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/product/property/ProductPropertyValueDetailRespVO.java deleted file mode 100644 index 3d6d3b0616..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/product/property/ProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.base.product.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商品属性值的明细 Response VO") -@Data -public class ProductPropertyValueDetailRespVO { - - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long propertyId; - - @Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long valueId; - - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java deleted file mode 100644 index bcf46d1dfe..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 佣金记录") -@RestController -@RequestMapping("/trade/brokerage-record") -@Validated -public class BrokerageRecordController { - - @Resource - private BrokerageRecordService brokerageRecordService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/get") - @Operation(summary = "获得佣金记录") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:brokerage-record:query')") - public CommonResult getBrokerageRecord(@RequestParam("id") Integer id) { - BrokerageRecordDO brokerageRecord = brokerageRecordService.getBrokerageRecord(id); - return success(BrokerageRecordConvert.INSTANCE.convert(brokerageRecord)); - } - - @GetMapping("/page") - @Operation(summary = "获得佣金记录分页") - @PreAuthorize("@ss.hasPermission('trade:brokerage-record:query')") - public CommonResult> getBrokerageRecordPage(@Valid BrokerageRecordPageReqVO pageVO) { - PageResult pageResult = brokerageRecordService.getBrokerageRecordPage(pageVO); - - // 查询用户信息 - Set userIds = convertSet(pageResult.getList(), BrokerageRecordDO::getUserId); - userIds.addAll(convertList(pageResult.getList(), BrokerageRecordDO::getSourceUserId)); - Map userMap = memberUserApi.getUserMap(userIds); - // 拼接数据 - return success(BrokerageRecordConvert.INSTANCE.convertPage(pageResult, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java deleted file mode 100644 index be197efb09..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.*; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 分销用户") -@RestController -@RequestMapping("/trade/brokerage-user") -@Validated -public class BrokerageUserController { - - @Resource - private BrokerageUserService brokerageUserService; - @Resource - private BrokerageRecordService brokerageRecordService; - @Resource - private BrokerageWithdrawService brokerageWithdrawService; - - @Resource - private MemberUserApi memberUserApi; - - @PutMapping("/update-bind-user") - @Operation(summary = "修改推广员") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:update-bind-user')") - public CommonResult updateBindUser(@Valid @RequestBody BrokerageUserUpdateBrokerageUserReqVO updateReqVO) { - brokerageUserService.updateBrokerageUserId(updateReqVO.getId(), updateReqVO.getBindUserId()); - return success(true); - } - - @PutMapping("/clear-bind-user") - @Operation(summary = "清除推广员") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:clear-bind-user')") - public CommonResult clearBindUser(@Valid @RequestBody BrokerageUserClearBrokerageUserReqVO updateReqVO) { - brokerageUserService.updateBrokerageUserId(updateReqVO.getId(), null); - return success(true); - } - - @PutMapping("/update-brokerage-enable") - @Operation(summary = "修改推广资格") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:update-brokerage-enable')") - public CommonResult updateBrokerageEnabled(@Valid @RequestBody BrokerageUserUpdateBrokerageEnabledReqVO updateReqVO) { - brokerageUserService.updateBrokerageUserEnabled(updateReqVO.getId(), updateReqVO.getEnabled()); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得分销用户") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:query')") - public CommonResult getBrokerageUser(@RequestParam("id") Long id) { - BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(id); - // TODO @疯狂:是不是搞成一个统一的 convert? - BrokerageUserRespVO respVO = BrokerageUserConvert.INSTANCE.convert(brokerageUser); - return success(BrokerageUserConvert.INSTANCE.copyTo(memberUserApi.getUser(id), respVO)); - } - - @GetMapping("/page") - @Operation(summary = "获得分销用户分页") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:query')") - public CommonResult> getBrokerageUserPage(@Valid BrokerageUserPageReqVO pageVO) { - // 分页查询 - PageResult pageResult = brokerageUserService.getBrokerageUserPage(pageVO); - - // 查询用户信息 - Set userIds = convertSet(pageResult.getList(), BrokerageUserDO::getId); - Map userMap = memberUserApi.getUserMap(userIds); - // 合计分佣的推广订单 - Map brokerageOrderSummaryMap = brokerageRecordService.getUserBrokerageSummaryMapByUserId( - userIds, BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus()); - // 合计分佣的推广用户 - // TODO @疯狂:转成 map 批量读取 - Map brokerageUserCountMap = convertMap(userIds, - userId -> userId, - userId -> brokerageUserService.getBrokerageUserCountByBindUserId(userId, null)); - // 合计分佣的提现 - // TODO @疯狂:如果未来支持了打款这个动作,可能 status 会不对; - Map withdrawMap = brokerageWithdrawService.getWithdrawSummaryMapByUserId( - userIds, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS); - // 拼接返回 - return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, - brokerageOrderSummaryMap, withdrawMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java deleted file mode 100644 index bb35c0d7f4..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRejectReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 佣金提现") -@RestController -@RequestMapping("/trade/brokerage-withdraw") -@Validated -public class BrokerageWithdrawController { - - @Resource - private BrokerageWithdrawService brokerageWithdrawService; - - @Resource - private MemberUserApi memberUserApi; - - @PutMapping("/approve") - @Operation(summary = "通过申请") - @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')") - public CommonResult approveBrokerageWithdraw(@RequestParam("id") Integer id) { - brokerageWithdrawService.auditBrokerageWithdraw(id, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS, ""); - return success(true); - } - - @PutMapping("/reject") - @Operation(summary = "驳回申请") - @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')") - public CommonResult rejectBrokerageWithdraw(@Valid @RequestBody BrokerageWithdrawRejectReqVO reqVO) { - brokerageWithdrawService.auditBrokerageWithdraw(reqVO.getId(), BrokerageWithdrawStatusEnum.AUDIT_FAIL, reqVO.getAuditReason()); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得佣金提现") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:query')") - public CommonResult getBrokerageWithdraw(@RequestParam("id") Integer id) { - BrokerageWithdrawDO brokerageWithdraw = brokerageWithdrawService.getBrokerageWithdraw(id); - return success(BrokerageWithdrawConvert.INSTANCE.convert(brokerageWithdraw)); - } - - @GetMapping("/page") - @Operation(summary = "获得佣金提现分页") - @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:query')") - public CommonResult> getBrokerageWithdrawPage(@Valid BrokerageWithdrawPageReqVO pageVO) { - // 分页查询 - PageResult pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(pageVO); - - // 拼接信息 - Map userMap = memberUserApi.getUserMap( - convertSet(pageResult.getList(), BrokerageWithdrawDO::getUserId)); - return success(BrokerageWithdrawConvert.INSTANCE.convertPage(pageResult, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java deleted file mode 100644 index 436a2f20cf..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 佣金记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BrokerageRecordBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25973") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23353") - @NotEmpty(message = "业务编号不能为空") - private String bizId; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "业务类型不能为空") - private Integer bizType; - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "标题不能为空") - private String title; - - @Schema(description = "金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "28731") - @NotNull(message = "金额不能为空") - private Integer price; - - @Schema(description = "当前总佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "13226") - @NotNull(message = "当前总佣金不能为空") - private Integer totalPrice; - - @Schema(description = "说明", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对") - @NotNull(message = "说明不能为空") - private String description; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "冻结时间(天)", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "冻结时间(天)不能为空") - private Integer frozenDays; - - @Schema(description = "解冻时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime unfreezeTime; - - @Schema(description = "来源用户等级") - private Integer sourceUserLevel; - - @Schema(description = "来源用户编号") - private Long sourceUserId; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordPageReqVO.java deleted file mode 100644 index 36c4744e84..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 佣金记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageRecordPageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "25973") - private Long userId; - - @Schema(description = "业务类型", example = "1") - private Integer bizType; - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "用户类型", example = "1") - private Integer sourceUserLevel; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java deleted file mode 100644 index 224ecf1e53..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 佣金记录 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageRecordRespVO extends BrokerageRecordBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28896") - private Integer id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - - // ========== 用户信息 ========== - - @Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png") - private String userAvatar; - @Schema(description = "用户昵称", example = "李四") - private String userNickname; - - - // ========== 来源用户信息 ========== - - @Schema(description = "来源用户头像", example = "https://www.iocoder.cn/xxx.png") - private String sourceUserAvatar; - @Schema(description = "来源用户昵称", example = "李四") - private String sourceUserNickname; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java deleted file mode 100644 index e732e3e142..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 分销用户 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BrokerageUserBaseVO { - - @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4587") - @NotNull(message = "推广员编号不能为空") - private Long bindUserId; - - @Schema(description = "推广员绑定时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime bindUserTime; - - @Schema(description = "推广资格", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "推广资格不能为空") - private Boolean brokerageEnabled; - - @Schema(description = "成为分销员时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime brokerageTime; - - @Schema(description = "可用佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "11089") - @NotNull(message = "可用佣金不能为空") - private Integer price; - - @Schema(description = "冻结佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "30916") - @NotNull(message = "冻结佣金不能为空") - private Integer frozenPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java deleted file mode 100644 index bc1b9254ea..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 分销用户 - 清除推广员 Request VO") -@Data -@ToString(callSuper = true) -public class BrokerageUserClearBrokerageUserReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - @NotNull(message = "用户编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserPageReqVO.java deleted file mode 100644 index cb0ce8954a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserPageReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 分销用户分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageUserPageReqVO extends PageParam { - - @Schema(description = "推广员编号", example = "4587") - private Long bindUserId; - - @Schema(description = "推广资格", example = "true") - private Boolean brokerageEnabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "用户等级", example = "1") // 注意,这了不是用户的会员等级,而是过滤推广的层级 - private Integer level; - - @Schema(description = "绑定时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] bindUserTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java deleted file mode 100644 index 3f5fe258f5..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 分销用户 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageUserRespVO extends BrokerageUserBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 用户信息 ========== - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.png") - private String avatar; - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String nickname; - - // ========== 推广信息 ========== 注意:是包括 1 + 2 级的数据 - - @Schema(description = "推广用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer brokerageUserCount; - @Schema(description = "推广订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer brokerageOrderCount; - @Schema(description = "推广订单金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer brokerageOrderPrice; - - // ========== 提现信息 ========== - - @Schema(description = "已提现金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer withdrawPrice; - @Schema(description = "已提现次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer withdrawCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java deleted file mode 100644 index 10519ad8c8..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 分销用户 - 修改推广员 Request VO") -@Data -@ToString(callSuper = true) -public class BrokerageUserUpdateBrokerageEnabledReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - @NotNull(message = "用户编号不能为空") - private Long id; - - @Schema(description = "推广资格", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "推广资格不能为空") - private Boolean enabled; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java deleted file mode 100644 index 8253463905..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 分销用户 - 修改推广员 Request VO") -@Data -@ToString(callSuper = true) -public class BrokerageUserUpdateBrokerageUserReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - @NotNull(message = "用户编号不能为空") - private Long id; - - @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4587") - @NotNull(message = "推广员编号不能为空") - private Long bindUserId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java deleted file mode 100644 index 69765a5287..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 佣金提现 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BrokerageWithdrawBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11436") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "提现金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "18781") - @NotNull(message = "提现金额不能为空") - private Integer price; - - @Schema(description = "提现手续费", requiredMode = Schema.RequiredMode.REQUIRED, example = "11417") - @NotNull(message = "提现手续费不能为空") - private Integer feePrice; - - @Schema(description = "当前总佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "18576") - @NotNull(message = "当前总佣金不能为空") - private Integer totalPrice; - - @Schema(description = "提现类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "提现类型不能为空") - private Integer type; - - @Schema(description = "真实姓名", example = "赵六") - private String name; - - @Schema(description = "账号", example = "88677912132") - private String accountNo; - - @Schema(description = "银行名称", example = "1") - private String bankName; - - @Schema(description = "开户地址", example = "海淀支行") - private String bankAddress; - - @Schema(description = "收款码", example = "https://www.iocoder.cn") - private String accountQrCodeUrl; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "审核驳回原因", example = "不对") - private String auditReason; - - @Schema(description = "审核时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime auditTime; - - @Schema(description = "备注", example = "随便") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawPageReqVO.java deleted file mode 100644 index b18ff74af4..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawPageReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 佣金提现分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageWithdrawPageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "11436") - private Long userId; - - @Schema(description = "提现类型", example = "1") - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现类型必须是 {value}") - private Integer type; - - @Schema(description = "真实姓名", example = "赵六") - private String name; - - @Schema(description = "账号", example = "886779132") - private String accountNo; - - @Schema(description = "银行名称", example = "1") - private String bankName; - - @Schema(description = "状态", example = "1") - @InEnum(value = BrokerageWithdrawStatusEnum.class, message = "状态必须是 {value}") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java deleted file mode 100644 index 7de2b7d7f2..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 驳回申请 Request VO") -@Data -@ToString(callSuper = true) -public class BrokerageWithdrawRejectReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") - @NotNull(message = "编号不能为空") - private Integer id; - - @Schema(description = "审核驳回原因", example = "不对") - @NotEmpty(message = "审核驳回原因不能为空") - private String auditReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java deleted file mode 100644 index de74bb4f6c..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 佣金提现 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageWithdrawRespVO extends BrokerageWithdrawBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") - private Integer id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String userNickname; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java deleted file mode 100644 index 74a9f8e00f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.config; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; -import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 交易中心配置") -@RestController -@RequestMapping("/trade/config") -@Validated -public class TradeConfigController { - - @Resource - private TradeConfigService tradeConfigService; - - @Value("${yudao.tencent-lbs-key}") - private String tencentLbsKey; - - @PutMapping("/save") - @Operation(summary = "更新交易中心配置") - @PreAuthorize("@ss.hasPermission('trade:config:save')") - public CommonResult updateConfig(@Valid @RequestBody TradeConfigSaveReqVO updateReqVO) { - tradeConfigService.saveTradeConfig(updateReqVO); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得交易中心配置") - @PreAuthorize("@ss.hasPermission('trade:config:query')") - public CommonResult getConfig() { - TradeConfigDO config = tradeConfigService.getTradeConfig(); - TradeConfigRespVO configVO = TradeConfigConvert.INSTANCE.convert(config); - if (configVO != null) { - configVO.setTencentLbsKey(tencentLbsKey); - } - return success(configVO); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java deleted file mode 100644 index 6b639b275b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.config.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.Range; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.PositiveOrZero; -import java.util.List; - -/** - * 交易中心配置 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class TradeConfigBaseVO { - - // ========== 售后相关 ========== - - @Schema(description = "售后的退款理由", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "售后的退款理由不能为空") - private List afterSaleRefundReasons; - - @Schema(description = "售后的退货理由", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "售后的退货理由不能为空") - private List afterSaleReturnReasons; - - // ========== 配送相关 ========== - - /** - * 是否启用全场包邮 - */ - @Schema(description = "是否启用全场包邮", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否启用全场包邮不能为空") - private Boolean deliveryExpressFreeEnabled; - - @Schema(description = "全场包邮的最小金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @NotNull(message = "全场包邮的最小金额不能为空") - @PositiveOrZero(message = "全场包邮的最小金额不能是负数") - private Integer deliveryExpressFreePrice; - - @Schema(description = "是否开启自提", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否开启自提不能为空") - private Boolean deliveryPickUpEnabled; - - // ========== 分销相关 ========== - - @Schema(description = "是否启用分佣", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否启用分佣不能为空") - private Boolean brokerageEnabled; - - @Schema(description = "分佣模式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "分佣模式不能为空") - @InEnum(value = BrokerageEnabledConditionEnum.class, message = "分佣模式必须是 {value}") - private Integer brokerageEnabledCondition; - - @Schema(description = "分销关系绑定模式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "分销关系绑定模式不能为空") - @InEnum(value = BrokerageBindModeEnum.class, message = "分销关系绑定模式必须是 {value}") - private Integer brokerageBindMode; - - @Schema(description = "分销海报图地址数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/yudao.jpg]") - private List brokeragePosterUrls; - - @Schema(description = "一级返佣比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "一级返佣比例不能为空") - @Range(min = 0, max = 100, message = "一级返佣比例必须在 0 - 100 之间") - private Integer brokerageFirstPercent; - - @Schema(description = "二级返佣比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "二级返佣比例不能为空") - @Range(min = 0, max = 100, message = "二级返佣比例必须在 0 - 100 之间") - private Integer brokerageSecondPercent; - - @Schema(description = "用户提现最低金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @NotNull(message = "用户提现最低金额不能为空") - @PositiveOrZero(message = "用户提现最低金额不能是负数") - private Integer brokerageWithdrawMinPrice; - - @Schema(description = "用户提现手续费百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @NotNull(message = "用户提现手续费百分比不能为空") - @PositiveOrZero(message = "用户提现手续费百分比不能是负数") - private Integer brokerageWithdrawFeePercent; - - @Schema(description = "提现银行", requiredMode = Schema.RequiredMode.REQUIRED, example = "[0, 1]") - @NotEmpty(message = "提现银行不能为空") - private List brokerageBankNames; - - @Schema(description = "佣金冻结时间(天)", requiredMode = Schema.RequiredMode.REQUIRED, example = "7") - @NotNull(message = "佣金冻结时间(天)不能为空") - @PositiveOrZero(message = "佣金冻结时间不能是负数") - private Integer brokerageFrozenDays; - - @Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[0, 1]") - @NotEmpty(message = "提现方式不能为空") - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现方式必须是 {value}") - private List brokerageWithdrawTypes; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java deleted file mode 100644 index 5ded00ace1..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 交易中心配置 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class TradeConfigRespVO extends TradeConfigBaseVO { - - @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "腾讯地图 KEY", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - private String tencentLbsKey; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java deleted file mode 100644 index 03a0c41dfb..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 交易中心配置更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class TradeConfigSaveReqVO extends TradeConfigBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java deleted file mode 100644 index 4b7f87279d..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.*; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; - -@Tag(name = "管理后台 - 快递公司") -@RestController -@RequestMapping("/trade/delivery/express") -@Validated -public class DeliveryExpressController { - - @Resource - private DeliveryExpressService deliveryExpressService; - - @PostMapping("/create") - @Operation(summary = "创建快递公司") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:create')") - public CommonResult createDeliveryExpress(@Valid @RequestBody DeliveryExpressCreateReqVO createReqVO) { - return success(deliveryExpressService.createDeliveryExpress(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新快递公司") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:update')") - public CommonResult updateDeliveryExpress(@Valid @RequestBody DeliveryExpressUpdateReqVO updateReqVO) { - deliveryExpressService.updateDeliveryExpress(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除快递公司") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('trade:delivery:express:delete')") - public CommonResult deleteDeliveryExpress(@RequestParam("id") Long id) { - deliveryExpressService.deleteDeliveryExpress(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得快递公司") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:query')") - public CommonResult getDeliveryExpress(@RequestParam("id") Long id) { - DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(id); - return success(DeliveryExpressConvert.INSTANCE.convert(deliveryExpress)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取快递公司精简信息列表", description = "主要用于前端的下拉选项") - public CommonResult> getSimpleDeliveryExpressList() { - List list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(DeliveryExpressConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得快递公司分页") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:query')") - public CommonResult> getDeliveryExpressPage(@Valid DeliveryExpressPageReqVO pageVO) { - PageResult pageResult = deliveryExpressService.getDeliveryExpressPage(pageVO); - return success(DeliveryExpressConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出快递公司 Excel") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:export')") - @OperateLog(type = EXPORT) - public void exportDeliveryExpressExcel(@Valid DeliveryExpressExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = deliveryExpressService.getDeliveryExpressList(exportReqVO); - // 导出 Excel - List dataList = DeliveryExpressConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "快递公司.xls", "数据", DeliveryExpressExcelVO.class, dataList); - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java deleted file mode 100644 index d445b630a1..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.*; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressTemplateConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 快递运费模板") -@RestController -@RequestMapping("/trade/delivery/express-template") -@Validated -public class DeliveryExpressTemplateController { - - @Resource - private DeliveryExpressTemplateService deliveryExpressTemplateService; - - @PostMapping("/create") - @Operation(summary = "创建快递运费模板") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:create')") - public CommonResult createDeliveryExpressTemplate(@Valid @RequestBody DeliveryExpressTemplateCreateReqVO createReqVO) { - return success(deliveryExpressTemplateService.createDeliveryExpressTemplate(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新快递运费模板") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:update')") - public CommonResult updateDeliveryExpressTemplate(@Valid @RequestBody DeliveryExpressTemplateUpdateReqVO updateReqVO) { - deliveryExpressTemplateService.updateDeliveryExpressTemplate(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除快递运费模板") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:delete')") - public CommonResult deleteDeliveryExpressTemplate(@RequestParam("id") Long id) { - deliveryExpressTemplateService.deleteDeliveryExpressTemplate(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得快递运费模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:query')") - public CommonResult getDeliveryExpressTemplate(@RequestParam("id") Long id) { - return success(deliveryExpressTemplateService.getDeliveryExpressTemplate(id)); - } - - @GetMapping("/list") - @Operation(summary = "获得快递运费模板列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:query')") - public CommonResult> getDeliveryExpressTemplateList(@RequestParam("ids") Collection ids) { - List list = deliveryExpressTemplateService.getDeliveryExpressTemplateList(ids); - return success(DeliveryExpressTemplateConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取快递模版精简信息列表", description = "主要用于前端的下拉选项") - public CommonResult> getSimpleTemplateList() { - // 获取运费模版列表,只要开启状态的 - List list = deliveryExpressTemplateService.getDeliveryExpressTemplateList(); - // 排序后,返回给前端 - return success(DeliveryExpressTemplateConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得快递运费模板分页") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:query')") - public CommonResult> getDeliveryExpressTemplatePage(@Valid DeliveryExpressTemplatePageReqVO pageVO) { - PageResult pageResult = deliveryExpressTemplateService.getDeliveryExpressTemplatePage(pageVO); - return success(DeliveryExpressTemplateConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java deleted file mode 100644 index b8d7f1fce2..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java +++ /dev/null @@ -1,91 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 自提门店") -@RestController -@RequestMapping("/trade/delivery/pick-up-store") -@Validated -public class DeliveryPickUpStoreController { - - @Resource - private DeliveryPickUpStoreService deliveryPickUpStoreService; - - @PostMapping("/create") - @Operation(summary = "创建自提门店") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')") - public CommonResult createDeliveryPickUpStore(@Valid @RequestBody DeliveryPickUpStoreCreateReqVO createReqVO) { - return success(deliveryPickUpStoreService.createDeliveryPickUpStore(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新自提门店") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:update')") - public CommonResult updateDeliveryPickUpStore(@Valid @RequestBody DeliveryPickUpStoreUpdateReqVO updateReqVO) { - deliveryPickUpStoreService.updateDeliveryPickUpStore(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除自提门店") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:delete')") - public CommonResult deleteDeliveryPickUpStore(@RequestParam("id") Long id) { - deliveryPickUpStoreService.deleteDeliveryPickUpStore(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得自提门店") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") - public CommonResult getDeliveryPickUpStore(@RequestParam("id") Long id) { - DeliveryPickUpStoreDO deliveryPickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(id); - return success(DeliveryPickUpStoreConvert.INSTANCE.convert(deliveryPickUpStore)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获得自提门店精简信息列表") - public CommonResult> getSimpleDeliveryPickUpStoreList() { - List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/list") - @Operation(summary = "获得自提门店列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") - public CommonResult> getDeliveryPickUpStoreList(@RequestParam("ids") Collection ids) { - List list = deliveryPickUpStoreService.getDeliveryPickUpStoreList(ids); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得自提门店分页") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") - public CommonResult> getDeliveryPickUpStorePage(@Valid DeliveryPickUpStorePageReqVO pageVO) { - PageResult pageResult = deliveryPickUpStoreService.getDeliveryPickUpStorePage(pageVO); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressBaseVO.java deleted file mode 100644 index 2d280c6beb..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressBaseVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** -* 快递公司 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DeliveryExpressBaseVO { - - @Schema(description = "快递公司编码", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "快递公司编码不能为空") - private String code; - - @Schema(description = "快递公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "快递公司名称不能为空") - private String name; - - @Schema(description = "快递公司logo") - private String logo; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressCreateReqVO.java deleted file mode 100644 index a9ba8a7cb3..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "管理后台 - 快递公司创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressCreateReqVO extends DeliveryExpressBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExcelVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExcelVO.java deleted file mode 100644 index c84a3a1896..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExcelVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 快递公司 Excel VO - */ -@Data -public class DeliveryExpressExcelVO { - - @ExcelProperty("编号") - private Long id; - - @ExcelProperty("快递公司编码") - private String code; - - @ExcelProperty("快递公司名称") - private String name; - - @ExcelProperty("快递公司 logo") - private String logo; - - @ExcelProperty("排序") - private Integer sort; - - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExportReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExportReqVO.java deleted file mode 100644 index c601721e8b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExportReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 快递公司 Excel 导出 Request VO") -@Data -public class DeliveryExpressExportReqVO { - - @Schema(description = "快递公司编码") - private String code; - - @Schema(description = "快递公司名称", example = "李四") - private String name; - - @Schema(description = "状态(0正常 1停用)", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressPageReqVO.java deleted file mode 100644 index 4a000f319b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressPageReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 快递公司分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressPageReqVO extends PageParam { - - @Schema(description = "快递公司编码") - private String code; - - @Schema(description = "快递公司名称", example = "李四") - private String name; - - @Schema(description = "状态(0正常 1停用)", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressRespVO.java deleted file mode 100644 index cc314d1052..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 快递公司 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressRespVO extends DeliveryExpressBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6592") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java deleted file mode 100644 index 8045133c42..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 快递公司精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DeliveryExpressSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6592") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "快递公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "顺丰速运") - @NotNull(message = "快递公司名称不能为空") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressUpdateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressUpdateReqVO.java deleted file mode 100644 index 2f5a084682..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 快递公司更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressUpdateReqVO extends DeliveryExpressBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6592") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateBaseVO.java deleted file mode 100644 index 4180740248..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateBaseVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** -* 快递运费模板 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DeliveryExpressTemplateBaseVO { - - @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotNull(message = "模板名称不能为空") - private String name; - - @Schema(description = "配送计费方式 1:按件 2:按重量 3:按体积", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "配送计费方式 1:按件 2:按重量 3:按体积不能为空") - private Integer chargeMode; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "排序不能为空") - private Integer sort; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateChargeBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateChargeBaseVO.java deleted file mode 100644 index 493c952b6f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateChargeBaseVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -/** - * 快递运费模板运费设置 Base VO,提供给添加运费模板使用 - */ -@Data -public class DeliveryExpressTemplateChargeBaseVO { - - @Schema(description = "编号", example = "6592", hidden = true) // 由于想简单一点,复用这个 VO 在更新操作,所以 hidden 为 false - private Long id; - - @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]") - @NotEmpty(message = "区域编号列表不能为空") - private List areaIds; - - @Schema(description = "首件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "首件数量不能为空") - private Double startCount; - - @Schema(description = "起步价", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @NotNull(message = "起步价不能为空") - private Integer startPrice; - - @Schema(description = "续件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "续件数量不能为空") - private Double extraCount; - - @Schema(description = "额外价", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - @NotNull(message = "额外价不能为空") - private Integer extraPrice; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java deleted file mode 100644 index 518e13e910..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.Valid; -import java.util.List; - -@Schema(description = "管理后台 - 快递运费模板创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplateCreateReqVO extends DeliveryExpressTemplateBaseVO { - - @Schema(description = "区域运费列表") - @Valid - private List charges; - - @Schema(description = "包邮区域列表") - @Valid - private List frees; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java deleted file mode 100644 index 272ab59a0a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 快递运费模板的详细 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplateDetailRespVO extends DeliveryExpressTemplateBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "371") - private Long id; - - @Schema(description = "运费模板运费设置", requiredMode = Schema.RequiredMode.REQUIRED) - private List charges; - - @Schema(description = "运费模板包邮区域", requiredMode = Schema.RequiredMode.REQUIRED) - private List frees; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateFreeBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateFreeBaseVO.java deleted file mode 100644 index 16070b58fd..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateFreeBaseVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -/** - * 快递运费模板包邮 Base VO,提供给添加运费模板使用 - */ -@Data -public class DeliveryExpressTemplateFreeBaseVO { - - @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]") - @NotEmpty(message = "区域编号列表不能为空") - private List areaIds; - - @Schema(description = "包邮金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "5000") - @NotNull(message = "包邮金额不能为空") - private Integer freePrice; - - @Schema(description = "包邮件数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "包邮件数不能为空") - private Integer freeCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplatePageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplatePageReqVO.java deleted file mode 100644 index ea1e4ab3e0..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplatePageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 快递运费模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplatePageReqVO extends PageParam { - - @Schema(description = "模板名称", example = "王五") - private String name; - - @Schema(description = "配送计费方式 1:按件 2:按重量 3:按体积") - private Integer chargeMode; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateRespVO.java deleted file mode 100644 index 19a8c16212..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 快递运费模板 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplateRespVO extends DeliveryExpressTemplateBaseVO { - - @Schema(description = "编号,自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "371") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateSimpleRespVO.java deleted file mode 100644 index 074cc53377..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateSimpleRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - - -@Schema(description = "管理后台 - 模版精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DeliveryExpressTemplateSimpleRespVO { - - @Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试模版") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java deleted file mode 100644 index 77b6dee12f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 快递运费模板更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplateUpdateReqVO extends DeliveryExpressTemplateBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "371") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "区域运费列表") - @Valid - private List charges; - - @Schema(description = "包邮区域列表") - @Valid - private List frees; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java deleted file mode 100644 index 79995ceb43..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import java.time.LocalTime; - -/** -* 自提门店 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DeliveryPickUpStoreBaseVO { - - @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotBlank(message = "门店名称不能为空") - private String name; - - @Schema(description = "门店简介", example = "我是门店简介") - private String introduction; - - @Schema(description = "门店手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601892312") - @NotBlank(message = "门店手机不能为空") - @Mobile - private String phone; - - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") - @NotNull(message = "区域编号不能为空") - private Integer areaId; - - @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") - @NotBlank(message = "门店详细地址不能为空") - private String detailAddress; - - @Schema(description = "门店 logo", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotBlank(message = "门店 logo 不能为空") - private String logo; - - @Schema(description = "营业开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "营业开始时间不能为空") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") - private LocalTime openingTime; - - @Schema(description = "营业结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "营业结束时间不能为空") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") - private LocalTime closingTime; - - @Schema(description = "纬度", requiredMode = Schema.RequiredMode.REQUIRED, example = "5.88") - @NotNull(message = "纬度不能为空") - private Double latitude; - - @Schema(description = "经度", requiredMode = Schema.RequiredMode.REQUIRED, example = "6.99") - @NotNull(message = "经度不能为空") - private Double longitude; - - @Schema(description = "门店状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "门店状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java deleted file mode 100644 index 6dda8399f3..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.*; - -@Schema(description = "管理后台 - 自提门店创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryPickUpStoreCreateReqVO extends DeliveryPickUpStoreBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java deleted file mode 100644 index 45f0c87b94..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import lombok.*; - -import java.time.LocalTime; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 自提门店分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryPickUpStorePageReqVO extends PageParam { - - @Schema(description = "门店名称", example = "李四") - private String name; - - @Schema(description = "门店手机") - private String phone; - - @Schema(description = "区域编号", example = "18733") - private Integer areaId; - - @Schema(description = "门店状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java deleted file mode 100644 index 5b5bd0d0c8..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 自提门店 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryPickUpStoreRespVO extends DeliveryPickUpStoreBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java deleted file mode 100644 index c12fc9fc3e..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - 自提门店精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DeliveryPickUpStoreSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") - private Long id; - - @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String name; - - @Schema(description = "门店手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601892312") - private String phone; - - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") - private Integer areaId; - - @Schema(description = "区域名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "xx市") - private String areaName; - - @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") - private String detailAddress; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java deleted file mode 100644 index e0774f6d91..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 自提门店更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryPickUpStoreUpdateReqVO extends DeliveryPickUpStoreBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http deleted file mode 100644 index 0bf8812b2e..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http +++ /dev/null @@ -1,9 +0,0 @@ -### 获得交易订单分页 => 成功 -GET {{baseUrl}}/trade/order/page?pageNo=1&pageSize=10 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 获得交易订单分页 => 成功 -GET {{baseUrl}}/trade/order/get-detail?id=21 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java deleted file mode 100644 index 5a572d6f60..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java +++ /dev/null @@ -1,168 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderLogService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 交易订单") -@RestController -@RequestMapping("/trade/order") -@Validated -@Slf4j -public class TradeOrderController { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - @Resource - private TradeOrderLogService tradeOrderLogService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @Operation(summary = "获得交易订单分页") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult> getOrderPage(TradeOrderPageReqVO reqVO) { - // 查询订单 - PageResult pageResult = tradeOrderQueryService.getOrderPage(reqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 查询用户信息 - Set userIds = CollUtil.unionDistinct(convertList(pageResult.getList(), TradeOrderDO::getUserId), - convertList(pageResult.getList(), TradeOrderDO::getBrokerageUserId, Objects::nonNull)); - Map userMap = memberUserApi.getUserMap(userIds); - // 查询订单项 - List orderItems = tradeOrderQueryService.getOrderItemListByOrderId( - convertSet(pageResult.getList(), TradeOrderDO::getId)); - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convertPage(pageResult, orderItems, userMap)); - } - - @GetMapping("/summary") - @Operation(summary = "获得交易订单统计") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult getOrderSummary(TradeOrderPageReqVO reqVO) { - return success(tradeOrderQueryService.getOrderSummary(reqVO)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得交易订单详情") - @Parameter(name = "id", description = "订单编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult getOrderDetail(@RequestParam("id") Long id) { - // 查询订单 - TradeOrderDO order = tradeOrderQueryService.getOrder(id); - if (order == null) { - return success(null); - } - // 查询订单项 - List orderItems = tradeOrderQueryService.getOrderItemListByOrderId(id); - - // 拼接数据 - MemberUserRespDTO user = memberUserApi.getUser(order.getUserId()); - MemberUserRespDTO brokerageUser = order.getBrokerageUserId() != null ? - memberUserApi.getUser(order.getBrokerageUserId()) : null; - List orderLogs = tradeOrderLogService.getOrderLogListByOrderId(id); - return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, orderLogs, user, brokerageUser)); - } - - @GetMapping("/get-express-track-list") - @Operation(summary = "获得交易订单的物流轨迹") - @Parameter(name = "id", description = "交易订单编号") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult> getOrderExpressTrackList(@RequestParam("id") Long id) { - return success(TradeOrderConvert.INSTANCE.convertList02( - tradeOrderQueryService.getExpressTrackList(id))); - } - - @PutMapping("/delivery") - @Operation(summary = "订单发货") - @PreAuthorize("@ss.hasPermission('trade:order:update')") - public CommonResult deliveryOrder(@RequestBody TradeOrderDeliveryReqVO deliveryReqVO) { - tradeOrderUpdateService.deliveryOrder(deliveryReqVO); - return success(true); - } - - @PutMapping("/update-remark") - @Operation(summary = "订单备注") - @PreAuthorize("@ss.hasPermission('trade:order:update')") - public CommonResult updateOrderRemark(@RequestBody TradeOrderRemarkReqVO reqVO) { - tradeOrderUpdateService.updateOrderRemark(reqVO); - return success(true); - } - - @PutMapping("/update-price") - @Operation(summary = "订单调价") - @PreAuthorize("@ss.hasPermission('trade:order:update')") - public CommonResult updateOrderPrice(@RequestBody TradeOrderUpdatePriceReqVO reqVO) { - tradeOrderUpdateService.updateOrderPrice(reqVO); - return success(true); - } - - @PutMapping("/update-address") - @Operation(summary = "修改订单收货地址") - @PreAuthorize("@ss.hasPermission('trade:order:update')") - public CommonResult updateOrderAddress(@RequestBody TradeOrderUpdateAddressReqVO reqVO) { - tradeOrderUpdateService.updateOrderAddress(reqVO); - return success(true); - } - - @PutMapping("/pick-up-by-id") - @Operation(summary = "订单核销") - @Parameter(name = "id", description = "交易订单编号") - @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") - public CommonResult pickUpOrderById(@RequestParam("id") Long id) { - tradeOrderUpdateService.pickUpOrderByAdmin(id); - return success(true); - } - - @PutMapping("/pick-up-by-verify-code") - @Operation(summary = "订单核销") - @Parameter(name = "pickUpVerifyCode", description = "自提核销码") - @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") - public CommonResult pickUpOrderByVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) { - tradeOrderUpdateService.pickUpOrderByAdmin(pickUpVerifyCode); - return success(true); - } - - @GetMapping("/get-by-pick-up-verify-code") - @Operation(summary = "查询核销码对应的订单") - @Parameter(name = "pickUpVerifyCode", description = "自提核销码") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult getByPickUpVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) { - TradeOrderDO tradeOrder = tradeOrderUpdateService.getByPickUpVerifyCode(pickUpVerifyCode); - return success(TradeOrderConvert.INSTANCE.convert2(tradeOrder, null)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java deleted file mode 100755 index 88f5b0cd43..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java +++ /dev/null @@ -1,151 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 交易订单 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class TradeOrderBaseVO { - - // ========== 订单基本信息 ========== - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "订单类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - @Schema(description = "订单来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer terminal; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long userId; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - private String userIp; - - @Schema(description = "用户备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String userRemark; - - @Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer productCount; - - @Schema(description = "订单完成时间") - private LocalDateTime finishTime; - - @Schema(description = "订单取消时间") - private LocalDateTime cancelTime; - - @Schema(description = "取消类型", example = "10") - private Integer cancelType; - - @Schema(description = "商家备注", example = "你猜一下") - private String remark; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - - @Schema(description = "是否已支付", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean payStatus; - - @Schema(description = "付款时间") - private LocalDateTime payTime; - - @Schema(description = "支付渠道", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_lite") - private String payChannelCode; - - @Schema(description = "商品原价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer totalPrice; - - @Schema(description = "订单优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer discountPrice; - - @Schema(description = "运费金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer deliveryPrice; - - @Schema(description = "订单调价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer adjustPrice; - - @Schema(description = "应付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - - @Schema(description = "配送方式", example = "10") - private Integer deliveryType; - - @Schema(description = "自提门店", example = "10") - private Long pickUpStoreId; - - @Schema(description = "自提核销码", example = "10") - private Long pickUpVerifyCode; - - @Schema(description = "配送模板编号", example = "1024") - private Long deliveryTemplateId; - - @Schema(description = "发货物流公司编号", example = "1024") - private Long logisticsId; - - @Schema(description = "发货物流单号", example = "1024") - private String logisticsNo; - - @Schema(description = "发货时间") - private LocalDateTime deliveryTime; - - @Schema(description = "收货时间") - private LocalDateTime receiveTime; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String receiverName; - - @Schema(description = "收件人手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "13800138000") - private String receiverMobile; - - @Schema(description = "收件人地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "110000") - private Integer receiverAreaId; - - @Schema(description = "收件人详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "中关村大街 1 号") - private String receiverDetailAddress; - - // ========== 售后基本信息 ========== - - @Schema(description = "售后状态", example = "1") - private Integer afterSaleStatus; - - @Schema(description = "退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer refundPrice; - - // ========== 营销基本信息 ========== - - @Schema(description = "优惠劵编号", example = "1024") - private Long couponId; - - @Schema(description = "优惠劵减免金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer couponPrice; - - @Schema(description = "积分抵扣的金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer pointPrice; - - @Schema(description = "VIP 减免金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Integer vipPrice; - - @Schema(description = "推广人编号", example = "1") - private Long brokerageUserId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java deleted file mode 100644 index b5574079b8..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 订单发货 Request VO") -@Data -public class TradeOrderDeliveryReqVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "订单编号不能为空") - private Long id; - - @Schema(description = "发货物流公司编号", example = "1") - @NotNull(message = "发货物流公司不能为空") - private Long logisticsId; - - @Schema(description = "发货物流单号", example = "SF123456789") - private String logisticsNo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java deleted file mode 100644 index 055639e47e..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 交易订单的详情 Response VO") -@Data -public class TradeOrderDetailRespVO extends TradeOrderBaseVO { - - /** - * 订单项列表 - */ - private List items; - - /** - * 下单用户信息 - */ - private MemberUserRespVO user; - /** - * 推广用户信息 - */ - private MemberUserRespVO brokerageUser; - - /** - * 操作日志列表 - */ - private List logs; - - @Schema(description = "收件人地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海 上海市 普陀区") - private String receiverAreaName; - - @Schema(description = "管理后台 - 交易订单的操作日志") - @Data - public static class OrderLog { - - @Schema(description = "操作详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "订单发货") - private String content; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-06-01 10:50:20") - private LocalDateTime createTime; - - @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer userType; - - } - - @Schema(description = "管理后台 - 交易订单的详情的订单项目") - @Data - public static class Item extends TradeOrderItemBaseVO { - - /** - * 属性数组 - */ - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderItemBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderItemBaseVO.java deleted file mode 100644 index ded1fe7a1f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderItemBaseVO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 交易订单项 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class TradeOrderItemBaseVO { - - // ========== 订单项基本信息 ========== - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long userId; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long orderId; - - // ========== 商品基本信息 ========== - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long skuId; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "商品原价(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - - @Schema(description = "商品优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer discountPrice; - - @Schema(description = "商品实付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer payPrice; - - @Schema(description = "子订单分摊金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer orderPartPrice; - - @Schema(description = "分摊后子订单实付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer orderDividePrice; - - // ========== 营销基本信息 ========== - - // TODO 芋艿:在捉摸一下 - - // ========== 售后基本信息 ========== - - @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer afterSaleStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java deleted file mode 100644 index 704067ed0e..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - 交易订单的分页项 Response VO") -@Data -public class TradeOrderPageItemRespVO extends TradeOrderBaseVO { - - @Schema(description = "收件人地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海 上海市 普陀区") - private String receiverAreaName; - - @Schema(description = "订单项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "用户信息", requiredMode = Schema.RequiredMode.REQUIRED) - private MemberUserRespVO user; - - @Schema(description = "推广人信息") - private MemberUserRespVO brokerageUser; - - @Schema(description = "管理后台 - 交易订单的分页项的订单项目") - @Data - public static class Item extends TradeOrderItemBaseVO { - - @Schema(description = "属性列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java deleted file mode 100644 index 074a1e5446..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 交易订单的分页 Request VO") -@Data -public class TradeOrderPageReqVO extends PageParam { - - @Schema(description = "订单号", example = "88888888") - private String no; - - @Schema(description = "用户编号", example = "1024") - private Long userId; - - @Schema(description = "用户昵称", example = "小王") - private String userNickname; - - @Schema(description = "用户手机号", example = "小王") - @Mobile - private String userMobile; - - @Schema(description = "配送方式", example = "1") - private Integer deliveryType; - - @Schema(description = "发货物流公司编号", example = "1") - private Long logisticsId; - - @Schema(description = "自提门店编号", example = "[1,2]") - private List pickUpStoreIds; - - @Schema(description = "自提核销码", example = "12345678") - private String pickUpVerifyCode; - - @Schema(description = "订单类型", example = "1") - private Integer type; - - @Schema(description = "订单状态", example = "1") - @InEnum(value = TradeOrderStatusEnum.class, message = "订单状态必须是 {value}") - private Integer status; - - @Schema(description = "支付渠道", example = "wx_lite") - private String payChannelCode; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "订单来源", example = "10") - @InEnum(value = TerminalEnum.class, message = "订单来源 {value}") - private Integer terminal; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java deleted file mode 100644 index 9395150885..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 订单备注 Request VO") -@Data -public class TradeOrderRemarkReqVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "订单编号不能为空") - private Long id; - - @Schema(description = "商家备注", example = "你猜一下") - @NotEmpty(message = "订单备注不能为空") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderSummaryRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderSummaryRespVO.java deleted file mode 100644 index 184c8db838..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderSummaryRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 交易订单统计 Response VO") -@Data -public class TradeOrderSummaryRespVO { - - @Schema(description = "订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderCount; - - @Schema(description = "订单金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderPayPrice; - - @Schema(description = "退款单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long afterSaleCount; - - @Schema(description = "退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long afterSalePrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdateAddressReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdateAddressReqVO.java deleted file mode 100644 index ef8905fb04..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdateAddressReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 订单修改地址 Request VO") -@Data -public class TradeOrderUpdateAddressReqVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "订单编号不能为空") - private Long id; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "z张三") - @NotEmpty(message = "收件人名称不能为空") - private String receiverName; - - @Schema(description = "收件人手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "19988188888") - @NotEmpty(message = "收件人手机不能为空") - private String receiverMobile; - - @Schema(description = "收件人地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7310") - @NotNull(message = "收件人地区编号不能为空") - private Integer receiverAreaId; - - @Schema(description = "收件人详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "昆明市五华区xxx小区xxx") - @NotEmpty(message = "收件人详细地址不能为空") - private String receiverDetailAddress; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdatePriceReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdatePriceReqVO.java deleted file mode 100644 index 273e7fc4d0..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdatePriceReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 订单改价 Request VO") -@Data -public class TradeOrderUpdatePriceReqVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "订单编号不能为空") - private Long id; - - @Schema(description = "订单调价,单位:分。正数,加价;负数,减价", requiredMode = Schema.RequiredMode.REQUIRED, example = "-100") - @NotNull(message = "订单调价价格不能为空") - private Integer adjustPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleController.java deleted file mode 100644 index d0677d5289..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO; -import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleConvert; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 交易售后") -@RestController -@RequestMapping("/trade/after-sale") -@Validated -@Slf4j -public class AppAfterSaleController { - - @Resource - private AfterSaleService afterSaleService; - - @GetMapping(value = "/page") - @Operation(summary = "获得售后分页") - public CommonResult> getAfterSalePage(PageParam pageParam) { - return success(AfterSaleConvert.INSTANCE.convertPage02( - afterSaleService.getAfterSalePage(getLoginUserId(), pageParam))); - } - - @GetMapping(value = "/get") - @Operation(summary = "获得售后订单") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - public CommonResult getAfterSale(@RequestParam("id") Long id) { - return success(AfterSaleConvert.INSTANCE.convert(afterSaleService.getAfterSale(getLoginUserId(), id))); - } - - @GetMapping(value = "/get-applying-count") - @Operation(summary = "获得进行中的售后订单数量") - public CommonResult getApplyingAfterSaleCount() { - return success(afterSaleService.getApplyingAfterSaleCount(getLoginUserId())); - } - - @PostMapping(value = "/create") - @Operation(summary = "申请售后") - public CommonResult createAfterSale(@RequestBody AppAfterSaleCreateReqVO createReqVO) { - return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO)); - } - - @PutMapping(value = "/delivery") - @Operation(summary = "退回货物") - public CommonResult deliveryAfterSale(@RequestBody AppAfterSaleDeliveryReqVO deliveryReqVO) { - afterSaleService.deliveryAfterSale(getLoginUserId(), deliveryReqVO); - return success(true); - } - - @DeleteMapping(value = "/cancel") - @Operation(summary = "取消售后") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - public CommonResult cancelAfterSale(@RequestParam("id") Long id) { - afterSaleService.cancelAfterSale(getLoginUserId(), id); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleCreateReqVO.java deleted file mode 100644 index 7e8635994e..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleCreateReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易售后创建 Request VO") -@Data -public class AppAfterSaleCreateReqVO { - - @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "售后方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "售后方式不能为空") - @InEnum(value = AfterSaleWayEnum.class, message = "售后方式必须是 {value}") - private Integer way; - - @Schema(description = "退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "退款金额不能为空") - @Min(value = 1, message = "退款金额必须大于 0") - private Integer refundPrice; - - @Schema(description = "申请原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "申请原因不能为空") - private String applyReason; - - @Schema(description = "补充描述", example = "商品质量不好") - private String applyDescription; - - @Schema(description = "补充凭证图片", example = "https://www.iocoder.cn/1.png, https://www.iocoder.cn/2.png") - private List applyPicUrls; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleDeliveryReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleDeliveryReqVO.java deleted file mode 100644 index 896d013e09..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleDeliveryReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 App - 交易售后退回货物 Request VO") -@Data -public class AppAfterSaleDeliveryReqVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "售后编号不能为空") - private Long id; - - @Schema(description = "退货物流公司编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "退货物流公司编号不能为空") - private Long logisticsId; - - @Schema(description = "退货物流单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "SF123456789") - @NotNull(message = "退货物流单号不能为空") - private String logisticsNo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleRespVO.java deleted file mode 100644 index 55ae73a030..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleRespVO.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 交易售后 Response VO") -@Data -public class AppAfterSaleRespVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "售后流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "售后方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer way; - - @Schema(description = "售后类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - @Schema(description = "申请原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String applyReason; - - @Schema(description = "补充描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String applyDescription; - - @Schema(description = "补充凭证图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private List applyPicUrls; - - // ========== 交易订单相关 ========== - - @Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long orderId; - - @Schema(description = "交易订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String orderNo; - - @Schema(description = "交易订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long orderItemId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long skuId; - - /** - * 属性数组 - */ - private List properties; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/01.jpg") - private String picUrl; - - @Schema(description = "退货商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - // ========== 审批相关 ========== - - /** - * 审批备注 - * - * 注意,只有审批不通过才会填写 - */ - private String auditReason; - - // ========== 退款相关 ========== - - @Schema(description = "退款金额,单位:分", example = "100") - private Integer refundPrice; - - @Schema(description = "退款时间") - private LocalDateTime refundTime; - - // ========== 退货相关 ========== - - @Schema(description = "退货物流公司编号", example = "1") - private Long logisticsId; - - @Schema(description = "退货物流单号", example = "SF123456789") - private String logisticsNo; - - @Schema(description = "退货时间") - private LocalDateTime deliveryTime; - - @Schema(description = "收货时间") - private LocalDateTime receiveTime; - - @Schema(description = "收货备注") - private String receiveReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/package-info.java deleted file mode 100644 index 08acfdbca5..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 基础包,放一些通用的 VO 类 - */ -package cn.iocoder.yudao.module.trade.controller.app.base; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/property/AppProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/property/AppProductPropertyValueDetailRespVO.java deleted file mode 100644 index 750f16bf37..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/property/AppProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.base.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 商品属性值的明细 Response VO") -@Data -public class AppProductPropertyValueDetailRespVO { - - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long propertyId; - - @Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long valueId; - - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/sku/AppProductSkuBaseRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/sku/AppProductSkuBaseRespVO.java deleted file mode 100644 index ac0c0ee6b2..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/sku/AppProductSkuBaseRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.base.sku; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -/** - * 商品 SKU 基础 Response VO - * - * @author 芋道源码 - */ -@Data -public class AppProductSkuBaseRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "图片地址", example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer stock; - - /** - * 属性数组 - */ - private List properties; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/spu/AppProductSpuBaseRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/spu/AppProductSpuBaseRespVO.java deleted file mode 100644 index a0e1bc6700..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/spu/AppProductSpuBaseRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.base.spu; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -/** - * 商品 SPU 基础 Response VO - * - * @author 芋道源码 - */ -@Data -public class AppProductSpuBaseRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "商品 SPU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "商品主图地址", example = "https://www.iocoder.cn/xx.png") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java deleted file mode 100644 index dd0fe6b205..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 分销用户") -@RestController -@RequestMapping("/trade/brokerage-record") -@Validated -@Slf4j -public class AppBrokerageRecordController { - @Resource - private BrokerageRecordService brokerageRecordService; - - @GetMapping("/page") - @Operation(summary = "获得分销记录分页") - @PreAuthenticated - public CommonResult> getBrokerageRecordPage(@Valid AppBrokerageRecordPageReqVO pageReqVO) { - PageResult pageResult = brokerageRecordService.getBrokerageRecordPage( - BrokerageRecordConvert.INSTANCE.convert(pageReqVO, getLoginUserId())); - return success(BrokerageRecordConvert.INSTANCE.convertPage02(pageResult)); - } - - @GetMapping("/get-product-brokerage-price") - @Operation(summary = "获得商品的分销金额") - public CommonResult getProductBrokeragePrice(@RequestParam("spuId") Long spuId) { - return success(brokerageRecordService.calculateProductBrokeragePrice(getLoginUserId(), spuId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java deleted file mode 100644 index bb2ba59fea..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java +++ /dev/null @@ -1,141 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.*; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.Map; -import java.util.Optional; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 分销用户") -@RestController -@RequestMapping("/trade/brokerage-user") -@Validated -@Slf4j -public class AppBrokerageUserController { - - @Resource - private BrokerageUserService brokerageUserService; - @Resource - private BrokerageRecordService brokerageRecordService; - @Resource - private BrokerageWithdrawService brokerageWithdrawService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/get") - @Operation(summary = "获得个人分销信息") - @PreAuthenticated - public CommonResult getBrokerageUser() { - Optional user = Optional.ofNullable(brokerageUserService.getBrokerageUser(getLoginUserId())); - // 返回数据 - AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO() - .setBrokerageEnabled(user.map(BrokerageUserDO::getBrokerageEnabled).orElse(false)) - .setBrokeragePrice(user.map(BrokerageUserDO::getBrokeragePrice).orElse(0)) - .setFrozenPrice(user.map(BrokerageUserDO::getFrozenPrice).orElse(0)); - return success(respVO); - } - - @PutMapping("/bind") - @Operation(summary = "绑定推广员") - @PreAuthenticated - public CommonResult bindBrokerageUser(@Valid @RequestBody AppBrokerageUserBindReqVO reqVO) { - return success(brokerageUserService.bindBrokerageUser(getLoginUserId(), reqVO.getBindUserId())); - } - - @GetMapping("/get-summary") - @Operation(summary = "获得个人分销统计") - @PreAuthenticated - public CommonResult getBrokerageUserSummary() { - // 查询当前登录用户信息 - BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(getLoginUserId()); - // 统计用户昨日的佣金 - LocalDateTime yesterday = LocalDateTime.now().minusDays(1); - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday); - LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday); - Integer yesterdayPrice = brokerageRecordService.getSummaryPriceByUserId(brokerageUser.getId(), - BrokerageRecordBizTypeEnum.ORDER, BrokerageRecordStatusEnum.SETTLEMENT, beginTime, endTime); - // 统计用户提现的佣金 - Integer withdrawPrice = brokerageWithdrawService.getWithdrawSummaryListByUserId(Collections.singleton(brokerageUser.getId()), - BrokerageWithdrawStatusEnum.AUDIT_SUCCESS).stream() - .findFirst().map(BrokerageWithdrawSummaryRespBO::getPrice).orElse(0); - // 统计分销用户数量(一级) - Long firstBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 1); - // 统计分销用户数量(二级) - Long secondBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 2); - - // 拼接返回 - return success(BrokerageUserConvert.INSTANCE.convert(yesterdayPrice, withdrawPrice, firstBrokerageUserCount, secondBrokerageUserCount, brokerageUser)); - } - - @GetMapping("/rank-page-by-user-count") - @Operation(summary = "获得分销用户排行分页(基于用户量)") - @PreAuthenticated - public CommonResult> getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO) { - // 分页查询 - PageResult pageResult = brokerageUserService.getBrokerageUserRankPageByUserCount(pageReqVO); - // 拼接数据 - Map userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), AppBrokerageUserRankByUserCountRespVO::getId)); - return success(BrokerageUserConvert.INSTANCE.convertPage03(pageResult, userMap)); - } - - @GetMapping("/rank-page-by-price") - @Operation(summary = "获得分销用户排行分页(基于佣金)") - @PreAuthenticated - public CommonResult> getBrokerageUserChildSummaryPageByPrice(AppBrokerageUserRankPageReqVO pageReqVO) { - // 分页查询 - PageResult pageResult = brokerageRecordService.getBrokerageUserChildSummaryPageByPrice(pageReqVO); - // 拼接数据 - Map userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), AppBrokerageUserRankByPriceRespVO::getId)); - return success(BrokerageRecordConvert.INSTANCE.convertPage03(pageResult, userMap)); - } - - @GetMapping("/child-summary-page") - @Operation(summary = "获得下级分销统计分页") - @PreAuthenticated - public CommonResult> getBrokerageUserChildSummaryPage( - AppBrokerageUserChildSummaryPageReqVO pageReqVO) { - PageResult pageResult = brokerageUserService.getBrokerageUserChildSummaryPage(pageReqVO, getLoginUserId()); - return success(pageResult); - } - - @GetMapping("/get-rank-by-price") - @Operation(summary = "获得分销用户排行(基于佣金)") - @Parameter(name = "times", description = "时间段", required = true) - public CommonResult getRankByPrice( - @RequestParam("times") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) LocalDateTime[] times) { - return success(brokerageRecordService.getUserRankByPrice(getLoginUserId(), times)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java deleted file mode 100644 index e9af594407..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 分销提现") -@RestController -@RequestMapping("/trade/brokerage-withdraw") -@Validated -@Slf4j -public class AppBrokerageWithdrawController { - - @Resource - private BrokerageWithdrawService brokerageWithdrawService; - - @GetMapping("/page") - @Operation(summary = "获得分销提现分页") - @PreAuthenticated - public CommonResult> getBrokerageWithdrawPage(AppBrokerageWithdrawPageReqVO pageReqVO) { - PageResult pageResult = brokerageWithdrawService.getBrokerageWithdrawPage( - BrokerageWithdrawConvert.INSTANCE.convert(pageReqVO, getLoginUserId())); - return success(BrokerageWithdrawConvert.INSTANCE.convertPage03(pageResult)); - } - - @PostMapping("/create") - @Operation(summary = "创建分销提现") - @PreAuthenticated - public CommonResult createBrokerageWithdraw(@RequestBody @Valid AppBrokerageWithdrawCreateReqVO createReqVO) { - return success(brokerageWithdrawService.createBrokerageWithdraw(getLoginUserId(), createReqVO)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageProductPriceRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageProductPriceRespVO.java deleted file mode 100644 index 6b2191d5ff..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageProductPriceRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 商品的分销金额 Response VO") -@Data -public class AppBrokerageProductPriceRespVO { - - @Schema(description = "是否开启", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Boolean enabled; - - @Schema(description = "分销最小金额,单位:分", example = "100") - private Integer brokerageMinPrice; - - @Schema(description = "分销最大金额,单位:分", example = "100") - private Integer brokerageMaxPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordPageReqVO.java deleted file mode 100644 index e2df6dae6b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordPageReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "应用 App - 分销记录分页 Request VO") -@Data -public class AppBrokerageRecordPageReqVO extends PageParam { - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageRecordBizTypeEnum.class, message = "业务类型必须是 {value}") - private Integer bizType; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageRecordStatusEnum.class, message = "状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordRespVO.java deleted file mode 100644 index 221d197587..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 分销记录 Response VO") -@Data -public class AppBrokerageRecordRespVO { - - @Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "分销标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "用户下单") - private String title; - - @Schema(description = "分销金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer price; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "完成时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime finishTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserBindReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserBindReqVO.java deleted file mode 100644 index e6f2982eb1..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserBindReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "应用 App - 绑定推广员 Request VO") -@Data -public class AppBrokerageUserBindReqVO extends PageParam { - - @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "推广员编号不能为空") - private Long bindUserId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryPageReqVO.java deleted file mode 100644 index 7a2b922322..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.SortingField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.Range; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 App - 下级分销统计分页 Request VO") -@Data -public class AppBrokerageUserChildSummaryPageReqVO extends PageParam { - - public static final String SORT_FIELD_USER_COUNT = "userCount"; - public static final String SORT_FIELD_ORDER_COUNT = "orderCount"; - public static final String SORT_FIELD_PRICE = "price"; - - @Schema(description = "用户昵称", example = "李") // 模糊匹配 - private String nickname; - - @Schema(description = "排序字段", example = "userCount") - private SortingField sortingField; - - @Schema(description = "下级的级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 1 - 直接下级;2 - 间接下级 - @NotNull(message = "下级的级别不能为空") - @Range(min = 1, max = 2, message = "下级的级别只能是 {min} 或者 {max}") - private Integer level; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java deleted file mode 100644 index 6bc4184e81..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 下级分销统计 Response VO") -@Data -public class AppBrokerageUserChildSummaryRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "佣金金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer brokeragePrice; - - @Schema(description = "分销订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer brokerageOrderCount; - - @Schema(description = "分销用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") - private Integer brokerageUserCount; - - @Schema(description = "绑定推广员的时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime brokerageTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java deleted file mode 100644 index 8a0c387c6a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 个人分销统计 Response VO") -@Data -public class AppBrokerageUserMySummaryRespVO { - - @Schema(description = "昨天的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer yesterdayPrice; - - @Schema(description = "提现的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer withdrawPrice; - - @Schema(description = "可用的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2408") - private Integer brokeragePrice; - - @Schema(description = "冻结的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "234") - private Integer frozenPrice; - - @Schema(description = "分销用户数量(一级)", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long firstBrokerageUserCount; - - @Schema(description = "分销用户数量(二级)", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long secondBrokerageUserCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByPriceRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByPriceRespVO.java deleted file mode 100644 index 91345ea789..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByPriceRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 分销排行用户(基于用户量) Response VO") -@Data -public class AppBrokerageUserRankByPriceRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer brokeragePrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByUserCountRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByUserCountRespVO.java deleted file mode 100644 index 1a6de81385..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByUserCountRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 分销排行用户(基于用户量) Response VO") -@Data -public class AppBrokerageUserRankByUserCountRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "邀请用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer brokerageUserCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankPageReqVO.java deleted file mode 100644 index 466c378ff6..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankPageReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotEmpty; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "应用 App - 分销用户排行 Request VO") -@Data -public class AppBrokerageUserRankPageReqVO extends PageParam { - - @Schema(description = "开始 + 结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @NotEmpty(message = "时间不能为空") - private LocalDateTime[] times; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java deleted file mode 100644 index f98da7eb6a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 分销用户信息 Response VO") -@Data -public class AppBrokerageUserRespVO { - - @Schema(description = "是否有分销资格", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean brokerageEnabled; - - @Schema(description = "可用的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2408") - private Integer brokeragePrice; - - @Schema(description = "冻结的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "234") - private Integer frozenPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java deleted file mode 100644 index feb6eae893..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw; - -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.URL; - -import jakarta.validation.Validator; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.PositiveOrZero; - -@Schema(description = "用户 App - 分销提现创建 Request VO") -@Data -public class AppBrokerageWithdrawCreateReqVO { - - @Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现方式必须是 {value}") - private Integer type; - - @Schema(description = "提现金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @PositiveOrZero(message = "提现金额不能小于 0") - @NotNull(message = "提现金额不能为空") - private Integer price; - - // ========== 银行卡、微信、支付宝 提现相关字段 ========== - - @Schema(description = "提现账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456789") - @NotBlank(message = "提现账号不能为空", groups = {Bank.class, Wechat.class, Alipay.class}) - private String accountNo; - - // ========== 微信、支付宝 提现相关字段 ========== - - @Schema(description = "收款码的图片", example = "https://www.iocoder.cn/1.png") - @URL(message = "收款码的图片,必须是一个 URL") - private String accountQrCodeUrl; - - // ========== 银行卡 提现相关字段 ========== - - @Schema(description = "持卡人姓名", example = "张三") - @NotBlank(message = "持卡人姓名不能为空", groups = {Bank.class}) - private String name; - @Schema(description = "提现银行", example = "1") - @NotNull(message = "提现银行不能为空", groups = {Bank.class}) - private Integer bankName; - @Schema(description = "开户地址", example = "海淀支行") - private String bankAddress; - - public interface Wallet { - } - - public interface Bank { - } - - public interface Wechat { - } - - public interface Alipay { - } - - public void validate(Validator validator) { - if (BrokerageWithdrawTypeEnum.WALLET.getType().equals(type)) { - ValidationUtils.validate(validator, this, Wallet.class); - } else if (BrokerageWithdrawTypeEnum.BANK.getType().equals(type)) { - ValidationUtils.validate(validator, this, Bank.class); - } else if (BrokerageWithdrawTypeEnum.WECHAT.getType().equals(type)) { - ValidationUtils.validate(validator, this, Wechat.class); - } else if (BrokerageWithdrawTypeEnum.ALIPAY.getType().equals(type)) { - ValidationUtils.validate(validator, this, Alipay.class); - } - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java deleted file mode 100644 index b1757d43ef..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "应用 App - 分销提现分页 Request VO") -@Data -public class AppBrokerageWithdrawPageReqVO extends PageParam { - - @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "类型必须是 {value}") - private Integer type; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageWithdrawStatusEnum.class, message = "状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawRespVO.java deleted file mode 100644 index 4cfe930c8a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 分销提现 Response VO") -@Data -public class AppBrokerageWithdrawRespVO { - - @Schema(description = "提现编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "提现状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer status; - - @Schema(description = "提现状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "审核中") - private String statusName; - - @Schema(description = "提现金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer price; - - @Schema(description = "提现时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.http deleted file mode 100644 index b341a48866..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.http +++ /dev/null @@ -1,42 +0,0 @@ -### 请求 /trade/cart/add 接口 => 成功 -POST {{appApi}}/trade/cart/add -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} -Content-Type: application/json - -{ - "skuId": 1, - "count": 10, - "addStatus": true -} - -### 请求 /trade/cart/update 接口 => 成功 -PUT {{appApi}}/trade/cart/update -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} -Content-Type: application/json - -{ - "id": 35, - "count": 5 -} - -### 请求 /trade/cart/delete 接口 => 成功 -DELETE {{appApi}}/trade/cart/delete?ids=1 -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /trade/cart/get-count 接口 => 成功 -GET {{appApi}}/trade/cart/get-count -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /trade/cart/get-count-map 接口 => 成功 -GET {{appApi}}/trade/cart/get-count-map -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /trade/cart/list 接口 => 成功 -GET {{appApi}}/trade/cart/list -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.java deleted file mode 100644 index d7f7b17994..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.*; -import cn.iocoder.yudao.module.trade.service.cart.CartService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 购物车") -@RestController -@RequestMapping("/trade/cart") -@RequiredArgsConstructor -@Validated -@Slf4j -public class AppCartController { - - @Resource - private CartService cartService; - - @PostMapping("/add") - @Operation(summary = "添加购物车商品") - @PreAuthenticated - public CommonResult addCart(@Valid @RequestBody AppCartAddReqVO addCountReqVO) { - return success(cartService.addCart(getLoginUserId(), addCountReqVO)); - } - - @PutMapping("/update-count") - @Operation(summary = "更新购物车商品数量") - @PreAuthenticated - public CommonResult updateCartCount(@Valid @RequestBody AppCartUpdateCountReqVO updateReqVO) { - cartService.updateCartCount(getLoginUserId(), updateReqVO); - return success(true); - } - - @PutMapping("/update-selected") - @Operation(summary = "更新购物车商品选中") - @PreAuthenticated - public CommonResult updateCartSelected(@Valid @RequestBody AppCartUpdateSelectedReqVO updateReqVO) { - cartService.updateCartSelected(getLoginUserId(), updateReqVO); - return success(true); - } - - @PutMapping("/reset") - @Operation(summary = "重置购物车商品") - @PreAuthenticated - public CommonResult resetCart(@Valid @RequestBody AppCartResetReqVO updateReqVO) { - cartService.resetCart(getLoginUserId(), updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除购物车商品") - @Parameter(name = "ids", description = "购物车商品编号", required = true, example = "1024,2048") - @PreAuthenticated - public CommonResult deleteCart(@RequestParam("ids") List ids) { - cartService.deleteCart(getLoginUserId(), ids); - return success(true); - } - - @GetMapping("get-count") - @Operation(summary = "查询用户在购物车中的商品数量") - @PreAuthenticated - public CommonResult getCartCount() { - return success(cartService.getCartCount(getLoginUserId())); - } - - @GetMapping("/list") - @Operation(summary = "查询用户的购物车列表") - @PreAuthenticated - public CommonResult getCartList() { - return success(cartService.getCartList(getLoginUserId())); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartAddReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartAddReqVO.java deleted file mode 100644 index 26d774234b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartAddReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 App - 购物车添加购物项 Request VO") -@Data -public class AppCartAddReqVO { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED,example = "1024") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "新增商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "数量不能为空") - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartDetailRespVO.java deleted file mode 100644 index 1a28d96a6a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartDetailRespVO.java +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.sku.AppProductSkuBaseRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 用户的购物车明细 Response VO") -@Data -public class AppCartDetailRespVO { - - /** - * 商品分组数组 - */ - private List itemGroups; - - /** - * 费用 - */ - private Order order; - - @Schema(description = "商品分组") // 多个商品,参加同一个活动,从而形成分组 - @Data - public static class ItemGroup { - - /** - * 商品数组 - */ - private List items; - /** - * 营销活动,订单级别 - */ - private Promotion promotion; - - } - - @Schema(description = "商品 SKU") - @Data - public static class Sku extends AppProductSkuBaseRespVO { - - /** - * SPU 信息 - */ - private AppProductSkuBaseRespVO spu; - - // ========== 购物车相关的字段 ========== - - @Schema(description = "商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - @Schema(description = "是否选中", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean selected; - - // ========== 价格相关的字段,对应 PriceCalculateRespDTO.OrderItem 的属性 ========== - - // TODO 芋艿:后续可以去除一些无用的字段 - - @Schema(description = "商品原价(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer originalPrice; - @Schema(description = "商品原价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer totalOriginalPrice; - @Schema(description = "商品级优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "300") - private Integer totalPromotionPrice; - @Schema(description = "最终购买金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "400") - private Integer totalPresentPrice; - @Schema(description = "最终购买金额(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "500") - private Integer presentPrice; - @Schema(description = "应付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "600") - private Integer totalPayPrice; - - // ========== 营销相关的字段 ========== - /** - * 营销活动,商品级别 - */ - private Promotion promotion; - - } - - @Schema(description = "订单") // 对应 PriceCalculateRespDTO.Order 类,用于费用(合计) - @Data - public static class Order { - - // TODO 芋艿:后续可以去除一些无用的字段 - - @Schema(description = "商品原价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer skuOriginalPrice; - @Schema(description = "商品优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer skuPromotionPrice; - @Schema(description = "订单优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "300") - private Integer orderPromotionPrice; - @Schema(description = "运费金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "400") - private Integer deliveryPrice; - @Schema(description = "应付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "500") - private Integer payPrice; - - } - - @Schema(description = "营销活动") // 对应 PriceCalculateRespDTO.Promotion 类的属性 - @Data - public static class Promotion { - - @Schema(description = "营销编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") // 营销活动的编号、优惠劵的编号 - private Long id; - @Schema(description = "营销名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "xx 活动") - private String name; - @Schema(description = "营销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - // ========== 匹配情况 ========== - @Schema(description = "是否满足优惠条件", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean meet; - @Schema(description = "满足条件的提示", requiredMode = Schema.RequiredMode.REQUIRED, example = "圣诞价:省 150.00 元") - private String meetTip; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartListRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartListRespVO.java deleted file mode 100644 index cef09f78fb..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartListRespVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.sku.AppProductSkuBaseRespVO; -import cn.iocoder.yudao.module.trade.controller.app.base.spu.AppProductSpuBaseRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 用户的购物列表 Response VO") -@Data -public class AppCartListRespVO { - - /** - * 有效的购物项数组 - */ - private List validList; - - /** - * 无效的购物项数组 - */ - private List invalidList; - - @Schema(description = "购物项") - @Data - public static class Cart { - - @Schema(description = "购物项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - @Schema(description = "是否选中", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean selected; - - /** - * 商品 SPU - */ - private AppProductSpuBaseRespVO spu; - /** - * 商品 SKU - */ - private AppProductSkuBaseRespVO sku; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartResetReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartResetReqVO.java deleted file mode 100644 index 08cdecaedf..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartResetReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 App - 购物车重置 Request VO") -@Data -public class AppCartResetReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED,example = "1024") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "数量不能为空") - @Min(message = "数量必须大于 0", value = 1L) - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateCountReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateCountReqVO.java deleted file mode 100644 index 19b6c5fbf5..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateCountReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 App - 购物车更新数量 Request VO") -@Data -public class AppCartUpdateCountReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "数量不能为空") - @Min(message = "数量必须大于 0", value = 1L) - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateSelectedReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateSelectedReqVO.java deleted file mode 100644 index 799e08f337..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateSelectedReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; -import java.util.Collection; - -@Schema(description = "用户 App - 购物车更新是否选中 Request VO") -@Data -public class AppCartUpdateSelectedReqVO { - - @Schema(description = "编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024,2048") - @NotNull(message = "编号列表不能为空") - private Collection ids; - - @Schema(description = "是否选中", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否选中不能为空") - private Boolean selected; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java deleted file mode 100644 index 215743b5ec..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.config; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO; -import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 交易配置") -@RestController -@RequestMapping("/trade/config") -@RequiredArgsConstructor -@Validated -@Slf4j -public class AppTradeConfigController { - - @Resource - private TradeConfigService tradeConfigService; - - @Value("${yudao.tencent-lbs-key}") - private String tencentLbsKey; - - @GetMapping("/get") - @Operation(summary = "获得交易配置") - public CommonResult getTradeConfig() { - TradeConfigDO config = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO()); - return success(TradeConfigConvert.INSTANCE.convert02(config).setTencentLbsKey(tencentLbsKey)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java deleted file mode 100644 index 6f10394c30..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易配置 Response VO") -@Data -public class AppTradeConfigRespVO { - - @Schema(description = "腾讯地图 KEY", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - private String tencentLbsKey; - - // ========== 配送相关 ========== - - @Schema(description = "是否开启自提", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否开启自提不能为空") - private Boolean deliveryPickUpEnabled; - - // ========== 售后相关 ========== - - @Schema(description = "售后的退款理由", requiredMode = Schema.RequiredMode.REQUIRED) - private List afterSaleRefundReasons; - - @Schema(description = "售后的退货理由", requiredMode = Schema.RequiredMode.REQUIRED) - private List afterSaleReturnReasons; - - // ========== 分销相关 ========== - - @Schema(description = "分销海报地址数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List brokeragePosterUrls; - - @Schema(description = "佣金冻结时间(天)", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer brokerageFrozenDays; - - @Schema(description = "佣金提现最小金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer brokerageWithdrawMinPrice; - - @Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") - private List brokerageWithdrawTypes; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java deleted file mode 100644 index 1d4e36f90b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.config.AppDeliveryConfigRespVO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 配送配置") -@RestController -@RequestMapping("/trade/delivery/config") -@Validated -public class AppDeliverConfigController { - - // TODO @芋艿:这里后面干掉,合并到 AppTradeConfigController 中 - @GetMapping("/get") - @Operation(summary = "获得配送配置") - public CommonResult getDeliveryConfig() { - return success(new AppDeliveryConfigRespVO().setPickUpEnable(true).setTencentLbsKey("123456")); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java deleted file mode 100644 index 4162b962bf..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.express.AppDeliveryExpressRespVO; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 快递公司") -@RestController -@RequestMapping("/trade/delivery/express") -@Validated -public class AppDeliverExpressController { - - @Resource - private DeliveryExpressService deliveryExpressService; - - @GetMapping("/list") - @Operation(summary = "获得快递公司列表") - public CommonResult> getDeliveryExpressList() { - List list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus()); - list.sort(Comparator.comparing(DeliveryExpressDO::getSort)); - return success(DeliveryExpressConvert.INSTANCE.convertList03(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java deleted file mode 100644 index 6a923fe368..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup.AppDeliveryPickUpStoreRespVO; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 自提门店") -@RestController -@RequestMapping("/trade/delivery/pick-up-store") -@Validated -public class AppDeliverPickUpStoreController { - - @Resource - private DeliveryPickUpStoreService deliveryPickUpStoreService; - - @GetMapping("/list") - @Operation(summary = "获得自提门店列表") - @Parameters({ - @Parameter(name = "latitude", description = "精度", example = "110"), - @Parameter(name = "longitude", description = "纬度", example = "120") - }) - public CommonResult> getDeliveryPickUpStoreList( - @RequestParam(value = "latitude", required = false) Double latitude, - @RequestParam(value = "longitude", required = false) Double longitude) { - List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList(list, latitude, longitude)); - } - - @GetMapping("/get") - @Operation(summary = "获得自提门店") - @Parameter(name = "id", description = "门店编号") - public CommonResult getOrder(@RequestParam("id") Long id) { - DeliveryPickUpStoreDO store = deliveryPickUpStoreService.getDeliveryPickUpStore(id); - return success(DeliveryPickUpStoreConvert.INSTANCE.convert03(store)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/config/AppDeliveryConfigRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/config/AppDeliveryConfigRespVO.java deleted file mode 100644 index f3b50bf84b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/config/AppDeliveryConfigRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -// TODO 芋艿:后续要实现下,配送配置;后续融合到 AppTradeConfigRespVO 中 -@Schema(description = "用户 App - 配送配置 Response VO") -@Data -public class AppDeliveryConfigRespVO { - - @Schema(description = "腾讯地图 KEY", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - private String tencentLbsKey; - - @Schema(description = "是否开启自提", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean pickUpEnable; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/express/AppDeliveryExpressRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/express/AppDeliveryExpressRespVO.java deleted file mode 100644 index d01d905021..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/express/AppDeliveryExpressRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 快递公司 Response VO") -@Data -public class AppDeliveryExpressRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "顺丰") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/pickup/AppDeliveryPickUpStoreRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/pickup/AppDeliveryPickUpStoreRespVO.java deleted file mode 100644 index 1ca25ade5f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/pickup/AppDeliveryPickUpStoreRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 自提门店 Response VO") -@Data -public class AppDeliveryPickUpStoreRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") - private Long id; - - @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String name; - - @Schema(description = "门店 logo", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String logo; - - @Schema(description = "门店手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601892312") - private String phone; - - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") - private Integer areaId; - - @Schema(description = "地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海上海市普陀区") - private String areaName; - - @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") - private String detailAddress; - - @Schema(description = "纬度", requiredMode = Schema.RequiredMode.REQUIRED, example = "5.88") - private Double latitude; - - @Schema(description = "经度", requiredMode = Schema.RequiredMode.REQUIRED, example = "6.99") - private Double longitude; - - @Schema(description = "距离,单位:千米", example = "100") // 只有在用户传递了经纬度时,才进行计算 - private Double distance; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http deleted file mode 100644 index 4a94416942..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http +++ /dev/null @@ -1,64 +0,0 @@ -### /trade-order/settlement 获得订单结算信息(基于商品) -GET {{appApi}}/trade/order/settlement?type=0&items[0].skuId=1&items[0].count=2&items[1].skuId=2&items[1].count=3&couponId=1 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### /trade-order/settlement 获得订单结算信息(基于购物车) -GET {{appApi}}/trade/order/settlement?type=0&items[0].cartId=50&couponId=1 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### /trade-order/create 创建订单(基于商品)【快递】 -POST {{appApi}}/trade/order/create -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "pointStatus": true, - "deliveryType": 1, - "addressId": 21, - "items": [ - { - "skuId": 1, - "count": 2 - } - ], - "remark": "我是备注" -} - -### /trade-order/create 创建订单(基于商品)【自提】 -POST {{appApi}}/trade/order/create -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "pointStatus": true, - "deliveryType": 2, - "pickUpStoreId": 1, - "items": [ - { - "skuId": 1, - "count": 2 - } - ], - "remark": "我是备注", - "receiverName": "土豆", - "receiverMobile": "15601691300" -} - -### 获得订单交易的分页 -GET {{appApi}}/trade/order/page?pageNo=1&pageSize=10 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得订单交易的详细 -GET {{appApi}}/trade/order/get-detail?id=21 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得交易订单的物流轨迹 -GET {{appApi}}/trade/order/get-express-track-list?id=70 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java deleted file mode 100644 index ac03d74a15..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java +++ /dev/null @@ -1,178 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.*; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import com.google.common.collect.Maps; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 交易订单") -@RestController -@RequestMapping("/trade/order") -@Validated -@Slf4j -public class AppTradeOrderController { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - @Resource - private DeliveryExpressService deliveryExpressService; - - @Resource - private TradeOrderProperties tradeOrderProperties; - - @GetMapping("/settlement") - @Operation(summary = "获得订单结算信息") - @PreAuthenticated - public CommonResult settlementOrder(@Valid AppTradeOrderSettlementReqVO settlementReqVO) { - return success(tradeOrderUpdateService.settlementOrder(getLoginUserId(), settlementReqVO)); - } - - @PostMapping("/create") - @Operation(summary = "创建订单") - @PreAuthenticated - public CommonResult createOrder(@Valid @RequestBody AppTradeOrderCreateReqVO createReqVO, - @RequestHeader Integer terminal) { - TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), getClientIP(), createReqVO, terminal); - return success(new AppTradeOrderCreateRespVO().setId(order.getId()).setPayOrderId(order.getPayOrderId())); - } - - @PostMapping("/update-paid") - @Operation(summary = "更新订单为已支付") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - public CommonResult updateOrderPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) { - tradeOrderUpdateService.updateOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayOrderId()); - return success(true); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得交易订单") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult getOrder(@RequestParam("id") Long id) { - // 查询订单 - TradeOrderDO order = tradeOrderQueryService.getOrder(getLoginUserId(), id); - if (order == null) { - return success(null); - } - - // 查询订单项 - List orderItems = tradeOrderQueryService.getOrderItemListByOrderId(order.getId()); - // 查询物流公司 - DeliveryExpressDO express = order.getLogisticsId() != null && order.getLogisticsId() > 0 ? - deliveryExpressService.getDeliveryExpress(order.getLogisticsId()) : null; - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems, tradeOrderProperties, express)); - } - - @GetMapping("/get-express-track-list") - @Operation(summary = "获得交易订单的物流轨迹") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult> getOrderExpressTrackList(@RequestParam("id") Long id) { - return success(TradeOrderConvert.INSTANCE.convertList02( - tradeOrderQueryService.getExpressTrackList(id, getLoginUserId()))); - } - - @GetMapping("/page") - @Operation(summary = "获得交易订单分页") - public CommonResult> getOrderPage(AppTradeOrderPageReqVO reqVO) { - // 查询订单 - PageResult pageResult = tradeOrderQueryService.getOrderPage(getLoginUserId(), reqVO); - // 查询订单项 - List orderItems = tradeOrderQueryService.getOrderItemListByOrderId( - convertSet(pageResult.getList(), TradeOrderDO::getId)); - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems)); - } - - @GetMapping("/get-count") - @Operation(summary = "获得交易订单数量") - public CommonResult> getOrderCount() { - Map orderCount = Maps.newLinkedHashMapWithExpectedSize(5); - // 全部 - orderCount.put("allCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), null, null)); - // 待付款(未支付) - orderCount.put("unpaidCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), - TradeOrderStatusEnum.UNPAID.getStatus(), null)); - // 待发货 - orderCount.put("undeliveredCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), - TradeOrderStatusEnum.UNDELIVERED.getStatus(), null)); - // 待收货 - orderCount.put("deliveredCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), - TradeOrderStatusEnum.DELIVERED.getStatus(), null)); - // 待评价 - orderCount.put("uncommentedCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), - TradeOrderStatusEnum.COMPLETED.getStatus(), false)); - return success(orderCount); - } - - @PutMapping("/receive") - @Operation(summary = "确认交易订单收货") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult receiveOrder(@RequestParam("id") Long id) { - tradeOrderUpdateService.receiveOrderByMember(getLoginUserId(), id); - return success(true); - } - - @DeleteMapping("/cancel") - @Operation(summary = "取消交易订单") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult cancelOrder(@RequestParam("id") Long id) { - tradeOrderUpdateService.cancelOrderByMember(getLoginUserId(), id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除交易订单") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult deleteOrder(@RequestParam("id") Long id) { - tradeOrderUpdateService.deleteOrder(getLoginUserId(), id); - return success(true); - } - - // ========== 订单项 ========== - - @GetMapping("/item/get") - @Operation(summary = "获得交易订单项") - @Parameter(name = "id", description = "交易订单项编号") - public CommonResult getOrderItem(@RequestParam("id") Long id) { - TradeOrderItemDO item = tradeOrderQueryService.getOrderItem(getLoginUserId(), id); - return success(TradeOrderConvert.INSTANCE.convert03(item)); - } - - @PostMapping("/item/create-comment") - @Operation(summary = "创建交易订单项的评价") - public CommonResult createOrderItemComment(@RequestBody AppTradeOrderItemCommentCreateReqVO createReqVO) { - return success(tradeOrderUpdateService.createOrderItemCommentByMember(getLoginUserId(), createReqVO)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppOrderExpressTrackRespDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppOrderExpressTrackRespDTO.java deleted file mode 100644 index 2324c40bb4..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppOrderExpressTrackRespDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 快递查询的轨迹 Resp DTO - * - * @author jason - */ -@Schema(description = "用户 App - 快递查询的轨迹 Response VO") -@Data -public class AppOrderExpressTrackRespDTO { - - @Schema(description = "发生时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime time; - - @Schema(description = "快递状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "已签收") - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java deleted file mode 100644 index 204e07810d..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.AssertTrue; - -@Schema(description = "用户 App - 交易订单创建 Request VO") -@Data -public class AppTradeOrderCreateReqVO extends AppTradeOrderSettlementReqVO { - - @Schema(description = "备注", example = "这个是我的订单哟") - private String remark; - - @AssertTrue(message = "配送方式不能为空") - @JsonIgnore - public boolean isDeliveryTypeNotNull() { - return getDeliveryType() != null; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateRespVO.java deleted file mode 100644 index ae3f831942..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 交易订单创建 Response VO") -@Data -public class AppTradeOrderCreateRespVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java deleted file mode 100644 index 3033cf0222..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; - -@Schema(description = "用户 App - 订单交易的明细 Response VO") -@Data -public class AppTradeOrderDetailRespVO { - - // ========== 订单基本信息 ========== - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "用户备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String userRemark; - - @Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer productCount; - - @Schema(description = "订单完成时间") - private LocalDateTime finishTime; - - @Schema(description = "订单取消时间") - private LocalDateTime cancelTime; - - @Schema(description = "是否评价", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean commentStatus; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "是否已支付", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean payStatus; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - - @Schema(description = "付款时间") - private LocalDateTime payTime; - - @Schema(description = "付款超时时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime payExpireTime; - - @Schema(description = "支付渠道", example = "wx_lite_pay") - private String payChannelCode; - @Schema(description = "支付渠道名", example = "微信小程序支付") - private String payChannelName; - - @Schema(description = "商品原价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer totalPrice; - - @Schema(description = "订单优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer discountPrice; - - @Schema(description = "运费金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer deliveryPrice; - - @Schema(description = "订单调价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer adjustPrice; - - @Schema(description = "应付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - - @Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer deliveryType; - - @Schema(description = "发货物流公司编号", example = "10") - private Long logisticsId; - - @Schema(description = "发货物流名称", example = "顺丰快递") - private String logisticsName; - - @Schema(description = "发货物流单号", example = "1024") - private String logisticsNo; - - @Schema(description = "发货时间") - private LocalDateTime deliveryTime; - - @Schema(description = "收货时间") - private LocalDateTime receiveTime; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String receiverName; - - @Schema(description = "收件人手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "13800138000") - private String receiverMobile; - - @Schema(description = "收件人地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "110000") - private Integer receiverAreaId; - - @Schema(description = "收件人地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海 上海市 普陀区") - private String receiverAreaName; - - @Schema(description = "收件人详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "中关村大街 1 号") - private String receiverDetailAddress; - - @Schema(description = "自提门店编号", example = "1088") - private Long pickUpStoreId; - - @Schema(description = "自提核销码", example = "40964096") - private String pickUpVerifyCode; - - // ========== 售后基本信息 ========== - - // ========== 营销基本信息 ========== - - @Schema(description = "优惠劵编号", example = "1024") - private Long couponId; - - @Schema(description = "优惠劵减免金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer couponPrice; - - @Schema(description = "积分抵扣的金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer pointPrice; - - /** - * 订单项数组 - */ - private List items; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java deleted file mode 100644 index 647356d086..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 订单交易的分页项 Response VO") -@Data -public class AppTradeOrderPageItemRespVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "订单类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer type; - - @Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer productCount; - - @Schema(description = "是否评价", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean commentStatus; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - - @Schema(description = "应付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - - @Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer deliveryType; - - /** - * 订单项数组 - */ - private List items; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageReqVO.java deleted file mode 100644 index c1e07c1768..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "交易订单分页 Request VO") -@Data -public class AppTradeOrderPageReqVO extends PageParam { - - @Schema(description = "订单状态", example = "1") - @InEnum(value = TradeOrderStatusEnum.class, message = "订单状态必须是 {value}") - private Integer status; - - @Schema(description = "是否评价", example = "true") - private Boolean commentStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java deleted file mode 100644 index f846ef1d15..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.AssertTrue; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易订单结算 Request VO") -@Data -@Valid -public class AppTradeOrderSettlementReqVO { - - @Schema(description = "商品项数组", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "商品不能为空") - private List items; - - @Schema(description = "优惠劵编号", example = "1024") - private Long couponId; - - @Schema(description = "是否使用积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否使用积分不能为空") - private Boolean pointStatus; - - // ========== 配送相关相关字段 ========== - @Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = DeliveryTypeEnum.class, message = "配送方式不正确") - private Integer deliveryType; - - @Schema(description = "收件地址编号", example = "1") - private Long addressId; - - @Schema(description = "自提门店编号", example = "1088") - private Long pickUpStoreId; - @Schema(description = "收件人名称", example = "芋艿") // 选择门店自提时,该字段为联系人名 - private String receiverName; - @Schema(description = "收件人手机", example = "15601691300") // 选择门店自提时,该字段为联系人手机 - @Mobile(message = "收件人手机格式不正确") - private String receiverMobile; - - // ========== 秒杀活动相关字段 ========== - @Schema(description = "秒杀活动编号", example = "1024") - private Long seckillActivityId; - - // ========== 拼团活动相关字段 ========== - @Schema(description = "拼团活动编号", example = "1024") - private Long combinationActivityId; - - @Schema(description = "拼团团长编号", example = "2048") - private Long combinationHeadId; - - // ========== 砍价活动相关字段 ========== - @Schema(description = "砍价记录编号", example = "123") - private Long bargainRecordId; - - @AssertTrue(message = "活动商品每次只能购买一种规格") - @JsonIgnore - public boolean isValidActivityItems() { - // 校验是否是活动订单 - if (ObjUtil.isAllEmpty(seckillActivityId, combinationActivityId, combinationHeadId, bargainRecordId)) { - return true; - } - // 校验订单项是否超出 - return items.size() == 1; - } - - @Data - @Schema(description = "用户 App - 商品项") - @Valid - public static class Item { - - @Schema(description = "商品 SKU 编号", example = "2048") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "购买数量", example = "1") - @Min(value = 1, message = "购买数量最小值为 {value}") - private Integer count; - - @Schema(description = "购物车项的编号", example = "1024") - private Long cartId; - - @AssertTrue(message = "商品不正确") - @JsonIgnore - public boolean isValid() { - // 组合一:skuId + count 使用商品 SKU - if (skuId != null && count != null) { - return true; - } - // 组合二:cartId 使用购物车项 - return cartId != null; - } - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java deleted file mode 100644 index 95f9fc8fa9..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易订单结算信息 Response VO") -@Data -public class AppTradeOrderSettlementRespVO { - - @Schema(description = "交易类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 对应 TradeOrderTypeEnum 枚举 - private Integer type; - - @Schema(description = "购物项数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "费用", requiredMode = Schema.RequiredMode.REQUIRED) - private Price price; - - @Schema(description = "收件地址", requiredMode = Schema.RequiredMode.REQUIRED) - private Address address; - - @Schema(description = "已使用的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer usedPoint; - - @Schema(description = "总积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer totalPoint; - - @Schema(description = "购物项") - @Data - public static class Item { - - // ========== SPU 信息 ========== - - @Schema(description = "品类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long categoryId; - @Schema(description = "SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - @Schema(description = "SPU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "Apple iPhone 12") - private String spuName; - - // ========== SKU 信息 ========== - - @Schema(description = "SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer skuId; - @Schema(description = "价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "属性数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private List properties; - - // ========== 购物车信息 ========== - - @Schema(description = "购物车编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long cartId; - - @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - } - - @Schema(description = "费用(合计)") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Price { - - @Schema(description = "商品原价(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "500") - private Integer totalPrice; - - @Schema(description = "订单优惠(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") - private Integer discountPrice; - - @Schema(description = "运费金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer deliveryPrice; - - @Schema(description = "优惠劵减免金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer couponPrice; - - @Schema(description = "积分抵扣的金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer pointPrice; - - @Schema(description = "VIP 减免金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") - private Integer vipPrice; - - @Schema(description = "实际支付金额(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "450") - private Integer payPrice; - - } - - @Schema(description = "地址信息") - @Data - public static class Address { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王") - private String name; - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") - private String mobile; - - @Schema(description = "地区编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "地区编号不能为空") - private Long areaId; - @Schema(description = "地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海上海市普陀区") - private String areaName; - - @Schema(description = "详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "望京悠乐汇 A 座") - private String detailAddress; - - @Schema(description = "是否默认收件地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean defaultStatus; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java deleted file mode 100644 index d012cf5c4f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo.item; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; -import java.util.List; - -@Schema(description = "用户 App - 商品评价创建 Request VO") -@Data -public class AppTradeOrderItemCommentCreateReqVO { - - @Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否匿名不能为空") - private Boolean anonymous; - - @Schema(description = "交易订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2312312") - @NotNull(message = "交易订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "描述星级 1-5 分不能为空") - private Integer descriptionScores; - - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "服务星级 1-5 分不能为空") - private Integer benefitScores; - - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "穿身上很漂亮诶(*^▽^*)") - @NotNull(message = "评论内容不能为空") - private String content; - - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") - private List picUrls; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemRespVO.java deleted file mode 100644 index 98d1820bc8..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemRespVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo.item; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 订单交易项 Response VO") -@Data -public class AppTradeOrderItemRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long spuId; - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long skuId; - - /** - * 属性数组 - */ - private List properties; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - @Schema(description = "是否评价", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean commentStatus; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "商品原价(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - - @Schema(description = "应付金额(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer payPrice; - - // ========== 营销基本信息 ========== - - // TODO 芋艿:在捉摸一下 - - // ========== 售后基本信息 ========== - - @Schema(description = "售后编号", example = "1024") - private Long afterSaleId; - - @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer afterSaleStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/package-info.java deleted file mode 100644 index aa2f99f35a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.trade.controller; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleConvert.java deleted file mode 100644 index fd759c6258..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleConvert.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRespPageItemVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.AfterSaleLogRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderBaseVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -@Mapper -public interface AfterSaleConvert { - - AfterSaleConvert INSTANCE = Mappers.getMapper(AfterSaleConvert.class); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(target = "createTime", ignore = true), - @Mapping(target = "updateTime", ignore = true), - @Mapping(target = "creator", ignore = true), - @Mapping(target = "updater", ignore = true), - }) - AfterSaleDO convert(AppAfterSaleCreateReqVO createReqVO, TradeOrderItemDO tradeOrderItem); - - @Mappings({ - @Mapping(source = "afterSale.orderId", target = "merchantOrderId"), - @Mapping(source = "afterSale.id", target = "merchantRefundId"), - @Mapping(source = "afterSale.applyReason", target = "reason"), - @Mapping(source = "afterSale.refundPrice", target = "price") - }) - PayRefundCreateReqDTO convert(String userIp, AfterSaleDO afterSale, - TradeOrderProperties orderProperties); - - MemberUserRespVO convert(MemberUserRespDTO bean); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult pageResult, - Map memberUsers) { - PageResult voPageResult = convertPage(pageResult); - // 处理会员 - voPageResult.getList().forEach(afterSale -> afterSale.setUser( - convert(memberUsers.get(afterSale.getUserId())))); - return voPageResult; - } - - ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean); - - AppAfterSaleRespVO convert(AfterSaleDO bean); - - PageResult convertPage02(PageResult page); - - default AfterSaleDetailRespVO convert(AfterSaleDO afterSale, TradeOrderDO order, TradeOrderItemDO orderItem, - MemberUserRespDTO user, List logs) { - AfterSaleDetailRespVO respVO = convert02(afterSale); - // 处理用户信息 - respVO.setUser(convert(user)); - // 处理订单信息 - respVO.setOrder(convert(order)); - respVO.setOrderItem(convert02(orderItem)); - // 处理售后日志 - respVO.setLogs(convertList1(logs)); - return respVO; - } - - List convertList1(List list); - AfterSaleDetailRespVO convert02(AfterSaleDO bean); - AfterSaleDetailRespVO.OrderItem convert02(TradeOrderItemDO bean); - TradeOrderBaseVO convert(TradeOrderDO bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleLogConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleLogConvert.java deleted file mode 100644 index e8960c4ac6..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleLogConvert.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.aftersale; - -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.service.aftersale.bo.AfterSaleLogCreateReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface AfterSaleLogConvert { - - AfterSaleLogConvert INSTANCE = Mappers.getMapper(AfterSaleLogConvert.class); - - AfterSaleLogDO convert(AfterSaleLogCreateReqBO bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java deleted file mode 100644 index e6c0e4f8cc..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.brokerage; - -import cn.hutool.core.math.Money; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import org.mapstruct.Mapper; -import org.mapstruct.MappingTarget; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 佣金记录 Convert - * - * @author owen - */ -@Mapper -public interface BrokerageRecordConvert { - - BrokerageRecordConvert INSTANCE = Mappers.getMapper(BrokerageRecordConvert.class); - - BrokerageRecordRespVO convert(BrokerageRecordDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default BrokerageRecordDO convert(BrokerageUserDO user, BrokerageRecordBizTypeEnum bizType, String bizId, - Integer brokerageFrozenDays, int brokeragePrice, LocalDateTime unfreezeTime, - String title, Long sourceUserId, Integer sourceUserLevel) { - brokerageFrozenDays = ObjectUtil.defaultIfNull(brokerageFrozenDays, 0); - // 不冻结时,佣金直接就是结算状态 - Integer status = brokerageFrozenDays > 0 - ? BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus() - : BrokerageRecordStatusEnum.SETTLEMENT.getStatus(); - return new BrokerageRecordDO().setUserId(user.getId()) - .setBizType(bizType.getType()).setBizId(bizId) - .setPrice(brokeragePrice).setTotalPrice(user.getBrokeragePrice()) - .setTitle(title) - .setDescription(StrUtil.format(bizType.getDescription(), MoneyUtils.fenToYuanStr(Math.abs(brokeragePrice)))) - .setStatus(status).setFrozenDays(brokerageFrozenDays).setUnfreezeTime(unfreezeTime) - .setSourceUserLevel(sourceUserLevel).setSourceUserId(sourceUserId); - } - - default PageResult convertPage(PageResult pageResult, Map userMap) { - PageResult result = convertPage(pageResult); - for (BrokerageRecordRespVO respVO : result.getList()) { - Optional.ofNullable(userMap.get(respVO.getUserId())).ifPresent(user -> - respVO.setUserNickname(user.getNickname()).setUserAvatar(user.getAvatar())); - Optional.ofNullable(userMap.get(respVO.getSourceUserId())).ifPresent(user -> - respVO.setSourceUserNickname(user.getNickname()).setSourceUserAvatar(user.getAvatar())); - } - return result; - } - - BrokerageRecordPageReqVO convert(AppBrokerageRecordPageReqVO pageReqVO, Long userId); - - PageResult convertPage02(PageResult pageResult); - - default PageResult convertPage03(PageResult pageResult, Map userMap) { - for (AppBrokerageUserRankByPriceRespVO vo : pageResult.getList()) { - copyTo(userMap.get(vo.getId()), vo); - } - return pageResult; - } - - void copyTo(MemberUserRespDTO from, @MappingTarget AppBrokerageUserRankByPriceRespVO to); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageUserConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageUserConvert.java deleted file mode 100644 index aa4ba348d9..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageUserConvert.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.brokerage; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserMySummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; -import org.mapstruct.Mapper; -import org.mapstruct.MappingTarget; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 分销用户 Convert - * - * @author owen - */ -@Mapper -public interface BrokerageUserConvert { - - BrokerageUserConvert INSTANCE = Mappers.getMapper(BrokerageUserConvert.class); - - BrokerageUserRespVO convert(BrokerageUserDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page, Map userMap, Map brokerageUserCountMap, Map userOrderSummaryMap); - - default PageResult convertPage(PageResult pageResult, - Map userMap, - Map brokerageUserCountMap, - Map userOrderSummaryMap, - Map withdrawMap) { - PageResult result = convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap); - for (BrokerageUserRespVO userVO : result.getList()) { - // 用户信息 - copyTo(userMap.get(userVO.getId()), userVO); - // 推广用户数量 - userVO.setBrokerageUserCount(MapUtil.getInt(brokerageUserCountMap, userVO.getId(), 0)); - // 推广订单数量、推广订单金额 - Optional orderSummaryOptional = Optional.ofNullable(userOrderSummaryMap.get(userVO.getId())); - userVO.setBrokerageOrderCount(orderSummaryOptional.map(UserBrokerageSummaryRespBO::getCount).orElse(0)) - .setBrokerageOrderPrice(orderSummaryOptional.map(UserBrokerageSummaryRespBO::getPrice).orElse(0)); - // 已提现次数、已提现金额 - Optional withdrawSummaryOptional = Optional.ofNullable(withdrawMap.get(userVO.getId())); - userVO.setWithdrawCount(withdrawSummaryOptional.map(BrokerageWithdrawSummaryRespBO::getCount).orElse(0)) - .setWithdrawPrice(withdrawSummaryOptional.map(BrokerageWithdrawSummaryRespBO::getPrice).orElse(0)); - } - return result; - } - - default BrokerageUserRespVO copyTo(MemberUserRespDTO source, BrokerageUserRespVO target) { - Optional.ofNullable(source).ifPresent( - user -> target.setNickname(user.getNickname()).setAvatar(user.getAvatar())); - return target; - } - - default PageResult convertPage03(PageResult pageResult, - Map userMap) { - pageResult.getList().forEach(vo -> copyTo(userMap.get(vo.getId()), vo)); - return pageResult; - } - - void copyTo(MemberUserRespDTO from, @MappingTarget AppBrokerageUserRankByUserCountRespVO to); - - default AppBrokerageUserMySummaryRespVO convert(Integer yesterdayPrice, Integer withdrawPrice, - Long firstBrokerageUserCount, Long secondBrokerageUserCount, - BrokerageUserDO brokerageUser) { - AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO() - .setYesterdayPrice(ObjUtil.defaultIfNull(yesterdayPrice, 0)) - .setWithdrawPrice(ObjUtil.defaultIfNull(withdrawPrice, 0)) - .setBrokeragePrice(0).setFrozenPrice(0) - .setFirstBrokerageUserCount(ObjUtil.defaultIfNull(firstBrokerageUserCount, 0L)) - .setSecondBrokerageUserCount(ObjUtil.defaultIfNull(secondBrokerageUserCount, 0L)); - // 设置 brokeragePrice、frozenPrice 字段 - Optional.ofNullable(brokerageUser) - .ifPresent(user -> respVO.setBrokeragePrice(user.getBrokeragePrice()).setFrozenPrice(user.getFrozenPrice())); - return respVO; - } - - default void copyTo(List list, Map userMap) { - for (AppBrokerageUserChildSummaryRespVO vo : list) { - Optional.ofNullable(userMap.get(vo.getId())).ifPresent(user -> - vo.setNickname(user.getNickname()).setAvatar(user.getAvatar())); - } - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java deleted file mode 100644 index 69441ab077..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.enums.DictTypeConstants; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 佣金提现 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BrokerageWithdrawConvert { - - BrokerageWithdrawConvert INSTANCE = Mappers.getMapper(BrokerageWithdrawConvert.class); - - BrokerageWithdrawDO convert(AppBrokerageWithdrawCreateReqVO createReqVO, Long userId, Integer feePrice); - - BrokerageWithdrawRespVO convert(BrokerageWithdrawDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult pageResult, Map userMap) { - PageResult result = convertPage(pageResult); - for (BrokerageWithdrawRespVO vo : result.getList()) { - vo.setUserNickname(Optional.ofNullable(userMap.get(vo.getUserId())).map(MemberUserRespDTO::getNickname).orElse(null)); - } - return result; - } - - PageResult convertPage02(PageResult pageResult); - - default PageResult convertPage03(PageResult pageResult) { - PageResult result = convertPage02(pageResult); - for (AppBrokerageWithdrawRespVO vo : result.getList()) { - vo.setStatusName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_WITHDRAW_STATUS, vo.getStatus())); - } - return result; - } - - BrokerageWithdrawPageReqVO convert(AppBrokerageWithdrawPageReqVO pageReqVO, Long userId); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/cart/TradeCartConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/cart/TradeCartConvert.java deleted file mode 100644 index 83cd459542..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/cart/TradeCartConvert.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.cart; - -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.trade.controller.app.base.sku.AppProductSkuBaseRespVO; -import cn.iocoder.yudao.module.trade.controller.app.base.spu.AppProductSpuBaseRespVO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppCartListRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -@Mapper -public interface TradeCartConvert { - - TradeCartConvert INSTANCE = Mappers.getMapper(TradeCartConvert.class); - - default AppCartListRespVO convertList(List carts, - List spus, List skus) { - Map spuMap = convertMap(spus, ProductSpuRespDTO::getId); - Map skuMap = convertMap(skus, ProductSkuRespDTO::getId); - // 遍历,开始转换 - List validList = new ArrayList<>(carts.size()); - List invalidList = new ArrayList<>(); - carts.forEach(cart -> { - AppCartListRespVO.Cart cartVO = new AppCartListRespVO.Cart(); - cartVO.setId(cart.getId()).setCount(cart.getCount()).setSelected(cart.getSelected()); - ProductSpuRespDTO spu = spuMap.get(cart.getSpuId()); - ProductSkuRespDTO sku = skuMap.get(cart.getSkuId()); - cartVO.setSpu(convert(spu)).setSku(convert(sku)); - // 如果 SPU 不存在,或者下架,或者库存不足,说明是无效的 - if (spu == null - || !ProductSpuStatusEnum.isEnable(spu.getStatus()) - || spu.getStock() <= 0) { - cartVO.setSelected(false); // 强制设置成不可选中 - invalidList.add(cartVO); - } else { - // 虽然 SKU 可能也会不存在,但是可以通过购物车重新选择 - validList.add(cartVO); - } - }); - return new AppCartListRespVO().setValidList(validList).setInvalidList(invalidList); - } - AppProductSpuBaseRespVO convert(ProductSpuRespDTO spu); - AppProductSkuBaseRespVO convert(ProductSkuRespDTO sku); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java deleted file mode 100644 index 57da020c25..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.config; - -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; -import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 交易中心配置 Convert - * - * @author owen - */ -@Mapper -public interface TradeConfigConvert { - - TradeConfigConvert INSTANCE = Mappers.getMapper(TradeConfigConvert.class); - - TradeConfigDO convert(TradeConfigSaveReqVO bean); - - TradeConfigRespVO convert(TradeConfigDO bean); - - AppTradeConfigRespVO convert02(TradeConfigDO tradeConfig); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java deleted file mode 100644 index 3910dcaa31..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.*; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExcelVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.express.AppDeliveryExpressRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface DeliveryExpressConvert { - - DeliveryExpressConvert INSTANCE = Mappers.getMapper(DeliveryExpressConvert.class); - - DeliveryExpressDO convert(DeliveryExpressCreateReqVO bean); - - DeliveryExpressDO convert(DeliveryExpressUpdateReqVO bean); - - DeliveryExpressRespVO convert(DeliveryExpressDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - - List convertList1(List list); - - List convertList03(List list); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java deleted file mode 100644 index b917d874bb..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.*; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; -import com.google.common.collect.Maps; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; - -@Mapper -public interface DeliveryExpressTemplateConvert { - - DeliveryExpressTemplateConvert INSTANCE = Mappers.getMapper(DeliveryExpressTemplateConvert.class); - - // ========== Template ========== - - DeliveryExpressTemplateDO convert(DeliveryExpressTemplateCreateReqVO bean); - - DeliveryExpressTemplateDO convert(DeliveryExpressTemplateUpdateReqVO bean); - - DeliveryExpressTemplateRespVO convert(DeliveryExpressTemplateDO bean); - - DeliveryExpressTemplateDetailRespVO convert2(DeliveryExpressTemplateDO bean); - - List convertList(List list); - - List convertList1(List list); - - PageResult convertPage(PageResult page); - - default DeliveryExpressTemplateDetailRespVO convert(DeliveryExpressTemplateDO bean, - List chargeList, - List freeList) { - DeliveryExpressTemplateDetailRespVO respVO = convert2(bean); - respVO.setCharges(convertTemplateChargeList(chargeList)); - respVO.setFrees(convertTemplateFreeList(freeList)); - return respVO; - } - - // ========== Template Charge ========== - - DeliveryExpressTemplateChargeDO convertTemplateCharge(Long templateId, Integer chargeMode, DeliveryExpressTemplateChargeBaseVO vo); - - DeliveryExpressTemplateRespBO.Charge convertTemplateCharge(DeliveryExpressTemplateChargeDO bean); - - default List convertTemplateChargeList(Long templateId, Integer chargeMode, List list) { - return CollectionUtils.convertList(list, vo -> convertTemplateCharge(templateId, chargeMode, vo)); - } - - // ========== Template Free ========== - - DeliveryExpressTemplateFreeDO convertTemplateFree(Long templateId, DeliveryExpressTemplateFreeBaseVO vo); - - DeliveryExpressTemplateRespBO.Free convertTemplateFree(DeliveryExpressTemplateFreeDO bean); - - List convertTemplateChargeList(List list); - - List convertTemplateFreeList(List list); - - default List convertTemplateFreeList(Long templateId, List list) { - return CollectionUtils.convertList(list, vo -> convertTemplateFree(templateId, vo)); - } - - default Map convertMap(Integer areaId, List templateList, - List chargeList, - List freeList) { - Map> templateIdChargeMap = convertMultiMap(chargeList, - DeliveryExpressTemplateChargeDO::getTemplateId); - Map> templateIdFreeMap = convertMultiMap(freeList, - DeliveryExpressTemplateFreeDO::getTemplateId); - // 组合运费模板配置 RespBO - Map result = Maps.newHashMapWithExpectedSize(templateList.size()); - templateList.forEach(template -> { - DeliveryExpressTemplateRespBO bo = new DeliveryExpressTemplateRespBO() - .setChargeMode(template.getChargeMode()) - .setCharge(convertTemplateCharge(findFirst(templateIdChargeMap.get(template.getId()), charge -> charge.getAreaIds().contains(areaId)))) - .setFree(convertTemplateFree(findFirst(templateIdFreeMap.get(template.getId()), free -> free.getAreaIds().contains(areaId)))); - result.put(template.getId(), bo); - }); - return result; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java deleted file mode 100644 index 1d5b360a5d..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreSimpleRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup.AppDeliveryPickUpStoreRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface DeliveryPickUpStoreConvert { - - DeliveryPickUpStoreConvert INSTANCE = Mappers.getMapper(DeliveryPickUpStoreConvert.class); - - DeliveryPickUpStoreDO convert(DeliveryPickUpStoreCreateReqVO bean); - - DeliveryPickUpStoreDO convert(DeliveryPickUpStoreUpdateReqVO bean); - - DeliveryPickUpStoreRespVO convert(DeliveryPickUpStoreDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList1(List list); - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") - DeliveryPickUpStoreSimpleRespVO convert02(DeliveryPickUpStoreDO bean); - - @Named("convertAreaIdToAreaName") - default String convertAreaIdToAreaName(Integer areaId) { - return AreaUtils.format(areaId); - } - - default List convertList(List list, - Double latitude, Double longitude) { - List voList = CollectionUtils.convertList(list, store -> { - AppDeliveryPickUpStoreRespVO storeVO = convert03(store); - if (latitude != null && longitude != null) { - storeVO.setDistance(NumberUtils.getDistance(latitude, longitude, storeVO.getLatitude(), storeVO.getLongitude())); - } - return storeVO; - }); - return voList; - } - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") - AppDeliveryPickUpStoreRespVO convert03(DeliveryPickUpStoreDO bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java deleted file mode 100644 index 773bb9e91d..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java +++ /dev/null @@ -1,289 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.order; - -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.enums.DictTypeConstants; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*; -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.*; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; - -@Mapper -public interface TradeOrderConvert { - - TradeOrderConvert INSTANCE = Mappers.getMapper(TradeOrderConvert.class); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "userId", target = "userId"), - @Mapping(source = "createReqVO.couponId", target = "couponId"), - @Mapping(target = "remark", ignore = true), - @Mapping(source = "createReqVO.remark", target = "userRemark"), - @Mapping(source = "calculateRespBO.price.totalPrice", target = "totalPrice"), - @Mapping(source = "calculateRespBO.price.discountPrice", target = "discountPrice"), - @Mapping(source = "calculateRespBO.price.deliveryPrice", target = "deliveryPrice"), - @Mapping(source = "calculateRespBO.price.couponPrice", target = "couponPrice"), - @Mapping(source = "calculateRespBO.price.pointPrice", target = "pointPrice"), - @Mapping(source = "calculateRespBO.price.vipPrice", target = "vipPrice"), - @Mapping(source = "calculateRespBO.price.payPrice", target = "payPrice") - }) - TradeOrderDO convert(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO, - TradePriceCalculateRespBO calculateRespBO); - - TradeOrderRespDTO convert(TradeOrderDO orderDO); - - default List convertList(TradeOrderDO tradeOrderDO, TradePriceCalculateRespBO calculateRespBO) { - return CollectionUtils.convertList(calculateRespBO.getItems(), item -> { - TradeOrderItemDO orderItem = convert(item); - orderItem.setOrderId(tradeOrderDO.getId()); - orderItem.setUserId(tradeOrderDO.getUserId()); - orderItem.setAfterSaleStatus(TradeOrderItemAfterSaleStatusEnum.NONE.getStatus()); - orderItem.setCommentStatus(false); - return orderItem; - }); - } - - TradeOrderItemDO convert(TradePriceCalculateRespBO.OrderItem item); - - default ProductSkuUpdateStockReqDTO convert(List list) { - List items = CollectionUtils.convertList(list, item -> - new ProductSkuUpdateStockReqDTO.Item().setId(item.getSkuId()).setIncrCount(item.getCount())); - return new ProductSkuUpdateStockReqDTO(items); - } - - default ProductSkuUpdateStockReqDTO convertNegative(List list) { - List items = CollectionUtils.convertList(list, item -> - new ProductSkuUpdateStockReqDTO.Item().setId(item.getSkuId()).setIncrCount(-item.getCount())); - return new ProductSkuUpdateStockReqDTO(items); - } - - default PayOrderCreateReqDTO convert(TradeOrderDO order, List orderItems, - TradeOrderProperties orderProperties) { - PayOrderCreateReqDTO createReqDTO = new PayOrderCreateReqDTO() - .setAppId(orderProperties.getAppId()).setUserIp(order.getUserIp()); - // 商户相关字段 - createReqDTO.setMerchantOrderId(String.valueOf(order.getId())); - String subject = orderItems.get(0).getSpuName(); - subject = StrUtils.maxLength(subject, PayOrderCreateReqDTO.SUBJECT_MAX_LENGTH); // 避免超过 32 位 - createReqDTO.setSubject(subject); - createReqDTO.setBody(subject); // TODO 芋艿:临时写死 - // 订单相关字段 - createReqDTO.setPrice(order.getPayPrice()).setExpireTime(addTime(orderProperties.getPayExpireTime())); - return createReqDTO; - } - - default PageResult convertPage(PageResult pageResult, - List orderItems, - Map memberUserMap) { - Map> orderItemMap = convertMultiMap(orderItems, TradeOrderItemDO::getOrderId); - // 转化 List - List orderVOs = CollectionUtils.convertList(pageResult.getList(), order -> { - List xOrderItems = orderItemMap.get(order.getId()); - TradeOrderPageItemRespVO orderVO = convert(order, xOrderItems); - // 处理收货地址 - orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); - // 增加用户信息 - orderVO.setUser(convertUser(memberUserMap.get(orderVO.getUserId()))); - // 增加推广人信息 - orderVO.setBrokerageUser(convertUser(memberUserMap.get(orderVO.getBrokerageUserId()))); - return orderVO; - }); - return new PageResult<>(orderVOs, pageResult.getTotal()); - } - - MemberUserRespVO convertUser(MemberUserRespDTO memberUserRespDTO); - - TradeOrderPageItemRespVO convert(TradeOrderDO order, List items); - - ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean); - - default TradeOrderDetailRespVO convert(TradeOrderDO order, List orderItems, - List orderLogs, - MemberUserRespDTO user, MemberUserRespDTO brokerageUser) { - TradeOrderDetailRespVO orderVO = convert2(order, orderItems); - // 处理收货地址 - orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); - // 处理用户信息 - orderVO.setUser(convert(user)); - orderVO.setBrokerageUser(convert(brokerageUser)); - // 处理日志 - orderVO.setLogs(convertList03(orderLogs)); - return orderVO; - } - List convertList03(List orderLogs); - - TradeOrderDetailRespVO convert2(TradeOrderDO order, List items); - - MemberUserRespVO convert(MemberUserRespDTO bean); - - default PageResult convertPage02(PageResult pageResult, - List orderItems) { - Map> orderItemMap = convertMultiMap(orderItems, TradeOrderItemDO::getOrderId); - // 转化 List - List orderVOs = CollectionUtils.convertList(pageResult.getList(), order -> { - List xOrderItems = orderItemMap.get(order.getId()); - return convert02(order, xOrderItems); - }); - return new PageResult<>(orderVOs, pageResult.getTotal()); - } - - AppTradeOrderPageItemRespVO convert02(TradeOrderDO order, List items); - - AppProductPropertyValueDetailRespVO convert02(ProductPropertyValueDetailRespDTO bean); - - default AppTradeOrderDetailRespVO convert02(TradeOrderDO order, List orderItems, - TradeOrderProperties tradeOrderProperties, - DeliveryExpressDO express) { - AppTradeOrderDetailRespVO orderVO = convert3(order, orderItems); - orderVO.setPayExpireTime(addTime(tradeOrderProperties.getPayExpireTime())); - if (StrUtil.isNotEmpty(order.getPayChannelCode())) { - orderVO.setPayChannelName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.CHANNEL_CODE, order.getPayChannelCode())); - } - // 处理收货地址 - orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); - if (express != null) { - orderVO.setLogisticsId(express.getId()).setLogisticsName(express.getName()); - } - return orderVO; - } - - AppTradeOrderDetailRespVO convert3(TradeOrderDO order, List items); - - AppTradeOrderItemRespVO convert03(TradeOrderItemDO bean); - - @Mappings({ - @Mapping(target = "skuId", source = "tradeOrderItemDO.skuId"), - @Mapping(target = "orderId", source = "tradeOrderItemDO.orderId"), - @Mapping(target = "orderItemId", source = "tradeOrderItemDO.id"), - @Mapping(target = "descriptionScores", source = "createReqVO.descriptionScores"), - @Mapping(target = "benefitScores", source = "createReqVO.benefitScores"), - @Mapping(target = "content", source = "createReqVO.content"), - @Mapping(target = "picUrls", source = "createReqVO.picUrls"), - @Mapping(target = "anonymous", source = "createReqVO.anonymous"), - @Mapping(target = "userId", source = "tradeOrderItemDO.userId") - }) - ProductCommentCreateReqDTO convert04(AppTradeOrderItemCommentCreateReqVO createReqVO, TradeOrderItemDO tradeOrderItemDO); - - TradePriceCalculateReqBO convert(AppTradeOrderSettlementReqVO settlementReqVO); - - default TradePriceCalculateReqBO convert(Long userId, AppTradeOrderSettlementReqVO settlementReqVO, - List cartList) { - TradePriceCalculateReqBO reqBO = new TradePriceCalculateReqBO().setUserId(userId) - .setItems(new ArrayList<>(settlementReqVO.getItems().size())) - .setCouponId(settlementReqVO.getCouponId()).setPointStatus(settlementReqVO.getPointStatus()) - // 物流信息 - .setDeliveryType(settlementReqVO.getDeliveryType()).setAddressId(settlementReqVO.getAddressId()) - .setPickUpStoreId(settlementReqVO.getPickUpStoreId()) - // 各种活动 - .setSeckillActivityId(settlementReqVO.getSeckillActivityId()) - .setBargainRecordId(settlementReqVO.getBargainRecordId()) - .setCombinationActivityId(settlementReqVO.getCombinationActivityId()) - .setCombinationHeadId(settlementReqVO.getCombinationHeadId()); - // 商品项的构建 - Map cartMap = convertMap(cartList, CartDO::getId); - for (AppTradeOrderSettlementReqVO.Item item : settlementReqVO.getItems()) { - // 情况一:skuId + count - if (item.getSkuId() != null) { - reqBO.getItems().add(new TradePriceCalculateReqBO.Item().setSkuId(item.getSkuId()).setCount(item.getCount()) - .setSelected(true)); // true 的原因,下单一定选中 - continue; - } - // 情况二:cartId - CartDO cart = cartMap.get(item.getCartId()); - if (cart == null) { - continue; - } - reqBO.getItems().add(new TradePriceCalculateReqBO.Item().setSkuId(cart.getSkuId()).setCount(cart.getCount()) - .setCartId(item.getCartId()).setSelected(true)); // true 的原因,下单一定选中 - } - return reqBO; - } - - default AppTradeOrderSettlementRespVO convert(TradePriceCalculateRespBO calculate, MemberAddressRespDTO address) { - AppTradeOrderSettlementRespVO respVO = convert0(calculate, address); - if (address != null) { - respVO.getAddress().setAreaName(AreaUtils.format(address.getAreaId())); - } - return respVO; - } - - AppTradeOrderSettlementRespVO convert0(TradePriceCalculateRespBO calculate, MemberAddressRespDTO address); - - List convertList02(List list); - - TradeOrderDO convert(TradeOrderUpdateAddressReqVO reqVO); - - TradeOrderDO convert(TradeOrderUpdatePriceReqVO reqVO); - - TradeOrderDO convert(TradeOrderRemarkReqVO reqVO); - - default BrokerageAddReqBO convert(MemberUserRespDTO user, TradeOrderItemDO item, - ProductSpuRespDTO spu, ProductSkuRespDTO sku) { - BrokerageAddReqBO bo = new BrokerageAddReqBO().setBizId(String.valueOf(item.getId())).setSourceUserId(item.getUserId()) - .setBasePrice(item.getPayPrice() * item.getCount()) - .setTitle(StrUtil.format("{}成功购买{}", user.getNickname(), item.getSpuName())) - .setFirstFixedPrice(0).setSecondFixedPrice(0); - if (BooleanUtil.isTrue(spu.getSubCommissionType())) { - bo.setFirstFixedPrice(sku.getFirstBrokeragePrice()).setSecondFixedPrice(sku.getSecondBrokeragePrice()); - } - return bo; - } - - @Named("convertList04") - List convertList04(List list); - - @Mappings({ - @Mapping(target = "activityId", source = "order.combinationActivityId"), - @Mapping(target = "spuId", source = "item.spuId"), - @Mapping(target = "skuId", source = "item.skuId"), - @Mapping(target = "count", source = "item.count"), - @Mapping(target = "orderId", source = "order.id"), - @Mapping(target = "userId", source = "order.userId"), - @Mapping(target = "headId", source = "order.combinationHeadId"), - @Mapping(target = "combinationPrice", source = "item.payPrice"), - }) - CombinationRecordCreateReqDTO convert(TradeOrderDO order, TradeOrderItemDO item); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderLogConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderLogConvert.java deleted file mode 100644 index 763f058227..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderLogConvert.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.order; - -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeOrderLogCreateReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface TradeOrderLogConvert { - - TradeOrderLogConvert INSTANCE = Mappers.getMapper(TradeOrderLogConvert.class); - - TradeOrderLogDO convert(TradeOrderLogCreateReqBO bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java deleted file mode 100644 index 214592b62b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java +++ /dev/null @@ -1,201 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.aftersale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 售后订单,用于处理 {@link TradeOrderDO} 交易订单的退款退货流程 - * - * @author 芋道源码 - */ -@TableName(value = "trade_after_sale", autoResultMap = true) -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class AfterSaleDO extends BaseDO { - - /** - * 售后编号,主键自增 - */ - private Long id; - /** - * 售后单号 - * - * 例如说,1146347329394184195 - */ - private String no; - /** - * 退款状态 - * - * 枚举 {@link AfterSaleStatusEnum} - */ - private Integer status; - /** - * 售后方式 - * - * 枚举 {@link AfterSaleWayEnum} - */ - private Integer way; - /** - * 售后类型 - * - * 枚举 {@link AfterSaleTypeEnum} - */ - private Integer type; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 申请原因 - * - * type = 退款,对应 trade_after_sale_refund_reason 类型 - * type = 退货退款,对应 trade_after_sale_refund_and_return_reason 类型 - */ - private String applyReason; - /** - * 补充描述 - */ - private String applyDescription; - /** - * 补充凭证图片 - * - * 数组,以逗号分隔 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List applyPicUrls; - - // ========== 交易订单相关 ========== - /** - * 交易订单编号 - * - * 关联 {@link TradeOrderDO#getId()} - */ - private Long orderId; - /** - * 订单流水号 - * - * 冗余 {@link TradeOrderDO#getNo()} - */ - private String orderNo; - /** - * 交易订单项编号 - * - * 关联 {@link TradeOrderItemDO#getId()} - */ - private Long orderItemId; - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 字段 - * 冗余 {@link TradeOrderItemDO#getSpuId()} - */ - private Long spuId; - /** - * 商品 SPU 名称 - * - * 关联 ProductSkuDO 的 name 字段 - * 冗余 {@link TradeOrderItemDO#getSpuName()} - */ - private String spuName; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的编号 - */ - private Long skuId; - /** - * 属性数组,JSON 格式 - * - * 冗余 {@link TradeOrderItemDO#getProperties()} - */ - @TableField(typeHandler = TradeOrderItemDO.PropertyTypeHandler.class) - private List properties; - /** - * 商品图片 - * - * 冗余 {@link TradeOrderItemDO#getPicUrl()} - */ - private String picUrl; - /** - * 退货商品数量 - */ - private Integer count; - - // ========== 审批相关 ========== - - /** - * 审批时间 - */ - private LocalDateTime auditTime; - /** - * 审批人 - * - * 关联 AdminUserDO 的 id 编号 - */ - private Long auditUserId; - /** - * 审批备注 - * - * 注意,只有审批不通过才会填写 - */ - private String auditReason; - - // ========== 退款相关 ========== - /** - * 退款金额,单位:分。 - */ - private Integer refundPrice; - /** - * 支付退款编号 - * - * 对接 pay-module-biz 支付服务的退款订单编号,即 PayRefundDO 的 id 编号 - */ - private Long payRefundId; - /** - * 退款时间 - */ - private LocalDateTime refundTime; - - // ========== 退货相关 ========== - /** - * 退货物流公司编号 - * - * 关联 LogisticsDO 的 id 编号 - */ - private Long logisticsId; - /** - * 退货物流单号 - */ - private String logisticsNo; - /** - * 退货时间 - */ - private LocalDateTime deliveryTime; - /** - * 收货时间 - */ - private LocalDateTime receiveTime; - /** - * 收货备注 - * - * 注意,只有拒绝收货才会填写 - */ - private String receiveReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleLogDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleLogDO.java deleted file mode 100644 index 2820f23e14..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleLogDO.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.aftersale; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 交易售后日志 DO - * - * @author 芋道源码 - */ -@TableName("trade_after_sale_log") -@KeySequence("trade_after_sale_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class AfterSaleLogDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 1:AdminUserDO 的 id 字段 - * 关联 2:MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 用户类型 - * - * 枚举 {@link UserTypeEnum} - */ - private Integer userType; - - /** - * 售后编号 - * - * 关联 {@link AfterSaleDO#getId()} - */ - private Long afterSaleId; - /** - * 操作前状态 - */ - private Integer beforeStatus; - /** - * 操作后状态 - */ - private Integer afterStatus; - - /** - * 操作类型 - * - * 枚举 {@link AfterSaleOperateTypeEnum} - */ - private Integer operateType; - /** - * 操作明细 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageRecordDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageRecordDO.java deleted file mode 100644 index c819d723bc..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageRecordDO.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 佣金记录 DO - * - * @author owen - */ -@TableName("trade_brokerage_record") -@KeySequence("trade_brokerage_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Integer id; - /** - * 用户编号 - *

- * 关联 MemberUserDO.id - */ - private Long userId; - /** - * 业务编号 - */ - private String bizId; - /** - * 业务类型 - *

- * 枚举 {@link BrokerageRecordBizTypeEnum} - */ - private Integer bizType; - - /** - * 标题 - */ - private String title; - /** - * 说明 - */ - private String description; - - /** - * 金额 - */ - private Integer price; - /** - * 当前总佣金 - */ - private Integer totalPrice; - - /** - * 状态 - *

- * 枚举 {@link BrokerageRecordStatusEnum} - */ - private Integer status; - - /** - * 冻结时间(天) - */ - private Integer frozenDays; - /** - * 解冻时间 - */ - private LocalDateTime unfreezeTime; - - /** - * 来源用户等级 - *

- * 被推广用户和 {@link #userId} 的推广层级关系 - */ - private Integer sourceUserLevel; - /** - * 来源用户编号 - *

- * 关联 MemberUserDO.id 字段,被推广用户的编号 - */ - private Long sourceUserId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java deleted file mode 100644 index 8d73858ec6..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 分销用户 DO - * - * @author owen - */ -@TableName("trade_brokerage_user") -@KeySequence("trade_brokerage_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageUserDO extends BaseDO { - - /** - * 用户编号 - *

- * 对应 MemberUserDO 的 id 字段 - */ - @TableId - private Long id; - - /** - * 推广员编号 - *

- * 关联 MemberUserDO 的 id 字段 - */ - private Long bindUserId; - /** - * 推广员绑定时间 - */ - private LocalDateTime bindUserTime; - - /** - * 是否有分销资格 - */ - private Boolean brokerageEnabled; - /** - * 成为分销员时间 - */ - private LocalDateTime brokerageTime; - - /** - * 可用佣金 - */ - private Integer brokeragePrice; - /** - * 冻结佣金 - */ - private Integer frozenPrice; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java deleted file mode 100644 index f31c238001..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 佣金提现 DO - * - * @author 芋道源码 - */ -@TableName("trade_brokerage_withdraw") -@KeySequence("trade_brokerage_withdraw_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageWithdrawDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 字段 - */ - private Long userId; - - /** - * 提现金额,单位:分 - */ - private Integer price; - /** - * 提现手续费,单位:分 - */ - private Integer feePrice; - /** - * 当前总佣金,单位:分 - */ - private Integer totalPrice; - /** - * 提现类型 - *

- * 枚举 {@link BrokerageWithdrawTypeEnum} - */ - private Integer type; - - /** - * 真实姓名 - */ - private String name; - /** - * 账号 - */ - private String accountNo; - /** - * 银行名称 - */ - private String bankName; - /** - * 开户地址 - */ - private String bankAddress; - /** - * 收款码 - */ - private String accountQrCodeUrl; - /** - * 状态 - *

- * 枚举 {@link BrokerageWithdrawStatusEnum} - */ - private Integer status; - /** - * 审核驳回原因 - */ - private String auditReason; - /** - * 审核时间 - */ - private LocalDateTime auditTime; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/cart/CartDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/cart/CartDO.java deleted file mode 100644 index d8bf140883..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/cart/CartDO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.cart; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -/** - * 购物车的商品信息 DO - * - * 每个商品,对应一条记录,通过 {@link #spuId} 和 {@link #skuId} 关联 - * - * @author 芋道源码 - */ -@TableName("trade_cart") -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class CartDO extends BaseDO { - - // ========= 基础字段 BEGIN ========= - - /** - * 编号,唯一自增 - */ - private Long id; - - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - - // ========= 商品信息 ========= - - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的 id 编号 - */ - private Long skuId; - /** - * 商品购买数量 - */ - private Integer count; - /** - * 是否选中 - */ - private Boolean selected; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java deleted file mode 100644 index fabd026224..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java +++ /dev/null @@ -1,123 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.config; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 交易中心配置 DO - * - * @author owen - */ -@TableName(value = "trade_config", autoResultMap = true) -@KeySequence("trade_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeConfigDO extends BaseDO { - - /** - * 自增主键 - */ - @TableId - private Long id; - - // ========== 售后相关 ========== - - /** - * 售后的退款理由 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List afterSaleRefundReasons; - /** - * 售后的退货理由 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List afterSaleReturnReasons; - - // ========== 配送相关 ========== - - /** - * 是否启用全场包邮 - */ - private Boolean deliveryExpressFreeEnabled; - /** - * 全场包邮的最小金额,单位:分 - */ - private Integer deliveryExpressFreePrice; - - /** - * 是否开启自提 - */ - private Boolean deliveryPickUpEnabled; - - // ========== 分销相关 ========== - - /** - * 是否启用分佣 - */ - private Boolean brokerageEnabled; - /** - * 分佣模式 - *

- * 枚举 {@link BrokerageEnabledConditionEnum 对应的类} - */ - private Integer brokerageEnabledCondition; - /** - * 分销关系绑定模式 - *

- * 枚举 {@link BrokerageBindModeEnum 对应的类} - */ - private Integer brokerageBindMode; - /** - * 分销海报图地址数组 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List brokeragePosterUrls; - /** - * 一级返佣比例 - */ - private Integer brokerageFirstPercent; - /** - * 二级返佣比例 - */ - private Integer brokerageSecondPercent; - /** - * 用户提现最低金额 - */ - private Integer brokerageWithdrawMinPrice; - /** - * 用户提现手续费百分比 - */ - private Integer brokerageWithdrawFeePercent; - /** - * 提现银行 - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List brokerageBankNames; - /** - * 佣金冻结时间(天) - */ - private Integer brokerageFrozenDays; - /** - * 提现方式 - *

- * 枚举 {@link BrokerageWithdrawTypeEnum 对应的类} - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List brokerageWithdrawTypes; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressDO.java deleted file mode 100644 index 265066d83b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressDO.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 快递公司 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_express") -@KeySequence("trade_delivery_express_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryExpressDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 快递公司 code - */ - private String code; - - /** - * 快递公司名称 - */ - private String name; - - /** - * 快递公司 logo - */ - private String logo; - - /** - * 排序 - */ - private Integer sort; - - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - - // TODO 芋艿:c 和结算相关的字段,后续在看 - // partnerId 是否需要月结账号 - // partnerKey 是否需要月结密码 - // net 是否需要取件网店 - // account 账号 - // password 网点名称 - // isShow 是否显示 -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java deleted file mode 100644 index c3bb30e9a8..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.util.List; - -/** - * 快递运费模板计费配置 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_express_template_charge", autoResultMap = true) -@KeySequence("trade_delivery_express_template_charge_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryExpressTemplateChargeDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 配送模板编号 - * - * 关联 {@link DeliveryExpressTemplateDO#getId()} - */ - private Long templateId; - - /** - * 配送区域编号列表 - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List areaIds; - - /** - * 配送计费方式 - * - * 冗余 {@link DeliveryExpressTemplateDO#getChargeMode()} - */ - private Integer chargeMode; - - /** - * 首件数量(件数,重量,或体积) - */ - private Double startCount; - /** - * 起步价,单位:分 - */ - private Integer startPrice; - - /** - * 续件数量(件, 重量,或体积) - */ - private Double extraCount; - /** - * 额外价,单位:分 - */ - private Integer extraPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateDO.java deleted file mode 100644 index b6d6db3b77..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateDO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryExpressChargeModeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 快递运费模板 DO - * - * @author jason - */ -@TableName("trade_delivery_express_template") -@KeySequence("trade_delivery_express_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryExpressTemplateDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 模板名称 - */ - private String name; - - /** - * 配送计费方式 - * - * 枚举 {@link DeliveryExpressChargeModeEnum} - */ - private Integer chargeMode; - - /** - * 排序 - */ - private Integer sort; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java deleted file mode 100644 index 07eef1be28..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.util.List; - -/** - * 快递运费模板包邮配置 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_express_template_free", autoResultMap = true) -@KeySequence("trade_delivery_express_template_free_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryExpressTemplateFreeDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 配送模板编号 - * - * 关联 {@link DeliveryExpressTemplateDO#getId()} - */ - private Long templateId; - - - /** - * 配送区域编号列表 - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List areaIds; - - /** - * 包邮金额,单位:分 - * - * 订单总金额 > 包邮金额时,才免运费 - */ - private Integer freePrice; - - /** - * 包邮件数 - * - * 订单总件数 > 包邮件数时,才免运费 - */ - private Integer freeCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java deleted file mode 100644 index 21ff993747..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.time.LocalTime; - -/** - * 自提门店 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_pick_up_store") -@KeySequence("trade_delivery_pick_up_store_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryPickUpStoreDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 门店名称 - */ - private String name; - - /** - * 门店简介 - */ - private String introduction; - - /** - * 门店手机 - */ - private String phone; - - /** - * 区域编号 - */ - private Integer areaId; - - /** - * 门店详细地址 - */ - private String detailAddress; - - /** - * 门店 logo - */ - private String logo; - - /** - * 营业开始时间 - */ - private LocalTime openingTime; - - /** - * 营业结束时间 - */ - private LocalTime closingTime; - - /** - * 纬度 - */ - private Double latitude; - /** - * 经度 - */ - private Double longitude; - - /** - * 门店状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java deleted file mode 100644 index 4c03a8e5db..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -// TODO @芋艿:后续再详细 review 一轮 -// TODO @芋艿:可能改成 DeliveryPickUpStoreUserDO -/** - * 自提门店店员 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_pick_up_store_staff") -@KeySequence("trade_delivery_pick_up_store_staff_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryPickUpStoreStaffDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 自提门店编号 - * - * 关联 {@link DeliveryPickUpStoreDO#getId()} - */ - private Long storeId; - - /** - * 管理员用户id - * - * 关联 {AdminUserDO#getId()} - */ - private Long adminUserId; - - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java deleted file mode 100644 index b127004aaa..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java +++ /dev/null @@ -1,333 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.order; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderCancelTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderRefundStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 交易订单 DO - * - * @author 芋道源码 - */ -@TableName("trade_order") -@KeySequence("trade_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeOrderDO extends BaseDO { - - /** - * 发货物流公司编号 - 空(无需发货) - */ - public static final Long LOGISTICS_ID_NULL = 0L; - - // ========== 订单基本信息 ========== - /** - * 订单编号,主键自增 - */ - private Long id; - /** - * 订单流水号 - * - * 例如说,1146347329394184195 - */ - private String no; - /** - * 订单类型 - * - * 枚举 {@link TradeOrderTypeEnum} - */ - private Integer type; - /** - * 订单来源 - * - * 枚举 {@link TerminalEnum} - */ - private Integer terminal; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 用户 IP - */ - private String userIp; - /** - * 用户备注 - */ - private String userRemark; - /** - * 订单状态 - * - * 枚举 {@link TradeOrderStatusEnum} - */ - private Integer status; - /** - * 购买的商品数量 - */ - private Integer productCount; - /** - * 订单完成时间 - */ - private LocalDateTime finishTime; - /** - * 订单取消时间 - */ - private LocalDateTime cancelTime; - /** - * 取消类型 - * - * 枚举 {@link TradeOrderCancelTypeEnum} - */ - private Integer cancelType; - /** - * 商家备注 - */ - private String remark; - /** - * 是否评价 - * - * true - 已评价 - * false - 未评价 - */ - private Boolean commentStatus; - - /** - * 推广人编号 - * - * 关联 {@link BrokerageUserDO#getId()} 字段,即 {@link MemberUserRespDTO#getId()} 字段 - */ - private Long brokerageUserId; - - // ========== 价格 + 支付基本信息 ========== - - // 价格文档 - 淘宝:https://open.taobao.com/docV3.htm?docId=108471&docType=1 - // 价格文档 - 京东到家:https://openo2o.jddj.com/api/getApiDetail/182/4d1494c5e7ac4679bfdaaed950c5bc7f.htm - // 价格文档 - 有赞:https://doc.youzanyun.com/detail/API/0/906 - - /** - * 支付订单编号 - * - * 对接 pay-module-biz 支付服务的支付订单编号,即 PayOrderDO 的 id 编号 - */ - private Long payOrderId; - /** - * 是否已支付 - * - * true - 已经支付过 - * false - 没有支付过 - */ - private Boolean payStatus; - /** - * 付款时间 - */ - private LocalDateTime payTime; - /** - * 支付渠道 - * - * 对应 PayChannelEnum 枚举 - */ - private String payChannelCode; - - /** - * 商品原价,单位:分 - * - * totalPrice = {@link TradeOrderItemDO#getPrice()} * {@link TradeOrderItemDO#getCount()} 求和 - * - * 对应 taobao 的 trade.total_fee 字段 - */ - private Integer totalPrice; - /** - * 优惠金额,单位:分 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额,单位:分 - */ - private Integer deliveryPrice; - /** - * 订单调价,单位:分 - * - * 正数,加价;负数,减价 - */ - private Integer adjustPrice; - /** - * 应付金额(总),单位:分 - * - * = {@link #totalPrice} - * - {@link #couponPrice} - * - {@link #pointPrice} - * - {@link #discountPrice} - * + {@link #deliveryPrice} - * + {@link #adjustPrice} - * - {@link #vipPrice} - */ - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - /** - * 配送方式 - * - * 枚举 {@link DeliveryTypeEnum} - */ - private Integer deliveryType; - /** - * 发货物流公司编号 - * - * 如果无需发货,则 logisticsId 设置为 0。原因是,不想再添加额外字段 - * - * 关联 {@link DeliveryExpressDO#getId()} - */ - private Long logisticsId; - /** - * 发货物流单号 - * - * 如果无需发货,则 logisticsNo 设置 ""。原因是,不想再添加额外字段 - */ - private String logisticsNo; - /** - * 发货时间 - */ - private LocalDateTime deliveryTime; - - /** - * 收货时间 - */ - private LocalDateTime receiveTime; - /** - * 收件人名称 - */ - private String receiverName; - /** - * 收件人手机 - */ - private String receiverMobile; - /** - * 收件人地区编号 - */ - private Integer receiverAreaId; - /** - * 收件人详细地址 - */ - private String receiverDetailAddress; - - /** - * 自提门店编号 - * - * 关联 {@link DeliveryPickUpStoreDO#getId()} - */ - private Long pickUpStoreId; - /** - * 自提核销码 - */ - private String pickUpVerifyCode; - - // ========== 售后基本信息 ========== - /** - * 售后状态 - * - * 枚举 {@link TradeOrderRefundStatusEnum} - */ - private Integer refundStatus; - /** - * 退款金额,单位:分 - * - * 注意,退款并不会影响 {@link #payPrice} 实际支付金额 - * 也就说,一个订单最终产生多少金额的收入 = payPrice - refundPrice - */ - private Integer refundPrice; - - // ========== 营销基本信息 ========== - /** - * 优惠劵编号 - */ - private Long couponId; - /** - * 优惠劵减免金额,单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 使用的积分 - */ - private Integer usePoint; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * 赠送的积分 - */ - private Integer givePoint; - /** - * 退还的使用的积分 - */ - private Integer refundPoint; - /** - * VIP 减免金额,单位:分 - */ - private Integer vipPrice; - - /** - * 秒杀活动编号 - * - * 关联 SeckillActivityDO 的 id 字段 - */ - private Long seckillActivityId; - - /** - * 砍价活动编号 - * - * 关联 BargainActivityDO 的 id 字段 - */ - private Long bargainActivityId; - /** - * 砍价记录编号 - * - * 关联 BargainRecordDO 的 id 字段 - */ - private Long bargainRecordId; - - /** - * 拼团活动编号 - * - * 关联 CombinationActivityDO 的 id 字段 - */ - private Long combinationActivityId; - /** - * 拼团团长编号 - * - * 关联 CombinationRecordDO 的 headId 字段 - */ - private Long combinationHeadId; - /** - * 拼团记录编号 - * - * 关联 CombinationRecordDO 的 id 字段 - */ - private Long combinationRecordId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java deleted file mode 100644 index 10b07ce581..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java +++ /dev/null @@ -1,229 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.order; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.List; - -/** - * 交易订单项 DO - * - * @author 芋道源码 - */ -@TableName(value = "trade_order_item", autoResultMap = true) -@Data -@Accessors(chain = true) -@EqualsAndHashCode(callSuper = true) -public class TradeOrderItemDO extends BaseDO { - - // ========== 订单项基本信息 ========== - /** - * 编号 - */ - private Long id; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 订单编号 - * - * 关联 {@link TradeOrderDO#getId()} - */ - private Long orderId; - /** - * 购物车项编号 - * - * 关联 {@link CartDO#getId()} - */ - private Long cartId; - - // ========== 商品基本信息; 冗余较多字段,减少关联查询 ========== - /** - * 商品 SPU 编号 - * - * 关联 ProductSkuDO 的 spuId 编号 - */ - private Long spuId; - /** - * 商品 SPU 名称 - * - * 冗余 ProductSkuDO 的 spuName 编号 - */ - private String spuName; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的 id 编号 - */ - private Long skuId; - /** - * 属性数组,JSON 格式 - * - * 冗余 ProductSkuDO 的 properties 字段 - */ - @TableField(typeHandler = PropertyTypeHandler.class) - private List properties; - /** - * 商品图片 - */ - private String picUrl; - /** - * 购买数量 - */ - private Integer count; - /** - * 是否评价 - * - * true - 已评价 - * false - 未评价 - */ - private Boolean commentStatus; - - // ========== 价格 + 支付基本信息 ========== - - /** - * 商品原价(单),单位:分 - * - * 对应 ProductSkuDO 的 price 字段 - * 对应 taobao 的 order.price 字段 - */ - private Integer price; - /** - * 优惠金额(总),单位:分 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额(总),单位:分 - */ - private Integer deliveryPrice; - /** - * 订单调价(总),单位:分 - * - * 正数,加价;负数,减价 - */ - private Integer adjustPrice; - /** - * 应付金额(总),单位:分 - * - * = {@link #price} * {@link #count} - * - {@link #couponPrice} - * - {@link #pointPrice} - * - {@link #discountPrice} - * + {@link #deliveryPrice} - * + {@link #adjustPrice} - * - {@link #vipPrice} - */ - private Integer payPrice; - - // ========== 营销基本信息 ========== - - /** - * 优惠劵减免金额,单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * 使用的积分 - * - * 目的:用于后续取消或者售后订单时,需要归还赠送 - */ - private Integer usePoint; - /** - * 赠送的积分 - * - * 目的:用于后续取消或者售后订单时,需要扣减赠送 - */ - private Integer givePoint; - /** - * VIP 减免金额,单位:分 - */ - private Integer vipPrice; - - // ========== 售后基本信息 ========== - - /** - * 售后单编号 - * - * 关联 {@link AfterSaleDO#getId()} 字段 - */ - private Long afterSaleId; - /** - * 售后状态 - * - * 枚举 {@link TradeOrderItemAfterSaleStatusEnum} - */ - private Integer afterSaleStatus; - - /** - * 商品属性 - */ - @Data - public static class Property implements Serializable { - - /** - * 属性编号 - * - * 关联 ProductPropertyDO 的 id 编号 - */ - private Long propertyId; - /** - * 属性名字 - * - * 关联 ProductPropertyDO 的 name 字段 - */ - private String propertyName; - - /** - * 属性值编号 - * - * 关联 ProductPropertyValueDO 的 id 编号 - */ - private Long valueId; - /** - * 属性值名字 - * - * 关联 ProductPropertyValueDO 的 name 字段 - */ - private String valueName; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class PropertyTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List parse(String json) { - return JsonUtils.parseArray(json, Property.class); - } - - @Override - protected String toJson(List obj) { - return JsonUtils.toJsonString(obj); - } - - } - -} - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderLogDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderLogDO.java deleted file mode 100644 index 36022c16ef..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderLogDO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.order; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderOperateTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 订单日志 DO - * - * @author 陈賝 - */ -@TableName("trade_order_log") -@KeySequence("trade_order_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeOrderLogDO extends BaseDO { - - /** - * 用户类型 - 系统 - * - * 例如说:Job 自动过期订单时,通过系统自动操作 - */ - public static final Integer USER_TYPE_SYSTEM = 0; - /** - * 用户编号 - 系统 - */ - public static final Long USER_ID_SYSTEM = 0L; - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 AdminUserDO 的 id 字段、或者 MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 用户类型 - * - * 枚举 {@link UserTypeEnum} - */ - private Integer userType; - - /** - * 订单号 - * - * 关联 {@link TradeOrderDO#getId()} - */ - private Long orderId; - /** - * 操作前状态 - */ - private Integer beforeStatus; - /** - * 操作后状态 - */ - private Integer afterStatus; - - /** - * 操作类型 - * - * {@link TradeOrderOperateTypeEnum} - */ - private Integer operateType; - /** - * 订单日志信息 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleLogMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleLogMapper.java deleted file mode 100644 index c0ec91c6d2..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleLogMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.aftersale; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface AfterSaleLogMapper extends BaseMapperX { - - default List selectListByAfterSaleId(Long afterSaleId) { - return selectList(AfterSaleLogDO::getAfterSaleId, afterSaleId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java deleted file mode 100644 index 68a09a82a2..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; - -@Mapper -public interface AfterSaleMapper extends BaseMapperX { - - default PageResult selectPage(AfterSalePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(AfterSaleDO::getNo, reqVO.getNo()) - .eqIfPresent(AfterSaleDO::getStatus, reqVO.getStatus()) - .eqIfPresent(AfterSaleDO::getType, reqVO.getType()) - .eqIfPresent(AfterSaleDO::getWay, reqVO.getWay()) - .likeIfPresent(AfterSaleDO::getOrderNo, reqVO.getOrderNo()) - .likeIfPresent(AfterSaleDO::getSpuName, reqVO.getSpuName()) - .betweenIfPresent(AfterSaleDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(AfterSaleDO::getId)); - } - - default PageResult selectPage(Long userId, PageParam pageParam) { - return selectPage(pageParam, new LambdaQueryWrapperX() - .eqIfPresent(AfterSaleDO::getUserId, userId) - .orderByDesc(AfterSaleDO::getId)); - } - - default int updateByIdAndStatus(Long id, Integer status, AfterSaleDO update) { - return update(update, new LambdaUpdateWrapper() - .eq(AfterSaleDO::getId, id).eq(AfterSaleDO::getStatus, status)); - } - - default AfterSaleDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(AfterSaleDO::getId, id, - AfterSaleDO::getUserId, userId); - } - - default Long selectCountByUserIdAndStatus(Long userId, Collection statuses) { - return selectCount(new LambdaQueryWrapperX() - .eq(AfterSaleDO::getUserId, userId) - .in(AfterSaleDO::getStatus, statuses)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java deleted file mode 100644 index e7a85868b6..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.brokerage; - -import cn.hutool.core.bean.BeanUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.yulichang.toolkit.MPJWrappers; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 佣金记录 Mapper - * - * @author owen - */ -@Mapper -public interface BrokerageRecordMapper extends BaseMapperX { - - default PageResult selectPage(BrokerageRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BrokerageRecordDO::getUserId, reqVO.getUserId()) - .eqIfPresent(BrokerageRecordDO::getBizType, reqVO.getBizType()) - .eqIfPresent(BrokerageRecordDO::getStatus, reqVO.getStatus()) - .eqIfPresent(BrokerageRecordDO::getSourceUserLevel, reqVO.getSourceUserLevel()) - .betweenIfPresent(BrokerageRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BrokerageRecordDO::getId)); - } - - default List selectListByStatusAndUnfreezeTimeLt(Integer status, LocalDateTime unfreezeTime) { - return selectList(new LambdaQueryWrapper() - .eq(BrokerageRecordDO::getStatus, status) - .lt(BrokerageRecordDO::getUnfreezeTime, unfreezeTime)); - } - - default int updateByIdAndStatus(Integer id, Integer status, BrokerageRecordDO updateObj) { - return update(updateObj, new LambdaQueryWrapper() - .eq(BrokerageRecordDO::getId, id) - .eq(BrokerageRecordDO::getStatus, status)); - } - - default BrokerageRecordDO selectByBizTypeAndBizIdAndUserId(Integer bizType, String bizId, Long userId) { - return selectOne(BrokerageRecordDO::getBizType, bizType, - BrokerageRecordDO::getBizId, bizId, - BrokerageRecordDO::getUserId, userId); - } - - default List selectCountAndSumPriceByUserIdInAndBizTypeAndStatus(Collection userIds, - Integer bizType, - Integer status) { - List> list = selectMaps(MPJWrappers.lambdaJoin(BrokerageRecordDO.class) - .select(BrokerageRecordDO::getUserId) - .selectCount(BrokerageRecordDO::getId, UserBrokerageSummaryRespBO::getCount) - .selectSum(BrokerageRecordDO::getPrice) - .in(BrokerageRecordDO::getUserId, userIds) - .eq(BrokerageRecordDO::getBizId, bizType) - .eq(BrokerageRecordDO::getStatus, status) - .groupBy(BrokerageRecordDO::getUserId)); // 按照 userId 聚合 - return BeanUtil.copyToList(list, UserBrokerageSummaryRespBO.class); - // selectJoinList有BUG,会与租户插件冲突:解析SQL时,发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW -// return selectJoinList(UserBrokerageSummaryBO.class, MPJWrappers.lambdaJoin(BrokerageRecordDO.class) -// .select(BrokerageRecordDO::getUserId) -// .selectCount(BrokerageRecordDO::getId, UserBrokerageSummaryBO::getCount) -// .selectSum(BrokerageRecordDO::getPrice) -// .in(BrokerageRecordDO::getUserId, userIds) -// .eq(BrokerageRecordDO::getBizId, bizType) -// .eq(BrokerageRecordDO::getStatus, status) -// .groupBy(BrokerageRecordDO::getUserId)); - } - - @Select("SELECT SUM(price) FROM trade_brokerage_record " + - "WHERE user_id = #{userId} AND biz_type = #{bizType} AND status = #{status} " + - "AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE") - Integer selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(@Param("userId") Long userId, - @Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - @Select("SELECT user_id AS id, SUM(price) AS brokeragePrice FROM trade_brokerage_record " + - "WHERE biz_type = #{bizType} AND status = #{status} AND deleted = FALSE " + - "AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} " + - "GROUP BY user_id " + - "ORDER BY brokeragePrice DESC") - IPage selectSummaryPricePageGroupByUserId(IPage page, - @Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - @Select("SELECT COUNT(1) FROM trade_brokerage_record " + - "WHERE biz_type = #{bizType} AND status = #{status} AND deleted = FALSE " + - "AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} " + - "GROUP BY user_id HAVING SUM(price) > #{brokeragePrice}") - Integer selectCountByPriceGt(@Param("brokeragePrice") Integer brokeragePrice, - @Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java deleted file mode 100644 index 6c24cac90e..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java +++ /dev/null @@ -1,167 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.brokerage; - -import cn.hutool.core.convert.Convert; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.SortingField; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * 分销用户 Mapper - * - * @author owen - */ -@Mapper -public interface BrokerageUserMapper extends BaseMapperX { - - default PageResult selectPage(BrokerageUserPageReqVO reqVO, List ids) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .inIfPresent(BrokerageUserDO::getId, ids) - .eqIfPresent(BrokerageUserDO::getBrokerageEnabled, reqVO.getBrokerageEnabled()) - .betweenIfPresent(BrokerageUserDO::getCreateTime, reqVO.getCreateTime()) - .betweenIfPresent(BrokerageUserDO::getBindUserTime, reqVO.getBindUserTime()) - .orderByDesc(BrokerageUserDO::getId)); - } - - /** - * 更新用户可用佣金(增加) - * - * @param id 用户编号 - * @param incrCount 增加佣金(正数) - */ - default void updatePriceIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" brokerage_price = brokerage_price + " + incrCount) - .eq(BrokerageUserDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户可用佣金(减少) - * 注意:理论上佣金可能已经提现,这时会扣出负数,确保平台不会造成损失 - * - * @param id 用户编号 - * @param incrCount 增加佣金(负数) - * @return 更新行数 - */ - default int updatePriceDecr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" brokerage_price = brokerage_price + " + incrCount) // 负数,所以使用 + 号 - .eq(BrokerageUserDO::getId, id); - return update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户冻结佣金(增加) - * - * @param id 用户编号 - * @param incrCount 增加冻结佣金(正数) - */ - default void updateFrozenPriceIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" frozen_price = frozen_price + " + incrCount) - .eq(BrokerageUserDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户冻结佣金(减少) - * 注意:理论上冻结佣金可能已经解冻,这时会扣出负数,确保平台不会造成损失 - * - * @param id 用户编号 - * @param incrCount 减少冻结佣金(负数) - */ - default void updateFrozenPriceDecr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" frozen_price = frozen_price + " + incrCount) // 负数,所以使用 + 号 - .eq(BrokerageUserDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户冻结佣金(减少), 更新用户佣金(增加) - * - * @param id 用户编号 - * @param incrCount 减少冻结佣金(负数) - * @return 更新条数 - */ - default int updateFrozenPriceDecrAndPriceIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" frozen_price = frozen_price + " + incrCount + // 负数,所以使用 + 号 - ", brokerage_price = brokerage_price + " + -incrCount) // 负数,所以使用 - 号 - .eq(BrokerageUserDO::getId, id) - .ge(BrokerageUserDO::getFrozenPrice, -incrCount); // cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - default void updateBindUserIdAndBindUserTimeToNull(Long id) { - update(null, new LambdaUpdateWrapper() - .eq(BrokerageUserDO::getId, id) - .set(BrokerageUserDO::getBindUserId, null).set(BrokerageUserDO::getBindUserTime, null)); - } - - default void updateEnabledFalseAndBrokerageTimeToNull(Long id) { - update(null, new LambdaUpdateWrapper() - .eq(BrokerageUserDO::getId, id) - .set(BrokerageUserDO::getBrokerageEnabled, false).set(BrokerageUserDO::getBrokerageTime, null)); - } - - @Select("SELECT bind_user_id AS id, COUNT(1) AS brokerageUserCount FROM trade_brokerage_user " + - "WHERE bind_user_id IS NOT NULL AND deleted = FALSE " + - "AND bind_user_time BETWEEN #{beginTime} AND #{endTime} " + - "GROUP BY bind_user_id " + - "ORDER BY brokerageUserCount DESC") - IPage selectCountPageGroupByBindUserId(Page page, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - /** - * 下级分销统计(分页) - * - * @param bizType 业务类型 - * @param status 状态 - * @param ids 用户编号列表 - * @param sortingField 排序字段 - * @return 下级分销统计分页列表 - */ - IPage selectSummaryPageByUserId(Page page, - @Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("ids") Collection ids, - @Param("sortingField") SortingField sortingField); - - /** - * 获得被 bindUserIds 推广的用户编号数组 - * - * @param bindUserIds 推广员编号数组 - * @return 用户编号数组 - */ - default List selectIdListByBindUserIdIn(Collection bindUserIds) { - return Convert.toList(Long.class, - selectObjs(new LambdaQueryWrapperX() - .select(Collections.singletonList(BrokerageUserDO::getId)) // 只查询 id 字段,加速返回速度 - .in(BrokerageUserDO::getBindUserId, bindUserIds))); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java deleted file mode 100644 index 9e2cf68ad1..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.brokerage; - -import cn.hutool.core.bean.BeanUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.github.yulichang.wrapper.MPJLambdaWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 佣金提现 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface BrokerageWithdrawMapper extends BaseMapperX { - - default PageResult selectPage(BrokerageWithdrawPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BrokerageWithdrawDO::getUserId, reqVO.getUserId()) - .eqIfPresent(BrokerageWithdrawDO::getType, reqVO.getType()) - .likeIfPresent(BrokerageWithdrawDO::getName, reqVO.getName()) - .eqIfPresent(BrokerageWithdrawDO::getAccountNo, reqVO.getAccountNo()) - .likeIfPresent(BrokerageWithdrawDO::getBankName, reqVO.getBankName()) - .eqIfPresent(BrokerageWithdrawDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BrokerageWithdrawDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(BrokerageWithdrawDO::getStatus).orderByDesc(BrokerageWithdrawDO::getId)); - } - - default int updateByIdAndStatus(Integer id, Integer status, BrokerageWithdrawDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(BrokerageWithdrawDO::getId, id) - .eq(BrokerageWithdrawDO::getStatus, status)); - } - - default List selectCountAndSumPriceByUserIdAndStatus(Collection userIds, Integer status) { - List> list = selectMaps(new MPJLambdaWrapper() - .select(BrokerageWithdrawDO::getUserId) - .selectCount(BrokerageWithdrawDO::getId, BrokerageWithdrawSummaryRespBO::getCount) - .selectSum(BrokerageWithdrawDO::getPrice) - .in(BrokerageWithdrawDO::getUserId, userIds) - .eq(BrokerageWithdrawDO::getStatus, status) - .groupBy(BrokerageWithdrawDO::getUserId)); - return BeanUtil.copyToList(list, BrokerageWithdrawSummaryRespBO.class); - // selectJoinList有BUG,会与租户插件冲突:解析SQL时,发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW -// return selectJoinList(UserWithdrawSummaryBO.class, new MPJLambdaWrapper() -// .select(BrokerageWithdrawDO::getUserId) -// .selectCount(BrokerageWithdrawDO::getId, UserWithdrawSummaryBO::getCount) -// .selectSum(BrokerageWithdrawDO::getPrice) -// .in(BrokerageWithdrawDO::getUserId, userIds) -// .eq(BrokerageWithdrawDO::getStatus, status) -// .groupBy(BrokerageWithdrawDO::getUserId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/cart/CartMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/cart/CartMapper.java deleted file mode 100644 index b672651567..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/cart/CartMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.cart; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@Mapper -public interface CartMapper extends BaseMapperX { - - default CartDO selectByUserIdAndSkuId(Long userId, Long skuId) { - return selectOne(CartDO::getUserId, userId, - CartDO::getSkuId, skuId); - } - - default Integer selectSumByUserId(Long userId) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(count) AS sumCount") - .eq("user_id", userId) - .eq("selected", true)); // 只计算选中的 - // 获得数量 - return CollUtil.getFirst(result) != null ? MapUtil.getInt(result.get(0), "sumCount") : 0; - } - - default CartDO selectById(Long id, Long userId) { - return selectOne(CartDO::getId, id, - CartDO::getUserId, userId); - } - - default List selectListByIds(Collection ids, Long userId) { - return selectList(new LambdaQueryWrapper() - .in(CartDO::getId, ids) - .eq(CartDO::getUserId, userId)); - } - - default List selectListByUserId(Long userId) { - return selectList(new LambdaQueryWrapper() - .eq(CartDO::getUserId, userId)); - } - - default List selectListByUserId(Long userId, Set ids) { - return selectList(new LambdaQueryWrapper() - .eq(CartDO::getUserId, userId) - .in(CartDO::getId, ids)); - } - - default void updateByIds(Collection ids, Long userId, CartDO updateObj) { - update(updateObj, new LambdaQueryWrapper() - .in(CartDO::getId, ids) - .eq(CartDO::getUserId, userId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java deleted file mode 100644 index 18a3f4df76..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.config; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 交易中心配置 Mapper - * - * @author owen - */ -@Mapper -public interface TradeConfigMapper extends BaseMapperX { - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java deleted file mode 100644 index 59e7cf02ef..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface DeliveryExpressMapper extends BaseMapperX { - - default PageResult selectPage(DeliveryExpressPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DeliveryExpressDO::getCode, reqVO.getCode()) - .likeIfPresent(DeliveryExpressDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryExpressDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DeliveryExpressDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(DeliveryExpressDO::getSort)); - } - - default List selectList(DeliveryExpressExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(DeliveryExpressDO::getCode, reqVO.getCode()) - .likeIfPresent(DeliveryExpressDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryExpressDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DeliveryExpressDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(DeliveryExpressDO::getSort)); - } - - default DeliveryExpressDO selectByCode(String code) { - return selectOne(new LambdaQueryWrapper() - .eq(DeliveryExpressDO::getCode, code)); - } - - default List selectListByStatus(Integer status) { - return selectList(DeliveryExpressDO::getStatus, status); - } - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java deleted file mode 100644 index a2403f0190..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface DeliveryExpressTemplateChargeMapper extends BaseMapperX { - - default List selectListByTemplateId(Long templateId){ - return selectList(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateChargeDO::getTemplateId, templateId)); - } - - default int deleteByTemplateId(Long templateId){ - return delete(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateChargeDO::getTemplateId, templateId)); - } - - default List selectByTemplateIds(Collection templateIds) { - return selectList(DeliveryExpressTemplateChargeDO::getTemplateId, templateIds); - } - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java deleted file mode 100644 index b64a3c9795..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface DeliveryExpressTemplateFreeMapper extends BaseMapperX { - - default List selectListByTemplateId(Long templateId) { - return selectList(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateFreeDO::getTemplateId, templateId)); - } - - default int deleteByTemplateId(Long templateId) { - return delete(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateFreeDO::getTemplateId, templateId)); - } - - default List selectListByTemplateIds(Collection templateIds) { - return selectList(DeliveryExpressTemplateFreeDO::getTemplateId, templateIds); - } -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java deleted file mode 100644 index c933468940..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplatePageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface DeliveryExpressTemplateMapper extends BaseMapperX { - - default PageResult selectPage(DeliveryExpressTemplatePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DeliveryExpressTemplateDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryExpressTemplateDO::getChargeMode, reqVO.getChargeMode()) - .betweenIfPresent(DeliveryExpressTemplateDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(DeliveryExpressTemplateDO::getSort)); - } - - default DeliveryExpressTemplateDO selectByName(String name) { - return selectOne(DeliveryExpressTemplateDO::getName,name); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java deleted file mode 100644 index b26b1c0159..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface DeliveryPickUpStoreMapper extends BaseMapperX { - - default PageResult selectPage(DeliveryPickUpStorePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DeliveryPickUpStoreDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryPickUpStoreDO::getPhone, reqVO.getPhone()) - .eqIfPresent(DeliveryPickUpStoreDO::getAreaId, reqVO.getAreaId()) - .eqIfPresent(DeliveryPickUpStoreDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DeliveryPickUpStoreDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(DeliveryPickUpStoreDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(DeliveryPickUpStoreDO::getStatus, status); - } - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java deleted file mode 100644 index 06cc14e268..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface DeliveryPickUpStoreStaffMapper extends BaseMapperX { - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java deleted file mode 100644 index b701b7f878..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@Mapper -public interface TradeOrderItemMapper extends BaseMapperX { - - default int updateAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus, - Long afterSaleId) { - return update(new TradeOrderItemDO().setAfterSaleStatus(newAfterSaleStatus).setAfterSaleId(afterSaleId), - new LambdaUpdateWrapper<>(new TradeOrderItemDO().setId(id).setAfterSaleStatus(oldAfterSaleStatus))); - } - - default List selectListByOrderId(Long orderId) { - return selectList(TradeOrderItemDO::getOrderId, orderId); - } - - default List selectListByOrderId(Collection orderIds) { - return selectList(TradeOrderItemDO::getOrderId, orderIds); - } - - default TradeOrderItemDO selectByIdAndUserId(Long orderItemId, Long loginUserId) { - return selectOne(new LambdaQueryWrapperX() - .eq(TradeOrderItemDO::getId, orderItemId) - .eq(TradeOrderItemDO::getUserId, loginUserId)); - } - - default List selectListByOrderIdAndCommentStatus(Long orderId, Boolean commentStatus) { - return selectList(new LambdaQueryWrapperX() - .eq(TradeOrderItemDO::getOrderId, orderId) - .eq(TradeOrderItemDO::getCommentStatus, commentStatus)); - } - - default int selectProductSumByOrderId(@Param("orderIds") Set orderIds) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(count) AS sumCount") - .in("order_id", orderIds)); // 只计算选中的 - // 获得数量 - return CollUtil.getFirst(result) != null ? MapUtil.getInt(result.get(0), "sumCount") : 0; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderLogMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderLogMapper.java deleted file mode 100644 index 7788030ffc..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderLogMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.order; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface TradeOrderLogMapper extends BaseMapperX { - - default List selectListByOrderId(Long orderId) { - return selectList(TradeOrderLogDO::getOrderId, orderId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java deleted file mode 100644 index 21fc038ba4..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@Mapper -public interface TradeOrderMapper extends BaseMapperX { - - default int updateByIdAndStatus(Long id, Integer status, TradeOrderDO update) { - return update(update, new LambdaUpdateWrapper() - .eq(TradeOrderDO::getId, id).eq(TradeOrderDO::getStatus, status)); - } - - default TradeOrderDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(TradeOrderDO::getId, id, TradeOrderDO::getUserId, userId); - } - - default PageResult selectPage(TradeOrderPageReqVO reqVO, Set userIds) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(TradeOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(TradeOrderDO::getUserId, reqVO.getUserId()) - .eqIfPresent(TradeOrderDO::getDeliveryType, reqVO.getDeliveryType()) - .inIfPresent(TradeOrderDO::getUserId, userIds) - .eqIfPresent(TradeOrderDO::getType, reqVO.getType()) - .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TradeOrderDO::getPayChannelCode, reqVO.getPayChannelCode()) - .eqIfPresent(TradeOrderDO::getTerminal, reqVO.getTerminal()) - .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId()) - .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds()) - .likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode()) - .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(TradeOrderDO::getId)); - } - - // TODO @疯狂:如果用 map 返回,要不这里直接用 TradeOrderSummaryRespVO 返回?也算合理,就当 sql 查询出这么个玩意~~ - default List> selectOrderSummaryGroupByRefundStatus(TradeOrderPageReqVO reqVO, Set userIds) { - return selectMaps(new MPJLambdaWrapperX() - .selectAs(TradeOrderDO::getRefundStatus, TradeOrderDO::getRefundStatus) // 售后状态 - .selectCount(TradeOrderDO::getId, "count") // 售后状态对应的数量 - .selectSum(TradeOrderDO::getPayPrice, "price") // 售后状态对应的支付金额 - .likeIfPresent(TradeOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(TradeOrderDO::getUserId, reqVO.getUserId()) - .eqIfPresent(TradeOrderDO::getDeliveryType, reqVO.getDeliveryType()) - .inIfPresent(TradeOrderDO::getUserId, userIds) - .eqIfPresent(TradeOrderDO::getType, reqVO.getType()) - .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TradeOrderDO::getPayChannelCode, reqVO.getPayChannelCode()) - .eqIfPresent(TradeOrderDO::getTerminal, reqVO.getTerminal()) - .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId()) - .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds()) - .likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode()) - .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime()) - .groupBy(TradeOrderDO::getRefundStatus)); // 按售后状态分组 - } - - default PageResult selectPage(AppTradeOrderPageReqVO reqVO, Long userId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(TradeOrderDO::getUserId, userId) - .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TradeOrderDO::getCommentStatus, reqVO.getCommentStatus()) - .orderByDesc(TradeOrderDO::getId)); // TODO 芋艿:未来不同的 status,不同的排序 - } - - default Long selectCountByUserIdAndStatus(Long userId, Integer status, Boolean commentStatus) { - return selectCount(new LambdaQueryWrapperX() - .eq(TradeOrderDO::getUserId, userId) - .eqIfPresent(TradeOrderDO::getStatus, status) - .eqIfPresent(TradeOrderDO::getCommentStatus, commentStatus)); - } - - default TradeOrderDO selectOrderByIdAndUserId(Long orderId, Long loginUserId) { - return selectOne(new LambdaQueryWrapperX() - .eq(TradeOrderDO::getId, orderId) - .eq(TradeOrderDO::getUserId, loginUserId)); - } - - default List selectListByStatusAndCreateTimeLt(Integer status, LocalDateTime createTime) { - return selectList(new LambdaUpdateWrapper() - .eq(TradeOrderDO::getStatus, status) - .lt(TradeOrderDO::getCreateTime, createTime)); - } - - default List selectListByStatusAndDeliveryTimeLt(Integer status, LocalDateTime deliveryTime) { - return selectList(new LambdaUpdateWrapper() - .eq(TradeOrderDO::getStatus, status) - .lt(TradeOrderDO::getDeliveryTime, deliveryTime)); - } - - default List selectListByStatusAndReceiveTimeLt(Integer status, LocalDateTime receive, - Boolean commentStatus) { - return selectList(new LambdaUpdateWrapper() - .eq(TradeOrderDO::getStatus, status) - .lt(TradeOrderDO::getReceiveTime, receive) - .eq(TradeOrderDO::getCommentStatus, commentStatus)); - } - - default List selectListByUserIdAndSeckillActivityId(Long userId, Long seckillActivityId) { - return selectList(new LambdaUpdateWrapper<>(TradeOrderDO.class) - .eq(TradeOrderDO::getUserId, userId) - .eq(TradeOrderDO::getSeckillActivityId, seckillActivityId)); - } - - default TradeOrderDO selectOneByPickUpVerifyCode(String pickUpVerifyCode) { - return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); - } - - default TradeOrderDO selectByUserIdAndCombinationActivityIdAndStatus(Long userId, Long combinationActivityId, Integer status) { - return selectOne(new LambdaQueryWrapperX() - .eq(TradeOrderDO::getUserId, userId) - .eq(TradeOrderDO::getStatus, status) - .eq(TradeOrderDO::getCombinationActivityId, combinationActivityId) - ); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/package-info.java deleted file mode 100644 index 37e0ba7d60..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位 - */ -package cn.iocoder.yudao.module.trade.dal.mysql; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/RedisKeyConstants.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/RedisKeyConstants.java deleted file mode 100644 index eff48e51c9..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/RedisKeyConstants.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.redis; - -/** - * 交易 Redis Key 枚举类 - * - * @author 芋道源码 - */ -public interface RedisKeyConstants { - - /** - * 交易序号的缓存 - * - * KEY 格式:trade_no:{prefix} - * VALUE 数据格式:编号自增 - */ - String TRADE_NO = "trade_no:"; - - /** - * 交易序号的缓存 - * - * KEY 格式:express_track:{code-logisticsNo-receiverMobile} - * VALUE 数据格式 String, 物流信息集合 - */ - String EXPRESS_TRACK = "express_track"; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/no/TradeNoRedisDAO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/no/TradeNoRedisDAO.java deleted file mode 100644 index 655f51d192..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/no/TradeNoRedisDAO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.redis.no; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.trade.dal.redis.RedisKeyConstants; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Repository; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; - -/** - * 订单序号的 Redis DAO - * - * @author HUIHUI - */ -@Repository -public class TradeNoRedisDAO { - - public static final String TRADE_ORDER_NO_PREFIX = "o"; - - public static final String AFTER_SALE_NO_PREFIX = "r"; - - @Resource - private StringRedisTemplate stringRedisTemplate; - - /** - * 生成序号 - * - * @param prefix 前缀 - * @return 序号 - */ - public String generate(String prefix) { - // 递增序号 - String noPrefix = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN); - String key = RedisKeyConstants.TRADE_NO + noPrefix; - Long no = stringRedisTemplate.opsForValue().increment(key); - // 设置过期时间 - stringRedisTemplate.expire(key, Duration.ofMinutes(1L)); - return noPrefix + no; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/config/AfterSaleLogConfiguration.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/config/AfterSaleLogConfiguration.java deleted file mode 100644 index 1c26137892..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/config/AfterSaleLogConfiguration.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.aftersale.config; - -import cn.iocoder.yudao.module.trade.framework.aftersale.core.aop.AfterSaleLogAspect; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -// TODO @chenchen:改成 aftersale 好点哈; -/** - * trade 模块的 afterSaleLog 组件的 Configuration - * - * @author 陈賝 - * @since 2023/6/18 11:09 - */ -@Configuration(proxyBeanMethods = false) -public class AfterSaleLogConfiguration { - - @Bean - public AfterSaleLogAspect afterSaleLogAspect() { - return new AfterSaleLogAspect(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/annotations/AfterSaleLog.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/annotations/AfterSaleLog.java deleted file mode 100644 index bc41bf9867..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/annotations/AfterSaleLog.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.aftersale.core.annotations; - -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; -import cn.iocoder.yudao.module.trade.framework.aftersale.core.aop.AfterSaleLogAspect; - -import java.lang.annotation.*; - -/** - * 售后日志的注解 - * - * 写在方法上时,会自动记录售后日志 - * - * @author 陈賝 - * @since 2023/6/8 17:04 - * @see AfterSaleLogAspect - */ -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface AfterSaleLog { - - /** - * 操作类型 - */ - AfterSaleOperateTypeEnum operateType(); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/aop/AfterSaleLogAspect.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/aop/AfterSaleLogAspect.java deleted file mode 100644 index d0d60e2c12..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/aop/AfterSaleLogAspect.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.aftersale.core.aop; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.framework.aftersale.core.annotations.AfterSaleLog; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleLogService; -import cn.iocoder.yudao.module.trade.service.aftersale.bo.AfterSaleLogCreateReqBO; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.Aspect; - -import jakarta.annotation.Resource; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static java.util.Collections.emptyMap; - -/** - * 售后订单的操作记录的 AOP 切面 - * - * @author 陈賝 - * @since 2023/6/13 13:54 - */ -@Slf4j -@Aspect -public class AfterSaleLogAspect { - - /** - * 用户编号 - * - * 目前的使用场景:支付回调时,需要强制设置下用户编号 - */ - private static final ThreadLocal USER_ID = new ThreadLocal<>(); - /** - * 用户类型 - */ - private static final ThreadLocal USER_TYPE = new ThreadLocal<>(); - /** - * 订单编号 - */ - private static final ThreadLocal AFTER_SALE_ID = new ThreadLocal<>(); - /** - * 操作前的状态 - */ - private static final ThreadLocal BEFORE_STATUS = new ThreadLocal<>(); - /** - * 操作后的状态 - */ - private static final ThreadLocal AFTER_STATUS = new ThreadLocal<>(); - /** - * 拓展参数 Map,用于格式化操作内容 - */ - private static final ThreadLocal> EXTS = new ThreadLocal<>(); - - @Resource - private AfterSaleLogService afterSaleLogService; - - @AfterReturning(pointcut = "@annotation(afterSaleLog)") - public void doAfterReturning(JoinPoint joinPoint, AfterSaleLog afterSaleLog) { - try { - // 1.1 操作用户 - Integer userType = getUserType(); - Long userId = getUserId(); - // 1.2 售后信息 - Long afterSaleId = AFTER_SALE_ID.get(); - if (afterSaleId == null) { // 如果未设置,只有注解,说明不需要记录日志 - return; - } - Integer beforeStatus = BEFORE_STATUS.get(); - Integer afterStatus = AFTER_STATUS.get(); - Map exts = ObjectUtil.defaultIfNull(EXTS.get(), emptyMap()); - String content = StrUtil.format(afterSaleLog.operateType().getContent(), exts); - - // 2. 记录日志 - AfterSaleLogCreateReqBO createBO = new AfterSaleLogCreateReqBO() - .setUserId(userId).setUserType(userType) - .setAfterSaleId(afterSaleId).setBeforeStatus(beforeStatus).setAfterStatus(afterStatus) - .setOperateType(afterSaleLog.operateType().getType()).setContent(content); - afterSaleLogService.createAfterSaleLog(createBO); - } catch (Exception exception) { - log.error("[doAfterReturning][afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception); - } finally { - clear(); - } - } - - /** - * 获得用户类型 - * - * 如果没有,则约定为 {@link TradeOrderLogDO#getUserType()} 系统 - * - * @return 用户类型 - */ - private static Integer getUserType() { - return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserType(), TradeOrderLogDO.USER_TYPE_SYSTEM); - } - - /** - * 获得用户编号 - * - * 如果没有,则约定为 {@link TradeOrderLogDO#getUserId()} 系统 - * - * @return 用户类型 - */ - private static Long getUserId() { - return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserId(), TradeOrderLogDO.USER_ID_SYSTEM); - } - - public static void setAfterSale(Long id, Integer beforeStatus, Integer afterStatus, Map exts) { - AFTER_SALE_ID.set(id); - BEFORE_STATUS.set(beforeStatus); - AFTER_STATUS.set(afterStatus); - EXTS.set(exts); - } - - public static void setUserInfo(Long userId, Integer userType) { - USER_ID.set(userId); - USER_TYPE.set(userType); - } - - private static void clear() { - USER_ID.remove(); - USER_TYPE.remove(); - AFTER_SALE_ID.remove(); - BEFORE_STATUS.remove(); - AFTER_STATUS.remove(); - EXTS.remove(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/utils/AfterSaleLogUtils.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/utils/AfterSaleLogUtils.java deleted file mode 100644 index 3f9fc5d74b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/utils/AfterSaleLogUtils.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.aftersale.core.utils; - - -import cn.iocoder.yudao.module.trade.framework.aftersale.core.aop.AfterSaleLogAspect; - -import java.util.Map; - -/** - * 操作日志工具类 - * 目前主要的作用,是提供给业务代码,记录操作明细和拓展字段 - * - * @author 芋道源码 - */ -public class AfterSaleLogUtils { - - public static void setAfterSaleInfo(Long id, Integer beforeStatus, Integer afterStatus) { - setAfterSaleInfo(id, beforeStatus, afterStatus, null); - } - - public static void setAfterSaleInfo(Long id, Integer beforeStatus, Integer afterStatus, - Map exts) { - AfterSaleLogAspect.setAfterSale(id, beforeStatus, afterStatus, exts); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java deleted file mode 100644 index 2799c3f1ca..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.config; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClientFactory; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.ExpressClientFactoryImpl; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.client.RestTemplate; - -/** - * 快递客户端端配置类: - * - * 1. 快递客户端工厂 {@link ExpressClientFactory} - * 2. 默认的快递客户端实现 {@link ExpressClient} - * - * @author jason - */ -@Configuration(proxyBeanMethods = false) -public class ExpressClientConfig { - - @Bean - public ExpressClientFactory expressClientFactory(TradeExpressProperties tradeExpressProperties, - RestTemplate restTemplate) { - return new ExpressClientFactoryImpl(tradeExpressProperties, restTemplate); - } - - @Bean - public ExpressClient defaultExpressClient(ExpressClientFactory expressClientFactory) { - return expressClientFactory.getDefaultExpressClient(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/TradeExpressProperties.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/TradeExpressProperties.java deleted file mode 100644 index 3d836bb176..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/TradeExpressProperties.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.config; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.enums.ExpressClientEnum; -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; -import org.springframework.validation.annotation.Validated; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; - -// TODO @芋艿:未来要不要放数据库中?考虑 saas 多租户时,不同租户使用不同的配置? -/** - * 交易运费快递的配置项 - * - * @author jason - */ -@Component -@ConfigurationProperties(prefix = "yudao.trade.express") -@Data -@Validated -public class TradeExpressProperties { - - /** - * 快递客户端 - * - * 默认不提供,需要提醒用户配置一个快递服务商。 - */ - private ExpressClientEnum client = ExpressClientEnum.NOT_PROVIDE; - - /** - * 快递鸟配置 - */ - @Valid - private KdNiaoConfig kdNiao; - /** - * 快递 100 配置 - */ - @Valid - private Kd100Config kd100; - - /** - * 快递鸟配置项目 - */ - @Data - public static class KdNiaoConfig { - - /** - * 快递鸟用户 ID - */ - @NotEmpty(message = "快递鸟用户 ID 配置项不能为空") - private String businessId; - /** - * 快递鸟 API Key - */ - @NotEmpty(message = "快递鸟 Api Key 配置项不能为空") - private String apiKey; - - } - - /** - * 快递 100 配置项 - */ - @Data - public static class Kd100Config { - - /** - * 快递 100 授权码 - */ - @NotEmpty(message = "快递 100 授权码配置项不能为空") - private String customer; - /** - * 快递 100 授权 key - */ - @NotEmpty(message = "快递 100 授权 Key 配置项不能为空") - private String key; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClient.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClient.java deleted file mode 100644 index 76b361c3f4..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClient.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; - -import java.util.List; - -/** - * 快递客户端接口 - * - * @author jason - */ -public interface ExpressClient { - - /** - * 快递实时查询 - * - * @param reqDTO 查询请求参数 - */ - // TODO @jason:返回字段可以参考 https://doc.youzanyun.com/detail/API/0/5 响应的 data - List getExpressTrackList(ExpressTrackQueryReqDTO reqDTO); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClientFactory.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClientFactory.java deleted file mode 100644 index 5e457092fc..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClientFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.enums.ExpressClientEnum; - -/** - * 快递客户端工厂接口:用于创建和缓存快递客户端 - * - * @author jason - */ -public interface ExpressClientFactory { - - /** - * 获取默认的快递客户端 - */ - ExpressClient getDefaultExpressClient(); - - /** - * 通过枚举获取快递客户端,如果不存在,就创建一个对应快递客户端 - * - * @param clientEnum 快递客户端枚举 - */ - ExpressClient getOrCreateExpressClient(ExpressClientEnum clientEnum); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/convert/ExpressQueryConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/convert/ExpressQueryConvert.java deleted file mode 100644 index b68e119c5f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/convert/ExpressQueryConvert.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.convert; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao.KdNiaoExpressQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao.KdNiaoExpressQueryRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface ExpressQueryConvert { - - ExpressQueryConvert INSTANCE = Mappers.getMapper(ExpressQueryConvert.class); - - List convertList(List list); - @Mapping(source = "acceptTime", target = "time") - @Mapping(source = "acceptStation", target = "content") - ExpressTrackRespDTO convert(KdNiaoExpressQueryRespDTO.ExpressTrack track); - - List convertList2(List list); - @Mapping(source = "context", target = "content") - ExpressTrackRespDTO convert(Kd100ExpressQueryRespDTO.ExpressTrack track); - - KdNiaoExpressQueryReqDTO convert(ExpressTrackQueryReqDTO dto); - - Kd100ExpressQueryReqDTO convert2(ExpressTrackQueryReqDTO dto); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java deleted file mode 100644 index 34ad0128d7..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto; - -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import lombok.Data; - -/** - * 快递轨迹的查询 Req DTO - * - * @author jason - */ -@Data -public class ExpressTrackQueryReqDTO { - - /** - * 快递公司编码 - * - * 对应 {@link DeliveryExpressDO#getCode()} - */ - private String expressCode; - - /** - * 发货快递单号 - */ - private String logisticsNo; - - /** - * 收、寄件人的电话号码 - */ - private String phone; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackRespDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackRespDTO.java deleted file mode 100644 index bc99e1cba4..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackRespDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto; - -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 快递查询的轨迹 Resp DTO - * - * @author jason - */ -@Data -public class ExpressTrackRespDTO { - - /** - * 发生时间 - */ - private LocalDateTime time; - - /** - * 快递状态 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryReqDTO.java deleted file mode 100644 index 7befc84f76..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryReqDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - * 快递 100 快递查询 Req DTO - * - * @author jason - */ -@Data -@JsonInclude(JsonInclude.Include.NON_NULL) -public class Kd100ExpressQueryReqDTO { - - /** - * 快递公司编码 - */ - @JsonProperty("com") - private String expressCode; - - /** - * 快递单号 - */ - @JsonProperty("num") - private String logisticsNo; - - /** - * 收、寄件人的电话号码 - */ - private String phone; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryRespDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryRespDTO.java deleted file mode 100644 index 9d33cac21b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryRespDTO.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** - * 快递 100 实时快递查询 Resp DTO - * - * 参见 快递 100 文档 - * - * @author jason - */ -@Data -public class Kd100ExpressQueryRespDTO { - - /** - * 快递公司编码 - */ - @JsonProperty("com") - private String expressCompanyCode; - /** - * 快递单号 - */ - @JsonProperty("nu") - private String logisticsNo; - /** - * 快递单当前状态 - */ - private String state; - - /** - * 查询结果 - * - * 失败返回 "false" - */ - private String result; - /** - * 查询结果失败时的错误信息 - */ - private String message; - - /** - * 轨迹数组 - */ - @JsonProperty("data") - private List tracks; - - @Data - public static class ExpressTrack { - - /** - * 轨迹发生时间 - */ - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime time; - - /** - * 轨迹描述 - */ - private String context; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryReqDTO.java deleted file mode 100644 index bcb6e33534..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryReqDTO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - * 快递鸟快递查询 Req DTO - * - * @author jason - */ -@Data -@JsonInclude(JsonInclude.Include.NON_NULL) -public class KdNiaoExpressQueryReqDTO { - - /** - * 快递公司编码 - */ - @JsonProperty("ShipperCode") - private String expressCode; - /** - * 快递单号 - */ - @JsonProperty("LogisticCode") - private String logisticsNo; - /** - * 订单编号 - */ - @JsonProperty("OrderCode") - private String orderNo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryRespDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryRespDTO.java deleted file mode 100644 index 04a7c1431e..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryRespDTO.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** - * 快递鸟快递查询 Resp DTO - * - * 参见 快递鸟接口文档 - * - * @author jason - */ -@Data -public class KdNiaoExpressQueryRespDTO { - - /** - * 快递公司编码 - */ - @JsonProperty("ShipperCode") - private String shipperCode; - - /** - * 快递单号 - */ - @JsonProperty("LogisticCode") - private String logisticsNo; - - /** - * 订单编号 - */ - @JsonProperty("OrderCode") - private String orderNo; - - /** - * 用户 ID - */ - @JsonProperty("EBusinessID") - private String businessId; - - /** - * 普通物流状态 - * - * 0 - 暂无轨迹信息 - * 1 - 已揽收 - * 2 - 在途中 - * 3 - 签收 - * 4 - 问题件 - * 5 - 转寄 - * 6 - 清关 - */ - @JsonProperty("State") - private String state; - - /** - * 成功与否 - */ - @JsonProperty("Success") - private Boolean success; - /** - * 失败原因 - */ - @JsonProperty("Reason") - private String reason; - - /** - * 轨迹数组 - */ - @JsonProperty("Traces") - private List tracks; - - @Data - public static class ExpressTrack { - - /** - * 发生时间 - */ - @JsonProperty("AcceptTime") - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - @JsonDeserialize(using = LocalDateTimeDeserializer.class) - private LocalDateTime acceptTime; - - /** - * 轨迹描述 - */ - @JsonProperty("AcceptStation") - private String acceptStation; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java deleted file mode 100644 index d4432b264f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kd100.Kd100ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kdniao.KdNiaoExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.enums.ExpressClientEnum; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClientFactory; -import lombok.AllArgsConstructor; -import org.springframework.web.client.RestTemplate; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * 快递客户端工厂实现类 - * - * @author jason - */ -@AllArgsConstructor -public class ExpressClientFactoryImpl implements ExpressClientFactory { - - private final Map clientMap = new ConcurrentHashMap<>(8); - - private final TradeExpressProperties tradeExpressProperties; - private final RestTemplate restTemplate; - - @Override - public ExpressClient getDefaultExpressClient() { - ExpressClient defaultClient = getOrCreateExpressClient(tradeExpressProperties.getClient()); - Assert.notNull("默认的快递客户端不能为空"); - return defaultClient; - } - - @Override - public ExpressClient getOrCreateExpressClient(ExpressClientEnum clientEnum) { - return clientMap.computeIfAbsent(clientEnum, - client -> createExpressClient(client, tradeExpressProperties)); - } - - private ExpressClient createExpressClient(ExpressClientEnum queryProviderEnum, - TradeExpressProperties tradeExpressProperties) { - switch (queryProviderEnum) { - case NOT_PROVIDE: - return new NoProvideExpressClient(); - case KD_NIAO: - return new KdNiaoExpressClient(restTemplate, tradeExpressProperties.getKdNiao()); - case KD_100: - return new Kd100ExpressClient(restTemplate, tradeExpressProperties.getKd100()); - } - return null; - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/NoProvideExpressClient.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/NoProvideExpressClient.java deleted file mode 100644 index 7289710f6d..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/NoProvideExpressClient.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; - -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_CLIENT_NOT_PROVIDE; - -/** - * 未实现的快递客户端,用来提醒用户需要接入快递服务商, - * - * @author jason - */ -public class NoProvideExpressClient implements ExpressClient { - - @Override - public List getExpressTrackList(ExpressTrackQueryReqDTO reqDTO) { - throw exception(EXPRESS_CLIENT_NOT_PROVIDE); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kd100/Kd100ExpressClient.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kd100/Kd100ExpressClient.java deleted file mode 100644 index f04abde70e..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kd100/Kd100ExpressClient.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kd100; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.HexUtil; -import cn.hutool.crypto.digest.DigestUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryRespDTO; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.*; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_API_QUERY_ERROR; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_API_QUERY_FAILED; -import static cn.iocoder.yudao.module.trade.framework.delivery.core.client.convert.ExpressQueryConvert.INSTANCE; - -/** - * 快递 100 客户端 - * - * @author jason - */ -@Slf4j -@AllArgsConstructor -public class Kd100ExpressClient implements ExpressClient { - - private static final String REAL_TIME_QUERY_URL = "https://poll.kuaidi100.com/poll/query.do"; - - private final RestTemplate restTemplate; - private final TradeExpressProperties.Kd100Config config; - - /** - * 查询快递轨迹 - * - * @see 接口文档 - * - * @param reqDTO 查询请求参数 - * @return 快递轨迹 - */ - @Override - public List getExpressTrackList(ExpressTrackQueryReqDTO reqDTO) { - // 发起请求 - Kd100ExpressQueryReqDTO requestDTO = INSTANCE.convert2(reqDTO) - .setExpressCode(reqDTO.getExpressCode().toLowerCase()); - Kd100ExpressQueryRespDTO respDTO = httpRequest(REAL_TIME_QUERY_URL, requestDTO, - Kd100ExpressQueryRespDTO.class); - - // 处理结果 - if (Objects.equals("false", respDTO.getResult())) { - throw exception(EXPRESS_API_QUERY_FAILED, respDTO.getMessage()); - } - if (CollUtil.isEmpty(respDTO.getTracks())) { - return Collections.emptyList(); - } - return INSTANCE.convertList2(respDTO.getTracks()); - } - - /** - * 快递 100 API 请求 - * - * @param url 请求 url - * @param req 对应请求的请求参数 - * @param respClass 对应请求的响应 class - * @param 每个请求的请求结构 Req DTO - * @param 每个请求的响应结构 Resp DTO - */ - private Resp httpRequest(String url, Req req, Class respClass) { - // 请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - // 请求体 - String param = JsonUtils.toJsonString(req); - String sign = generateReqSign(param, config.getKey(), config.getCustomer()); // 签名 - MultiValueMap requestBody = new LinkedMultiValueMap<>(); - requestBody.add("customer", config.getCustomer()); - requestBody.add("sign", sign); - requestBody.add("param", param); - log.debug("[httpRequest][请求参数({})]", requestBody); - - // 发送请求 - HttpEntity> requestEntity = new HttpEntity<>(requestBody, headers); - ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); - log.debug("[httpRequest][的响应结果({})]", responseEntity); - // 处理响应 - if (!responseEntity.getStatusCode().is2xxSuccessful()) { - throw exception(EXPRESS_API_QUERY_ERROR); - } - return JsonUtils.parseObject(responseEntity.getBody(), respClass); - } - - private String generateReqSign(String param, String key, String customer) { - String plainText = String.format("%s%s%s", param, key, customer); - return HexUtil.encodeHexStr(DigestUtil.md5(plainText), false); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kdniao/KdNiaoExpressClient.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kdniao/KdNiaoExpressClient.java deleted file mode 100644 index 1f1116882f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kdniao/KdNiaoExpressClient.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kdniao; - -import cn.hutool.core.codec.Base64; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.net.URLEncodeUtil; -import cn.hutool.crypto.digest.DigestUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao.KdNiaoExpressQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao.KdNiaoExpressQueryRespDTO; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.*; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_API_QUERY_FAILED; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_API_QUERY_ERROR; -import static cn.iocoder.yudao.module.trade.framework.delivery.core.client.convert.ExpressQueryConvert.INSTANCE; - -/** - * 快递鸟客户端 - * - * @author jason - */ -@Slf4j -@AllArgsConstructor -public class KdNiaoExpressClient implements ExpressClient { - - private static final String REAL_TIME_QUERY_URL = "https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx"; - - /** - * 快递鸟即时查询免费版 RequestType - */ - private static final String REAL_TIME_FREE_REQ_TYPE = "1002"; - - private final RestTemplate restTemplate; - private final TradeExpressProperties.KdNiaoConfig config; - - /** - * 查询快递轨迹【免费版】 - * - * 仅支持 3 家:申通快递、圆通速递、百世快递 - * - * @see 接口文档 - * - * @param reqDTO 查询请求参数 - * @return 快递轨迹 - */ - @Override - public List getExpressTrackList(ExpressTrackQueryReqDTO reqDTO) { - // 发起请求 - KdNiaoExpressQueryReqDTO requestDTO = INSTANCE.convert(reqDTO) - .setExpressCode(reqDTO.getExpressCode().toUpperCase()); - KdNiaoExpressQueryRespDTO respDTO = httpRequest(REAL_TIME_QUERY_URL, REAL_TIME_FREE_REQ_TYPE, - requestDTO, KdNiaoExpressQueryRespDTO.class); - - // 处理结果 - if (respDTO == null || !respDTO.getSuccess()) { - throw exception(EXPRESS_API_QUERY_FAILED, respDTO == null ? "" : respDTO.getReason()); - } - if (CollUtil.isEmpty(respDTO.getTracks())) { - return Collections.emptyList(); - } - return INSTANCE.convertList(respDTO.getTracks()); - } - - /** - * 快递鸟 API 请求 - * - * @param url 请求 url - * @param requestType 对应的请求指令 (快递鸟的 RequestType) - * @param req 对应请求的请求参数 - * @param respClass 对应请求的响应 class - * @param 每个请求的请求结构 Req DTO - * @param 每个请求的响应结构 Resp DTO - */ - private Resp httpRequest(String url, String requestType, Req req, Class respClass) { - // 请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - // 请求体 - String reqData = JsonUtils.toJsonString(req); - String dataSign = generateDataSign(reqData, config.getApiKey()); - MultiValueMap requestBody = new LinkedMultiValueMap<>(); - requestBody.add("RequestData", reqData); - requestBody.add("DataType", "2"); - requestBody.add("EBusinessID", config.getBusinessId()); - requestBody.add("DataSign", dataSign); - requestBody.add("RequestType", requestType); - log.debug("[httpRequest][RequestType({}) 的请求参数({})]", requestType, requestBody); - - // 发送请求 - HttpEntity> requestEntity = new HttpEntity<>(requestBody, headers); - ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); - log.debug("[httpRequest][RequestType({}) 的响应结果({})", requestType, responseEntity); - // 处理响应 - if (!responseEntity.getStatusCode().is2xxSuccessful()) { - throw exception(EXPRESS_API_QUERY_ERROR); - } - return JsonUtils.parseObject(responseEntity.getBody(), respClass); - } - - /** - * 快递鸟生成请求签名 - * - * 参见 签名说明 - * - * @param reqData 请求实体 - * @param apiKey api Key - */ - private String generateDataSign(String reqData, String apiKey) { - String plainText = String.format("%s%s", reqData, apiKey); - return URLEncodeUtil.encode(Base64.encode(DigestUtil.md5Hex(plainText))); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/enums/ExpressClientEnum.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/enums/ExpressClientEnum.java deleted file mode 100644 index 81b96184c9..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/enums/ExpressClientEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.enums; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 快递客户端枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum ExpressClientEnum { - - NOT_PROVIDE("not-provide","未提供"), - KD_NIAO("kd-niao", "快递鸟"), - KD_100("kd-100", "快递100"); - - /** - * 快递服务商唯一编码 - */ - private final String code; - /** - * 快递服务商名称 - */ - private final String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java deleted file mode 100644 index 715169275f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.config; - -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -// TODO @LeeYan9: 可以直接给 TradeOrderProperties 一个 @Component生效哈 -/** - * @author LeeYan9 - * @since 2022-09-15 - */ -@Configuration -@EnableConfigurationProperties(TradeOrderProperties.class) -public class TradeOrderConfig { -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java deleted file mode 100644 index 1b564b06d7..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -import jakarta.validation.constraints.NotNull; -import java.time.Duration; - -/** - * 交易订单的配置项 - * - * @author LeeYan9 - * @since 2022-09-15 - */ -@ConfigurationProperties(prefix = "yudao.trade.order") -@Data -@Validated -public class TradeOrderProperties { - - /** - * 应用编号 - */ - @NotNull(message = "应用编号不能为空") - private Long appId; - - /** - * 支付超时时间 - */ - @NotNull(message = "支付超时时间不能为空") - private Duration payExpireTime; - - /** - * 收货超时时间 - */ - @NotNull(message = "收货超时时间不能为空") - private Duration receiveExpireTime; - - /** - * 评论超时时间 - */ - @NotNull(message = "评论超时时间不能为空") - private Duration commentExpireTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/annotations/TradeOrderLog.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/annotations/TradeOrderLog.java deleted file mode 100644 index cc023c10d4..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/annotations/TradeOrderLog.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.core.annotations; - -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderOperateTypeEnum; -import cn.iocoder.yudao.module.trade.framework.order.core.aop.TradeOrderLogAspect; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.METHOD; - -/** - * 交易订单的操作日志 AOP 注解 - * - * @author 陈賝 - * @since 2023/7/6 15:37 - * @see TradeOrderLogAspect - */ -@Target({METHOD, ANNOTATION_TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface TradeOrderLog { - - /** - * 操作类型 - */ - TradeOrderOperateTypeEnum operateType(); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/aop/TradeOrderLogAspect.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/aop/TradeOrderLogAspect.java deleted file mode 100644 index 840e9b05b9..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/aop/TradeOrderLogAspect.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.core.aop; - - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.framework.order.core.annotations.TradeOrderLog; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderLogService; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeOrderLogCreateReqBO; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.Aspect; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static java.util.Collections.emptyMap; - -/** - * 交易订单的操作日志的记录 AOP 切面 - * - * @author 陈賝 - * @since 2023/6/13 13:54 - */ -@Component -@Aspect -@Slf4j -public class TradeOrderLogAspect { - - /** - * 用户编号 - * - * 目前的使用场景:支付回调时,需要强制设置下用户编号 - */ - private static final ThreadLocal USER_ID = new ThreadLocal<>(); - /** - * 用户类型 - */ - private static final ThreadLocal USER_TYPE = new ThreadLocal<>(); - /** - * 订单编号 - */ - private static final ThreadLocal ORDER_ID = new ThreadLocal<>(); - /** - * 操作前的状态 - */ - private static final ThreadLocal BEFORE_STATUS = new ThreadLocal<>(); - /** - * 操作后的状态 - */ - private static final ThreadLocal AFTER_STATUS = new ThreadLocal<>(); - /** - * 拓展参数 Map,用于格式化操作内容 - */ - private static final ThreadLocal> EXTS = new ThreadLocal<>(); - - @Resource - private TradeOrderLogService orderLogService; - - @AfterReturning("@annotation(orderLog)") - public void doAfterReturning(JoinPoint joinPoint, TradeOrderLog orderLog) { - try { - // 1.1 操作用户 - Integer userType = getUserType(); - Long userId = getUserId(); - // 1.2 订单信息 - Long orderId = ORDER_ID.get(); - if (orderId == null) { // 如果未设置,只有注解,说明不需要记录日志 - return; - } - Integer beforeStatus = BEFORE_STATUS.get(); - Integer afterStatus = AFTER_STATUS.get(); - Map exts = ObjectUtil.defaultIfNull(EXTS.get(), emptyMap()); - String content = StrUtil.format(orderLog.operateType().getContent(), exts); - - // 2. 记录日志 - TradeOrderLogCreateReqBO createBO = new TradeOrderLogCreateReqBO() - .setUserId(userId).setUserType(userType) - .setOrderId(orderId).setBeforeStatus(beforeStatus).setAfterStatus(afterStatus) - .setOperateType(orderLog.operateType().getType()).setContent(content); - orderLogService.createOrderLog(createBO); - } catch (Exception ex) { - log.error("[doAfterReturning][orderLog({}) 订单日志错误]", toJsonString(orderLog), ex); - } finally { - clear(); - } - } - - /** - * 获得用户类型 - * - * 如果没有,则约定为 {@link TradeOrderLogDO#getUserType()} 系统 - * - * @return 用户类型 - */ - private static Integer getUserType() { - return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserType(), TradeOrderLogDO.USER_TYPE_SYSTEM); - } - - /** - * 获得用户编号 - * - * 如果没有,则约定为 {@link TradeOrderLogDO#getUserId()} 系统 - * - * @return 用户类型 - */ - private static Long getUserId() { - return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserId(), TradeOrderLogDO.USER_ID_SYSTEM); - } - - public static void setOrderInfo(Long id, Integer beforeStatus, Integer afterStatus, Map exts) { - ORDER_ID.set(id); - BEFORE_STATUS.set(beforeStatus); - AFTER_STATUS.set(afterStatus); - EXTS.set(exts); - } - - public static void setUserInfo(Long userId, Integer userType) { - USER_ID.set(userId); - USER_TYPE.set(userType); - } - - private static void clear() { - USER_ID.remove(); - USER_TYPE.remove(); - ORDER_ID.remove(); - BEFORE_STATUS.remove(); - AFTER_STATUS.remove(); - EXTS.remove(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/utils/TradeOrderLogUtils.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/utils/TradeOrderLogUtils.java deleted file mode 100644 index d134b7573e..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/utils/TradeOrderLogUtils.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.core.utils; - -import cn.iocoder.yudao.module.trade.framework.order.core.aop.TradeOrderLogAspect; - -import java.util.Map; - -/** - * 交易订单的操作日志 Utils - * - * @author 芋道源码 - */ -public class TradeOrderLogUtils { - - public static void setOrderInfo(Long id, Integer beforeStatus, Integer afterStatus) { - TradeOrderLogAspect.setOrderInfo(id, beforeStatus, afterStatus, null); - } - - public static void setOrderInfo(Long id, Integer beforeStatus, Integer afterStatus, - Map exts) { - TradeOrderLogAspect.setOrderInfo(id, beforeStatus, afterStatus, exts); - } - - public static void setUserInfo(Long userId, Integer userType) { - TradeOrderLogAspect.setUserInfo(userId, userType); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/package-info.java deleted file mode 100644 index 68c67112f1..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 trade 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.trade.framework; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/web/config/TradeWebConfiguration.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/web/config/TradeWebConfiguration.java deleted file mode 100644 index 837fc5b3a3..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/web/config/TradeWebConfiguration.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.web.config; - -import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration; -import org.springdoc.core.models.GroupedOpenApi; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * trade 模块的 web 组件的 Configuration - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -public class TradeWebConfiguration { - - /** - * trade 模块的 API 分组 - */ - @Bean - public GroupedOpenApi tradeGroupedOpenApi() { - return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("trade"); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/web/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/web/package-info.java deleted file mode 100644 index 2081798515..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/web/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * trade 模块的 web 配置 - */ -package cn.iocoder.yudao.module.trade.framework.web; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/BrokerageRecordUnfreezeJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/BrokerageRecordUnfreezeJob.java deleted file mode 100644 index 7ecf2de55a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/BrokerageRecordUnfreezeJob.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.trade.job.brokerage; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -/** - * 佣金解冻 Job - * - * @author owen - */ -@Component -public class BrokerageRecordUnfreezeJob implements JobHandler { - - @Resource - private BrokerageRecordService brokerageRecordService; - - @Override - @TenantJob - public String execute(String param) { - int count = brokerageRecordService.unfreezeRecord(); - return StrUtil.format("解冻佣金 {} 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCancelJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCancelJob.java deleted file mode 100644 index 75a45de36b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCancelJob.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.job.order; - -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -/** - * 交易订单的自动过期 Job - * - * @author 芋道源码 - */ -@Component -public class TradeOrderAutoCancelJob implements JobHandler { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - - @Override - @TenantJob - public String execute(String param) { - int count = tradeOrderUpdateService.cancelOrderBySystem(); - return String.format("过期订单 %s 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCommentJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCommentJob.java deleted file mode 100644 index c7b7d0b9f1..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCommentJob.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.job.order; - -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -/** - * 交易订单的自动评论 Job - * - * @author 芋道源码 - */ -@Component -public class TradeOrderAutoCommentJob implements JobHandler { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - - @Override - @TenantJob - public String execute(String param) { - int count = tradeOrderUpdateService.createOrderItemCommentBySystem(); - return String.format("评论订单 %s 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoReceiveJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoReceiveJob.java deleted file mode 100644 index 1010547f33..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoReceiveJob.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.job.order; - -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -/** - * 交易订单的自动收货 Job - * - * @author 芋道源码 - */ -@Component -public class TradeOrderAutoReceiveJob implements JobHandler { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - - @Override - @TenantJob - public String execute(String param) { - int count = tradeOrderUpdateService.receiveOrderBySystem(); - return String.format("自动收货 %s 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/package-info.java deleted file mode 100644 index eba4aa766f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * trade 模块,product 模块,主要实现商品相关功能 - * 例如:品牌、商品分类、spu、sku等功能。 - * - * 1. Controller URL:以 /product/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 product_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.trade; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogService.java deleted file mode 100644 index 2620ca0c6e..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogService.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - - -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.service.aftersale.bo.AfterSaleLogCreateReqBO; - -import java.util.List; - -/** - * 交易售后日志 Service 接口 - * - * @author 陈賝 - * @since 2023/6/12 14:18 - */ -public interface AfterSaleLogService { - - /** - * 创建售后日志 - * - * @param createReqBO 日志记录 - * @author 陈賝 - * @since 2023/6/12 14:18 - */ - void createAfterSaleLog(AfterSaleLogCreateReqBO createReqBO); - - /** - * 获取售后日志 - * - * @param afterSaleId 售后编号 - * @return 售后日志 - */ - List getAfterSaleLogList(Long afterSaleId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogServiceImpl.java deleted file mode 100644 index 29d2eb50d8..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleLogConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.dal.mysql.aftersale.AfterSaleLogMapper; -import cn.iocoder.yudao.module.trade.service.aftersale.bo.AfterSaleLogCreateReqBO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - -/** - * 交易售后日志 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class AfterSaleLogServiceImpl implements AfterSaleLogService { - - @Resource - private AfterSaleLogMapper afterSaleLogMapper; - - @Override - public void createAfterSaleLog(AfterSaleLogCreateReqBO createReqBO) { - AfterSaleLogDO afterSaleLog = AfterSaleLogConvert.INSTANCE.convert(createReqBO); - afterSaleLogMapper.insert(afterSaleLog); - } - - @Override - public List getAfterSaleLogList(Long afterSaleId) { - return afterSaleLogMapper.selectListByAfterSaleId(afterSaleId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java deleted file mode 100644 index 1a0c1e95d9..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; - -/** - * 售后订单 Service 接口 - * - * @author 芋道源码 - */ -public interface AfterSaleService { - - /** - * 【管理员】获得售后订单分页 - * - * @param pageReqVO 分页查询 - * @return 售后订单分页 - */ - PageResult getAfterSalePage(AfterSalePageReqVO pageReqVO); - - /** - * 【会员】获得售后订单分页 - * - * @param userId 用户编号 - * @param pageParam 分页参数 - * @return 售后订单分页 - */ - PageResult getAfterSalePage(Long userId, PageParam pageParam); - - /** - * 【会员】获得售后单 - * - * @param userId 用户编号 - * @param id 售后编号 - * @return 售后订单 - */ - AfterSaleDO getAfterSale(Long userId, Long id); - - /** - * 【管理员】获得售后单 - * - * @param id 售后编号 - * @return 售后订单 - */ - AfterSaleDO getAfterSale(Long id); - - /** - * 【会员】创建售后订单 - * - * @param userId 会员用户编号 - * @param createReqVO 创建 Request 信息 - * @return 售后编号 - */ - Long createAfterSale(Long userId, AppAfterSaleCreateReqVO createReqVO); - - /** - * 【管理员】同意售后订单 - * - * @param userId 管理员用户编号 - * @param id 售后编号 - */ - void agreeAfterSale(Long userId, Long id); - - /** - * 【管理员】拒绝售后订单 - * - * @param userId 管理员用户编号 - * @param auditReqVO 审批 Request 信息 - */ - void disagreeAfterSale(Long userId, AfterSaleDisagreeReqVO auditReqVO); - - /** - * 【会员】退回货物 - * - * @param userId 会员用户编号 - * @param deliveryReqVO 退货 Request 信息 - */ - void deliveryAfterSale(Long userId, AppAfterSaleDeliveryReqVO deliveryReqVO); - - /** - * 【管理员】确认收货 - * - * @param userId 管理员编号 - * @param id 售后编号 - */ - void receiveAfterSale(Long userId, Long id); - - /** - * 【管理员】拒绝收货 - * - * @param userId 管理员用户编号 - * @param refuseReqVO 拒绝收货 Request 信息 - */ - void refuseAfterSale(Long userId, AfterSaleRefuseReqVO refuseReqVO); - - /** - * 【管理员】确认退款 - * - * @param userId 管理员用户编号 - * @param userIp 管理员用户 IP - * @param id 售后编号 - */ - void refundAfterSale(Long userId, String userIp, Long id); - - /** - * 【会员】取消售后 - * - * @param userId 会员用户编号 - * @param id 售后编号 - */ - void cancelAfterSale(Long userId, Long id); - - /** - * 【会员】获得正在进行中的售后订单数量 - * - * @param userId 用户编号 - * @return 数量 - */ - Long getApplyingAfterSaleCount(Long userId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java deleted file mode 100644 index c570f75604..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java +++ /dev/null @@ -1,413 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO; -import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.aftersale.AfterSaleMapper; -import cn.iocoder.yudao.module.trade.dal.redis.no.TradeNoRedisDAO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.aftersale.core.annotations.AfterSaleLog; -import cn.iocoder.yudao.module.trade.framework.aftersale.core.utils.AfterSaleLogUtils; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 售后订单 Service 实现类 - * - * @author 芋道源码 - */ -@Slf4j -@Service -@Validated -public class AfterSaleServiceImpl implements AfterSaleService { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - @Resource - private DeliveryExpressService deliveryExpressService; - - @Resource - private AfterSaleMapper tradeAfterSaleMapper; - @Resource - private TradeNoRedisDAO tradeNoRedisDAO; - - @Resource - private PayRefundApi payRefundApi; - - @Resource - private TradeOrderProperties tradeOrderProperties; - - @Override - public PageResult getAfterSalePage(AfterSalePageReqVO pageReqVO) { - return tradeAfterSaleMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getAfterSalePage(Long userId, PageParam pageParam) { - return tradeAfterSaleMapper.selectPage(userId, pageParam); - } - - @Override - public AfterSaleDO getAfterSale(Long userId, Long id) { - return tradeAfterSaleMapper.selectByIdAndUserId(id, userId); - } - - @Override - public AfterSaleDO getAfterSale(Long id) { - return tradeAfterSaleMapper.selectById(id); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.MEMBER_CREATE) - public Long createAfterSale(Long userId, AppAfterSaleCreateReqVO createReqVO) { - // 第一步,前置校验 - TradeOrderItemDO tradeOrderItem = validateOrderItemApplicable(userId, createReqVO); - - // 第二步,存储售后订单 - AfterSaleDO afterSale = createAfterSale(createReqVO, tradeOrderItem); - return afterSale.getId(); - } - - /** - * 校验交易订单项是否可以申请售后 - * - * @param userId 用户编号 - * @param createReqVO 售后创建信息 - * @return 交易订单项 - */ - private TradeOrderItemDO validateOrderItemApplicable(Long userId, AppAfterSaleCreateReqVO createReqVO) { - // 校验订单项存在 - TradeOrderItemDO orderItem = tradeOrderQueryService.getOrderItem(userId, createReqVO.getOrderItemId()); - if (orderItem == null) { - throw exception(ORDER_ITEM_NOT_FOUND); - } - // 已申请售后,不允许再发起售后申请 - if (!TradeOrderItemAfterSaleStatusEnum.isNone(orderItem.getAfterSaleStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_ITEM_APPLIED); - } - // 申请的退款金额,不能超过商品的价格 - if (createReqVO.getRefundPrice() > orderItem.getPayPrice()) { - throw exception(AFTER_SALE_CREATE_FAIL_REFUND_PRICE_ERROR); - } - - // 校验订单存在 - TradeOrderDO order = tradeOrderQueryService.getOrder(userId, orderItem.getOrderId()); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // TODO 芋艿:超过一定时间,不允许售后 - // 已取消,无法发起售后 - if (TradeOrderStatusEnum.isCanceled(order.getStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_CANCELED); - } - // 未支付,无法发起售后 - if (!TradeOrderStatusEnum.havePaid(order.getStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_PAID); - } - // 如果是【退货退款】的情况,需要额外校验是否发货 - if (createReqVO.getWay().equals(AfterSaleWayEnum.RETURN_AND_REFUND.getWay()) - && !TradeOrderStatusEnum.haveDelivered(order.getStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_DELIVERED); - } - return orderItem; - } - - private AfterSaleDO createAfterSale(AppAfterSaleCreateReqVO createReqVO, - TradeOrderItemDO orderItem) { - // 创建售后单 - AfterSaleDO afterSale = AfterSaleConvert.INSTANCE.convert(createReqVO, orderItem); - afterSale.setNo(tradeNoRedisDAO.generate(TradeNoRedisDAO.AFTER_SALE_NO_PREFIX)); - afterSale.setStatus(AfterSaleStatusEnum.APPLY.getStatus()); - // 标记是售中还是售后 - TradeOrderDO order = tradeOrderQueryService.getOrder(orderItem.getUserId(), orderItem.getOrderId()); - afterSale.setOrderNo(order.getNo()); // 记录 orderNo 订单流水,方便后续检索 - afterSale.setType(TradeOrderStatusEnum.isCompleted(order.getStatus()) - ? AfterSaleTypeEnum.AFTER_SALE.getType() : AfterSaleTypeEnum.IN_SALE.getType()); - tradeAfterSaleMapper.insert(afterSale); - - // 更新交易订单项的售后状态 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleCreate(orderItem.getId(), afterSale.getId()); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), null, - AfterSaleStatusEnum.APPLY.getStatus()); - - // TODO 发送售后消息 - return afterSale; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_AGREE_APPLY) - public void agreeAfterSale(Long userId, Long id) { - // 校验售后单存在,并状态未审批 - AfterSaleDO afterSale = validateAfterSaleAuditable(id); - - // 更新售后单的状态 - // 情况一:退款:标记为 WAIT_REFUND 状态。后续等退款发起成功后,在标记为 COMPLETE 状态 - // 情况二:退货退款:需要等用户退货后,才能发起退款 - Integer newStatus = afterSale.getWay().equals(AfterSaleWayEnum.REFUND.getWay()) ? - AfterSaleStatusEnum.WAIT_REFUND.getStatus() : AfterSaleStatusEnum.SELLER_AGREE.getStatus(); - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.APPLY.getStatus(), new AfterSaleDO() - .setStatus(newStatus).setAuditUserId(userId).setAuditTime(LocalDateTime.now())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), newStatus); - - // TODO 发送售后消息 - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_DISAGREE_APPLY) - public void disagreeAfterSale(Long userId, AfterSaleDisagreeReqVO auditReqVO) { - // 校验售后单存在,并状态未审批 - AfterSaleDO afterSale = validateAfterSaleAuditable(auditReqVO.getId()); - - // 更新售后单的状态 - Integer newStatus = AfterSaleStatusEnum.SELLER_DISAGREE.getStatus(); - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.APPLY.getStatus(), new AfterSaleDO() - .setStatus(newStatus).setAuditUserId(userId).setAuditTime(LocalDateTime.now()) - .setAuditReason(auditReqVO.getAuditReason())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), newStatus); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【未申请】 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId()); - } - - /** - * 校验售后单是否可审批(同意售后、拒绝售后) - * - * @param id 售后编号 - * @return 售后单 - */ - private AfterSaleDO validateAfterSaleAuditable(Long id) { - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.APPLY.getStatus())) { - throw exception(AFTER_SALE_AUDIT_FAIL_STATUS_NOT_APPLY); - } - return afterSale; - } - - private void updateAfterSaleStatus(Long id, Integer status, AfterSaleDO updateObj) { - int updateCount = tradeAfterSaleMapper.updateByIdAndStatus(id, status, updateObj); - if (updateCount == 0) { - throw exception(AFTER_SALE_UPDATE_STATUS_FAIL); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.MEMBER_DELIVERY) - public void deliveryAfterSale(Long userId, AppAfterSaleDeliveryReqVO deliveryReqVO) { - // 校验售后单存在,并状态未退货 - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(deliveryReqVO.getId()); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.SELLER_AGREE.getStatus())) { - throw exception(AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_SELLER_AGREE); - } - DeliveryExpressDO express = deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId()); - - // 更新售后单的物流信息 - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.SELLER_AGREE.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.BUYER_DELIVERY.getStatus()) - .setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()) - .setDeliveryTime(LocalDateTime.now())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), - MapUtil.builder().put("expressName", express.getName()) - .put("logisticsNo", deliveryReqVO.getLogisticsNo()).build()); - - // TODO 发送售后消息 - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_AGREE_RECEIVE) - public void receiveAfterSale(Long userId, Long id) { - // 校验售后单存在,并状态为已退货 - AfterSaleDO afterSale = validateAfterSaleReceivable(id); - - // 更新售后单的状态 - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.WAIT_REFUND.getStatus()).setReceiveTime(LocalDateTime.now())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.WAIT_REFUND.getStatus()); - - // TODO 发送售后消息 - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_DISAGREE_RECEIVE) - public void refuseAfterSale(Long userId, AfterSaleRefuseReqVO refuseReqVO) { - // 校验售后单存在,并状态为已退货 - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(refuseReqVO.getId()); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.BUYER_DELIVERY.getStatus())) { - throw exception(AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_DELIVERY); - } - - // 更新售后单的状态 - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.SELLER_REFUSE.getStatus()).setReceiveTime(LocalDateTime.now()) - .setReceiveReason(refuseReqVO.getRefuseMemo())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.SELLER_REFUSE.getStatus(), - MapUtil.of("reason", refuseReqVO.getRefuseMemo())); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【未申请】 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId()); - } - - /** - * 校验售后单是否可收货,即处于买家已发货 - * - * @param id 售后编号 - * @return 售后单 - */ - private AfterSaleDO validateAfterSaleReceivable(Long id) { - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.BUYER_DELIVERY.getStatus())) { - throw exception(AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_DELIVERY); - } - return afterSale; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_REFUND) - public void refundAfterSale(Long userId, String userIp, Long id) { - // 校验售后单的状态,并状态待退款 - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.WAIT_REFUND.getStatus())) { - throw exception(AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND); - } - - // 发起退款单。注意,需要在事务提交后,再进行发起,避免重复发起 - createPayRefund(userIp, afterSale); - - // 更新售后单的状态为【已完成】 - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.WAIT_REFUND.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.COMPLETE.getStatus()).setRefundTime(LocalDateTime.now())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.COMPLETE.getStatus()); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【已完成】 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleSuccess(afterSale.getOrderItemId(), afterSale.getRefundPrice()); - } - - private void createPayRefund(String userIp, AfterSaleDO afterSale) { - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - - @Override - public void afterCommit() { - // 创建退款单 - PayRefundCreateReqDTO createReqDTO = AfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties); - Long payRefundId = payRefundApi.createRefund(createReqDTO); - // 更新售后单的退款单号 - tradeAfterSaleMapper.updateById(new AfterSaleDO().setId(afterSale.getId()).setPayRefundId(payRefundId)); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.MEMBER_CANCEL) - public void cancelAfterSale(Long userId, Long id) { - // 校验售后单的状态,并状态待退款 - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (!ObjectUtils.equalsAny(afterSale.getStatus(), AfterSaleStatusEnum.APPLY.getStatus(), - AfterSaleStatusEnum.SELLER_AGREE.getStatus(), - AfterSaleStatusEnum.BUYER_DELIVERY.getStatus())) { - throw exception(AFTER_SALE_CANCEL_FAIL_STATUS_NOT_APPLY_OR_AGREE_OR_BUYER_DELIVERY); - } - - // 更新售后单的状态为【已取消】 - updateAfterSaleStatus(afterSale.getId(), afterSale.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.BUYER_CANCEL.getStatus())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.BUYER_CANCEL.getStatus()); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【未申请】 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId()); - } - - @Override - public Long getApplyingAfterSaleCount(Long userId) { - return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, AfterSaleStatusEnum.APPLYING_STATUSES); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/bo/AfterSaleLogCreateReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/bo/AfterSaleLogCreateReqBO.java deleted file mode 100644 index 5c8b3dbc3d..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/bo/AfterSaleLogCreateReqBO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale.bo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * 售后日志的创建 Request BO - * - * @author 陈賝 - * @since 2023/6/19 09:54 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class AfterSaleLogCreateReqBO { - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 用户类型 - */ - @NotNull(message = "用户类型不能为空") - private Integer userType; - - /** - * 售后编号 - */ - @NotNull(message = "售后编号不能为空") - private Long afterSaleId; - /** - * 操作前状态 - */ - private Integer beforeStatus; - /** - * 操作后状态 - */ - @NotNull(message = "操作后的状态不能为空") - private Integer afterStatus; - - /** - * 操作类型 - */ - @NotNull(message = "操作类型不能为空") - private Integer operateType; - /** - * 操作明细 - */ - @NotEmpty(message = "操作明细不能为空") - private String content; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java deleted file mode 100644 index b5b5a27d56..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java +++ /dev/null @@ -1,159 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; - -import jakarta.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 佣金记录 Service 接口 - * - * @author owen - */ -public interface BrokerageRecordService { - - /** - * 获得佣金记录 - * - * @param id 编号 - * @return 佣金记录 - */ - BrokerageRecordDO getBrokerageRecord(Integer id); - - /** - * 获得佣金记录分页 - * - * @param pageReqVO 分页查询 - * @return 佣金记录分页 - */ - PageResult getBrokerageRecordPage(BrokerageRecordPageReqVO pageReqVO); - - /** - * 增加佣金【多级分佣】 - * - * @param userId 会员编号 - * @param bizType 业务类型 - * @param list 请求参数列表 - */ - void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, @Valid List list); - - /** - * 增加佣金【只针对自己】 - * - * @param userId 会员编号 - * @param bizType 业务类型 - * @param bizId 业务编号 - * @param brokeragePrice 佣金 - * @param title 标题 - */ - void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title); - - /** - * 减少佣金【只针对自己】 - * - * @param userId 会员编号 - * @param bizType 业务类型 - * @param bizId 业务编号 - * @param brokeragePrice 佣金 - * @param title 标题 - */ - default void reduceBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) { - addBrokerage(userId, bizType, bizId, -brokeragePrice, title); - } - - /** - * 取消佣金:将佣金记录,状态修改为已失效 - * - * @param userId 会员编号 - * @param bizType 业务类型 - * @param bizId 业务编号 - */ - void cancelBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId); - - /** - * 解冻佣金:将待结算的佣金记录,状态修改为已结算 - * - * @return 解冻佣金的数量 - */ - int unfreezeRecord(); - - /** - * 按照 userId,汇总每个用户的佣金 - * - * @param userIds 用户编号 - * @param bizType 业务类型 - * @param status 佣金状态 - * @return 用户佣金汇总 List - */ - List getUserBrokerageSummaryListByUserId(Collection userIds, - Integer bizType, Integer status); - - /** - * 按照 userId,汇总每个用户的佣金 - * - * @param userIds 用户编号 - * @param bizType 业务类型 - * @param status 佣金状态 - * @return 用户佣金汇总 Map - */ - default Map getUserBrokerageSummaryMapByUserId(Collection userIds, - Integer bizType, Integer status) { - return convertMap(getUserBrokerageSummaryListByUserId(userIds, bizType, status), - UserBrokerageSummaryRespBO::getUserId); - } - - /** - * 获得用户佣金合计 - * - * @param userId 用户编号 - * @param bizType 业务类型 - * @param status 状态 - * @param beginTime 开始时间 - * @param endTime 截止时间 - * @return 用户佣金合计 - */ - Integer getSummaryPriceByUserId(Long userId, BrokerageRecordBizTypeEnum bizType, BrokerageRecordStatusEnum status, - LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获得用户佣金排行分页列表(基于佣金总数) - * - * @param pageReqVO 分页查询 - * @return 排行榜分页 - */ - PageResult getBrokerageUserChildSummaryPageByPrice( - AppBrokerageUserRankPageReqVO pageReqVO); - - /** - * 获取用户的排名(基于佣金总数) - * - * @param userId 用户编号 - * @param times 时间范围 - * @return 用户的排名 - */ - Integer getUserRankByPrice(Long userId, LocalDateTime[] times); - - /** - * 计算商品被购买后,推广员可以得到的佣金 - * - * @param userId 用户编号 - * @param spuId 商品编号 - * @return 用户佣金 - */ - AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long userId, Long spuId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java deleted file mode 100644 index c7f3f14814..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java +++ /dev/null @@ -1,368 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.*; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageRecordMapper; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import com.baomidou.mybatisplus.core.metadata.IPage; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMaxValue; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH; - -/** - * 佣金记录 Service 实现类 - * - * @author owen - */ -@Slf4j -@Service -@Validated -public class BrokerageRecordServiceImpl implements BrokerageRecordService { - - @Resource - private BrokerageRecordMapper brokerageRecordMapper; - @Resource - private TradeConfigService tradeConfigService; - @Resource - private BrokerageUserService brokerageUserService; - - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Override - public BrokerageRecordDO getBrokerageRecord(Integer id) { - return brokerageRecordMapper.selectById(id); - } - - @Override - public PageResult getBrokerageRecordPage(BrokerageRecordPageReqVO pageReqVO) { - return brokerageRecordMapper.selectPage(pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, List list) { - TradeConfigDO memberConfig = tradeConfigService.getTradeConfig(); - // 0 未启用分销功能 - if (memberConfig == null || !BooleanUtil.isTrue(memberConfig.getBrokerageEnabled())) { - log.warn("[addBrokerage][增加佣金失败:brokerageEnabled 未配置,userId({})", userId); - return; - } - - // 1.1 获得一级推广人 - BrokerageUserDO firstUser = brokerageUserService.getBindBrokerageUser(userId); - if (firstUser == null || !BooleanUtil.isTrue(firstUser.getBrokerageEnabled())) { - return; - } - // 1.2 计算一级分佣 - addBrokerage(firstUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageFirstPercent(), - bizType, 1); - - // 2.1 获得二级推广员 - if (firstUser.getBindUserId() == null) { - return; - } - BrokerageUserDO secondUser = brokerageUserService.getBrokerageUser(firstUser.getBindUserId()); - if (secondUser == null || !BooleanUtil.isTrue(secondUser.getBrokerageEnabled())) { - return; - } - // 2.2 计算二级分佣 - addBrokerage(secondUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageSecondPercent(), - bizType, 2); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void cancelBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId) { - BrokerageRecordDO record = brokerageRecordMapper.selectByBizTypeAndBizIdAndUserId(bizType.getType(), bizId, userId); - if (record == null) { - log.error("[cancelBrokerage][userId({})][bizId({}) 更新为已失效失败:记录不存在]", userId, bizId); - return; - } - - // 1. 更新佣金记录为已失效 - BrokerageRecordDO updateObj = new BrokerageRecordDO().setStatus(BrokerageRecordStatusEnum.CANCEL.getStatus()); - int updateRows = brokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj); - if (updateRows == 0) { - log.error("[cancelBrokerage][record({}) 更新为已失效失败]", record.getId()); - return; - } - - // 2. 更新用户的佣金 - if (BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus().equals(record.getStatus())) { - brokerageUserService.updateUserFrozenPrice(userId, -record.getPrice()); - } else if (BrokerageRecordStatusEnum.SETTLEMENT.getStatus().equals(record.getStatus())) { - brokerageUserService.updateUserPrice(userId, -record.getPrice()); - } - } - - /** - * 计算佣金 - * - * @param basePrice 佣金基数 - * @param percent 佣金比例 - * @param fixedPrice 固定佣金 - * @return 佣金 - */ - int calculatePrice(Integer basePrice, Integer percent, Integer fixedPrice) { - // 1. 优先使用固定佣金 - if (fixedPrice != null && fixedPrice > 0) { - return ObjectUtil.defaultIfNull(fixedPrice, 0); - } - // 2. 根据比例计算佣金 - if (basePrice != null && basePrice > 0 && percent != null && percent > 0) { - return MoneyUtils.calculateRatePriceFloor(basePrice, Double.valueOf(percent)); - } - return 0; - } - - /** - * 增加用户佣金 - * - * @param user 用户 - * @param list 佣金增加参数列表 - * @param brokerageFrozenDays 冻结天数 - * @param brokeragePercent 佣金比例 - * @param bizType 业务类型 - * @param sourceUserLevel 来源用户等级 - */ - private void addBrokerage(BrokerageUserDO user, List list, Integer brokerageFrozenDays, - Integer brokeragePercent, BrokerageRecordBizTypeEnum bizType, Integer sourceUserLevel) { - // 1.1 处理冻结时间 - LocalDateTime unfreezeTime = null; - if (brokerageFrozenDays != null && brokerageFrozenDays > 0) { - unfreezeTime = LocalDateTime.now().plusDays(brokerageFrozenDays); - } - // 1.2 计算分佣 - int totalBrokerage = 0; - List records = new ArrayList<>(); - for (BrokerageAddReqBO item : list) { - // 计算金额 - Integer fixedPrice; - if (Objects.equals(sourceUserLevel, 1)) { - fixedPrice = item.getFirstFixedPrice(); - } else if (Objects.equals(sourceUserLevel, 2)) { - fixedPrice = item.getSecondFixedPrice(); - } else { - throw new IllegalArgumentException(StrUtil.format("用户等级({}) 不合法", sourceUserLevel)); - } - int brokeragePrice = calculatePrice(item.getBasePrice(), brokeragePercent, fixedPrice); - if (brokeragePrice <= 0) { - continue; - } - totalBrokerage += brokeragePrice; - // 创建记录实体 - records.add(BrokerageRecordConvert.INSTANCE.convert(user, bizType, item.getBizId(), - brokerageFrozenDays, brokeragePrice, unfreezeTime, item.getTitle(), - item.getSourceUserId(), sourceUserLevel)); - } - if (CollUtil.isEmpty(records)) { - return; - } - // 1.3 保存佣金记录 - brokerageRecordMapper.insertBatch(records); - - // 2. 更新用户佣金 - if (brokerageFrozenDays != null && brokerageFrozenDays > 0) { // 更新用户冻结佣金 - brokerageUserService.updateUserFrozenPrice(user.getId(), totalBrokerage); - } else { // 更新用户可用佣金 - brokerageUserService.updateUserPrice(user.getId(), totalBrokerage); - } - } - - @Override - public int unfreezeRecord() { - // 1. 查询待结算的佣金记录 - List records = brokerageRecordMapper.selectListByStatusAndUnfreezeTimeLt( - BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus(), LocalDateTime.now()); - if (CollUtil.isEmpty(records)) { - return 0; - } - - // 2. 遍历执行 - int count = 0; - for (BrokerageRecordDO record : records) { - try { - boolean success = getSelf().unfreezeRecord(record); - if (success) { - count++; - } - } catch (Exception e) { - log.error("[unfreezeRecord][record({}) 更新为已结算失败]", record.getId(), e); - } - } - return count; - } - - /** - * 解冻单条佣金记录 - * - * @param record 佣金记录 - * @return 解冻是否成功 - */ - @Transactional(rollbackFor = Exception.class) - public boolean unfreezeRecord(BrokerageRecordDO record) { - // 更新记录状态 - BrokerageRecordDO updateObj = new BrokerageRecordDO() - .setStatus(BrokerageRecordStatusEnum.SETTLEMENT.getStatus()) - .setUnfreezeTime(LocalDateTime.now()); - int updateRows = brokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj); - if (updateRows == 0) { - log.error("[unfreezeRecord][record({}) 更新为已结算失败]", record.getId()); - return false; - } - - // 更新用户冻结佣金 - brokerageUserService.updateFrozenPriceDecrAndPriceIncr(record.getUserId(), -record.getPrice()); - log.info("[unfreezeRecord][record({}) 更新为已结算成功]", record.getId()); - return true; - } - - @Override - public List getUserBrokerageSummaryListByUserId(Collection userIds, - Integer bizType, Integer status) { - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - return brokerageRecordMapper.selectCountAndSumPriceByUserIdInAndBizTypeAndStatus(userIds, bizType, status); - } - - @Override - public Integer getSummaryPriceByUserId(Long userId, BrokerageRecordBizTypeEnum bizType, BrokerageRecordStatusEnum status, - LocalDateTime beginTime, LocalDateTime endTime) { - return brokerageRecordMapper.selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(userId, - bizType.getType(), status.getStatus(), beginTime, endTime); - } - - @Override - public PageResult getBrokerageUserChildSummaryPageByPrice(AppBrokerageUserRankPageReqVO pageReqVO) { - IPage pageResult = brokerageRecordMapper.selectSummaryPricePageGroupByUserId( - MyBatisUtils.buildPage(pageReqVO), - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), - ArrayUtil.get(pageReqVO.getTimes(), 0), ArrayUtil.get(pageReqVO.getTimes(), 1)); - return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); - } - - @Override - public Integer getUserRankByPrice(Long userId, LocalDateTime[] times) { - // 用户的推广金额 - Integer price = brokerageRecordMapper.selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(userId, - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), - ArrayUtil.get(times, 0), ArrayUtil.get(times, 1)); - // 排在用户前面的人数 - Integer greaterCount = brokerageRecordMapper.selectCountByPriceGt(price, - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), - ArrayUtil.get(times, 0), ArrayUtil.get(times, 1)); - // 获得排名 - return ObjUtil.defaultIfNull(greaterCount, 0) + 1; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) { - // 1. 校验佣金余额 - BrokerageUserDO user = brokerageUserService.getBrokerageUser(userId); - int balance = Optional.of(user) - .map(BrokerageUserDO::getBrokeragePrice).orElse(0); - if (balance + brokeragePrice < 0) { - throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance)); - } - - // 2. 更新佣金余额 - boolean success = brokerageUserService.updateUserPrice(userId, brokeragePrice); - if (!success) { - // 失败时,则抛出异常。只会出现扣减佣金时,余额不足的情况 - throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance)); - } - - // 3. 新增记录 - BrokerageRecordDO record = BrokerageRecordConvert.INSTANCE.convert(user, bizType, bizId, 0, brokeragePrice, - null, title, null, null); - brokerageRecordMapper.insert(record); - } - - @Override - public AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long userId, Long spuId) { - // 1. 构建默认的返回值 - AppBrokerageProductPriceRespVO respVO = new AppBrokerageProductPriceRespVO().setEnabled(false) - .setBrokerageMinPrice(0).setBrokerageMaxPrice(0); - - // 2.1 校验分销功能是否开启 - TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); - if (tradeConfig == null || BooleanUtil.isFalse(tradeConfig.getBrokerageEnabled())) { - return respVO; - } - // 2.2 校验用户是否有分销资格 - respVO.setEnabled(brokerageUserService.getUserBrokerageEnabled(getLoginUserId())); - if (BooleanUtil.isFalse(respVO.getEnabled())) { - return respVO; - } - // 2.3 校验商品是否存在 - ProductSpuRespDTO spu = productSpuApi.getSpu(spuId); - if (spu == null) { - return respVO; - } - - // 3.1 商品单独分佣模式 - Integer fixedMinPrice = 0; - Integer fixedMaxPrice = 0; - Integer spuMinPrice = 0; - Integer spuMaxPrice = 0; - List skuList = productSkuApi.getSkuListBySpuId(ListUtil.of(spuId)); - if (BooleanUtil.isTrue(spu.getSubCommissionType())) { - fixedMinPrice = getMinValue(skuList, ProductSkuRespDTO::getFirstBrokeragePrice); - fixedMaxPrice = getMaxValue(skuList, ProductSkuRespDTO::getFirstBrokeragePrice); - // 3.2 全局分佣模式(根据商品价格比例计算) - } else { - spuMinPrice = getMinValue(skuList, ProductSkuRespDTO::getPrice); - spuMaxPrice = getMaxValue(skuList, ProductSkuRespDTO::getPrice); - } - respVO.setBrokerageMinPrice(calculatePrice(spuMinPrice, tradeConfig.getBrokerageFirstPercent(), fixedMinPrice)); - respVO.setBrokerageMaxPrice(calculatePrice(spuMaxPrice, tradeConfig.getBrokerageFirstPercent(), fixedMaxPrice)); - return respVO; - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private BrokerageRecordServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java deleted file mode 100644 index a50eedda1a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; - -import jakarta.validation.constraints.NotNull; -import java.util.Collection; -import java.util.List; - -/** - * 分销用户 Service 接口 - * - * @author owen - */ -public interface BrokerageUserService { - - /** - * 获得分销用户 - * - * @param id 编号 - * @return 分销用户 - */ - BrokerageUserDO getBrokerageUser(Long id); - - /** - * 获得分销用户列表 - * - * @param ids 编号 - * @return 分销用户列表 - */ - List getBrokerageUserList(Collection ids); - - /** - * 获得分销用户分页 - * - * @param pageReqVO 分页查询 - * @return 分销用户分页 - */ - PageResult getBrokerageUserPage(BrokerageUserPageReqVO pageReqVO); - - /** - * 修改推广员编号 - * - * @param id 用户编号 - * @param bindUserId 推广员编号 - */ - void updateBrokerageUserId(Long id, Long bindUserId); - - /** - * 修改推广资格 - * - * @param id 用户编号 - * @param enabled 推广资格 - */ - void updateBrokerageUserEnabled(Long id, Boolean enabled); - - /** - * 获得用户的推广人 - * - * @param id 用户编号 - * @return 用户的推广人 - */ - BrokerageUserDO getBindBrokerageUser(Long id); - - /** - * 更新用户佣金 - * - * @param id 用户编号 - * @param price 用户可用佣金 - * @return 更新结果 - */ - boolean updateUserPrice(Long id, Integer price); - - /** - * 更新用户冻结佣金 - * - * @param id 用户编号 - * @param frozenPrice 用户冻结佣金 - */ - void updateUserFrozenPrice(Long id, Integer frozenPrice); - - /** - * 更新用户冻结佣金(减少),更新用户佣金(增加) - * - * @param id 用户编号 - * @param frozenPrice 减少冻结佣金(负数) - */ - void updateFrozenPriceDecrAndPriceIncr(Long id, Integer frozenPrice); - - /** - * 获得推广用户数量 - * - * @param bindUserId 绑定的推广员编号 - * @param level 推广用户等级 - * @return 推广用户数量 - */ - Long getBrokerageUserCountByBindUserId(Long bindUserId, Integer level); - - /** - * 【会员】绑定推广员 - * - * @param userId 用户编号 - * @param bindUserId 推广员编号 - * @return 是否绑定 - */ - boolean bindBrokerageUser(@NotNull Long userId, @NotNull Long bindUserId); - - /** - * 获取用户是否有分销资格 - * - * @param userId 用户编号 - * @return 是否有分销资格 - */ - Boolean getUserBrokerageEnabled(Long userId); - - /** - * 获得推广人排行 - * - * @param pageReqVO 分页查询 - * @return 推广人排行 - */ - PageResult getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO); - - /** - * 获得下级分销统计分页 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 下级分销统计分页 - */ - PageResult getBrokerageUserChildSummaryPage(AppBrokerageUserChildSummaryPageReqVO pageReqVO, Long userId); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java deleted file mode 100644 index 355e1ee8b8..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java +++ /dev/null @@ -1,356 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageUserMapper; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMapByFilter; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 分销用户 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class BrokerageUserServiceImpl implements BrokerageUserService { - - @Resource - private BrokerageUserMapper brokerageUserMapper; - - @Resource - private TradeConfigService tradeConfigService; - - @Resource - private MemberUserApi memberUserApi; - - @Override - public BrokerageUserDO getBrokerageUser(Long id) { - return brokerageUserMapper.selectById(id); - } - - @Override - public List getBrokerageUserList(Collection ids) { - return brokerageUserMapper.selectBatchIds(ids); - } - - @Override - public PageResult getBrokerageUserPage(BrokerageUserPageReqVO pageReqVO) { - List childIds = getChildUserIdsByLevel(pageReqVO.getBindUserId(), pageReqVO.getLevel()); - // 有”绑定用户编号“查询条件时,没有查到下级会员,直接返回空 - if (pageReqVO.getBindUserId() != null && CollUtil.isEmpty(childIds)) { - return PageResult.empty(); - } - return brokerageUserMapper.selectPage(pageReqVO, childIds); - } - - @Override - public void updateBrokerageUserId(Long id, Long bindUserId) { - // 校验存在 - BrokerageUserDO brokerageUser = validateBrokerageUserExists(id); - // 绑定关系未发生变化 - if (Objects.equals(brokerageUser.getBindUserId(), bindUserId)) { - return; - } - - // 情况一:清除推广员 - if (bindUserId == null) { - // 清除推广员 - brokerageUserMapper.updateBindUserIdAndBindUserTimeToNull(id); - return; - } - - // 情况二:修改推广员 - validateCanBindUser(brokerageUser, bindUserId); - brokerageUserMapper.updateById(fillBindUserData(bindUserId, new BrokerageUserDO().setId(id))); - } - - @Override - public void updateBrokerageUserEnabled(Long id, Boolean enabled) { - // 校验存在 - validateBrokerageUserExists(id); - if (BooleanUtil.isTrue(enabled)) { - // 开通推广资格 - brokerageUserMapper.updateById(new BrokerageUserDO().setId(id) - .setBrokerageEnabled(true).setBrokerageTime(LocalDateTime.now())); - } else { - // 取消推广资格 - brokerageUserMapper.updateEnabledFalseAndBrokerageTimeToNull(id); - } - } - - private BrokerageUserDO validateBrokerageUserExists(Long id) { - BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(id); - if (brokerageUserDO == null) { - throw exception(BROKERAGE_USER_NOT_EXISTS); - } - - return brokerageUserDO; - } - - @Override - public BrokerageUserDO getBindBrokerageUser(Long id) { - return Optional.ofNullable(id) - .map(this::getBrokerageUser) - .map(BrokerageUserDO::getBindUserId) - .map(this::getBrokerageUser) - .orElse(null); - } - - @Override - public boolean updateUserPrice(Long id, Integer price) { - if (price > 0) { - brokerageUserMapper.updatePriceIncr(id, price); - } else if (price < 0) { - return brokerageUserMapper.updatePriceDecr(id, price) > 0; - } - return true; - } - - @Override - public void updateUserFrozenPrice(Long id, Integer frozenPrice) { - if (frozenPrice > 0) { - brokerageUserMapper.updateFrozenPriceIncr(id, frozenPrice); - } else if (frozenPrice < 0) { - brokerageUserMapper.updateFrozenPriceDecr(id, frozenPrice); - } - } - - @Override - public void updateFrozenPriceDecrAndPriceIncr(Long id, Integer frozenPrice) { - Assert.isTrue(frozenPrice < 0); - int updateRows = brokerageUserMapper.updateFrozenPriceDecrAndPriceIncr(id, frozenPrice); - if (updateRows == 0) { - throw exception(BROKERAGE_USER_FROZEN_PRICE_NOT_ENOUGH); - } - } - - @Override - public Long getBrokerageUserCountByBindUserId(Long bindUserId, Integer level) { - List childIds = getChildUserIdsByLevel(bindUserId, level); - return (long) CollUtil.size(childIds); - } - - @Override - public boolean bindBrokerageUser(Long userId, Long bindUserId) { - // 1. 获得分销用户 - boolean isNewBrokerageUser = false; - BrokerageUserDO brokerageUser = brokerageUserMapper.selectById(userId); - if (brokerageUser == null) { // 分销用户不存在的情况:1. 新注册;2. 旧数据;3. 分销功能关闭后又打开 - isNewBrokerageUser = true; - brokerageUser = new BrokerageUserDO().setId(userId).setBrokerageEnabled(false).setBrokeragePrice(0).setFrozenPrice(0); - } - - // 2.1 校验是否能绑定用户 - boolean validated = isUserCanBind(brokerageUser); - if (!validated) { - return false; - } - // 2.3 校验能否绑定 - validateCanBindUser(brokerageUser, bindUserId); - // 2.3 绑定用户 - if (isNewBrokerageUser) { - Integer enabledCondition = tradeConfigService.getTradeConfig().getBrokerageEnabledCondition(); - if (BrokerageEnabledConditionEnum.ALL.getCondition().equals(enabledCondition)) { // 人人分销:用户默认就有分销资格 - brokerageUser.setBrokerageEnabled(true).setBrokerageTime(LocalDateTime.now()); - } - brokerageUser.setBindUserId(bindUserId).setBindUserTime(LocalDateTime.now()); - brokerageUserMapper.insert(fillBindUserData(bindUserId, brokerageUser)); - } else { - brokerageUserMapper.updateById(fillBindUserData(bindUserId, new BrokerageUserDO().setId(userId))); - } - return true; - } - - /** - * 补全绑定用户的字段 - * - * @param bindUserId 绑定的用户编号 - * @param brokerageUser update 对象 - * @return 补全后的 update 对象 - */ - private BrokerageUserDO fillBindUserData(Long bindUserId, BrokerageUserDO brokerageUser) { - return brokerageUser.setBindUserId(bindUserId).setBindUserTime(LocalDateTime.now()); - } - - @Override - public Boolean getUserBrokerageEnabled(Long userId) { - // 全局分销功能是否开启 - TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); - if (tradeConfig == null || BooleanUtil.isFalse(tradeConfig.getBrokerageEnabled())) { - return false; - } - - // 用户是否有分销资格 - return Optional.ofNullable(getBrokerageUser(userId)) - .map(BrokerageUserDO::getBrokerageEnabled) - .orElse(false); - } - - @Override - public PageResult getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO) { - IPage pageResult = brokerageUserMapper.selectCountPageGroupByBindUserId(MyBatisUtils.buildPage(pageReqVO), - ArrayUtil.get(pageReqVO.getTimes(), 0), ArrayUtil.get(pageReqVO.getTimes(), 1)); - return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); - } - - @Override - public PageResult getBrokerageUserChildSummaryPage(AppBrokerageUserChildSummaryPageReqVO pageReqVO, Long userId) { - // 1.1 查询下级用户编号列表 - List childIds = getChildUserIdsByLevel(userId, pageReqVO.getLevel()); - if (CollUtil.isEmpty(childIds)) { - return PageResult.empty(); - } - // 1.2 根据昵称过滤下级用户 - List users = memberUserApi.getUserList(childIds); - Map userMap = convertMapByFilter(users, - user -> StrUtil.contains(user.getNickname(), pageReqVO.getNickname()), - MemberUserRespDTO::getId); - if (CollUtil.isEmpty(userMap)) { - return PageResult.empty(); - } - - // 2. 分页查询 - IPage pageResult = brokerageUserMapper.selectSummaryPageByUserId( - MyBatisUtils.buildPage(pageReqVO), BrokerageRecordBizTypeEnum.ORDER.getType(), - BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), userMap.keySet(), pageReqVO.getSortingField() - ); - - // 3. 拼接数据并返回 - BrokerageUserConvert.INSTANCE.copyTo(pageResult.getRecords(), userMap); - return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); - } - - private boolean isUserCanBind(BrokerageUserDO user) { - // 校验分销功能是否启用 - TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); - if (tradeConfig == null || !BooleanUtil.isTrue(tradeConfig.getBrokerageEnabled())) { - return false; - } - - // 校验分佣模式:仅可后台手动设置推广员 - if (BrokerageEnabledConditionEnum.ADMIN.getCondition().equals(tradeConfig.getBrokerageEnabledCondition())) { - throw exception(BROKERAGE_BIND_CONDITION_ADMIN); - } - - // 校验分销关系绑定模式 - if (BrokerageBindModeEnum.REGISTER.getMode().equals(tradeConfig.getBrokerageBindMode())) { - // 判断是否为新用户:注册时间在 30 秒内的,都算新用户 - if (!isNewRegisterUser(user.getId())) { - throw exception(BROKERAGE_BIND_MODE_REGISTER); // 只有在注册时可以绑定 - } - } else if (BrokerageBindModeEnum.ANYTIME.getMode().equals(tradeConfig.getBrokerageBindMode())) { - if (user.getBindUserId() != null) { - throw exception(BROKERAGE_BIND_OVERRIDE); // 已绑定了推广人 - } - } - return true; - } - - /** - * 判断是否为新用户 - *

- * 标准:注册时间在 30 秒内的,都算新用户 - *

- * 疑问:为什么通过这样的方式实现? - * 回答:因为注册在 member 模块,希望它和 trade 模块解耦,所以只能用这种约定的逻辑。 - * - * @param userId 用户编号 - * @return 是否新用户 - */ - private boolean isNewRegisterUser(Long userId) { - MemberUserRespDTO user = memberUserApi.getUser(userId); - return user != null && LocalDateTimeUtils.beforeNow(user.getCreateTime().plusSeconds(30)); - } - - private void validateCanBindUser(BrokerageUserDO user, Long bindUserId) { - // 校验要绑定的用户有无推广资格 - BrokerageUserDO bindUser = brokerageUserMapper.selectById(bindUserId); - if (bindUser == null || BooleanUtil.isFalse(bindUser.getBrokerageEnabled())) { - throw exception(BROKERAGE_BIND_USER_NOT_ENABLED); - } - - // 校验绑定自己 - if (Objects.equals(user.getId(), bindUserId)) { - throw exception(BROKERAGE_BIND_SELF); - } - - // 下级不能绑定自己的上级 - for (int i = 0; i <= Short.MAX_VALUE; i++) { - if (Objects.equals(bindUser.getBindUserId(), user.getId())) { - throw exception(BROKERAGE_BIND_LOOP); - } - bindUser = getBrokerageUser(bindUser.getBindUserId()); - // 找到根节点,结束循环 - if (bindUser == null || bindUser.getBindUserId() == null) { - break; - } - } - } - - /** - * 根据绑定用户编号,获得下级用户编号列表 - * - * @param bindUserId 绑定用户编号 - * @param level 下级用户的层级。 - * 如果 level 为空,则查询 1+2 两个层级 - * @return 下级用户编号列表 - */ - private List getChildUserIdsByLevel(Long bindUserId, Integer level) { - if (bindUserId == null) { - return Collections.emptyList(); - } - // 先查第 1 级 - List bindUserIds = brokerageUserMapper.selectIdListByBindUserIdIn(Collections.singleton(bindUserId)); - if (CollUtil.isEmpty(bindUserIds)) { - return Collections.emptyList(); - } - - // 情况一:level 为空,查询所有级别 - if (level == null) { - // 再查第 2 级,并合并结果 - bindUserIds.addAll(brokerageUserMapper.selectIdListByBindUserIdIn(bindUserIds)); - return bindUserIds; - } - // 情况二:level 为 1,只查询第 1 级 - if (level == 1) { - return bindUserIds; - } - // 情况三:level 为 1,只查询第 2 级 - if (level == 2) { - return brokerageUserMapper.selectIdListByBindUserIdIn(bindUserIds); - } - throw exception(BROKERAGE_USER_LEVEL_NOT_SUPPORT); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java deleted file mode 100644 index 04ea9c49bc..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 佣金提现 Service 接口 - * - * @author 芋道源码 - */ -public interface BrokerageWithdrawService { - - /** - * 【管理员】审核佣金提现 - * - * @param id 佣金编号 - * @param status 审核状态 - * @param auditReason 驳回原因 - */ - void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason); - - /** - * 获得佣金提现 - * - * @param id 编号 - * @return 佣金提现 - */ - BrokerageWithdrawDO getBrokerageWithdraw(Integer id); - - /** - * 获得佣金提现分页 - * - * @param pageReqVO 分页查询 - * @return 佣金提现分页 - */ - PageResult getBrokerageWithdrawPage(BrokerageWithdrawPageReqVO pageReqVO); - - /** - * 【会员】创建佣金提现 - * - * @param userId 会员用户编号 - * @param createReqVO 创建信息 - * @return 佣金提现编号 - */ - Long createBrokerageWithdraw(Long userId, AppBrokerageWithdrawCreateReqVO createReqVO); - - /** - * 按照 userId,汇总每个用户的提现 - * - * @param userIds 用户编号 - * @param status 提现状态 - * @return 用户提现汇总 List - */ - List getWithdrawSummaryListByUserId(Collection userIds, - BrokerageWithdrawStatusEnum status); - - /** - * 按照 userId,汇总每个用户的提现 - * - * @param userIds 用户编号 - * @param status 提现状态 - * @return 用户提现汇总 Map - */ - default Map getWithdrawSummaryMapByUserId(Set userIds, - BrokerageWithdrawStatusEnum status) { - return convertMap(getWithdrawSummaryListByUserId(userIds, status), BrokerageWithdrawSummaryRespBO::getUserId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java deleted file mode 100644 index 0560c33d84..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; -import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageWithdrawMapper; -import cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import jakarta.validation.Validator; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 佣金提现 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { - - @Resource - private BrokerageWithdrawMapper brokerageWithdrawMapper; - - @Resource - private BrokerageRecordService brokerageRecordService; - @Resource - private TradeConfigService tradeConfigService; - - @Resource - private NotifyMessageSendApi notifyMessageSendApi; - - @Resource - private Validator validator; - - @Override - @Transactional(rollbackFor = Exception.class) - public void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason) { - // 1.1 校验存在 - BrokerageWithdrawDO withdraw = validateBrokerageWithdrawExists(id); - // 1.2 校验状态为审核中 - if (ObjectUtil.notEqual(BrokerageWithdrawStatusEnum.AUDITING.getStatus(), withdraw.getStatus())) { - throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); - } - - // 2. 更新 - int rows = brokerageWithdrawMapper.updateByIdAndStatus(id, BrokerageWithdrawStatusEnum.AUDITING.getStatus(), - new BrokerageWithdrawDO().setStatus(status.getStatus()).setAuditReason(auditReason).setAuditTime(LocalDateTime.now())); - if (rows == 0) { - throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); - } - - String templateCode; - if (BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.equals(status)) { - templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_APPROVE; - // 3.1 通过时佣金转余额 - if (BrokerageWithdrawTypeEnum.WALLET.getType().equals(withdraw.getType())) { - // todo 疯狂: - } - // TODO 疯狂:调用转账接口 - } else if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) { - templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_REJECT; - // 3.2 驳回时需要退还用户佣金 - brokerageRecordService.addBrokerage(withdraw.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT, - String.valueOf(withdraw.getId()), withdraw.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT.getTitle()); - } else { - throw new IllegalArgumentException("不支持的提现状态:" + status); - } - - // 4. 通知用户 - Map templateParams = MapUtil.builder() - .put("createTime", LocalDateTimeUtil.formatNormal(withdraw.getCreateTime())) - .put("price", MoneyUtils.fenToYuanStr(withdraw.getPrice())) - .put("reason", withdraw.getAuditReason()) - .build(); - notifyMessageSendApi.sendSingleMessageToMember(new NotifySendSingleToUserReqDTO() - .setUserId(withdraw.getUserId()).setTemplateCode(templateCode).setTemplateParams(templateParams)); - } - - private BrokerageWithdrawDO validateBrokerageWithdrawExists(Integer id) { - BrokerageWithdrawDO withdraw = brokerageWithdrawMapper.selectById(id); - if (withdraw == null) { - throw exception(BROKERAGE_WITHDRAW_NOT_EXISTS); - } - return withdraw; - } - - @Override - public BrokerageWithdrawDO getBrokerageWithdraw(Integer id) { - return brokerageWithdrawMapper.selectById(id); - } - - @Override - public PageResult getBrokerageWithdrawPage(BrokerageWithdrawPageReqVO pageReqVO) { - return brokerageWithdrawMapper.selectPage(pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createBrokerageWithdraw(Long userId, AppBrokerageWithdrawCreateReqVO createReqVO) { - // 1.1 校验提现金额 - TradeConfigDO tradeConfig = validateWithdrawPrice(createReqVO.getPrice()); - // 1.2 校验提现参数 - createReqVO.validate(validator); - - // 2.1 计算手续费 - Integer feePrice = calculateFeePrice(createReqVO.getPrice(), tradeConfig.getBrokerageWithdrawFeePercent()); - // 2.2 创建佣金提现记录 - BrokerageWithdrawDO withdraw = BrokerageWithdrawConvert.INSTANCE.convert(createReqVO, userId, feePrice); - brokerageWithdrawMapper.insert(withdraw); - - // 3. 创建用户佣金记录 - // 注意,佣金是否充足,reduceBrokerage 已经进行校验 - brokerageRecordService.reduceBrokerage(userId, BrokerageRecordBizTypeEnum.WITHDRAW, String.valueOf(withdraw.getId()), - createReqVO.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW.getTitle()); - return withdraw.getId(); - } - - @Override - public List getWithdrawSummaryListByUserId(Collection userIds, - BrokerageWithdrawStatusEnum status) { - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - return brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userIds, status.getStatus()); - } - - /** - * 计算提现手续费 - * - * @param withdrawPrice 提现金额 - * @param percent 手续费百分比 - * @return 提现手续费 - */ - Integer calculateFeePrice(Integer withdrawPrice, Integer percent) { - Integer feePrice = 0; - if (percent != null && percent > 0) { - feePrice = MoneyUtils.calculateRatePrice(withdrawPrice, Double.valueOf(percent)); - } - return feePrice; - } - - /** - * 校验提现金额要求 - * - * @param withdrawPrice 提现金额 - * @return 分销配置 - */ - TradeConfigDO validateWithdrawPrice(Integer withdrawPrice) { - TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); - if (tradeConfig.getBrokerageWithdrawMinPrice() != null && withdrawPrice < tradeConfig.getBrokerageWithdrawMinPrice()) { - throw exception(BROKERAGE_WITHDRAW_MIN_PRICE, MoneyUtils.fenToYuanStr(tradeConfig.getBrokerageWithdrawMinPrice())); - } - return tradeConfig; - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageAddReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageAddReqBO.java deleted file mode 100644 index fe7877961f..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageAddReqBO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage.bo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * 佣金 增加 Request BO - * - * @author owen - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageAddReqBO { - - /** - * 业务编号 - */ - @NotBlank(message = "业务编号不能为空") - private String bizId; - /** - * 佣金基数 - */ - @NotNull(message = "佣金基数不能为空") - private Integer basePrice; - /** - * 一级佣金(固定) - */ - @NotNull(message = "一级佣金(固定)不能为空") - private Integer firstFixedPrice; - /** - * 二级佣金(固定) - */ - private Integer secondFixedPrice; - - /** - * 来源用户编号 - */ - @NotNull(message = "来源用户编号不能为空") - private Long sourceUserId; - - /** - * 佣金记录标题 - */ - @NotEmpty(message = "佣金记录标题不能为空") - private String title; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageWithdrawSummaryRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageWithdrawSummaryRespBO.java deleted file mode 100644 index 1c3a3c9917..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageWithdrawSummaryRespBO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage.bo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 佣金提现合计 BO - * - * @author owen - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageWithdrawSummaryRespBO { - - /** - * 用户编号 - */ - private Long userId; - - /** - * 提现次数 - */ - private Integer count; - /** - * 提现金额 - */ - private Integer price; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/UserBrokerageSummaryRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/UserBrokerageSummaryRespBO.java deleted file mode 100644 index 3e677b96a4..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/UserBrokerageSummaryRespBO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage.bo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 用户佣金合计 BO - * - * @author owen - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class UserBrokerageSummaryRespBO { - - /** - * 用户编号 - */ - private Long userId; - /** - * 推广数量 - */ - private Integer count; - /** - * 佣金总额 - */ - private Integer price; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartService.java deleted file mode 100644 index fbe6b337ac..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartService.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.cart; - -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.*; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -/** - * 购物车 Service 接口 - * - * @author 芋道源码 - */ -public interface CartService { - - /** - * 添加商品到购物车 - * - * @param userId 用户编号 - * @param addReqVO 添加信息 - * @return 购物项的编号 - */ - Long addCart(Long userId, @Valid AppCartAddReqVO addReqVO); - - /** - * 更新购物车商品数量 - * - * @param userId 用户编号 - * @param updateCountReqVO 更新信息 - */ - void updateCartCount(Long userId, AppCartUpdateCountReqVO updateCountReqVO); - - /** - * 更新购物车选中状态 - * - * @param userId 用户编号 - * @param updateSelectedReqVO 更新信息 - */ - void updateCartSelected(Long userId, @Valid AppCartUpdateSelectedReqVO updateSelectedReqVO); - - /** - * 重置购物车商品 - * - * 使用场景:在一个购物车项对应的商品失效(例如说 SPU 被下架),可以重新选择对应的 SKU - * - * @param userId 用户编号 - * @param updateReqVO 重置信息 - */ - void resetCart(Long userId, AppCartResetReqVO updateReqVO); - - /** - * 删除购物车商品 - * - * @param userId 用户编号 - * @param ids 购物项的编号 - */ - void deleteCart(Long userId, Collection ids); - - /** - * 查询用户在购物车中的商品数量 - * - * @param userId 用户编号 - * @return 商品数量 - */ - Integer getCartCount(Long userId); - - /** - * 查询用户的购物车列表 - * - * @param userId 用户编号 - * @return 购物车列表 - */ - AppCartListRespVO getCartList(Long userId); - - /** - * 查询用户的购物车列表 - * - * @param userId 用户编号 - * @param ids 购物项的编号 - * @return 购物车列表 - */ - List getCartList(Long userId, Set ids); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartServiceImpl.java deleted file mode 100644 index b032fb2a22..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartServiceImpl.java +++ /dev/null @@ -1,196 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.cart; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.*; -import cn.iocoder.yudao.module.trade.convert.cart.TradeCartConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import cn.iocoder.yudao.module.trade.dal.mysql.cart.CartMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_STOCK_NOT_ENOUGH; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.CARD_ITEM_NOT_FOUND; -import static java.util.Collections.emptyList; - -/** - * 购物车 Service 实现类 - * - * // TODO 芋艿:未来优化:购物车的价格计算,支持营销信息;目前不支持的原因,前端界面需要前端 pr 支持下;例如说:会员价格; - * - * @author 芋道源码 - */ -@Service -@Validated -public class CartServiceImpl implements CartService { - - @Resource - private CartMapper cartMapper; - - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Override - public Long addCart(Long userId, AppCartAddReqVO addReqVO) { - // 查询 TradeCartDO - CartDO cart = cartMapper.selectByUserIdAndSkuId(userId, addReqVO.getSkuId()); - // 校验 SKU - Integer count = addReqVO.getCount(); - ProductSkuRespDTO sku = checkProductSku(addReqVO.getSkuId(), count); - - // 情况一:存在,则进行数量更新 - if (cart != null) { - cartMapper.updateById(new CartDO().setId(cart.getId()).setSelected(true) - .setCount(cart.getCount() + count)); - return cart.getId(); - // 情况二:不存在,则进行插入 - } else { - cart = new CartDO().setUserId(userId).setSelected(true) - .setSpuId(sku.getSpuId()).setSkuId(sku.getId()).setCount(count); - cartMapper.insert(cart); - } - return cart.getId(); - } - - @Override - public void updateCartCount(Long userId, AppCartUpdateCountReqVO updateReqVO) { - // 校验 TradeCartDO 存在 - CartDO cart = cartMapper.selectById(updateReqVO.getId(), userId); - if (cart == null) { - throw exception(CARD_ITEM_NOT_FOUND); - } - // 校验商品 SKU - checkProductSku(cart.getSkuId(), updateReqVO.getCount()); - - // 更新数量 - cartMapper.updateById(new CartDO().setId(cart.getId()) - .setCount(updateReqVO.getCount())); - } - - @Override - public void updateCartSelected(Long userId, AppCartUpdateSelectedReqVO updateSelectedReqVO) { - cartMapper.updateByIds(updateSelectedReqVO.getIds(), userId, - new CartDO().setSelected(updateSelectedReqVO.getSelected())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void resetCart(Long userId, AppCartResetReqVO resetReqVO) { - // 第一步:删除原本的购物项 - CartDO oldCart = cartMapper.selectById(resetReqVO.getId(), userId); - if (oldCart == null) { - throw exception(CARD_ITEM_NOT_FOUND); - } - cartMapper.deleteById(oldCart.getId()); - - // 第二步:添加新的购物项 - CartDO newCart = cartMapper.selectByUserIdAndSkuId(userId, resetReqVO.getSkuId()); - if (newCart != null) { - updateCartCount(userId, new AppCartUpdateCountReqVO() - .setId(newCart.getId()).setCount(resetReqVO.getCount())); - } else { - addCart(userId, new AppCartAddReqVO().setSkuId(resetReqVO.getSkuId()) - .setCount(resetReqVO.getCount())); - } - } - - /** - * 购物车删除商品 - * - * @param userId 用户编号 - * @param ids 商品 SKU 编号的数组 - */ - @Override - public void deleteCart(Long userId, Collection ids) { - // 查询 TradeCartDO 列表 - List carts = cartMapper.selectListByIds(ids, userId); - if (CollUtil.isEmpty(carts)) { - return; - } - - // 批量标记删除 - cartMapper.deleteBatchIds(ids); - } - - @Override - public Integer getCartCount(Long userId) { - // TODO 芋艿:需要算上 selected - return cartMapper.selectSumByUserId(userId); - } - - @Override - public AppCartListRespVO getCartList(Long userId) { - // 获得购物车的商品 - List carts = cartMapper.selectListByUserId(userId); - carts.sort(Comparator.comparing(CartDO::getId).reversed()); - // 如果未空,则返回空结果 - if (CollUtil.isEmpty(carts)) { - return new AppCartListRespVO().setValidList(emptyList()) - .setInvalidList(emptyList()); - } - - // 查询 SPU、SKU 列表 - List spus = productSpuApi.getSpuList(convertSet(carts, CartDO::getSpuId)); - List skus = productSkuApi.getSkuList(convertSet(carts, CartDO::getSkuId)); - - // 如果 SPU 被删除,则删除购物车对应的商品。延迟删除 - // 为什么不是 SKU 被删除呢?因为 SKU 被删除时,还可以通过 SPU 选择其它 SKU - deleteCartIfSpuDeleted(carts, spus); - - // 拼接数据 - return TradeCartConvert.INSTANCE.convertList(carts, spus, skus); - } - - @Override - public List getCartList(Long userId, Set ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return cartMapper.selectListByUserId(userId, ids); - } - - private void deleteCartIfSpuDeleted(List carts, List spus) { - // 如果 SPU 被删除,则删除购物车对应的商品。延迟删除 - carts.removeIf(cart -> { - if (spus.stream().noneMatch(spu -> spu.getId().equals(cart.getSpuId()))) { - cartMapper.deleteById(cart.getId()); - return true; - } - return false; - }); - } - - /** - * 校验商品 SKU 是否合法 - * 1. 是否存在 - * 2. 是否下架 - * 3. 库存不足 - * - * @param skuId 商品 SKU 编号 - * @param count 商品数量 - * @return 商品 SKU - */ - private ProductSkuRespDTO checkProductSku(Long skuId, Integer count) { - ProductSkuRespDTO sku = productSkuApi.getSku(skuId); - if (sku == null) { - throw exception(SKU_NOT_EXISTS); - } - if (count > sku.getStock()) { - throw exception(SKU_STOCK_NOT_ENOUGH); - } - return sku; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java deleted file mode 100644 index 7c70f21aa3..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.config; - -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; - -import jakarta.validation.Valid; - -/** - * 交易中心配置 Service 接口 - * - * @author owen - */ -public interface TradeConfigService { - - /** - * 更新交易中心配置 - * - * @param updateReqVO 更新信息 - */ - void saveTradeConfig(@Valid TradeConfigSaveReqVO updateReqVO); - - /** - * 获得交易中心配置 - * - * @return 交易中心配置 - */ - TradeConfigDO getTradeConfig(); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java deleted file mode 100644 index 314d228d9a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.config; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; -import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.mysql.config.TradeConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - -/** - * 交易中心配置 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class TradeConfigServiceImpl implements TradeConfigService { - - @Resource - private TradeConfigMapper tradeConfigMapper; - - @Override - public void saveTradeConfig(TradeConfigSaveReqVO saveReqVO) { - // 存在,则进行更新 - TradeConfigDO dbConfig = getTradeConfig(); - if (dbConfig != null) { - tradeConfigMapper.updateById(TradeConfigConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId())); - return; - } - // 不存在,则进行插入 - tradeConfigMapper.insert(TradeConfigConvert.INSTANCE.convert(saveReqVO)); - } - - @Override - public TradeConfigDO getTradeConfig() { - List list = tradeConfigMapper.selectList(); - return CollectionUtils.getFirst(list); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java deleted file mode 100644 index 50f96108ae..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * 快递公司 Service 接口 - * - * @author jason - */ -public interface DeliveryExpressService { - - /** - * 创建快递公司 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDeliveryExpress(@Valid DeliveryExpressCreateReqVO createReqVO); - - /** - * 更新快递公司 - * - * @param updateReqVO 更新信息 - */ - void updateDeliveryExpress(@Valid DeliveryExpressUpdateReqVO updateReqVO); - - /** - * 删除快递公司 - * - * @param id 编号 - */ - void deleteDeliveryExpress(Long id); - - /** - * 获得快递公司 - * - * @param id 编号 - * @return 快递公司 - */ - DeliveryExpressDO getDeliveryExpress(Long id); - - /** - * 校验快递公司是否合法 - * - * @param id 编号 - * @return 快递公司 - */ - DeliveryExpressDO validateDeliveryExpress(Long id); - - /** - * 获得快递公司分页 - * - * @param pageReqVO 分页查询 - * @return 快递公司分页 - */ - PageResult getDeliveryExpressPage(DeliveryExpressPageReqVO pageReqVO); - - /** - * 获得快递公司列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 快递公司列表 - */ - List getDeliveryExpressList(DeliveryExpressExportReqVO exportReqVO); - - /** - * 获取指定状态的快递公司列表 - * - * @param status 状态 - * @return 快递公司列表 - */ - List getDeliveryExpressListByStatus(Integer status); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java deleted file mode 100644 index e2a718a583..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 快递公司 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class DeliveryExpressServiceImpl implements DeliveryExpressService { - - @Resource - private DeliveryExpressMapper deliveryExpressMapper; - - @Override - public Long createDeliveryExpress(DeliveryExpressCreateReqVO createReqVO) { - //校验编码是否唯一 - validateExpressCodeUnique(createReqVO.getCode(), null); - // 插入 - DeliveryExpressDO deliveryExpress = DeliveryExpressConvert.INSTANCE.convert(createReqVO); - deliveryExpressMapper.insert(deliveryExpress); - // 返回 - return deliveryExpress.getId(); - } - - @Override - public void updateDeliveryExpress(DeliveryExpressUpdateReqVO updateReqVO) { - // 校验存在 - validateDeliveryExpressExists(updateReqVO.getId()); - //校验编码是否唯一 - validateExpressCodeUnique(updateReqVO.getCode(), updateReqVO.getId()); - // 更新 - DeliveryExpressDO updateObj = DeliveryExpressConvert.INSTANCE.convert(updateReqVO); - deliveryExpressMapper.updateById(updateObj); - } - - @Override - public void deleteDeliveryExpress(Long id) { - // 校验存在 - validateDeliveryExpressExists(id); - // 删除 - deliveryExpressMapper.deleteById(id); - } - - private void validateExpressCodeUnique(String code, Long id) { - DeliveryExpressDO express = deliveryExpressMapper.selectByCode(code); - if (express == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的快递公司 - if (id == null) { - throw exception(EXPRESS_CODE_DUPLICATE); - } - if (!express.getId().equals(id)) { - throw exception(EXPRESS_CODE_DUPLICATE); - } - } - private void validateDeliveryExpressExists(Long id) { - if (deliveryExpressMapper.selectById(id) == null) { - throw exception(EXPRESS_NOT_EXISTS); - } - } - - @Override - public DeliveryExpressDO getDeliveryExpress(Long id) { - return deliveryExpressMapper.selectById(id); - } - - @Override - public DeliveryExpressDO validateDeliveryExpress(Long id) { - DeliveryExpressDO deliveryExpress = deliveryExpressMapper.selectById(id); - if (deliveryExpress == null) { - throw exception(EXPRESS_NOT_EXISTS); - } - if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { - throw exception(EXPRESS_STATUS_NOT_ENABLE); - } - return deliveryExpress; - } - - @Override - public PageResult getDeliveryExpressPage(DeliveryExpressPageReqVO pageReqVO) { - return deliveryExpressMapper.selectPage(pageReqVO); - } - - @Override - public List getDeliveryExpressList(DeliveryExpressExportReqVO exportReqVO) { - return deliveryExpressMapper.selectList(exportReqVO); - } - - @Override - public List getDeliveryExpressListByStatus(Integer status) { - return deliveryExpressMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java deleted file mode 100644 index cdbeb2f020..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplateCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplateDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplatePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplateUpdateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 快递运费模板 Service 接口 - * - * @author jason - */ -public interface DeliveryExpressTemplateService { - - /** - * 创建快递运费模板 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDeliveryExpressTemplate(@Valid DeliveryExpressTemplateCreateReqVO createReqVO); - - /** - * 更新快递运费模板 - * - * @param updateReqVO 更新信息 - */ - void updateDeliveryExpressTemplate(@Valid DeliveryExpressTemplateUpdateReqVO updateReqVO); - - /** - * 删除快递运费模板 - * - * @param id 编号 - */ - void deleteDeliveryExpressTemplate(Long id); - - /** - * 获得快递运费模板 - * - * @param id 编号 - * @return 快递运费模板详情 - */ - DeliveryExpressTemplateDetailRespVO getDeliveryExpressTemplate(Long id); - - /** - * 获得快递运费模板列表 - * - * @param ids 编号 - * @return 快递运费模板列表 - */ - List getDeliveryExpressTemplateList(Collection ids); - - /** - * 获得快递运费模板列表 - * - * @return 快递运费模板列表 - */ - List getDeliveryExpressTemplateList(); - - /** - * 获得快递运费模板分页 - * - * @param pageReqVO 分页查询 - * @return 快递运费模板分页 - */ - PageResult getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO); - - /** - * 校验快递运费模板 - * - * 如果校验不通过,抛出 {@link cn.iocoder.yudao.framework.common.exception.ServiceException} 异常 - * - * @param templateId 模板编号 - * @return 快递运费模板 - */ - DeliveryExpressTemplateDO validateDeliveryExpressTemplate(Long templateId); - - /** - * 基于运费模板编号数组和收件人地址区域编号,获取匹配运费模板 - * - * @param ids 编号列表 - * @param areaId 区域编号 - * @return Map (templateId -> 运费模板设置) - */ - Map getExpressTemplateMapByIdsAndArea(Collection ids, Integer areaId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java deleted file mode 100644 index c939e85310..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java +++ /dev/null @@ -1,218 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.*; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressTemplateChargeMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressTemplateFreeMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressTemplateMapper; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressTemplateConvert.INSTANCE; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_TEMPLATE_NAME_DUPLICATE; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_TEMPLATE_NOT_EXISTS; - -/** - * 快递运费模板 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTemplateService { - - @Resource - private DeliveryExpressTemplateMapper expressTemplateMapper; - @Resource - private DeliveryExpressTemplateChargeMapper expressTemplateChargeMapper; - @Resource - private DeliveryExpressTemplateFreeMapper expressTemplateFreeMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createDeliveryExpressTemplate(DeliveryExpressTemplateCreateReqVO createReqVO) { - // 校验模板名是否唯一 - validateTemplateNameUnique(createReqVO.getName(), null); - - // 插入 - DeliveryExpressTemplateDO template = INSTANCE.convert(createReqVO); - expressTemplateMapper.insert(template); - // 插入运费模板计费表 - if (CollUtil.isNotEmpty(createReqVO.getCharges())) { - expressTemplateChargeMapper.insertBatch( - INSTANCE.convertTemplateChargeList(template.getId(), createReqVO.getChargeMode(), createReqVO.getCharges()) - ); - } - // 插入运费模板包邮表 - if (CollUtil.isNotEmpty(createReqVO.getFrees())) { - expressTemplateFreeMapper.insertBatch( - INSTANCE.convertTemplateFreeList(template.getId(), createReqVO.getFrees()) - ); - } - return template.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateDeliveryExpressTemplate(DeliveryExpressTemplateUpdateReqVO updateReqVO) { - // 校验存在 - validateDeliveryExpressTemplateExists(updateReqVO.getId()); - // 校验模板名是否唯一 - validateTemplateNameUnique(updateReqVO.getName(), updateReqVO.getId()); - - // 更新运费从表 - updateExpressTemplateCharge(updateReqVO.getId(), updateReqVO.getChargeMode(), updateReqVO.getCharges()); - // 更新包邮从表 - updateExpressTemplateFree(updateReqVO.getId(), updateReqVO.getFrees()); - // 更新模板主表 - DeliveryExpressTemplateDO updateObj = INSTANCE.convert(updateReqVO); - expressTemplateMapper.updateById(updateObj); - } - - private void updateExpressTemplateFree(Long templateId, List frees) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = expressTemplateFreeMapper.selectListByTemplateId(templateId); - List newList = INSTANCE.convertTemplateFreeList(templateId, frees); - List> diffList = CollectionUtils.diffList(oldList, newList, - (oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getTemplateId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - expressTemplateFreeMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - expressTemplateFreeMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - expressTemplateFreeMapper.deleteBatchIds(convertList(diffList.get(2), DeliveryExpressTemplateFreeDO::getId)); - } - } - - private void updateExpressTemplateCharge(Long templateId, Integer chargeMode, List charges) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = expressTemplateChargeMapper.selectListByTemplateId(templateId); - List newList = INSTANCE.convertTemplateChargeList(templateId, chargeMode, charges); - List> diffList = diffList(oldList, newList, (oldVal, newVal) -> { - boolean same = ObjectUtil.equal(oldVal.getId(), newVal.getId()); - if (same) { - newVal.setChargeMode(chargeMode); // 更新下收费模式 - } - return same; - }); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - expressTemplateChargeMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - expressTemplateChargeMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - expressTemplateChargeMapper.deleteBatchIds(convertList(diffList.get(2), DeliveryExpressTemplateChargeDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteDeliveryExpressTemplate(Long id) { - // 校验存在 - validateDeliveryExpressTemplateExists(id); - - // 删除主表 - expressTemplateMapper.deleteById(id); - // 删除运费从表 - expressTemplateChargeMapper.deleteByTemplateId(id); - // 删除包邮从表 - expressTemplateFreeMapper.deleteByTemplateId(id); - } - - /** - * 校验运费模板名是否唯一 - * - * @param name 模板名称 - * @param id 运费模板编号,可以为 null - */ - private void validateTemplateNameUnique(String name, Long id) { - DeliveryExpressTemplateDO template = expressTemplateMapper.selectByName(name); - if (template == null) { - return; - } - // 如果 id 为空 - if (id == null) { - throw exception(EXPRESS_TEMPLATE_NAME_DUPLICATE); - } - if (!template.getId().equals(id)) { - throw exception(EXPRESS_TEMPLATE_NAME_DUPLICATE); - } - } - - private void validateDeliveryExpressTemplateExists(Long id) { - if (expressTemplateMapper.selectById(id) == null) { - throw exception(EXPRESS_TEMPLATE_NOT_EXISTS); - } - } - - @Override - public DeliveryExpressTemplateDetailRespVO getDeliveryExpressTemplate(Long id) { - List chargeList = expressTemplateChargeMapper.selectListByTemplateId(id); - List freeList = expressTemplateFreeMapper.selectListByTemplateId(id); - DeliveryExpressTemplateDO template = expressTemplateMapper.selectById(id); - return INSTANCE.convert(template, chargeList, freeList); - } - - @Override - public List getDeliveryExpressTemplateList(Collection ids) { - return expressTemplateMapper.selectBatchIds(ids); - } - - @Override - public List getDeliveryExpressTemplateList() { - return expressTemplateMapper.selectList(); - } - - @Override - public PageResult getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO) { - return expressTemplateMapper.selectPage(pageReqVO); - } - - @Override - public DeliveryExpressTemplateDO validateDeliveryExpressTemplate(Long templateId) { - DeliveryExpressTemplateDO template = expressTemplateMapper.selectById(templateId); - if (template == null) { - throw exception(EXPRESS_TEMPLATE_NOT_EXISTS); - } - return template; - } - - @Override - public Map getExpressTemplateMapByIdsAndArea(Collection ids, Integer areaId) { - Assert.notNull(areaId, "区域编号 {} 不能为空", areaId); - // 查询 template 数组 - if (CollUtil.isEmpty(ids)) { - return Collections.emptyMap(); - } - List templateList = expressTemplateMapper.selectBatchIds(ids); - // 查询 templateCharge 数组 - List chargeList = expressTemplateChargeMapper.selectByTemplateIds(ids); - // 查询 templateFree 数组 - List freeList = expressTemplateFreeMapper.selectListByTemplateIds(ids); - - // 组合运费模板配置 RespBO - return INSTANCE.convertMap(areaId, templateList, chargeList, freeList); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java deleted file mode 100644 index 300b24d0e8..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 自提门店 Service 接口 - * - * @author jason - */ -public interface DeliveryPickUpStoreService { - - /** - * 创建自提门店 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDeliveryPickUpStore(@Valid DeliveryPickUpStoreCreateReqVO createReqVO); - - /** - * 更新自提门店 - * - * @param updateReqVO 更新信息 - */ - void updateDeliveryPickUpStore(@Valid DeliveryPickUpStoreUpdateReqVO updateReqVO); - - /** - * 删除自提门店 - * - * @param id 编号 - */ - void deleteDeliveryPickUpStore(Long id); - - /** - * 获得自提门店 - * - * @param id 编号 - * @return 自提门店 - */ - DeliveryPickUpStoreDO getDeliveryPickUpStore(Long id); - - /** - * 获得自提门店列表 - * - * @param ids 编号 - * @return 自提门店列表 - */ - List getDeliveryPickUpStoreList(Collection ids); - - /** - * 获得自提门店分页 - * - * @param pageReqVO 分页查询 - * @return 自提门店分页 - */ - PageResult getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO); - - /** - * 获得指定状态的自提门店列表 - * - * @param status 状态 - * @return 自提门店列表 - */ - List getDeliveryPickUpStoreListByStatus(Integer status); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java deleted file mode 100644 index 278235f653..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PICK_UP_STORE_NOT_EXISTS; - -/** - * 自提门店 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreService { - - @Resource - private DeliveryPickUpStoreMapper deliveryPickUpStoreMapper; - - @Override - public Long createDeliveryPickUpStore(DeliveryPickUpStoreCreateReqVO createReqVO) { - // 插入 - DeliveryPickUpStoreDO deliveryPickUpStore = DeliveryPickUpStoreConvert.INSTANCE.convert(createReqVO); - deliveryPickUpStoreMapper.insert(deliveryPickUpStore); - // 返回 - return deliveryPickUpStore.getId(); - } - - @Override - public void updateDeliveryPickUpStore(DeliveryPickUpStoreUpdateReqVO updateReqVO) { - // 校验存在 - validateDeliveryPickUpStoreExists(updateReqVO.getId()); - // 更新 - DeliveryPickUpStoreDO updateObj = DeliveryPickUpStoreConvert.INSTANCE.convert(updateReqVO); - deliveryPickUpStoreMapper.updateById(updateObj); - } - - @Override - public void deleteDeliveryPickUpStore(Long id) { - // 校验存在 - validateDeliveryPickUpStoreExists(id); - // 删除 - deliveryPickUpStoreMapper.deleteById(id); - } - - private void validateDeliveryPickUpStoreExists(Long id) { - if (deliveryPickUpStoreMapper.selectById(id) == null) { - throw exception(PICK_UP_STORE_NOT_EXISTS); - } - } - - @Override - public DeliveryPickUpStoreDO getDeliveryPickUpStore(Long id) { - return deliveryPickUpStoreMapper.selectById(id); - } - - @Override - public List getDeliveryPickUpStoreList(Collection ids) { - return deliveryPickUpStoreMapper.selectBatchIds(ids); - } - - @Override - public PageResult getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO) { - return deliveryPickUpStoreMapper.selectPage(pageReqVO); - } - - @Override - public List getDeliveryPickUpStoreListByStatus(Integer status) { - return deliveryPickUpStoreMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/bo/DeliveryExpressTemplateRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/bo/DeliveryExpressTemplateRespBO.java deleted file mode 100644 index db0af04eb7..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/bo/DeliveryExpressTemplateRespBO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery.bo; - -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryExpressChargeModeEnum; -import lombok.Data; - -/** - * 运费模板配置 Resp BO - * - * @author jason - */ -@Data -public class DeliveryExpressTemplateRespBO { - - /** - * 配送计费方式 - * - * 枚举 {@link DeliveryExpressChargeModeEnum} - */ - private Integer chargeMode; - - /** - * 运费模板快递运费设置 - */ - private Charge charge; - - /** - * 运费模板包邮设置 - */ - private Free free; - - /** - * 快递运费模板费用配置 BO - * - * @author jason - */ - @Data - public static class Charge { - - /** - * 首件数量(件数,重量,或体积) - */ - private Double startCount; - /** - * 起步价,单位:分 - */ - private Integer startPrice; - /** - * 续件数量(件, 重量,或体积) - */ - private Double extraCount; - /** - * 额外价,单位:分 - */ - private Integer extraPrice; - } - - /** - * 快递运费模板包邮配置 BO - * - * @author jason - */ - @Data - public static class Free { - - /** - * 包邮金额,单位:分 - * - * 订单总金额 > 包邮金额时,才免运费 - */ - private Integer freePrice; - - /** - * 包邮件数 - * - * 订单总件数 > 包邮件数时,才免运费 - */ - private Integer freeCount; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageService.java deleted file mode 100644 index dce5faf0eb..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageService.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.message; - -import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; - -/** - * Trade 消息 service 接口 - * - * @author HUIHUI - */ -public interface TradeMessageService { - - /** - * 订单发货时发送通知 - * - * @param reqBO 发送消息 - */ - void sendMessageWhenDeliveryOrder(TradeOrderMessageWhenDeliveryOrderReqBO reqBO); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java deleted file mode 100644 index eefd26c6e1..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.message; - -import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; -import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; -import cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants; -import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -/** - * Trade 消息 service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class TradeMessageServiceImpl implements TradeMessageService { - - @Resource - private NotifyMessageSendApi notifyMessageSendApi; - - @Override - public void sendMessageWhenDeliveryOrder(TradeOrderMessageWhenDeliveryOrderReqBO reqBO) { - if (true) { - return; - } - // 1、构造消息 - Map msgMap = new HashMap<>(2); - msgMap.put("orderId", reqBO.getOrderId()); - msgMap.put("deliveryMessage", reqBO.getMessage()); - // TODO 芋艿:看下模版 - // 2、发送站内信 - notifyMessageSendApi.sendSingleMessageToMember( - new NotifySendSingleToUserReqDTO() - .setUserId(reqBO.getUserId()) - .setTemplateCode(MessageTemplateConstants.ORDER_DELIVERY) - .setTemplateParams(msgMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/bo/TradeOrderMessageWhenDeliveryOrderReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/bo/TradeOrderMessageWhenDeliveryOrderReqBO.java deleted file mode 100644 index 6e903822fd..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/bo/TradeOrderMessageWhenDeliveryOrderReqBO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.message.bo; - -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * 订单发货时通知创建 Req BO - * - * @author HUIHUI - */ -@Data -public class TradeOrderMessageWhenDeliveryOrderReqBO { - - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 消息 - */ - @NotEmpty(message = "发送消息不能为空") - private String message; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogService.java deleted file mode 100644 index a08f013988..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogService.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeOrderLogCreateReqBO; -import org.springframework.scheduling.annotation.Async; - -import java.util.List; - -/** - * 交易下单日志 Service 接口 - * - * @author 陈賝 - * @since 2023/7/6 15:44 - */ -public interface TradeOrderLogService { - - /** - * 创建交易下单日志 - * - * @param logDTO 日志记录 - * @author 陈賝 - * @since 2023/7/6 15:45 - */ - @Async - void createOrderLog(TradeOrderLogCreateReqBO logDTO); - - /** - * 获得交易订单日志列表 - * - * @param orderId 订单编号 - * @return 交易订单日志列表 - */ - List getOrderLogListByOrderId(Long orderId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogServiceImpl.java deleted file mode 100644 index a57a9d9c93..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderLogConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderLogMapper; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeOrderLogCreateReqBO; -import org.springframework.stereotype.Service; - -import jakarta.annotation.Resource; -import java.util.List; - -/** - * 交易下单日志 Service 实现类 - * - * @author 陈賝 - * @since 2023/7/6 15:44 - */ -@Service -public class TradeOrderLogServiceImpl implements TradeOrderLogService { - - @Resource - private TradeOrderLogMapper tradeOrderLogMapper; - - @Override - public void createOrderLog(TradeOrderLogCreateReqBO createReqBO) { - tradeOrderLogMapper.insert(TradeOrderLogConvert.INSTANCE.convert(createReqBO)); - } - - @Override - public List getOrderLogListByOrderId(Long orderId) { - return tradeOrderLogMapper.selectListByOrderId(orderId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java deleted file mode 100644 index 445792232a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java +++ /dev/null @@ -1,158 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; - -import java.util.Collection; -import java.util.List; - -import static java.util.Collections.singleton; - -/** - * 交易订单【读】 Service 接口 - * - * @author 芋道源码 - */ -public interface TradeOrderQueryService { - - // =================== Order =================== - - /** - * 获得指定编号的交易订单 - * - * @param id 交易订单编号 - * @return 交易订单 - */ - TradeOrderDO getOrder(Long id); - - /** - * 获得指定用户,指定的交易订单 - * - * @param userId 用户编号 - * @param id 交易订单编号 - * @return 交易订单 - */ - TradeOrderDO getOrder(Long userId, Long id); - - /** - * 获得指定用户,指定活动,指定状态的交易订单 - * - * @param userId 用户编号 - * @param combinationActivityId 活动编号 - * @param status 订单状态 - * @return 交易订单 - */ - TradeOrderDO getOrderByUserIdAndStatusAndCombination(Long userId, Long combinationActivityId, Integer status); - - /** - * 获得订单列表 - * - * @param ids 订单编号数组 - * @return 订单列表 - */ - List getOrderList(Collection ids); - - /** - * 【管理员】获得交易订单分页 - * - * @param reqVO 分页请求 - * @return 交易订单 - */ - PageResult getOrderPage(TradeOrderPageReqVO reqVO); - - /** - * 获得订单统计 - * - * @param reqVO 请求参数 - * @return 订单统计 - */ - TradeOrderSummaryRespVO getOrderSummary(TradeOrderPageReqVO reqVO); - - /** - * 【会员】获得交易订单分页 - * - * @param userId 用户编号 - * @param reqVO 分页请求 - * @return 交易订单 - */ - PageResult getOrderPage(Long userId, AppTradeOrderPageReqVO reqVO); - - /** - * 【会员】获得交易订单数量 - * - * @param userId 用户编号 - * @param status 订单状态。如果为空,则不进行筛选 - * @param commonStatus 评价状态。如果为空,则不进行筛选 - * @return 订单数量 - */ - Long getOrderCount(Long userId, Integer status, Boolean commonStatus); - - /** - * 【前台】获得订单的物流轨迹 - * - * @param id 订单编号 - * @param userId 用户编号 - * @return 物流轨迹数组 - */ - List getExpressTrackList(Long id, Long userId); - - /** - * 【后台】获得订单的物流轨迹 - * - * @param id 订单编号 - * @return 物流轨迹数组 - */ - List getExpressTrackList(Long id); - - /** - * 【会员】在指定秒杀活动下,用户购买的商品数量 - * - * @param userId 用户编号 - * @param activityId 活动编号 - * @return 秒杀商品数量 - */ - int getSeckillProductCount(Long userId, Long activityId); - - // =================== Order Item =================== - - /** - * 获得指定用户,指定的交易订单项 - * - * @param userId 用户编号 - * @param itemId 交易订单项编号 - * @return 交易订单项 - */ - TradeOrderItemDO getOrderItem(Long userId, Long itemId); - - /** - * 获得交易订单项 - * - * @param id 交易订单项编号 itemId - * @return 交易订单项 - */ - TradeOrderItemDO getOrderItem(Long id); - - /** - * 根据交易订单编号,查询交易订单项 - * - * @param orderId 交易订单编号 - * @return 交易订单项数组 - */ - default List getOrderItemListByOrderId(Long orderId) { - return getOrderItemListByOrderId(singleton(orderId)); - } - - /** - * 根据交易订单编号数组,查询交易订单项 - * - * @param orderIds 交易订单编号数组 - * @return 交易订单项数组 - */ - List getOrderItemListByOrderId(Collection orderIds); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java deleted file mode 100644 index 3d15220bb1..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java +++ /dev/null @@ -1,260 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; -import cn.iocoder.yudao.module.trade.dal.redis.RedisKeyConstants; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderRefundStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClientFactory; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; - -import jakarta.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_NOT_EXISTS; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND; - -/** - * 交易订单【读】 Service 实现类 - * - * @author 芋道源码 - */ -@Service -public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { - - @Resource - private ExpressClientFactory expressClientFactory; - - @Resource - private TradeOrderMapper tradeOrderMapper; - @Resource - private TradeOrderItemMapper tradeOrderItemMapper; - - @Resource - private DeliveryExpressService deliveryExpressService; - - @Resource - private MemberUserApi memberUserApi; - - // =================== Order =================== - - @Override - public TradeOrderDO getOrder(Long id) { - return tradeOrderMapper.selectById(id); - } - - @Override - public TradeOrderDO getOrder(Long userId, Long id) { - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order != null - && ObjectUtil.notEqual(order.getUserId(), userId)) { - return null; - } - return order; - } - - @Override - public TradeOrderDO getOrderByUserIdAndStatusAndCombination(Long userId, Long combinationActivityId, Integer status) { - return tradeOrderMapper.selectByUserIdAndCombinationActivityIdAndStatus(userId, combinationActivityId, status); - } - - @Override - public List getOrderList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return tradeOrderMapper.selectBatchIds(ids); - } - - @Override - public PageResult getOrderPage(TradeOrderPageReqVO reqVO) { - // 根据用户查询条件构建用户编号列表 - Set userIds = buildQueryConditionUserIds(reqVO); - if (userIds == null) { // 没查询到用户,说明肯定也没他的订单 - return PageResult.empty(); - } - // 分页查询 - return tradeOrderMapper.selectPage(reqVO, userIds); - } - - private Set buildQueryConditionUserIds(TradeOrderPageReqVO reqVO) { - // 获得 userId 相关的查询 - Set userIds = new HashSet<>(); - if (StrUtil.isNotEmpty(reqVO.getUserMobile())) { - MemberUserRespDTO user = memberUserApi.getUserByMobile(reqVO.getUserMobile()); - if (user == null) { // 没查询到用户,说明肯定也没他的订单 - return null; - } - userIds.add(user.getId()); - } - if (StrUtil.isNotEmpty(reqVO.getUserNickname())) { - List users = memberUserApi.getUserListByNickname(reqVO.getUserNickname()); - if (CollUtil.isEmpty(users)) { // 没查询到用户,说明肯定也没他的订单 - return null; - } - userIds.addAll(convertSet(users, MemberUserRespDTO::getId)); - } - return userIds; - } - - @Override - public TradeOrderSummaryRespVO getOrderSummary(TradeOrderPageReqVO reqVO) { - // 根据用户查询条件构建用户编号列表 - Set userIds = buildQueryConditionUserIds(reqVO); - if (userIds == null) { // 没查询到用户,说明肯定也没他的订单 - return new TradeOrderSummaryRespVO(); - } - // 查询每个售后状态对应的数量、金额 - List> list = tradeOrderMapper.selectOrderSummaryGroupByRefundStatus(reqVO, null); - - TradeOrderSummaryRespVO vo = new TradeOrderSummaryRespVO().setAfterSaleCount(0L).setAfterSalePrice(0L); - for (Map map : list) { - Long count = MapUtil.getLong(map, "count", 0L); - Long price = MapUtil.getLong(map, "price", 0L); - // 未退款的计入订单,部分退款、全部退款计入售后 - if (TradeOrderRefundStatusEnum.NONE.getStatus().equals(MapUtil.getInt(map, "refundStatus"))) { - vo.setOrderCount(count).setOrderPayPrice(price); - } else { - vo.setAfterSaleCount(vo.getAfterSaleCount() + count).setAfterSalePrice(vo.getAfterSalePrice() + price); - } - } - return vo; - } - - @Override - public PageResult getOrderPage(Long userId, AppTradeOrderPageReqVO reqVO) { - return tradeOrderMapper.selectPage(reqVO, userId); - } - - @Override - public Long getOrderCount(Long userId, Integer status, Boolean commentStatus) { - return tradeOrderMapper.selectCountByUserIdAndStatus(userId, status, commentStatus); - } - - @Override - public List getExpressTrackList(Long id, Long userId) { - // 查询订单 - TradeOrderDO order = tradeOrderMapper.selectByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 查询物流 - return getExpressTrackList(order); - } - - @Override - public List getExpressTrackList(Long id) { - // 查询订单 - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 查询物流 - return getExpressTrackList(order); - } - - @Override - public int getSeckillProductCount(Long userId, Long activityId) { - // 获得订单列表 - List orders = tradeOrderMapper.selectListByUserIdAndSeckillActivityId(userId, activityId); - orders.removeIf(order -> TradeOrderStatusEnum.isCanceled(order.getStatus())); // 过滤掉【已取消】的订单 - if (CollUtil.isEmpty(orders)) { - return 0; - } - // 获得订单项列表 - return tradeOrderItemMapper.selectProductSumByOrderId(convertSet(orders, TradeOrderDO::getId)); - } - - /** - * 获得订单的物流轨迹 - * - * @param order 订单 - * @return 物流轨迹 - */ - private List getExpressTrackList(TradeOrderDO order) { - if (order.getLogisticsId() == null) { - return Collections.emptyList(); - } - // 查询物流公司 - DeliveryExpressDO express = deliveryExpressService.getDeliveryExpress(order.getLogisticsId()); - if (express == null) { - throw exception(EXPRESS_NOT_EXISTS); - } - // 查询物流轨迹 - return getSelf().getExpressTrackList(express.getCode(), order.getLogisticsNo(), order.getReceiverMobile()); - } - - /** - * 查询物流轨迹 - * 加个 spring 缓存,30 分钟;主要考虑及时性要求不高,但是每次调用需要钱;TODO @艿艿:这个时间不会搞了。。。交给你了哈哈哈 - * - * @param code 快递公司编码 - * @param logisticsNo 发货快递单号 - * @param receiverMobile 收、寄件人的电话号码 - * @return 物流轨迹 - */ - @Cacheable(cacheNames = RedisKeyConstants.EXPRESS_TRACK, key = "#code + '-' + #logisticsNo + '-' + #receiverMobile", - condition = "#result != null") - public List getExpressTrackList(String code, String logisticsNo, String receiverMobile) { - // 查询物流轨迹 - return expressClientFactory.getDefaultExpressClient().getExpressTrackList( - new ExpressTrackQueryReqDTO().setExpressCode(code).setLogisticsNo(logisticsNo) - .setPhone(receiverMobile)); - } - - - // =================== Order Item =================== - - @Override - public TradeOrderItemDO getOrderItem(Long userId, Long itemId) { - TradeOrderItemDO orderItem = tradeOrderItemMapper.selectById(itemId); - if (orderItem != null - && ObjectUtil.notEqual(orderItem.getUserId(), userId)) { - return null; - } - return orderItem; - } - - @Override - public TradeOrderItemDO getOrderItem(Long id) { - return tradeOrderItemMapper.selectById(id); - } - - @Override - public List getOrderItemListByOrderId(Collection orderIds) { - if (CollUtil.isEmpty(orderIds)) { - return Collections.emptyList(); - } - return tradeOrderItemMapper.selectListByOrderId(orderIds); - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private TradeOrderQueryServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java deleted file mode 100644 index b26d84c65b..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java +++ /dev/null @@ -1,201 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdatePriceReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; - -import jakarta.validation.constraints.NotNull; - -/** - * 交易订单【写】Service 接口 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface TradeOrderUpdateService { - - // =================== Order =================== - - /** - * 获得订单结算信息 - * - * @param userId 登录用户 - * @param settlementReqVO 订单结算请求 - * @return 订单结算结果 - */ - AppTradeOrderSettlementRespVO settlementOrder(Long userId, AppTradeOrderSettlementReqVO settlementReqVO); - - /** - * 【会员】创建交易订单 - * - * @param userId 登录用户 - * @param userIp 用户 IP 地址 - * @param createReqVO 创建交易订单请求模型 - * @param terminal 终端 {@link TerminalEnum} - * @return 交易订单的 - */ - TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO, Integer terminal); - - /** - * 更新交易订单已支付 - * - * @param id 交易订单编号 - * @param payOrderId 支付订单编号 - */ - void updateOrderPaid(Long id, Long payOrderId); - - /** - * 【管理员】发货交易订单 - * - * @param deliveryReqVO 发货请求 - */ - void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO); - - /** - * 【会员】收货交易订单 - * - * @param userId 用户编号 - * @param id 订单编号 - */ - void receiveOrderByMember(Long userId, Long id); - - /** - * 【系统】自动收货交易订单 - * - * @return 收货数量 - */ - int receiveOrderBySystem(); - - /** - * 【会员】取消交易订单 - * - * @param userId 用户编号 - * @param id 订单编号 - */ - void cancelOrderByMember(Long userId, Long id); - - /** - * 【系统】自动取消订单 - * - * @return 取消数量 - */ - int cancelOrderBySystem(); - - /** - * 【会员】删除订单 - * - * @param userId 用户编号 - * @param id 订单编号 - */ - void deleteOrder(Long userId, Long id); - - /** - * 【管理员】交易订单备注 - * - * @param reqVO 请求 - */ - void updateOrderRemark(TradeOrderRemarkReqVO reqVO); - - /** - * 【管理员】调整价格 - * - * @param reqVO 请求 - */ - void updateOrderPrice(TradeOrderUpdatePriceReqVO reqVO); - - /** - * 【管理员】调整地址 - * - * @param reqVO 请求 - */ - void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO); - - /** - * 【管理员】核销订单 - * - * @param id 订单编号 - */ - void pickUpOrderByAdmin(Long id); - - /** - * 【管理员】核销订单 - * - * @param pickUpVerifyCode 自提核销码 - */ - void pickUpOrderByAdmin(String pickUpVerifyCode); - - /** - * 【管理员】根据自提核销码,查询订单 - * - * @param pickUpVerifyCode 自提核销码 - */ - TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode); - - // =================== Order Item =================== - - /** - * 当售后申请后,更新交易订单项的售后状态 - * - * @param id 交易订单项编号 - * @param afterSaleId 售后单编号 - */ - void updateOrderItemWhenAfterSaleCreate(@NotNull Long id, @NotNull Long afterSaleId); - - /** - * 当售后完成后,更新交易订单项的售后状态 - * - * @param id 交易订单项编号 - * @param refundPrice 退款金额 - */ - void updateOrderItemWhenAfterSaleSuccess(@NotNull Long id, @NotNull Integer refundPrice); - - /** - * 当售后取消(用户取消、管理员驳回、管理员拒绝收货)后,更新交易订单项的售后状态 - * - * @param id 交易订单项编号 - */ - void updateOrderItemWhenAfterSaleCancel(@NotNull Long id); - - /** - * 【会员】创建订单项的评论 - * - * @param userId 用户编号 - * @param createReqVO 创建请求 - * @return 得到评价 id - */ - Long createOrderItemCommentByMember(Long userId, AppTradeOrderItemCommentCreateReqVO createReqVO); - - /** - * 【系统】创建订单项的评论 - * - * @return 被评论的订单数 - */ - int createOrderItemCommentBySystem(); - - /** - * 更新拼团相关信息到订单 - * - * @param orderId 订单编号 - * @param activityId 拼团活动编号 - * @param combinationRecordId 拼团记录编号 - * @param headId 团长编号 - */ - void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId); - - // TODO 芋艿:拼团取消,不调这个接口哈; - /** - * 取消支付订单 - * - * @param userId 用户编号 - * @param orderId 订单编号 - */ - void cancelPaidOrder(Long userId, Long orderId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java deleted file mode 100644 index 40e26a2b78..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ /dev/null @@ -1,900 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.RandomUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.module.member.api.address.MemberAddressApi; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdatePriceReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; -import cn.iocoder.yudao.module.trade.dal.redis.no.TradeNoRedisDAO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.*; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.framework.order.core.annotations.TradeOrderLog; -import cn.iocoder.yudao.module.trade.framework.order.core.utils.TradeOrderLogUtils; -import cn.iocoder.yudao.module.trade.service.cart.CartService; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import cn.iocoder.yudao.module.trade.service.message.TradeMessageService; -import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; -import cn.iocoder.yudao.module.trade.service.order.handler.TradeOrderHandler; -import cn.iocoder.yudao.module.trade.service.price.TradePriceService; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper; -import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.minusTime; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 交易订单【写】Service 实现类 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -@Service -@Slf4j -public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { - - @Resource - private TradeOrderMapper tradeOrderMapper; - @Resource - private TradeOrderItemMapper tradeOrderItemMapper; - @Resource - private TradeNoRedisDAO tradeNoRedisDAO; - - @Resource - private List tradeOrderHandlers; - - @Resource - private CartService cartService; - @Resource - private TradePriceService tradePriceService; - @Resource - private DeliveryExpressService deliveryExpressService; - @Resource - private TradeMessageService tradeMessageService; - - @Resource - private PayOrderApi payOrderApi; - @Resource - private MemberAddressApi addressApi; - @Resource - private ProductCommentApi productCommentApi; - - @Resource - private TradeOrderProperties tradeOrderProperties; - - // =================== Order =================== - - @Override - public AppTradeOrderSettlementRespVO settlementOrder(Long userId, AppTradeOrderSettlementReqVO settlementReqVO) { - // 1. 获得收货地址 - MemberAddressRespDTO address = getAddress(userId, settlementReqVO.getAddressId()); - if (address != null) { - settlementReqVO.setAddressId(address.getId()); - } - - // 2. 计算价格 - TradePriceCalculateRespBO calculateRespBO = calculatePrice(userId, settlementReqVO); - - // 3. 拼接返回 - return TradeOrderConvert.INSTANCE.convert(calculateRespBO, address); - } - - /** - * 获得用户地址 - * - * @param userId 用户编号 - * @param addressId 地址编号 - * @return 地址 - */ - private MemberAddressRespDTO getAddress(Long userId, Long addressId) { - if (addressId != null) { - return addressApi.getAddress(addressId, userId); - } - return addressApi.getDefaultAddress(userId); - } - - /** - * 计算订单价格 - * - * @param userId 用户编号 - * @param settlementReqVO 结算信息 - * @return 订单价格 - */ - private TradePriceCalculateRespBO calculatePrice(Long userId, AppTradeOrderSettlementReqVO settlementReqVO) { - // 1. 如果来自购物车,则获得购物车的商品 - List cartList = cartService.getCartList(userId, - convertSet(settlementReqVO.getItems(), AppTradeOrderSettlementReqVO.Item::getCartId)); - - // 2. 计算价格 - TradePriceCalculateReqBO calculateReqBO = TradeOrderConvert.INSTANCE.convert(userId, settlementReqVO, cartList); - calculateReqBO.getItems().forEach(item -> Assert.isTrue(item.getSelected(), // 防御性编程,保证都是选中的 - "商品({}) 未设置为选中", item.getSkuId())); - return tradePriceService.calculatePrice(calculateReqBO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CREATE) - public TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO, Integer terminal) { - // 1.1 价格计算 - TradePriceCalculateRespBO calculateRespBO = calculatePrice(userId, createReqVO); - // 1.2 构建订单 - TradeOrderDO order = buildTradeOrder(userId, userIp, createReqVO, calculateRespBO, terminal); - List orderItems = buildTradeOrderItems(order, calculateRespBO); - - // 2. 订单创建前的逻辑 - tradeOrderHandlers.forEach(handler -> handler.beforeOrderCreate(order, orderItems)); - - // 3. 保存订单 - tradeOrderMapper.insert(order); - orderItems.forEach(orderItem -> orderItem.setOrderId(order.getId())); - tradeOrderItemMapper.insertBatch(orderItems); - - // 4. 订单创建后的逻辑 - afterCreateTradeOrder(order, orderItems, createReqVO); - return order; - } - - private TradeOrderDO buildTradeOrder(Long userId, String clientIp, AppTradeOrderCreateReqVO createReqVO, - TradePriceCalculateRespBO calculateRespBO, Integer terminal) { - TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(userId, clientIp, createReqVO, calculateRespBO); - order.setType(calculateRespBO.getType()); - order.setNo(tradeNoRedisDAO.generate(TradeNoRedisDAO.TRADE_ORDER_NO_PREFIX)); - order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus()); - order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()); - order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum)); - order.setTerminal(terminal); - // 支付 + 退款信息 - order.setAdjustPrice(0).setPayStatus(false); - order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0); - // 物流信息 - order.setDeliveryType(createReqVO.getDeliveryType()); - if (Objects.equals(createReqVO.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getType())) { - MemberAddressRespDTO address = addressApi.getAddress(createReqVO.getAddressId(), userId); - Assert.notNull(address, "地址({}) 不能为空", createReqVO.getAddressId()); // 价格计算时,已经计算 - order.setReceiverName(address.getName()).setReceiverMobile(address.getMobile()) - .setReceiverAreaId(address.getAreaId()).setReceiverDetailAddress(address.getDetailAddress()); - } else if (Objects.equals(createReqVO.getDeliveryType(), DeliveryTypeEnum.PICK_UP.getType())) { - order.setReceiverName(createReqVO.getReceiverName()).setReceiverMobile(createReqVO.getReceiverMobile()); - order.setPickUpVerifyCode(RandomUtil.randomNumbers(8)); // 随机一个核销码,长度为 8 位 - } - return order; - } - - private List buildTradeOrderItems(TradeOrderDO tradeOrderDO, - TradePriceCalculateRespBO calculateRespBO) { - return TradeOrderConvert.INSTANCE.convertList(tradeOrderDO, calculateRespBO); - } - - /** - * 订单创建后,执行后置逻辑 - *

- * 例如说:优惠劵的扣减、积分的扣减、支付单的创建等等 - * - * @param order 订单 - * @param orderItems 订单项 - * @param createReqVO 创建订单请求 - */ - private void afterCreateTradeOrder(TradeOrderDO order, List orderItems, - AppTradeOrderCreateReqVO createReqVO) { - // 1. 执行订单创建后置处理器 - tradeOrderHandlers.forEach(handler -> handler.afterOrderCreate(order, orderItems)); - - // 2. 删除购物车商品 - Set cartIds = convertSet(createReqVO.getItems(), AppTradeOrderSettlementReqVO.Item::getCartId); - if (CollUtil.isNotEmpty(cartIds)) { - cartService.deleteCart(order.getUserId(), cartIds); - } - - // 3. 生成预支付 - createPayOrder(order, orderItems); - - // 4. 插入订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), null, order.getStatus()); - - // TODO @LeeYan9: 是可以思考下, 订单的营销优惠记录, 应该记录在哪里, 微信讨论起来! - } - - private void createPayOrder(TradeOrderDO order, List orderItems) { - // 创建支付单,用于后续的支付 - PayOrderCreateReqDTO payOrderCreateReqDTO = TradeOrderConvert.INSTANCE.convert( - order, orderItems, tradeOrderProperties); - Long payOrderId = payOrderApi.createOrder(payOrderCreateReqDTO); - - // 更新到交易单上 - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setPayOrderId(payOrderId)); - order.setPayOrderId(payOrderId); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_PAY) - public void updateOrderPaid(Long id, Long payOrderId) { - // 1. 校验并获得交易订单(可支付) - KeyValue orderResult = validateOrderPayable(id, payOrderId); - TradeOrderDO order = orderResult.getKey(); - PayOrderRespDTO payOrder = orderResult.getValue(); - - // 2. 更新 TradeOrderDO 状态为已支付,等待发货 - int updateCount = tradeOrderMapper.updateByIdAndStatus(id, order.getStatus(), - new TradeOrderDO().setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()).setPayStatus(true) - .setPayTime(LocalDateTime.now()).setPayChannelCode(payOrder.getChannelCode())); - if (updateCount == 0) { - throw exception(ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - - // 3. 执行 TradeOrderHandler 的后置处理 - List orderItems = tradeOrderItemMapper.selectListByOrderId(id); - tradeOrderHandlers.forEach(handler -> handler.afterPayOrder(order, orderItems)); - - // 4. 记录订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.UNDELIVERED.getStatus()); - TradeOrderLogUtils.setUserInfo(order.getUserId(), UserTypeEnum.MEMBER.getValue()); - } - - /** - * 校验交易订单满足被支付的条件 - *

- * 1. 交易订单未支付 - * 2. 支付单已支付 - * - * @param id 交易订单编号 - * @param payOrderId 支付订单编号 - * @return 交易订单 - */ - private KeyValue validateOrderPayable(Long id, Long payOrderId) { - // 校验订单是否存在 - TradeOrderDO order = validateOrderExists(id); - // 校验订单未支付 - if (!TradeOrderStatusEnum.isUnpaid(order.getStatus()) || order.getPayStatus()) { - log.error("[validateOrderPaid][order({}) 不处于待支付状态,请进行处理!order 数据是:{}]", - id, JsonUtils.toJsonString(order)); - throw exception(ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - // 校验支付订单匹配 - if (ObjectUtil.notEqual(order.getPayOrderId(), payOrderId)) { // 支付单号 - log.error("[validateOrderPaid][order({}) 支付单不匹配({}),请进行处理!order 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(order)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - - // 校验支付单是否存在 - PayOrderRespDTO payOrder = payOrderApi.getOrder(payOrderId); - if (payOrder == null) { - log.error("[validateOrderPaid][order({}) payOrder({}) 不存在,请进行处理!]", id, payOrderId); - throw exception(ORDER_NOT_FOUND); - } - // 校验支付单已支付 - if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) { - log.error("[validateOrderPaid][order({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(payOrder)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS); - } - // 校验支付金额一致 - if (ObjectUtil.notEqual(payOrder.getPrice(), order.getPayPrice())) { - log.error("[validateOrderPaid][order({}) payOrder({}) 支付金额不匹配,请进行处理!order 数据是:{},payOrder 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(order), JsonUtils.toJsonString(payOrder)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH); - } - // 校验支付订单匹配(二次) - if (ObjectUtil.notEqual(payOrder.getMerchantOrderId(), id.toString())) { - log.error("[validateOrderPaid][order({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(payOrder)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - return new KeyValue<>(order, payOrder); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_DELIVERY) - public void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO) { - // 1.1 校验并获得交易订单(可发货) - TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); - // 1.2 校验 deliveryType 是否为快递,是快递才可以发货 - if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getType())) { - throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS); - } - - // 2. 更新订单为已发货 - TradeOrderDO updateOrderObj = new TradeOrderDO(); - // 2.1 快递发货 - DeliveryExpressDO express = null; - if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), TradeOrderDO.LOGISTICS_ID_NULL)) { - express = deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId()); - updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()); - } else { - // 2.2 无需发货 - updateOrderObj.setLogisticsId(0L).setLogisticsNo(""); - } - // 执行更新 - updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now()); - int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj); - if (updateCount == 0) { - throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED); - } - - // 3. 记录订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus(), - MapUtil.builder().put("expressName", express != null ? express.getName() : "") - .put("logisticsNo", express != null ? deliveryReqVO.getLogisticsNo() : "").build()); - - // 4. 发送站内信 - tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO() - .setOrderId(order.getId()).setUserId(order.getUserId()).setMessage(null)); - } - - /** - * 校验交易订单满足被发货的条件 - *

- * 1. 交易订单未发货 - * - * @param id 交易订单编号 - * @return 交易订单 - */ - private TradeOrderDO validateOrderDeliverable(Long id) { - TradeOrderDO order = validateOrderExists(id); - // 1. 校验订单是否未发货 - if (ObjectUtil.notEqual(TradeOrderRefundStatusEnum.NONE.getStatus(), order.getRefundStatus())) { - throw exception(ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE); - } - - // 2. 执行 TradeOrderHandler 前置处理 - tradeOrderHandlers.forEach(handler -> handler.beforeDeliveryOrder(order)); - return order; - } - - @NotNull - private TradeOrderDO validateOrderExists(Long id) { - // 校验订单是否存在 - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - return order; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_RECEIVE) - public void receiveOrderByMember(Long userId, Long id) { - // 校验并获得交易订单(可收货) - TradeOrderDO order = validateOrderReceivable(userId, id); - - // 收货订单 - receiveOrder0(order); - } - - @Override - public int receiveOrderBySystem() { - // 1. 查询过期的待支付订单 - LocalDateTime expireTime = minusTime(tradeOrderProperties.getReceiveExpireTime()); - List orders = tradeOrderMapper.selectListByStatusAndDeliveryTimeLt( - TradeOrderStatusEnum.DELIVERED.getStatus(), expireTime); - if (CollUtil.isEmpty(orders)) { - return 0; - } - - // 2. 遍历执行,逐个取消 - int count = 0; - for (TradeOrderDO order : orders) { - try { - getSelf().receiveOrderBySystem(order); - count++; - } catch (Throwable e) { - log.error("[receiveOrderBySystem][order({}) 自动收货订单异常]", order.getId(), e); - } - } - return count; - } - - /** - * 自动收货单个订单 - * - * @param order 订单 - */ - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_RECEIVE) - public void receiveOrderBySystem(TradeOrderDO order) { - receiveOrder0(order); - } - - /** - * 收货订单的核心实现 - * - * @param order 订单 - */ - private void receiveOrder0(TradeOrderDO order) { - // 更新 TradeOrderDO 状态为已完成 - int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), - new TradeOrderDO().setStatus(TradeOrderStatusEnum.COMPLETED.getStatus()).setReceiveTime(LocalDateTime.now())); - if (updateCount == 0) { - throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED); - } - - // 插入订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus()); - } - - /** - * 校验交易订单满足可售货的条件 - *

- * 1. 交易订单待收货 - * - * @param userId 用户编号 - * @param id 交易订单编号 - * @return 交易订单 - */ - private TradeOrderDO validateOrderReceivable(Long userId, Long id) { - // 校验订单是否存在 - TradeOrderDO order = tradeOrderMapper.selectByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 校验订单是否是待收货状态 - if (!TradeOrderStatusEnum.isDelivered(order.getStatus())) { - throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED); - } - return order; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CANCEL) - public void cancelOrderByMember(Long userId, Long id) { - // 1.1 校验存在 - TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 1.2 校验状态 - if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.UNPAID.getStatus())) { - throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID); - } - - // 2. 取消订单 - cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL); - } - - @Override - public int cancelOrderBySystem() { - // 1. 查询过期的待支付订单 - LocalDateTime expireTime = minusTime(tradeOrderProperties.getPayExpireTime()); - List orders = tradeOrderMapper.selectListByStatusAndCreateTimeLt( - TradeOrderStatusEnum.UNPAID.getStatus(), expireTime); - if (CollUtil.isEmpty(orders)) { - return 0; - } - - // 2. 遍历执行,逐个取消 - int count = 0; - for (TradeOrderDO order : orders) { - try { - getSelf().cancelOrderBySystem(order); - count++; - } catch (Throwable e) { - log.error("[cancelOrderBySystem][order({}) 过期订单异常]", order.getId(), e); - } - } - return count; - } - - /** - * 自动取消单个订单 - * - * @param order 订单 - */ - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_CANCEL) - public void cancelOrderBySystem(TradeOrderDO order) { - cancelOrder0(order, TradeOrderCancelTypeEnum.PAY_TIMEOUT); - } - - /** - * 取消订单的核心实现 - * - * @param order 订单 - * @param cancelType 取消类型 - */ - private void cancelOrder0(TradeOrderDO order, TradeOrderCancelTypeEnum cancelType) { - // 1. 更新 TradeOrderDO 状态为已取消 - int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), - new TradeOrderDO().setStatus(TradeOrderStatusEnum.CANCELED.getStatus()) - .setCancelType(cancelType.getType()).setCancelTime(LocalDateTime.now())); - if (updateCount == 0) { - throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID); - } - - // 2. 执行 TradeOrderHandler 的后置处理 - List orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); - tradeOrderHandlers.forEach(handler -> handler.afterCancelOrder(order, orderItems)); - - // 3. 增加订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.CANCELED.getStatus()); - } - - /** - * 如果金额全部被退款,则取消订单 - * 如果还有未被退款的金额,则无需取消订单 - * - * @param order 订单 - * @param refundPrice 退款金额 - */ - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_CANCEL_AFTER_SALE) - public void cancelOrderByAfterSale(TradeOrderDO order, Integer refundPrice) { - // 1. 更新订单 - if (refundPrice < order.getPayPrice()) { - return; - } - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()) - .setStatus(TradeOrderStatusEnum.CANCELED.getStatus()) - .setCancelType(TradeOrderCancelTypeEnum.AFTER_SALE_CLOSE.getType()).setCancelTime(LocalDateTime.now())); - - // 2. 执行 TradeOrderHandler 的后置处理 - List orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); - tradeOrderHandlers.forEach(handler -> handler.afterCancelOrder(order, orderItems)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_DELETE) - public void deleteOrder(Long userId, Long id) { - // 1.1 校验存在 - TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 1.2 校验状态 - if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.CANCELED.getStatus())) { - throw exception(ORDER_DELETE_FAIL_STATUS_NOT_CANCEL); - } - // 2. 删除订单 - tradeOrderMapper.deleteById(id); - - // 3. 记录日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); - } - - @Override - public void updateOrderRemark(TradeOrderRemarkReqVO reqVO) { - // 校验并获得交易订单 - validateOrderExists(reqVO.getId()); - - // 更新 - TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(reqVO); - tradeOrderMapper.updateById(order); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_PRICE) - public void updateOrderPrice(TradeOrderUpdatePriceReqVO reqVO) { - // 1.1 校验交易订单 - TradeOrderDO order = validateOrderExists(reqVO.getId()); - if (order.getPayStatus()) { - throw exception(ORDER_UPDATE_PRICE_FAIL_PAID); - } - // 1.2 校验调价金额是否变化 - if (order.getAdjustPrice() > 0) { - throw exception(ORDER_UPDATE_PRICE_FAIL_ALREADY); - } - // 1.3 支付价格不能为 0 - int newPayPrice = order.getPayPrice() + order.getAdjustPrice(); - if (newPayPrice <= 0) { - throw exception(ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR); - } - - // 2. 更新订单 - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()) - .setAdjustPrice(reqVO.getAdjustPrice()).setPayPrice(newPayPrice)); - - // 3. 更新 TradeOrderItem,需要做 adjustPrice 的分摊 - List orderOrderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); - List dividePrices = TradePriceCalculatorHelper.dividePrice2(orderOrderItems, newPayPrice); - List updateItems = new ArrayList<>(); - for (int i = 0; i < orderOrderItems.size(); i++) { - TradeOrderItemDO item = orderOrderItems.get(i); - updateItems.add(new TradeOrderItemDO().setId(item.getId()).setAdjustPrice(dividePrices.get(i)) - .setPayPrice(item.getPayPrice() + dividePrices.get(i))); - } - tradeOrderItemMapper.updateBatch(updateItems); - - // 4. 更新支付订单 - payOrderApi.updatePayOrderPrice(order.getPayOrderId(), newPayPrice); - - // 5. 记录订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus(), - MapUtil.builder().put("oldPayPrice", MoneyUtils.fenToYuanStr(order.getPayPrice())) - .put("newPayPrice", MoneyUtils.fenToYuanStr(newPayPrice)).build()); - } - - @Override - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_ADDRESS) - public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) { - // 校验交易订单 - TradeOrderDO order = validateOrderExists(reqVO.getId()); - // 只有待发货状态,才可以修改订单收货地址; - if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())) { - throw exception(ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED); - } - - // 更新 - tradeOrderMapper.updateById(TradeOrderConvert.INSTANCE.convert(reqVO)); - - // 记录订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); - } - - @Override - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE) - public void pickUpOrderByAdmin(Long id) { - getSelf().pickUpOrder(tradeOrderMapper.selectById(id)); - } - - @Override - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE) - public void pickUpOrderByAdmin(String pickUpVerifyCode) { - getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode)); - } - - @Override - public TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode) { - return tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode); - } - - @Transactional(rollbackFor = Exception.class) - public void pickUpOrder(TradeOrderDO order) { - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - if (ObjUtil.notEqual(DeliveryTypeEnum.PICK_UP.getType(), order.getDeliveryType())) { - throw exception(ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP); - } - receiveOrder0(order); - } - - // =================== Order Item =================== - - @Override - public void updateOrderItemWhenAfterSaleCreate(Long id, Long afterSaleId) { - // 更新订单项 - updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), - TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), afterSaleId); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateOrderItemWhenAfterSaleSuccess(Long id, Integer refundPrice) { - // 1.1 更新订单项 - updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), - TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus(), null); - // 1.2 执行 TradeOrderHandler 的后置处理 - TradeOrderItemDO orderItem = tradeOrderItemMapper.selectById(id); - TradeOrderDO order = tradeOrderMapper.selectById(orderItem.getOrderId()); - tradeOrderHandlers.forEach(handler -> handler.afterCancelOrderItem(order, orderItem)); - - // 2.1 更新订单的退款金额、积分 - Integer orderRefundPrice = order.getRefundPrice() + refundPrice; - Integer orderRefundPoint = order.getRefundPoint() + orderItem.getUsePoint(); - Integer refundStatus = isAllOrderItemAfterSaleSuccess(order.getId()) ? - TradeOrderRefundStatusEnum.ALL.getStatus() // 如果都售后成功,则需要取消订单 - : TradeOrderRefundStatusEnum.PART.getStatus(); - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()) - .setRefundStatus(refundStatus) - .setRefundPrice(orderRefundPrice).setRefundPoint(orderRefundPoint)); - // 2.2 如果全部退款,则进行取消订单 - getSelf().cancelOrderByAfterSale(order, orderRefundPrice); - } - - @Override - public void updateOrderItemWhenAfterSaleCancel(Long id) { - // 更新订单项 - updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), - TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), null); - } - - private void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus, - Long afterSaleId) { - // 更新订单项 - int updateCount = tradeOrderItemMapper.updateAfterSaleStatus(id, oldAfterSaleStatus, newAfterSaleStatus, afterSaleId); - if (updateCount <= 0) { - throw exception(ORDER_ITEM_UPDATE_AFTER_SALE_STATUS_FAIL); - } - - } - - /** - * 判断指定订单的所有订单项,是不是都售后成功 - * - * @param id 订单编号 - * @return 是否都售后成功 - */ - private boolean isAllOrderItemAfterSaleSuccess(Long id) { - List orderItems = tradeOrderItemMapper.selectListByOrderId(id); - return orderItems.stream().allMatch(orderItem -> Objects.equals(orderItem.getAfterSaleStatus(), - TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_COMMENT) - public Long createOrderItemCommentByMember(Long userId, AppTradeOrderItemCommentCreateReqVO createReqVO) { - // 1.1 先通过订单项 ID,查询订单项是否存在 - TradeOrderItemDO orderItem = tradeOrderItemMapper.selectByIdAndUserId(createReqVO.getOrderItemId(), userId); - if (orderItem == null) { - throw exception(ORDER_ITEM_NOT_FOUND); - } - // 1.2 校验订单相关状态 - TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderItem.getOrderId(), userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus())) { - throw exception(ORDER_COMMENT_FAIL_STATUS_NOT_COMPLETED); - } - if (ObjectUtil.notEqual(order.getCommentStatus(), Boolean.FALSE)) { - throw exception(ORDER_COMMENT_STATUS_NOT_FALSE); - } - - // 2. 创建评价 - Long commentId = createOrderItemComment0(orderItem, createReqVO); - - // 3. 如果订单项都评论了,则更新订单评价状态 - List orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); - if (!anyMatch(orderItems, item -> Objects.equals(item.getCommentStatus(), Boolean.FALSE))) { - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE) - .setFinishTime(LocalDateTime.now())); - // 增加订单日志。注意:只有在所有订单项都评价后,才会增加 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); - } - return commentId; - } - - @Override - public int createOrderItemCommentBySystem() { - // 1. 查询过期的待支付订单 - LocalDateTime expireTime = minusTime(tradeOrderProperties.getCommentExpireTime()); - List orders = tradeOrderMapper.selectListByStatusAndReceiveTimeLt( - TradeOrderStatusEnum.COMPLETED.getStatus(), expireTime, false); - if (CollUtil.isEmpty(orders)) { - return 0; - } - - // 2. 遍历执行,逐个取消 - int count = 0; - for (TradeOrderDO order : orders) { - try { - getSelf().createOrderItemCommentBySystemBySystem(order); - count++; - } catch (Throwable e) { - log.error("[createOrderItemCommentBySystem][order({}) 过期订单异常]", order.getId(), e); - } - } - return count; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId) { - tradeOrderMapper.updateById( - new TradeOrderDO().setId(orderId).setCombinationActivityId(activityId) - .setCombinationRecordId(combinationRecordId).setCombinationHeadId(headId)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void cancelPaidOrder(Long userId, Long orderId) { - // TODO 芋艿:这里实现要优化下; - TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL); - } - - /** - * 创建单个订单的评论 - * - * @param order 订单 - */ - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_COMMENT) - public void createOrderItemCommentBySystemBySystem(TradeOrderDO order) { - // 1. 查询未评论的订单项 - List orderItems = tradeOrderItemMapper.selectListByOrderIdAndCommentStatus( - order.getId(), Boolean.FALSE); - if (CollUtil.isEmpty(orderItems)) { - return; - } - - // 2. 逐个评论 - for (TradeOrderItemDO orderItem : orderItems) { - // 2.1 创建评价 - AppTradeOrderItemCommentCreateReqVO commentCreateReqVO = new AppTradeOrderItemCommentCreateReqVO() - .setOrderItemId(orderItem.getId()).setAnonymous(false).setContent("") - .setBenefitScores(5).setDescriptionScores(5); - createOrderItemComment0(orderItem, commentCreateReqVO); - - // 2.2 更新订单项评价状态 - tradeOrderItemMapper.updateById(new TradeOrderItemDO().setId(orderItem.getId()).setCommentStatus(Boolean.TRUE)); - } - - // 3. 所有订单项都评论了,则更新订单评价状态 - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE) - .setFinishTime(LocalDateTime.now())); - // 增加订单日志。注意:只有在所有订单项都评价后,才会增加 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); - } - - /** - * 创建订单项的评论的核心实现 - * - * @param orderItem 订单项 - * @param createReqVO 评论内容 - * @return 评论编号 - */ - private Long createOrderItemComment0(TradeOrderItemDO orderItem, AppTradeOrderItemCommentCreateReqVO createReqVO) { - // 1. 创建评价 - ProductCommentCreateReqDTO productCommentCreateReqDTO = TradeOrderConvert.INSTANCE.convert04(createReqVO, orderItem); - Long commentId = productCommentApi.createComment(productCommentCreateReqDTO); - - // 2. 更新订单项评价状态 - tradeOrderItemMapper.updateById(new TradeOrderItemDO().setId(orderItem.getId()).setCommentStatus(Boolean.TRUE)); - return commentId; - } - - // =================== 营销相关的操作 =================== - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private TradeOrderUpdateServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeOrderLogCreateReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeOrderLogCreateReqBO.java deleted file mode 100644 index e8a6311a94..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeOrderLogCreateReqBO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.bo; - -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * 订单日志的创建 Request BO - * - * @author 陈賝 - * @since 2023/7/6 15:27 - */ -@Data -public class TradeOrderLogCreateReqBO { - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 用户类型 - */ - @NotNull(message = "用户类型不能为空") - private Integer userType; - - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - /** - * 操作前状态 - */ - private Integer beforeStatus; - /** - * 操作后状态 - */ - @NotNull(message = "操作后的状态不能为空") - private Integer afterStatus; - - /** - * 操作类型 - */ - @NotNull(message = "操作类型不能为空") - private Integer operateType; - /** - * 操作明细 - */ - @NotEmpty(message = "操作明细不能为空") - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainOrderHandler.java deleted file mode 100644 index 15a2064063..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainOrderHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainActivityApi; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainRecordApi; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; - -/** - * 砍价订单的 {@link TradeOrderHandler} 实现类 - * - * @author HUIHUI - */ -@Component -public class TradeBargainOrderHandler implements TradeOrderHandler { - - @Resource - private BargainActivityApi bargainActivityApi; - @Resource - private BargainRecordApi bargainRecordApi; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isBargain(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "砍价时,只允许选择一个商品"); - - // 扣减砍价活动的库存 - bargainActivityApi.updateBargainActivityStock(order.getBargainActivityId(), - -orderItems.get(0).getCount()); - } - - @Override - public void afterOrderCreate(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isBargain(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "砍价时,只允许选择一个商品"); - - // 记录砍价记录对应的订单编号 - bargainRecordApi.updateBargainRecordOrderId(order.getBargainRecordId(), order.getId()); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isBargain(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "砍价时,只允许选择一个商品"); - - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - afterCancelOrderItem(order, orderItems.get(0)); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - if (!TradeOrderTypeEnum.isBargain(order.getType())) { - return; - } - // 恢复(增加)砍价活动的库存 - bargainActivityApi.updateBargainActivityStock(order.getBargainActivityId(), orderItem.getCount()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBrokerageOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBrokerageOrderHandler.java deleted file mode 100644 index b2a40b2dc8..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBrokerageOrderHandler.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * 订单分销的 {@link TradeOrderHandler} 实现类 - * - * @author 芋道源码 - */ -@Component -public class TradeBrokerageOrderHandler implements TradeOrderHandler { - - @Resource - private MemberUserApi memberUserApi; - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Resource - private BrokerageRecordService brokerageRecordService; - @Resource - private BrokerageUserService brokerageUserService; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - // 设置订单推广人 - BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(order.getUserId()); - if (brokerageUser != null && brokerageUser.getBindUserId() != null) { - order.setBrokerageUserId(brokerageUser.getBindUserId()); - } - } - - @Override - public void afterPayOrder(TradeOrderDO order, List orderItems) { - if (order.getBrokerageUserId() == null) { - return; - } - addBrokerage(order.getUserId(), orderItems); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - // 如果是未支付的订单,不会产生分销结果,所以直接 return - if (!order.getPayStatus()) { - return; - } - if (order.getBrokerageUserId() == null) { - return; - } - - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - orderItems.forEach(orderItem -> afterCancelOrderItem(order, orderItem)); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - if (order.getBrokerageUserId() == null) { - return; - } - cancelBrokerage(order.getId(), orderItem.getOrderId()); - } - - /** - * 创建分销记录 - *

- * 目前是支付成功后,就会创建分销记录。 - *

- * 业内还有两种做法,可以根据自己的业务调整: - * 1. 确认收货后,才创建分销记录 - * 2. 支付 or 下单成功时,创建分销记录(冻结),确认收货解冻或者 n 天后解冻 - * - * @param userId 用户编号 - * @param orderItems 订单项 - */ - protected void addBrokerage(Long userId, List orderItems) { - MemberUserRespDTO user = memberUserApi.getUser(userId); - Assert.notNull(user); - ProductSpuRespDTO spu = productSpuApi.getSpu(orderItems.get(0).getSpuId()); - Assert.notNull(spu); - ProductSkuRespDTO sku = productSkuApi.getSku(orderItems.get(0).getSkuId()); - - // 每一个订单项,都会去生成分销记录 - List addList = convertList(orderItems, - item -> TradeOrderConvert.INSTANCE.convert(user, item, spu, sku)); - brokerageRecordService.addBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, addList); - } - - protected void cancelBrokerage(Long userId, Long orderItemId) { - brokerageRecordService.cancelBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, String.valueOf(orderItemId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java deleted file mode 100644 index e3892dcd59..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_CREATE_FAIL_EXIST_UNPAID; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS; - -/** - * 拼团订单的 {@link TradeOrderHandler} 实现类 - * - * @author HUIHUI - */ -@Component -public class TradeCombinationOrderHandler implements TradeOrderHandler { - - @Resource - private TradeOrderUpdateService orderUpdateService; - @Resource - private TradeOrderQueryService orderQueryService; - - @Resource - private CombinationRecordApi combinationRecordApi; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - // 如果不是拼团订单则结束 - if (!TradeOrderTypeEnum.isCombination(order.getType())) { - return; - } - Assert.isTrue(orderItems.size() == 1, "拼团时,只允许选择一个商品"); - - // 1. 校验是否满足拼团活动相关限制 - TradeOrderItemDO item = orderItems.get(0); - combinationRecordApi.validateCombinationRecord(order.getUserId(), order.getCombinationActivityId(), - order.getCombinationHeadId(), item.getSkuId(), item.getCount()); - - // 2. 校验该用户是否存在未支付的拼团活动订单,避免一个拼团可以下多个单子了 - TradeOrderDO activityOrder = orderQueryService.getOrderByUserIdAndStatusAndCombination( - order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus()); - if (activityOrder != null) { - throw exception(ORDER_CREATE_FAIL_EXIST_UNPAID); - } - } - - @Override - public void afterPayOrder(TradeOrderDO order, List orderItems) { - // 1.如果不是拼团订单则结束 - if (!TradeOrderTypeEnum.isCombination(order.getType())) { - return; - } - Assert.isTrue(orderItems.size() == 1, "拼团时,只允许选择一个商品"); - - // 2. 创建拼团记录 - TradeOrderItemDO item = orderItems.get(0); - CombinationRecordCreateRespDTO combinationRecord = combinationRecordApi.createCombinationRecord( - TradeOrderConvert.INSTANCE.convert(order, item)); - - // 3. 更新拼团相关信息到订单。为什么几个字段都要更新? - // 原因是:如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 的,设置团长编号这个操作时在订单是否后创建拼团记录时才设置的。 - orderUpdateService.updateOrderCombinationInfo(order.getId(), order.getCombinationActivityId(), - combinationRecord.getCombinationRecordId(), combinationRecord.getCombinationHeadId()); - } - - @Override - public void beforeDeliveryOrder(TradeOrderDO order) { - if (!TradeOrderTypeEnum.isCombination(order.getType())) { - return; - } - // 校验订单拼团是否成功 - if (!combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) { - throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); - } - } - -} - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCouponOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCouponOrderHandler.java deleted file mode 100644 index 478de450f9..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCouponOrderHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; - -/** - * 优惠劵的 {@link TradeOrderHandler} 实现类 - * - * @author 芋道源码 - */ -@Component -public class TradeCouponOrderHandler implements TradeOrderHandler { - - @Resource - private CouponApi couponApi; - - @Override - public void afterOrderCreate(TradeOrderDO order, List orderItems) { - if (order.getCouponId() == null || order.getCouponId() <= 0) { - return; - } - // 不在前置扣减的原因,是因为优惠劵要记录使用的订单号 - couponApi.useCoupon(new CouponUseReqDTO().setId(order.getCouponId()).setUserId(order.getUserId()) - .setOrderId(order.getId())); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - if (order.getCouponId() == null || order.getCouponId() <= 0) { - return; - } - // 退回优惠劵 - couponApi.returnUsedCoupon(order.getCouponId()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeMemberPointOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeMemberPointOrderHandler.java deleted file mode 100644 index db41eb9de5..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeMemberPointOrderHandler.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.point.MemberPointApi; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; - -/** - * 会员积分、等级的 {@link TradeOrderHandler} 实现类 - * - * @author owen - */ -@Component -public class TradeMemberPointOrderHandler implements TradeOrderHandler { - - @Resource - private MemberPointApi memberPointApi; - @Resource - private MemberLevelApi memberLevelApi; - - @Resource - private AfterSaleService afterSaleService; - - @Override - public void afterOrderCreate(TradeOrderDO order, List orderItems) { - // 扣减用户积分(订单抵扣)。不在前置扣减的原因,是因为积分扣减时,需要记录关联业务 - reducePoint(order.getUserId(), order.getUsePoint(), MemberPointBizTypeEnum.ORDER_USE, order.getId()); - } - - @Override - public void afterPayOrder(TradeOrderDO order, List orderItems) { - // 增加用户积分(订单赠送) - addPoint(order.getUserId(), order.getGivePoint(), MemberPointBizTypeEnum.ORDER_GIVE, - order.getId()); - - // 增加用户经验 - memberLevelApi.addExperience(order.getUserId(), order.getPayPrice(), - MemberExperienceBizTypeEnum.ORDER_GIVE.getType(), String.valueOf(order.getId())); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - - // 增加(回滚)用户积分(订单抵扣) - Integer usePoint = getSumValue(orderItems, TradeOrderItemDO::getUsePoint, Integer::sum); - addPoint(order.getUserId(), usePoint, MemberPointBizTypeEnum.ORDER_USE_CANCEL, - order.getId()); - - // 如下的返还,需要经过支持,也就是经历 afterPayOrder 流程 - if (!order.getPayStatus()) { - return; - } - // 扣减(回滚)积分(订单赠送) - Integer givePoint = getSumValue(orderItems, TradeOrderItemDO::getGivePoint, Integer::sum); - reducePoint(order.getUserId(), givePoint, MemberPointBizTypeEnum.ORDER_GIVE_CANCEL, - order.getId()); - // 扣减(回滚)用户经验 - int payPrice = order.getPayPrice() - order.getRefundPrice(); - memberLevelApi.addExperience(order.getUserId(), payPrice, - MemberExperienceBizTypeEnum.ORDER_GIVE_CANCEL.getType(), String.valueOf(order.getId())); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - // 扣减(回滚)积分(订单赠送) - reducePoint(order.getUserId(), orderItem.getGivePoint(), MemberPointBizTypeEnum.ORDER_GIVE_CANCEL_ITEM, - orderItem.getId()); - // 增加(回滚)积分(订单抵扣) - addPoint(order.getUserId(), orderItem.getUsePoint(), MemberPointBizTypeEnum.ORDER_USE_CANCEL_ITEM, - orderItem.getId()); - - // 扣减(回滚)用户经验 - AfterSaleDO afterSale = afterSaleService.getAfterSale(orderItem.getAfterSaleId()); - memberLevelApi.reduceExperience(order.getUserId(), afterSale.getRefundPrice(), - MemberExperienceBizTypeEnum.ORDER_GIVE_CANCEL_ITEM.getType(), String.valueOf(orderItem.getId())); - } - - /** - * 添加用户积分 - *

- * 目前是支付成功后,就会创建积分记录。 - *

- * 业内还有两种做法,可以根据自己的业务调整: - * 1. 确认收货后,才创建积分记录 - * 2. 支付 or 下单成功时,创建积分记录(冻结),确认收货解冻或者 n 天后解冻 - * - * @param userId 用户编号 - * @param point 增加积分数量 - * @param bizType 业务编号 - * @param bizId 业务编号 - */ - protected void addPoint(Long userId, Integer point, MemberPointBizTypeEnum bizType, Long bizId) { - if (point != null && point > 0) { - memberPointApi.addPoint(userId, point, bizType.getType(), String.valueOf(bizId)); - } - } - - protected void reducePoint(Long userId, Integer point, MemberPointBizTypeEnum bizType, Long bizId) { - if (point != null && point > 0) { - memberPointApi.reducePoint(userId, point, bizType.getType(), String.valueOf(bizId)); - } - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java deleted file mode 100644 index 4cc5c69a37..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; - -import java.util.List; - -/** - * 订单活动特殊逻辑处理器 handler 接口 - * 提供订单生命周期钩子接口;订单创建前、订单创建后、订单支付后、订单取消 - * - * @author HUIHUI - */ -public interface TradeOrderHandler { - - /** - * 订单创建前 - * - * @param order 订单 - * @param orderItems 订单项 - */ - default void beforeOrderCreate(TradeOrderDO order, List orderItems) {} - - /** - * 订单创建后 - * - * @param order 订单 - * @param orderItems 订单项 - */ - default void afterOrderCreate(TradeOrderDO order, List orderItems) {} - - /** - * 支付订单后 - * - * @param order 订单 - * @param orderItems 订单项 - */ - default void afterPayOrder(TradeOrderDO order, List orderItems) {} - - /** - * 订单取消后 - * - * @param order 订单 - * @param orderItems 订单项 - */ - default void afterCancelOrder(TradeOrderDO order, List orderItems) {} - - /** - * 订单项取消后 - * - * @param order 订单 - * @param orderItem 订单项 - */ - default void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) {} - - /** - * 订单发货前 - * - * @param order 订单 - */ - default void beforeDeliveryOrder(TradeOrderDO order) {} - - // ========== 公用方法 ========== - - /** - * 过滤“未售后”的订单项列表 - * - * @param orderItems 订单项列表 - * @return 过滤后的订单项列表 - */ - default List filterOrderItemListByNoneAfterSale(List orderItems) { - return CollectionUtils.filterList(orderItems, - item -> TradeOrderItemAfterSaleStatusEnum.isNone(item.getAfterSaleStatus())); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeProductSkuOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeProductSkuOrderHandler.java deleted file mode 100644 index 1666cb88ca..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeProductSkuOrderHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; - -import static java.util.Collections.singletonList; - -/** - * 商品 SKU 库存的 {@link TradeOrderHandler} 实现类 - * - * @author 芋道源码 - */ -@Component -public class TradeProductSkuOrderHandler implements TradeOrderHandler { - - @Resource - private ProductSkuApi productSkuApi; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - productSkuApi.updateSkuStock(TradeOrderConvert.INSTANCE.convertNegative(orderItems)); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - productSkuApi.updateSkuStock(TradeOrderConvert.INSTANCE.convert(orderItems)); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - productSkuApi.updateSkuStock(TradeOrderConvert.INSTANCE.convert(singletonList(orderItem))); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillOrderHandler.java deleted file mode 100644 index e70c7fa58a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillOrderHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.promotion.api.seckill.SeckillActivityApi; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; - -/** - * 秒杀订单的 {@link TradeOrderHandler} 实现类 - * - * @author HUIHUI - */ -@Component -public class TradeSeckillOrderHandler implements TradeOrderHandler { - - @Resource - private SeckillActivityApi seckillActivityApi; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isSeckill(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "秒杀时,只允许选择一个商品"); - - // 扣减秒杀活动的库存 - seckillActivityApi.updateSeckillStockDecr(order.getSeckillActivityId(), - orderItems.get(0).getSkuId(), orderItems.get(0).getCount()); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isSeckill(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "秒杀时,只允许选择一个商品"); - - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - afterCancelOrderItem(order, orderItems.get(0)); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - if (!TradeOrderTypeEnum.isSeckill(order.getType())) { - return; - } - // 恢复秒杀活动的库存 - seckillActivityApi.updateSeckillStockIncr(order.getSeckillActivityId(), - orderItem.getSkuId(), orderItem.getCount()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceService.java deleted file mode 100644 index bb1a8bf076..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceService.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price; - -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; - -import jakarta.validation.Valid; - -/** - * 价格计算 Service 接口 - * - * @author 芋道源码 - */ -public interface TradePriceService { - - /** - * 价格计算 - * - * @param calculateReqDTO 计算信息 - * @return 计算结果 - */ - TradePriceCalculateRespBO calculatePrice(@Valid TradePriceCalculateReqBO calculateReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java deleted file mode 100644 index e92d75d624..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price; - -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculator; -import cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_STOCK_NOT_ENOUGH; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_PAY_PRICE_ILLEGAL; - -/** - * 价格计算 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class TradePriceServiceImpl implements TradePriceService { - - @Resource - private ProductSkuApi productSkuApi; - @Resource - private ProductSpuApi productSpuApi; - - @Resource - private List priceCalculators; - - @Override - public TradePriceCalculateRespBO calculatePrice(TradePriceCalculateReqBO calculateReqBO) { - // 1.1 获得商品 SKU 数组 - List skuList = checkSkuList(calculateReqBO); - // 1.2 获得商品 SPU 数组 - List spuList = checkSpuList(skuList); - - // 2.1 计算价格 - TradePriceCalculateRespBO calculateRespBO = TradePriceCalculatorHelper - .buildCalculateResp(calculateReqBO, spuList, skuList); - priceCalculators.forEach(calculator -> calculator.calculate(calculateReqBO, calculateRespBO)); - // 2.2 如果最终支付金额小于等于 0,则抛出业务异常 - if (calculateRespBO.getPrice().getPayPrice() <= 0) { - log.error("[calculatePrice][价格计算不正确,请求 calculateReqDTO({}),结果 priceCalculate({})]", - calculateReqBO, calculateRespBO); - throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL); - } - return calculateRespBO; - } - - private List checkSkuList(TradePriceCalculateReqBO reqBO) { - // 获得商品 SKU 数组 - Map skuIdCountMap = convertMap(reqBO.getItems(), - TradePriceCalculateReqBO.Item::getSkuId, TradePriceCalculateReqBO.Item::getCount); - List skus = productSkuApi.getSkuList(skuIdCountMap.keySet()); - - // 校验商品 SKU - skus.forEach(sku -> { - Integer count = skuIdCountMap.get(sku.getId()); - if (count == null) { - throw exception(SKU_NOT_EXISTS); - } - if (count > sku.getStock()) { - throw exception(SKU_STOCK_NOT_ENOUGH); - } - }); - return skus; - } - - private List checkSpuList(List skuList) { - // 获得商品 SPU 数组 - return productSpuApi.validateSpuList(convertSet(skuList, ProductSkuRespDTO::getSpuId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateReqBO.java deleted file mode 100644 index 9b6f1d6bda..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateReqBO.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.bo; - -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import lombok.Data; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -/** - * 价格计算 Request BO - * - * @author yudao源码 - */ -@Data -public class TradePriceCalculateReqBO { - - /** - * 用户编号 - * - * 对应 MemberUserDO 的 id 编号 - */ - private Long userId; - - /** - * 优惠劵编号 - * - * 对应 CouponDO 的 id 编号 - */ - private Long couponId; - - /** - * 是否使用积分 - */ - @NotNull(message = "是否使用积分不能为空") - private Boolean pointStatus; - - /** - * 配送方式 - * - * 枚举 {@link DeliveryTypeEnum} - */ - private Integer deliveryType; - /** - * 收货地址编号 - * - * 对应 MemberAddressDO 的 id 编号 - */ - private Long addressId; - /** - * 自提门店编号 - * - * 对应 PickUpStoreDO 的 id 编号 - */ - private Long pickUpStoreId; - - /** - * 商品 SKU 数组 - */ - @NotNull(message = "商品数组不能为空") - private List items; - - // ========== 秒杀活动相关字段 ========== - /** - * 秒杀活动编号 - */ - private Long seckillActivityId; - - // ========== 拼团活动相关字段 ========== - /** - * 拼团活动编号 - */ - private Long combinationActivityId; - - /** - * 拼团团长编号 - */ - private Long combinationHeadId; - - // ========== 砍价活动相关字段 ========== - /** - * 砍价记录编号 - */ - private Long bargainRecordId; - - /** - * 商品 SKU - */ - @Data - @Valid - public static class Item { - - /** - * SKU 编号 - */ - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - /** - * SKU 数量 - */ - @NotNull(message = "商品 SKU 数量不能为空") - @Min(value = 0L, message = "商品 SKU 数量必须大于等于 0") - private Integer count; - - /** - * 购物车项的编号 - */ - private Long cartId; - - /** - * 是否选中 - */ - @NotNull(message = "是否选中不能为空") - private Boolean selected; - - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java deleted file mode 100644 index 93867f1e4a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java +++ /dev/null @@ -1,311 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.bo; - -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import lombok.Data; - -import java.util.List; - -/** - * 价格计算 Response BO - * - * 整体设计,参考 taobao 的技术文档: - * 1. 订单管理 - * 2. 常用订单金额说明 - * - * @author 芋道源码 - */ -@Data -public class TradePriceCalculateRespBO { - - /** - * 订单类型 - * - * 枚举 {@link TradeOrderTypeEnum} - */ - private Integer type; - - /** - * 订单价格 - */ - private Price price; - - /** - * 订单项数组 - */ - private List items; - - /** - * 营销活动数组 - * - * 只对应 {@link Price#items} 商品匹配的活动 - */ - private List promotions; - - /** - * 优惠劵编号 - */ - private Long couponId; - - /** - * 使用的积分 - */ - private Integer usePoint; - - /** - * 使用的积分 - */ - private Integer givePoint; - - /** - * 砍价活动编号 - */ - private Long bargainActivityId; - - /** - * 订单价格 - */ - @Data - public static class Price { - - /** - * 商品原价(总),单位:分 - * - * 基于 {@link OrderItem#getPrice()} * {@link OrderItem#getCount()} 求和 - * - * 对应 taobao 的 trade.total_fee 字段 - */ - private Integer totalPrice; - /** - * 订单优惠(总),单位:分 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额,单位:分 - */ - private Integer deliveryPrice; - /** - * 优惠劵减免金额(总),单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * VIP 减免金额,单位:分 - */ - private Integer vipPrice; - /** - * 最终购买金额(总),单位:分 - * - * = {@link #totalPrice} - * - {@link #couponPrice} - * - {@link #pointPrice} - * - {@link #discountPrice} - * + {@link #deliveryPrice} - * - {@link #vipPrice} - */ - private Integer payPrice; - - } - - /** - * 订单商品 SKU - */ - @Data - public static class OrderItem { - - /** - * SPU 编号 - */ - private Long spuId; - /** - * SKU 编号 - */ - private Long skuId; - /** - * 购买数量 - */ - private Integer count; - /** - * 购物车项的编号 - */ - private Long cartId; - /** - * 是否选中 - */ - private Boolean selected; - - /** - * 商品原价(单),单位:分 - * - * 对应 ProductSkuDO 的 price 字段 - * 对应 taobao 的 order.price 字段 - */ - private Integer price; - /** - * 优惠金额(总),单位:分 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额(总),单位:分 - */ - private Integer deliveryPrice; - /** - * 优惠劵减免金额,单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * 使用的积分 - */ - private Integer usePoint; - /** - * VIP 减免金额,单位:分 - */ - private Integer vipPrice; - /** - * 应付金额(总),单位:分 - * - * = {@link #price} * {@link #count} - * - {@link #couponPrice} - * - {@link #pointPrice} - * - {@link #discountPrice} - * + {@link #deliveryPrice} - * - {@link #vipPrice} - */ - private Integer payPrice; - - // ========== 商品 SPU 信息 ========== - /** - * 商品名 - */ - private String spuName; - /** - * 商品图片 - * - * 优先级:SKU.picUrl > SPU.picUrl - */ - private String picUrl; - /** - * 分类编号 - */ - private Long categoryId; - - /** - * 运费模板 Id - */ - private Long deliveryTemplateId; - - // ========== 商品 SKU 信息 ========== - /** - * 商品重量,单位:kg 千克 - */ - private Double weight; - /** - * 商品体积,单位:m^3 平米 - */ - private Double volume; - - /** - * 商品属性数组 - */ - private List properties; - - /** - * 使用的积分 - */ - private Integer givePoint; - - } - - /** - * 营销明细 - */ - @Data - public static class Promotion { - - /** - * 营销编号 - * - * 例如说:营销活动的编号、优惠劵的编号 - */ - private Long id; - /** - * 营销名字 - */ - private String name; - /** - * 营销类型 - * - * 枚举 {@link PromotionTypeEnum} - */ - private Integer type; - /** - * 计算时的原价(总),单位:分 - */ - private Integer totalPrice; - /** - * 计算时的优惠(总),单位:分 - */ - private Integer discountPrice; - /** - * 匹配的商品 SKU 数组 - */ - private List items; - - // ========== 匹配情况 ========== - - /** - * 是否满足优惠条件 - */ - private Boolean match; - /** - * 满足条件的提示 - * - * 如果 {@link #match} = true 满足,则提示“圣诞价:省 150.00 元” - * 如果 {@link #match} = false 不满足,则提示“购满 85 元,可减 40 元” - */ - private String description; - - } - - /** - * 营销匹配的商品 SKU - */ - @Data - public static class PromotionItem { - - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 计算时的原价(总),单位:分 - */ - private Integer totalPrice; - /** - * 计算时的优惠(总),单位:分 - */ - private Integer discountPrice; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeBargainActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeBargainActivityPriceCalculator.java deleted file mode 100644 index ecc4e63ec4..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeBargainActivityPriceCalculator.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainRecordApi; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -// TODO huihui:单测需要补充 -/** - * 砍价活动的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_BARGAIN_ACTIVITY) -public class TradeBargainActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private BargainRecordApi bargainRecordApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1. 判断订单类型和是否具有拼团记录编号 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.BARGAIN.getType())) { - return; - } - Assert.isTrue(param.getItems().size() == 1, "砍价时,只允许选择一个商品"); - Assert.isTrue(param.getItems().get(0).getCount() == 1, "砍价时,只允许选择一个商品"); - // 2. 校验是否可以参与砍价 - TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0); - BargainValidateJoinRespDTO bargainActivity = bargainRecordApi.validateJoinBargain( - param.getUserId(), param.getBargainRecordId(), orderItem.getSkuId()); - - // 3.1 记录优惠明细 - Integer discountPrice = orderItem.getPayPrice() - bargainActivity.getBargainPrice() * orderItem.getCount(); - // TODO 芋艿:极端情况,优惠金额为负数,需要处理 - TradePriceCalculatorHelper.addPromotion(result, orderItem, - param.getSeckillActivityId(), bargainActivity.getName(), PromotionTypeEnum.BARGAIN_ACTIVITY.getType(), - StrUtil.format("砍价活动:省 {} 元", TradePriceCalculatorHelper.formatPrice(discountPrice)), - discountPrice); - // 3.2 更新 SKU 优惠金额 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + discountPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - TradePriceCalculatorHelper.recountAllPrice(result); - // 4. 特殊:设置对应的砍价活动编号 - result.setBargainActivityId(bargainActivity.getActivityId()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCombinationActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCombinationActivityPriceCalculator.java deleted file mode 100644 index 80a3d49984..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCombinationActivityPriceCalculator.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -// TODO @puhui999:单测可以后补下 - -/** - * 拼团活动的 {@link TradePriceCalculator} 实现类 - * - * @author HUIHUI - */ -@Component -@Order(TradePriceCalculator.ORDER_COMBINATION_ACTIVITY) -public class TradeCombinationActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private CombinationRecordApi combinationRecordApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1. 判断订单类型和是否具有拼团活动编号 - if (param.getCombinationActivityId() == null) { - return; - } - Assert.isTrue(param.getItems().size() == 1, "拼团时,只允许选择一个商品"); - // 2. 校验是否可以参与拼团 - TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0); - CombinationValidateJoinRespDTO combinationActivity = combinationRecordApi.validateJoinCombination( - param.getUserId(), param.getCombinationActivityId(), param.getCombinationHeadId(), - orderItem.getSkuId(), orderItem.getCount()); - - // 3.1 记录优惠明细 - Integer discountPrice = orderItem.getPayPrice() - combinationActivity.getCombinationPrice() * orderItem.getCount(); - TradePriceCalculatorHelper.addPromotion(result, orderItem, - param.getCombinationActivityId(), combinationActivity.getName(), PromotionTypeEnum.COMBINATION_ACTIVITY.getType(), - StrUtil.format("拼团活动:省 {} 元", TradePriceCalculatorHelper.formatPrice(discountPrice)), - discountPrice); - // 3.2 更新 SKU 优惠金额 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + discountPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - TradePriceCalculatorHelper.recountAllPrice(result); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculator.java deleted file mode 100644 index d2b52ea45e..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculator.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.function.Predicate; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_NO_MATCH_MIN_PRICE; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_NO_MATCH_SPU; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER; - -/** - * 优惠劵的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_COUPON) -public class TradeCouponPriceCalculator implements TradePriceCalculator { - - @Resource - private CouponApi couponApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1.1 校验优惠劵 - if (param.getCouponId() == null) { - return; - } - CouponRespDTO coupon = couponApi.validateCoupon(new CouponValidReqDTO() - .setId(param.getCouponId()).setUserId(param.getUserId())); - Assert.notNull(coupon, "校验通过的优惠劵({}),不能为空", param.getCouponId()); - // 1.2 只有【普通】订单,才允许使用优惠劵 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { - throw exception(PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER); - } - - // 2.1 获得匹配的商品 SKU 数组 - List orderItems = filterMatchCouponOrderItems(result, coupon); - if (CollUtil.isEmpty(orderItems)) { - throw exception(COUPON_NO_MATCH_SPU); - } - // 2.2 计算是否满足优惠劵的使用金额 - Integer totalPayPrice = TradePriceCalculatorHelper.calculateTotalPayPrice(orderItems); - if (totalPayPrice < coupon.getUsePrice()) { - throw exception(COUPON_NO_MATCH_MIN_PRICE); - } - - // 3.1 计算可以优惠的金额 - Integer couponPrice = getCouponPrice(coupon, totalPayPrice); - Assert.isTrue(couponPrice < totalPayPrice, - "优惠劵({}) 的优惠金额({}),不能大于订单总金额({})", coupon.getId(), couponPrice, totalPayPrice); - // 3.2 计算分摊的优惠金额 - List divideCouponPrices = TradePriceCalculatorHelper.dividePrice(orderItems, couponPrice); - - // 4.1 记录使用的优惠劵 - result.setCouponId(param.getCouponId()); - // 4.2 记录优惠明细 - TradePriceCalculatorHelper.addPromotion(result, orderItems, - param.getCouponId(), coupon.getName(), PromotionTypeEnum.COUPON.getType(), - StrUtil.format("优惠劵:省 {} 元", TradePriceCalculatorHelper.formatPrice(couponPrice)), - divideCouponPrices); - // 4.3 更新 SKU 优惠金额 - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - orderItem.setCouponPrice(divideCouponPrices.get(i)); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - } - TradePriceCalculatorHelper.recountAllPrice(result); - } - - private Integer getCouponPrice(CouponRespDTO coupon, Integer totalPayPrice) { - if (PromotionDiscountTypeEnum.PRICE.getType().equals(coupon.getDiscountType())) { // 减价 - return coupon.getDiscountPrice(); - } else if (PromotionDiscountTypeEnum.PERCENT.getType().equals(coupon.getDiscountType())) { // 打折 - int couponPrice = totalPayPrice * coupon.getDiscountPercent() / 100; - return coupon.getDiscountLimitPrice() == null ? couponPrice - : Math.min(couponPrice, coupon.getDiscountLimitPrice()); // 优惠上限 - } - throw new IllegalArgumentException(String.format("优惠劵(%s) 的优惠类型不正确", coupon)); - } - - /** - * 获得优惠劵可使用的订单项(商品)列表 - * - * @param result 计算结果 - * @param coupon 优惠劵 - * @return 订单项(商品)列表 - */ - private List filterMatchCouponOrderItems(TradePriceCalculateRespBO result, - CouponRespDTO coupon) { - Predicate matchPredicate = TradePriceCalculateRespBO.OrderItem::getSelected; - if (PromotionProductScopeEnum.SPU.getScope().equals(coupon.getProductScope())) { - matchPredicate = matchPredicate // 额外加如下条件 - .and(orderItem -> coupon.getProductScopeValues().contains(orderItem.getSpuId())); - } else if (PromotionProductScopeEnum.CATEGORY.getScope().equals(coupon.getProductScope())) { - matchPredicate = matchPredicate // 额外加如下条件 - .and(orderItem -> coupon.getProductScopeValues().contains(orderItem.getCategoryId())); - } - return filterList(result.getItems(), matchPredicate); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculator.java deleted file mode 100644 index 30558bdb67..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculator.java +++ /dev/null @@ -1,226 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.module.member.api.address.MemberAddressApi; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryExpressChargeModeEnum; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressTemplateService; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO.OrderItem; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 运费的 {@link TradePriceCalculator} 实现类 - * - * @author jason - */ -@Component -@Order(TradePriceCalculator.ORDER_DELIVERY) -@Slf4j -public class TradeDeliveryPriceCalculator implements TradePriceCalculator { - - @Resource - private MemberAddressApi addressApi; - - @Resource - private DeliveryPickUpStoreService deliveryPickUpStoreService; - @Resource - private DeliveryExpressTemplateService deliveryExpressTemplateService; - @Resource - private TradeConfigService tradeConfigService; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - if (param.getDeliveryType() == null) { - return; - } - if (DeliveryTypeEnum.PICK_UP.getType().equals(param.getDeliveryType())) { - calculateByPickUp(param); - } else if (DeliveryTypeEnum.EXPRESS.getType().equals(param.getDeliveryType())) { - calculateExpress(param, result); - } - } - - private void calculateByPickUp(TradePriceCalculateReqBO param) { - if (param.getPickUpStoreId() == null) { - // 价格计算时,如果为空就不算~最终下单,会校验该字段不允许空 - return; - } - DeliveryPickUpStoreDO pickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(param.getPickUpStoreId()); - if (pickUpStore == null || CommonStatusEnum.DISABLE.getStatus().equals(pickUpStore.getStatus())) { - throw exception(PICK_UP_STORE_NOT_EXISTS); - } - } - - // ========= 快递发货 ========== - - private void calculateExpress(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 0. 得到收件地址区域 - if (param.getAddressId() == null) { - // 价格计算时,如果为空就不算~最终下单,会校验该字段不允许空 - return; - } - MemberAddressRespDTO address = addressApi.getAddress(param.getAddressId(), param.getUserId()); - Assert.notNull(address, "收件人({})的地址,不能为空", param.getUserId()); - - // 情况一:全局包邮 - if (isGlobalExpressFree(result)) { - return; - } - - // 情况二:快递模版 - // 2.1 过滤出已选中的商品 SKU - List selectedItem = filterList(result.getItems(), OrderItem::getSelected); - Set deliveryTemplateIds = convertSet(selectedItem, OrderItem::getDeliveryTemplateId); - Map expressTemplateMap = - deliveryExpressTemplateService.getExpressTemplateMapByIdsAndArea(deliveryTemplateIds, address.getAreaId()); - // 2.2 计算配送费用 - if (CollUtil.isEmpty(expressTemplateMap)) { - log.error("[calculate][找不到商品 templateIds {} areaId{} 对应的运费模板]", deliveryTemplateIds, address.getAreaId()); - throw exception(PRICE_CALCULATE_DELIVERY_PRICE_TEMPLATE_NOT_FOUND); - } - calculateDeliveryPrice(selectedItem, expressTemplateMap, result); - } - - /** - * 是否全局包邮 - * - * @param result 计算结果 - * @return 是否包邮 - */ - private boolean isGlobalExpressFree(TradePriceCalculateRespBO result) { - TradeConfigDO config = tradeConfigService.getTradeConfig(); - return config != null - && Boolean.TRUE.equals(config.getDeliveryExpressFreeEnabled()) // 开启包邮 - && result.getPrice().getPayPrice() >= config.getDeliveryExpressFreePrice(); // 满足包邮的价格 - } - - private void calculateDeliveryPrice(List selectedSkus, - Map expressTemplateMap, - TradePriceCalculateRespBO result) { - // 按商品运费模板来计算商品的运费:相同的运费模板可能对应多条订单商品 SKU - Map> template2ItemMap = convertMultiMap(selectedSkus, OrderItem::getDeliveryTemplateId); - // 依次计算快递运费 - for (Map.Entry> entry : template2ItemMap.entrySet()) { - Long templateId = entry.getKey(); - List orderItems = entry.getValue(); - DeliveryExpressTemplateRespBO templateBO = expressTemplateMap.get(templateId); - if (templateBO == null) { - log.error("[calculateDeliveryPrice][不能计算快递运费,找不到 templateId({}) 对应的运费模板配置]", templateId); - continue; - } - // 1. 优先判断是否包邮。如果包邮不计算快递运费 - if (isExpressTemplateFree(orderItems, templateBO.getChargeMode(), templateBO.getFree())) { - continue; - } - // 2. 计算快递运费 - calculateExpressFeeByChargeMode(orderItems, templateBO.getChargeMode(), templateBO.getCharge()); - } - TradePriceCalculatorHelper.recountAllPrice(result); - } - - /** - * 按配送方式来计算运费 - * - * @param orderItems SKU 商品项目 - * @param chargeMode 配送计费方式 - * @param templateCharge 快递运费配置 - */ - private void calculateExpressFeeByChargeMode(List orderItems, Integer chargeMode, - DeliveryExpressTemplateRespBO.Charge templateCharge) { - if (templateCharge == null) { - log.error("[calculateExpressFeeByChargeMode][计算快递运费时,找不到 SKU({}) 对应的运费模版]", orderItems); - return; - } - double totalChargeValue = getTotalChargeValue(orderItems, chargeMode); - // 1. 计算 SKU 商品快递费用 - int deliveryPrice; - if (totalChargeValue <= templateCharge.getStartCount()) { - deliveryPrice = templateCharge.getStartPrice(); - } else { - double remainWeight = totalChargeValue - templateCharge.getStartCount(); - // 剩余重量/ 续件 = 续件的次数. 向上取整 - int extraNum = (int) Math.ceil(remainWeight / templateCharge.getExtraCount()); - int extraPrice = templateCharge.getExtraPrice() * extraNum; - deliveryPrice = templateCharge.getStartPrice() + extraPrice; - } - - // 2. 分摊快递费用到 SKU. 退费的时候,可能按照 SKU 考虑退费金额 - int remainPrice = deliveryPrice; - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem item = orderItems.get(i); - int partPrice; - double chargeValue = getChargeValue(item, chargeMode); - if (i < orderItems.size() - 1) { // 减一的原因,是因为拆分时,如果按照比例,可能会出现.所以最后一个,使用反减 - partPrice = (int) (deliveryPrice * (chargeValue / totalChargeValue)); - remainPrice -= partPrice; - } else { - partPrice = remainPrice; - } - Assert.isTrue(partPrice >= 0, "分摊金额必须大于等于 0"); - // 更新快递运费 - item.setDeliveryPrice(partPrice); - TradePriceCalculatorHelper.recountPayPrice(item); - } - } - - /** - * 检查是否包邮 - * - * @param chargeMode 配送计费方式 - * @param templateFree 包邮配置 - */ - private boolean isExpressTemplateFree(List orderItems, Integer chargeMode, - DeliveryExpressTemplateRespBO.Free templateFree) { - if (templateFree == null) { - return false; - } - double totalChargeValue = getTotalChargeValue(orderItems, chargeMode); - double totalPrice = TradePriceCalculatorHelper.calculateTotalPayPrice(orderItems); - return totalChargeValue >= templateFree.getFreeCount() && totalPrice >= templateFree.getFreePrice(); - } - - private double getTotalChargeValue(List orderItems, Integer chargeMode) { - double total = 0; - for (OrderItem orderItem : orderItems) { - total += getChargeValue(orderItem, chargeMode); - } - return total; - } - - private double getChargeValue(OrderItem orderItem, Integer chargeMode) { - DeliveryExpressChargeModeEnum chargeModeEnum = DeliveryExpressChargeModeEnum.valueOf(chargeMode); - switch (chargeModeEnum) { - case COUNT: - return orderItem.getCount(); - case WEIGHT: - return orderItem.getWeight() != null ? orderItem.getWeight() * orderItem.getCount() : 0; - case VOLUME: - return orderItem.getVolume() != null ? orderItem.getVolume() * orderItem.getCount() : 0; - default: - throw new IllegalArgumentException(StrUtil.format("未知的计费模式({})", chargeMode)); - } - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDiscountActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDiscountActivityPriceCalculator.java deleted file mode 100644 index 844d5266e5..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDiscountActivityPriceCalculator.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.discount.DiscountActivityApi; -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper.formatPrice; - -/** - * 限时折扣的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_DISCOUNT_ACTIVITY) -public class TradeDiscountActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private DiscountActivityApi discountActivityApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 0. 只有【普通】订单,才计算该优惠 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { - return; - } - // 获得 SKU 对应的限时折扣活动 - List discountProducts = discountActivityApi.getMatchDiscountProductList( - convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSkuId)); - if (CollUtil.isEmpty(discountProducts)) { - return; - } - Map discountProductMap = convertMap(discountProducts, DiscountProductRespDTO::getSkuId); - - // 处理每个 SKU 的限时折扣 - result.getItems().forEach(orderItem -> { - // 1. 获取该 SKU 的优惠信息 - DiscountProductRespDTO discountProduct = discountProductMap.get(orderItem.getSkuId()); - if (discountProduct == null) { - return; - } - // 2. 计算优惠金额 - Integer newPayPrice = calculatePayPrice(discountProduct, orderItem); - Integer newDiscountPrice = orderItem.getPayPrice() - newPayPrice; - - // 3.1 记录优惠明细 - if (orderItem.getSelected()) { - // 注意,只有在选中的情况下,才会记录到优惠明细。否则仅仅是更新 SKU 优惠金额,用于展示 - TradePriceCalculatorHelper.addPromotion(result, orderItem, - discountProduct.getActivityId(), discountProduct.getActivityName(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType(), - StrUtil.format("限时折扣:省 {} 元", formatPrice(newDiscountPrice)), - newDiscountPrice); - } - // 3.2 更新 SKU 优惠金额 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + newDiscountPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - }); - TradePriceCalculatorHelper.recountAllPrice(result); - } - - private Integer calculatePayPrice(DiscountProductRespDTO discountProduct, - TradePriceCalculateRespBO.OrderItem orderItem) { - Integer price = orderItem.getPayPrice(); - if (PromotionDiscountTypeEnum.PRICE.getType().equals(discountProduct.getDiscountType())) { // 减价 - price -= discountProduct.getDiscountPrice() * orderItem.getCount(); - } else if (PromotionDiscountTypeEnum.PERCENT.getType().equals(discountProduct.getDiscountType())) { // 打折 - price = price * discountProduct.getDiscountPercent() / 100; - } else { - throw new IllegalArgumentException(String.format("优惠活动的商品(%s) 的优惠类型不正确", discountProduct)); - } - return price; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeMemberLevelPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeMemberLevelPriceCalculator.java deleted file mode 100644 index f4a5350652..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeMemberLevelPriceCalculator.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper.formatPrice; - -/** - * 会员 VIP 折扣的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_MEMBER_LEVEL) -public class TradeMemberLevelPriceCalculator implements TradePriceCalculator { - - @Resource - private MemberLevelApi memberLevelApi; - @Resource - private MemberUserApi memberUserApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 0. 只有【普通】订单,才计算该优惠 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { - return; - } - // 1. 获得用户的会员等级 - MemberUserRespDTO user = memberUserApi.getUser(param.getUserId()); - if (user.getLevelId() == null || user.getLevelId() <= 0) { - return; - } - MemberLevelRespDTO level = memberLevelApi.getMemberLevel(user.getLevelId()); - if (level == null || level.getDiscountPercent() == null) { - return; - } - - // 2. 计算每个 SKU 的优惠金额 - result.getItems().forEach(orderItem -> { - // 2.1 计算优惠金额 - Integer vipPrice = calculateVipPrice(orderItem.getPayPrice(), level.getDiscountPercent()); - if (vipPrice <= 0) { - return; - } - - // 2.2 记录优惠明细 - if (orderItem.getSelected()) { - // 注意,只有在选中的情况下,才会记录到优惠明细。否则仅仅是更新 SKU 优惠金额,用于展示 - TradePriceCalculatorHelper.addPromotion(result, orderItem, - level.getId(), level.getName(), PromotionTypeEnum.MEMBER_LEVEL.getType(), - String.format("会员等级折扣:省 %s 元", formatPrice(vipPrice)), - vipPrice); - } - - // 2.3 更新 SKU 的优惠金额 - orderItem.setVipPrice(vipPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - }); - TradePriceCalculatorHelper.recountAllPrice(result); - } - - /** - * 计算会员 VIP 优惠价格 - * - * @param price 原价 - * @param discountPercent 折扣 - * @return 优惠价格 - */ - public Integer calculateVipPrice(Integer price, Integer discountPercent) { - if (discountPercent == null) { - return 0; - } - Integer newPrice = price * discountPercent / 100; - return price - newPrice; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointGiveCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointGiveCalculator.java deleted file mode 100644 index e5322015dc..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointGiveCalculator.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.util.BooleanUtil; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.module.member.api.config.MemberConfigApi; -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.Optional; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; - -/** - * 赠送积分的 {@link TradePriceCalculator} 实现类 - * - * @author owen - */ -@Component -@Order(TradePriceCalculator.ORDER_POINT_GIVE) -@Slf4j -public class TradePointGiveCalculator implements TradePriceCalculator { - - @Resource - private MemberConfigApi memberConfigApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1.1 校验积分功能是否开启 - int givePointPerYuan = Optional.ofNullable(memberConfigApi.getConfig()) - .filter(config -> BooleanUtil.isTrue(config.getPointTradeDeductEnable())) - .map(MemberConfigRespDTO::getPointTradeGivePoint) - .orElse(0); - if (givePointPerYuan <= 0) { - return; - } - // 1.2 校验支付金额 - if (result.getPrice().getPayPrice() <= 0) { - return; - } - - // 2.1 计算赠送积分 - int givePoint = MoneyUtils.calculateRatePriceFloor(result.getPrice().getPayPrice(), (double) givePointPerYuan); - // 2.2 计算分摊的赠送积分 - List orderItems = filterList(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSelected); - List dividePoints = TradePriceCalculatorHelper.dividePrice(orderItems, givePoint); - - // 3.2 更新 SKU 赠送积分 - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - // 商品可能赠送了积分,所以这里要加上 - orderItem.setGivePoint(orderItem.getGivePoint() + dividePoints.get(i)); - } - // 3.3 更新订单赠送积分 - TradePriceCalculatorHelper.recountAllGivePoint(result); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointUsePriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointUsePriceCalculator.java deleted file mode 100644 index 40b7450fdf..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointUsePriceCalculator.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.member.api.config.MemberConfigApi; -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_PAY_PRICE_ILLEGAL; - -/** - * 使用积分的 {@link TradePriceCalculator} 实现类 - * - * @author owen - */ -@Component -@Order(TradePriceCalculator.ORDER_POINT_USE) -@Slf4j -public class TradePointUsePriceCalculator implements TradePriceCalculator { - - @Resource - private MemberConfigApi memberConfigApi; - @Resource - private MemberUserApi memberUserApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 默认使用积分为 0 - result.setUsePoint(0); - // 1.1 校验是否使用积分 - if (!BooleanUtil.isTrue(param.getPointStatus())) { - result.setUsePoint(0); - return; - } - // 1.2 校验积分抵扣是否开启 - MemberConfigRespDTO config = memberConfigApi.getConfig(); - if (!isDeductPointEnable(config)) { - return; - } - // 1.3 校验用户积分余额 - MemberUserRespDTO user = memberUserApi.getUser(param.getUserId()); - if (user.getPoint() == null || user.getPoint() <= 0) { - return; - } - - // 2.1 计算积分优惠金额 - int pointPrice = calculatePointPrice(config, user.getPoint(), result); - // 2.2 计算分摊的积分、抵扣金额 - List orderItems = filterList(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSelected); - List dividePointPrices = TradePriceCalculatorHelper.dividePrice(orderItems, pointPrice); - List divideUsePoints = TradePriceCalculatorHelper.dividePrice(orderItems, result.getUsePoint()); - - // 3.1 记录优惠明细 - TradePriceCalculatorHelper.addPromotion(result, orderItems, - param.getUserId(), "积分抵扣", PromotionTypeEnum.POINT.getType(), - StrUtil.format("积分抵扣:省 {} 元", TradePriceCalculatorHelper.formatPrice(pointPrice)), - dividePointPrices); - // 3.2 更新 SKU 优惠金额 - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - orderItem.setPointPrice(dividePointPrices.get(i)); - orderItem.setUsePoint(divideUsePoints.get(i)); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - } - TradePriceCalculatorHelper.recountAllPrice(result); - } - - private boolean isDeductPointEnable(MemberConfigRespDTO config) { - return config != null && - BooleanUtil.isTrue(config.getPointTradeDeductEnable()) && // 积分功能是否启用 - config.getPointTradeDeductUnitPrice() != null && config.getPointTradeDeductUnitPrice() > 0; // 有没有配置:1 积分抵扣多少分 - } - - private Integer calculatePointPrice(MemberConfigRespDTO config, Integer usePoint, TradePriceCalculateRespBO result) { - // 每个订单最多可以使用的积分数量 - if (config.getPointTradeDeductMaxPrice() != null && config.getPointTradeDeductMaxPrice() > 0) { - usePoint = Math.min(usePoint, config.getPointTradeDeductMaxPrice()); - } - // TODO @疯狂:这里应该是,抵扣到只剩下 0.01; - // 积分优惠金额(分) - int pointPrice = usePoint * config.getPointTradeDeductUnitPrice(); - if (result.getPrice().getPayPrice() <= pointPrice) { - // 禁止 0 元购 - throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL); - } -// // 允许0 元购!!!:用户积分比较多时,积分可以抵扣的金额要大于支付金额,这时需要根据支付金额反推使用多少积分 -// if (result.getPrice().getPayPrice() < pointPrice) { -// pointPrice = result.getPrice().getPayPrice(); -// // 反推需要扣除的积分 -// usePoint = NumberUtil.toBigDecimal(pointPrice) -// .divide(NumberUtil.toBigDecimal(config.getPointTradeDeductUnitPrice()), 0, RoundingMode.HALF_UP) -// .intValue(); -// } - // 记录使用的积分 - result.setUsePoint(usePoint); - return pointPrice; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculator.java deleted file mode 100644 index 1fc7e69157..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculator.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; - -/** - * 价格计算的计算器接口 - * - * 优惠计算顺序: - * 1. 积分抵现、会员价、优惠券、粉丝专享价、满减送哪个优先计算? - * - * @author 芋道源码 - */ -public interface TradePriceCalculator { - - int ORDER_MEMBER_LEVEL = 5; - - int ORDER_SECKILL_ACTIVITY = 8; - int ORDER_BARGAIN_ACTIVITY = 8; - int ORDER_COMBINATION_ACTIVITY = 8; - - int ORDER_DISCOUNT_ACTIVITY = 10; - int ORDER_REWARD_ACTIVITY = 20; - int ORDER_COUPON = 30; - int ORDER_POINT_USE = 40; - /** - * 快递运费的计算 - * - * 放在各种营销活动、优惠劵后面 - */ - int ORDER_DELIVERY = 50; - /** - * 赠送积分,放最后 - * - * 放在 {@link #ORDER_DELIVERY} 后面的原因,是运费也会产生费用,需要赠送对应积分 - */ - int ORDER_POINT_GIVE = 999; - - void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java deleted file mode 100644 index 7def3e34ef..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java +++ /dev/null @@ -1,342 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; -import static java.util.Collections.singletonList; - -/** - * {@link TradePriceCalculator} 的工具类 - * - * 主要实现对 {@link TradePriceCalculateRespBO} 计算结果的操作 - * - * @author 芋道源码 - */ -public class TradePriceCalculatorHelper { - - public static TradePriceCalculateRespBO buildCalculateResp(TradePriceCalculateReqBO param, - List spuList, List skuList) { - // 创建 PriceCalculateRespDTO 对象 - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO(); - result.setType(getOrderType(param)); - result.setPromotions(new ArrayList<>()); - - // 创建它的 OrderItem 属性 - result.setItems(new ArrayList<>(param.getItems().size())); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map skuMap = convertMap(skuList, ProductSkuRespDTO::getId); - param.getItems().forEach(item -> { - ProductSkuRespDTO sku = skuMap.get(item.getSkuId()); - if (sku == null) { - return; - } - ProductSpuRespDTO spu = spuMap.get(sku.getSpuId()); - if (spu == null) { - return; - } - // 商品项 - TradePriceCalculateRespBO.OrderItem orderItem = new TradePriceCalculateRespBO.OrderItem(); - result.getItems().add(orderItem); - orderItem.setSpuId(sku.getSpuId()).setSkuId(sku.getId()) - .setCount(item.getCount()).setCartId(item.getCartId()).setSelected(item.getSelected()); - // sku 价格 - orderItem.setPrice(sku.getPrice()).setPayPrice(sku.getPrice() * item.getCount()) - .setDiscountPrice(0).setDeliveryPrice(0).setCouponPrice(0).setPointPrice(0).setVipPrice(0); - // sku 信息 - orderItem.setPicUrl(sku.getPicUrl()).setProperties(sku.getProperties()) - .setWeight(sku.getWeight()).setVolume(sku.getVolume()); - // spu 信息 - orderItem.setSpuName(spu.getName()).setCategoryId(spu.getCategoryId()) - .setDeliveryTemplateId(spu.getDeliveryTemplateId()) - .setGivePoint(spu.getGiveIntegral()).setUsePoint(0); - if (orderItem.getPicUrl() == null) { - orderItem.setPicUrl(spu.getPicUrl()); - } - }); - - // 创建它的 Price 属性 - result.setPrice(new TradePriceCalculateRespBO.Price()); - recountAllPrice(result); - recountAllGivePoint(result); - return result; - } - - /** - * 计算订单类型 - * - * @param param 计算参数 - * @return 订单类型 - */ - private static Integer getOrderType(TradePriceCalculateReqBO param) { - if (param.getSeckillActivityId() != null) { - return TradeOrderTypeEnum.SECKILL.getType(); - } - if (param.getCombinationActivityId() != null) { - return TradeOrderTypeEnum.COMBINATION.getType(); - } - if (param.getBargainRecordId() != null) { - return TradeOrderTypeEnum.BARGAIN.getType(); - } - return TradeOrderTypeEnum.NORMAL.getType(); - } - - /** - * 基于订单项,重新计算 price 总价 - * - * @param result 计算结果 - */ - public static void recountAllPrice(TradePriceCalculateRespBO result) { - // 先重置 - TradePriceCalculateRespBO.Price price = result.getPrice(); - price.setTotalPrice(0).setDiscountPrice(0).setDeliveryPrice(0) - .setCouponPrice(0).setPointPrice(0).setVipPrice(0).setPayPrice(0); - // 再合计 item - result.getItems().forEach(item -> { - if (!item.getSelected()) { - return; - } - price.setTotalPrice(price.getTotalPrice() + item.getPrice() * item.getCount()); - price.setDiscountPrice(price.getDiscountPrice() + item.getDiscountPrice()); - price.setDeliveryPrice(price.getDeliveryPrice() + item.getDeliveryPrice()); - price.setCouponPrice(price.getCouponPrice() + item.getCouponPrice()); - price.setPointPrice(price.getPointPrice() + item.getPointPrice()); - price.setVipPrice(price.getVipPrice() + item.getVipPrice()); - price.setPayPrice(price.getPayPrice() + item.getPayPrice()); - }); - } - - /** - * 基于订单项,重新计算赠送积分 - * - * @param result 计算结果 - */ - public static void recountAllGivePoint(TradePriceCalculateRespBO result) { - result.setGivePoint(getSumValue(result.getItems(), item -> item.getSelected() ? item.getGivePoint() : 0, Integer::sum)); - } - - /** - * 重新计算单个订单项的支付金额 - * - * @param orderItem 订单项 - */ - public static void recountPayPrice(TradePriceCalculateRespBO.OrderItem orderItem) { - orderItem.setPayPrice(orderItem.getPrice() * orderItem.getCount() - - orderItem.getDiscountPrice() - + orderItem.getDeliveryPrice() - - orderItem.getCouponPrice() - - orderItem.getPointPrice() - - orderItem.getVipPrice() - ); - } - - /** - * 重新计算每个订单项的支付金额 - * - * 【目前主要是单测使用】 - * - * @param orderItems 订单项数组 - */ - public static void recountPayPrice(List orderItems) { - orderItems.forEach(orderItem -> { - if (orderItem.getDiscountPrice() == null) { - orderItem.setDiscountPrice(0); - } - if (orderItem.getDeliveryPrice() == null) { - orderItem.setDeliveryPrice(0); - } - if (orderItem.getCouponPrice() == null) { - orderItem.setCouponPrice(0); - } - if (orderItem.getPointPrice() == null) { - orderItem.setPointPrice(0); - } - if (orderItem.getUsePoint() == null) { - orderItem.setUsePoint(0); - } - if (orderItem.getGivePoint() == null) { - orderItem.setGivePoint(0); - } - if (orderItem.getVipPrice() == null) { - orderItem.setVipPrice(0); - } - recountPayPrice(orderItem); - }); - } - - /** - * 计算已选中的订单项,总支付金额 - * - * @param orderItems 订单项数组 - * @return 总支付金额 - */ - public static Integer calculateTotalPayPrice(List orderItems) { - return getSumValue(orderItems, - orderItem -> orderItem.getSelected() ? orderItem.getPayPrice() : 0, // 未选中的情况下,不计算支付金额 - Integer::sum); - } - - /** - * 计算已选中的订单项,总商品数 - * - * @param orderItems 订单项数组 - * @return 总商品数 - */ - public static Integer calculateTotalCount(List orderItems) { - return getSumValue(orderItems, - orderItem -> orderItem.getSelected() ? orderItem.getCount() : 0, // 未选中的情况下,不计算数量 - Integer::sum); - } - - /** - * 按照支付金额,返回每个订单项的分摊金额数组 - * - * 实际上 price 不仅仅可以传递的是金额,也可以是积分。因为它的实现逻辑,就是根据 payPrice 做分摊而已 - * - * @param orderItems 订单项数组 - * @param price 金额 - * @return 分摊金额数组,和传入的 orderItems 一一对应 - */ - public static List dividePrice(List orderItems, Integer price) { - Integer total = calculateTotalPayPrice(orderItems); - assert total != null; - // 遍历每一个,进行分摊 - List prices = new ArrayList<>(orderItems.size()); - int remainPrice = price; - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - // 1. 如果是未选中,则分摊为 0 - if (!orderItem.getSelected()) { - prices.add(0); - continue; - } - // 2. 如果选中,则按照百分比,进行分摊 - int partPrice; - if (i < orderItems.size() - 1) { // 减一的原因,是因为拆分时,如果按照比例,可能会出现.所以最后一个,使用反减 - partPrice = (int) (price * (1.0D * orderItem.getPayPrice() / total)); - remainPrice -= partPrice; - } else { - partPrice = remainPrice; - } - Assert.isTrue(partPrice >= 0, "分摊金额必须大于等于 0"); - prices.add(partPrice); - } - return prices; - } - - /** - * 计算订单调价价格分摊 - * - * 和 {@link #dividePrice(List, Integer)} 逻辑一致,只是传入的是 TradeOrderItemDO 对象 - * - * @param items 订单项 - * @param price 订单支付金额 - * @return 分摊金额数组,和传入的 orderItems 一一对应 - */ - public static List dividePrice2(List items, Integer price) { - Integer total = getSumValue(items, TradeOrderItemDO::getPrice, Integer::sum); - assert total != null; - // 遍历每一个,进行分摊 - List prices = new ArrayList<>(items.size()); - int remainPrice = price; - for (int i = 0; i < items.size(); i++) { - TradeOrderItemDO orderItem = items.get(i); - int partPrice; - if (i < items.size() - 1) { // 减一的原因,是因为拆分时,如果按照比例,可能会出现.所以最后一个,使用反减 - partPrice = (int) (price * (1.0D * orderItem.getPayPrice() / total)); - remainPrice -= partPrice; - } else { - partPrice = remainPrice; - } - Assert.isTrue(partPrice >= 0, "分摊金额必须大于等于 0"); - prices.add(partPrice); - } - return prices; - } - - /** - * 添加【匹配】单个 OrderItem 的营销明细 - * - * @param result 价格计算结果 - * @param orderItem 单个订单商品 SKU - * @param id 营销编号 - * @param name 营销名字 - * @param description 满足条件的提示 - * @param type 营销类型 - * @param discountPrice 单个订单商品 SKU 的优惠价格(总) - */ - public static void addPromotion(TradePriceCalculateRespBO result, TradePriceCalculateRespBO.OrderItem orderItem, - Long id, String name, Integer type, String description, Integer discountPrice) { - addPromotion(result, singletonList(orderItem), id, name, type, description, singletonList(discountPrice)); - } - - /** - * 添加【匹配】多个 OrderItem 的营销明细 - * - * @param result 价格计算结果 - * @param orderItems 多个订单商品 SKU - * @param id 营销编号 - * @param name 营销名字 - * @param description 满足条件的提示 - * @param type 营销类型 - * @param discountPrices 多个订单商品 SKU 的优惠价格(总),和 orderItems 一一对应 - */ - public static void addPromotion(TradePriceCalculateRespBO result, List orderItems, - Long id, String name, Integer type, String description, List discountPrices) { - // 创建营销明细 Item - List promotionItems = new ArrayList<>(discountPrices.size()); - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - promotionItems.add(new TradePriceCalculateRespBO.PromotionItem().setSkuId(orderItem.getSkuId()) - .setTotalPrice(orderItem.getPayPrice()).setDiscountPrice(discountPrices.get(i))); - } - // 创建营销明细 - TradePriceCalculateRespBO.Promotion promotion = new TradePriceCalculateRespBO.Promotion() - .setId(id).setName(name).setType(type) - .setTotalPrice(calculateTotalPayPrice(orderItems)) - .setDiscountPrice(getSumValue(discountPrices, value -> value, Integer::sum)) - .setItems(promotionItems).setMatch(true).setDescription(description); - result.getPromotions().add(promotion); - } - - /** - * 添加【不匹配】多个 OrderItem 的营销明细 - * - * @param result 价格计算结果 - * @param orderItems 多个订单商品 SKU - * @param id 营销编号 - * @param name 营销名字 - * @param description 满足条件的提示 - * @param type 营销类型 - */ - public static void addNotMatchPromotion(TradePriceCalculateRespBO result, List orderItems, - Long id, String name, Integer type, String description) { - // 创建营销明细 Item - List promotionItems = CollectionUtils.convertList(orderItems, - orderItem -> new TradePriceCalculateRespBO.PromotionItem().setSkuId(orderItem.getSkuId()) - .setTotalPrice(orderItem.getPayPrice()).setDiscountPrice(0)); - // 创建营销明细 - TradePriceCalculateRespBO.Promotion promotion = new TradePriceCalculateRespBO.Promotion() - .setId(id).setName(name).setType(type) - .setTotalPrice(calculateTotalPayPrice(orderItems)) - .setDiscountPrice(0) - .setItems(promotionItems).setMatch(false).setDescription(description); - result.getPromotions().add(promotion); - } - - public static String formatPrice(Integer price) { - return String.format("%.2f", price / 100d); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java deleted file mode 100644 index 4374783d2c..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.reward.RewardActivityApi; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; -import static cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper.formatPrice; - -/** - * 满减送活动的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_REWARD_ACTIVITY) -public class TradeRewardActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private RewardActivityApi rewardActivityApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 0. 只有【普通】订单,才计算该优惠 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { - return; - } - // 获得 SKU 对应的满减送活动 - List rewardActivities = rewardActivityApi.getMatchRewardActivityList( - convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSpuId)); - if (CollUtil.isEmpty(rewardActivities)) { - return; - } - - // 处理每个满减送活动 - rewardActivities.forEach(rewardActivity -> calculate(param, result, rewardActivity)); - } - - private void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result, - RewardActivityMatchRespDTO rewardActivity) { - // 1.1 获得满减送的订单项(商品)列表 - List orderItems = filterMatchCouponOrderItems(result, rewardActivity); - if (CollUtil.isEmpty(orderItems)) { - return; - } - // 1.2 获得最大匹配的满减送活动的规则 - RewardActivityMatchRespDTO.Rule rule = getMaxMatchRewardActivityRule(rewardActivity, orderItems); - if (rule == null) { - TradePriceCalculatorHelper.addNotMatchPromotion(result, orderItems, - rewardActivity.getId(), rewardActivity.getName(), PromotionTypeEnum.REWARD_ACTIVITY.getType(), - getRewardActivityNotMeetTip(rewardActivity)); - return; - } - - // 2.1 计算可以优惠的金额 - Integer newDiscountPrice = rule.getDiscountPrice(); - // 2.2 计算分摊的优惠金额 - List divideDiscountPrices = TradePriceCalculatorHelper.dividePrice(orderItems, newDiscountPrice); - - // 3.1 记录使用的优惠劵 - result.setCouponId(param.getCouponId()); - // 3.2 记录优惠明细 - TradePriceCalculatorHelper.addPromotion(result, orderItems, - rewardActivity.getId(), rewardActivity.getName(), PromotionTypeEnum.REWARD_ACTIVITY.getType(), - StrUtil.format("满减送:省 {} 元", formatPrice(rule.getDiscountPrice())), - divideDiscountPrices); - // 3.3 更新 SKU 优惠金额 - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + divideDiscountPrices.get(i)); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - } - TradePriceCalculatorHelper.recountAllPrice(result); - } - - /** - * 获得满减送的订单项(商品)列表 - * - * @param result 计算结果 - * @param rewardActivity 满减送活动 - * @return 订单项(商品)列表 - */ - private List filterMatchCouponOrderItems(TradePriceCalculateRespBO result, - RewardActivityMatchRespDTO rewardActivity) { - return filterList(result.getItems(), - orderItem -> CollUtil.contains(rewardActivity.getSpuIds(), orderItem.getSpuId())); - } - - /** - * 获得最大匹配的满减送活动的规则 - * - * @param rewardActivity 满减送活动 - * @param orderItems 商品项 - * @return 匹配的活动规则 - */ - private RewardActivityMatchRespDTO.Rule getMaxMatchRewardActivityRule(RewardActivityMatchRespDTO rewardActivity, - List orderItems) { - // 1. 计算数量和价格 - Integer count = TradePriceCalculatorHelper.calculateTotalCount(orderItems); - Integer price = TradePriceCalculatorHelper.calculateTotalPayPrice(orderItems); - assert count != null && price != null; - - // 2. 倒序找一个最大优惠的规则 - for (int i = rewardActivity.getRules().size() - 1; i >= 0; i--) { - RewardActivityMatchRespDTO.Rule rule = rewardActivity.getRules().get(i); - if (PromotionConditionTypeEnum.PRICE.getType().equals(rewardActivity.getConditionType()) - && price >= rule.getLimit()) { - return rule; - } - if (PromotionConditionTypeEnum.COUNT.getType().equals(rewardActivity.getConditionType()) - && count >= rule.getLimit()) { - return rule; - } - } - return null; - } - - /** - * 获得满减送活动部匹配时的提示 - * - * @param rewardActivity 满减送活动 - * @return 提示 - */ - private String getRewardActivityNotMeetTip(RewardActivityMatchRespDTO rewardActivity) { - // TODO 芋艿:后面再想想;应该找第一个规则,算下还差多少即可。 - return "TODO"; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java deleted file mode 100644 index fe984ec0e0..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.seckill.SeckillActivityApi; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT; - -// TODO huihui:单测需要补充 -/** - * 秒杀活动的 {@link TradePriceCalculator} 实现类 - * - * @author HUIHUI - */ -@Component -@Order(TradePriceCalculator.ORDER_SECKILL_ACTIVITY) -public class TradeSeckillActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private SeckillActivityApi seckillActivityApi; - - @Resource - private TradeOrderQueryService tradeOrderQueryService; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1. 判断订单类型和是否具有秒杀活动编号 - if (param.getSeckillActivityId() == null) { - return; - } - Assert.isTrue(param.getItems().size() == 1, "秒杀时,只允许选择一个商品"); - // 2. 校验是否可以参与秒杀 - TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0); - SeckillValidateJoinRespDTO seckillActivity = validateJoinSeckill( - param.getUserId(), param.getSeckillActivityId(), - orderItem.getSkuId(), orderItem.getCount()); - - // 3.1 记录优惠明细 - Integer discountPrice = orderItem.getPayPrice() - seckillActivity.getSeckillPrice() * orderItem.getCount(); - TradePriceCalculatorHelper.addPromotion(result, orderItem, - param.getSeckillActivityId(), seckillActivity.getName(), PromotionTypeEnum.SECKILL_ACTIVITY.getType(), - StrUtil.format("秒杀活动:省 {} 元", TradePriceCalculatorHelper.formatPrice(discountPrice)), - discountPrice); - // 3.2 更新 SKU 优惠金额 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + discountPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - TradePriceCalculatorHelper.recountAllPrice(result); - } - - private SeckillValidateJoinRespDTO validateJoinSeckill(Long userId, Long activityId, Long skuId, Integer count) { - // 1. 校验是否可以参与秒杀 - SeckillValidateJoinRespDTO seckillActivity = seckillActivityApi.validateJoinSeckill(activityId, skuId, count); - // 2. 校验总限购数量,目前只有 trade 有具体下单的数据,需要交给 trade 价格计算使用 - int seckillProductCount = tradeOrderQueryService.getSeckillProductCount(userId, activityId); - if (seckillProductCount + count > seckillActivity.getTotalLimitCount()) { - throw exception(PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT); - } - return seckillActivity; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/mapper/brokerage/BrokerageUserMapper.xml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/mapper/brokerage/BrokerageUserMapper.xml deleted file mode 100644 index 066f75d4ea..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/mapper/brokerage/BrokerageUserMapper.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/Kd100ExpressClientIntegrationTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/Kd100ExpressClientIntegrationTest.java deleted file mode 100644 index 11b027bc8c..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/Kd100ExpressClientIntegrationTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kd100.Kd100ExpressClient; -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.web.client.RestTemplate; - -import java.util.List; - -/** - * {@link Kd100ExpressClient} 的集成测试 - * - * @author jason - */ -@Slf4j -public class Kd100ExpressClientIntegrationTest { - - private Kd100ExpressClient client; - - @BeforeEach - public void init() { - RestTemplate restTemplate = new RestTemplateBuilder().build(); - TradeExpressProperties.Kd100Config config = new TradeExpressProperties.Kd100Config() - .setKey("pLXUGAwK5305") - .setCustomer("E77DF18BE109F454A5CD319E44BF5177"); - client = new Kd100ExpressClient(restTemplate, config); - } - - @Test - @Disabled("集成测试,暂时忽略") - public void testGetExpressTrackList() { - ExpressTrackQueryReqDTO reqDTO = new ExpressTrackQueryReqDTO(); - reqDTO.setExpressCode("STO"); - reqDTO.setLogisticsNo("773220402764314"); - List tracks = client.getExpressTrackList(reqDTO); - System.out.println(JsonUtils.toJsonPrettyString(tracks)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/KdNiaoExpressClientIntegrationTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/KdNiaoExpressClientIntegrationTest.java deleted file mode 100644 index a270c4b848..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/KdNiaoExpressClientIntegrationTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kdniao.KdNiaoExpressClient; -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.web.client.RestTemplate; - -import java.util.List; - -/** - * {@link KdNiaoExpressClient} 的集成测试 - * - * @author jason - */ -@Slf4j -public class KdNiaoExpressClientIntegrationTest { - - private KdNiaoExpressClient client; - - @BeforeEach - public void init() { - RestTemplate restTemplate = new RestTemplateBuilder().build(); - TradeExpressProperties.KdNiaoConfig config = new TradeExpressProperties.KdNiaoConfig() - .setApiKey("cb022f1e-48f1-4c4a-a723-9001ac9676b8") - .setBusinessId("1809751"); - client = new KdNiaoExpressClient(restTemplate, config); - } - - @Test - @Disabled("集成测试,暂时忽略") - public void testGetExpressTrackList() { - ExpressTrackQueryReqDTO reqDTO = new ExpressTrackQueryReqDTO(); - reqDTO.setExpressCode("STO"); - reqDTO.setLogisticsNo("777168349863987"); - List tracks = client.getExpressTrackList(reqDTO); - System.out.println(JsonUtils.toJsonPrettyString(tracks)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceTest.java deleted file mode 100644 index 4ae510a958..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceTest.java +++ /dev/null @@ -1,158 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.aftersale.AfterSaleLogMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.aftersale.AfterSaleMapper; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link AfterSaleService} 的单元测试 - * - * @author 芋道源码 - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(AfterSaleServiceImpl.class) -public class AfterSaleServiceTest extends BaseDbUnitTest { - - @Resource - private AfterSaleServiceImpl tradeAfterSaleService; - - @Resource - private AfterSaleMapper tradeAfterSaleMapper; - @Resource - private AfterSaleLogMapper tradeAfterSaleLogMapper; - - @MockBean - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - - @MockBean - private PayRefundApi payRefundApi; - - @MockBean - private TradeOrderProperties tradeOrderProperties; - - @Test - public void testCreateAfterSale() { - // 准备参数 - Long userId = 1024L; - AppAfterSaleCreateReqVO createReqVO = new AppAfterSaleCreateReqVO() - .setOrderItemId(1L).setRefundPrice(100).setWay(AfterSaleWayEnum.RETURN_AND_REFUND.getWay()) - .setApplyReason("退钱").setApplyDescription("快退") - .setApplyPicUrls(asList("https://www.baidu.com/1.png", "https://www.baidu.com/2.png")); - // mock 方法(交易订单项) - TradeOrderItemDO orderItem = randomPojo(TradeOrderItemDO.class, o -> { - o.setOrderId(111L).setUserId(userId).setPayPrice(200); - o.setAfterSaleStatus(TradeOrderItemAfterSaleStatusEnum.NONE.getStatus()); - }); - when(tradeOrderQueryService.getOrderItem(eq(1024L), eq(1L))) - .thenReturn(orderItem); - // mock 方法(交易订单) - TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> o.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()) - .setNo("202211301234")); - when(tradeOrderQueryService.getOrder(eq(1024L), eq(111L))).thenReturn(order); - - // 调用 - Long afterSaleId = tradeAfterSaleService.createAfterSale(userId, createReqVO); - // 断言(TradeAfterSaleDO) - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(afterSaleId); - assertNotNull(afterSale.getNo()); - assertEquals(afterSale.getStatus(), AfterSaleStatusEnum.APPLY.getStatus()); - assertEquals(afterSale.getType(), AfterSaleTypeEnum.IN_SALE.getType()); - assertPojoEquals(afterSale, createReqVO); - assertEquals(afterSale.getUserId(), 1024L); - assertPojoEquals(afterSale, orderItem, "id", "creator", "createTime", "updater", "updateTime"); - assertEquals(afterSale.getOrderNo(), "202211301234"); - assertNull(afterSale.getPayRefundId()); - assertNull(afterSale.getRefundTime()); - assertNull(afterSale.getLogisticsId()); - assertNull(afterSale.getLogisticsNo()); - assertNull(afterSale.getDeliveryTime()); - assertNull(afterSale.getReceiveReason()); - // 断言(TradeAfterSaleLogDO) - AfterSaleLogDO afterSaleLog = tradeAfterSaleLogMapper.selectList().get(0); - assertEquals(afterSaleLog.getUserId(), userId); - assertEquals(afterSaleLog.getUserType(), UserTypeEnum.MEMBER.getValue()); - assertEquals(afterSaleLog.getAfterSaleId(), afterSaleId); - assertPojoEquals(afterSale, orderItem, "id", "creator", "createTime", "updater", "updateTime"); - assertEquals(afterSaleLog.getContent(), AfterSaleStatusEnum.APPLY.getContent()); - } - - @Test - public void testGetAfterSalePage() { - // mock 数据 - AfterSaleDO dbAfterSale = randomPojo(AfterSaleDO.class, o -> { // 等会查询到 - o.setNo("202211190847450020500077"); - o.setStatus(AfterSaleStatusEnum.APPLY.getStatus()); - o.setWay(AfterSaleWayEnum.RETURN_AND_REFUND.getWay()); - o.setType(AfterSaleTypeEnum.IN_SALE.getType()); - o.setOrderNo("202211190847450020500011"); - o.setSpuName("芋艿"); - o.setCreateTime(buildTime(2022, 1, 15)); - }); - tradeAfterSaleMapper.insert(dbAfterSale); - // 测试 no 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setNo("202211190847450020500066"))); - // 测试 status 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setStatus(AfterSaleStatusEnum.SELLER_REFUSE.getStatus()))); - // 测试 way 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setWay(AfterSaleWayEnum.REFUND.getWay()))); - // 测试 type 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setType(AfterSaleTypeEnum.AFTER_SALE.getType()))); - // 测试 orderNo 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setOrderNo("202211190847450020500022"))); - // 测试 spuName 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setSpuName("土豆"))); - // 测试 createTime 不匹配 - tradeAfterSaleMapper.insert(cloneIgnoreId(dbAfterSale, o -> o.setCreateTime(buildTime(2022, 1, 20)))); - // 准备参数 - AfterSalePageReqVO reqVO = new AfterSalePageReqVO(); - reqVO.setNo("20221119084745002050007"); - reqVO.setStatus(AfterSaleStatusEnum.APPLY.getStatus()); - reqVO.setWay(AfterSaleWayEnum.RETURN_AND_REFUND.getWay()); - reqVO.setType(AfterSaleTypeEnum.IN_SALE.getType()); - reqVO.setOrderNo("20221119084745002050001"); - reqVO.setSpuName("芋"); - reqVO.setCreateTime(new LocalDateTime[]{buildTime(2022, 1, 1), buildTime(2022, 1, 16)}); - - // 调用 - PageResult pageResult = tradeAfterSaleService.getAfterSalePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbAfterSale, pageResult.getList().get(0)); - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImplTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImplTest.java deleted file mode 100644 index 06d9bffe07..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImplTest.java +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.hutool.core.util.NumberUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageRecordMapper; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.math.RoundingMode; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.hutool.core.util.RandomUtil.randomInt; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomInteger; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; - -// TODO @芋艿:单测后续看看 -/** - * {@link BrokerageRecordServiceImpl} 的单元测试类 - * - * @author owen - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(BrokerageRecordServiceImpl.class) -public class BrokerageRecordServiceImplTest extends BaseDbUnitTest { - - @Resource - private BrokerageRecordServiceImpl brokerageRecordService; - @Resource - private BrokerageRecordMapper brokerageRecordMapper; - - @MockBean - private TradeConfigService tradeConfigService; - @MockBean - private BrokerageUserService brokerageUserService; - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetBrokerageRecordPage() { - // mock 数据 - BrokerageRecordDO dbBrokerageRecord = randomPojo(BrokerageRecordDO.class, o -> { // 等会查询到 - o.setUserId(null); - o.setBizType(null); - o.setStatus(null); - o.setCreateTime(null); - }); - brokerageRecordMapper.insert(dbBrokerageRecord); - // 测试 userId 不匹配 - brokerageRecordMapper.insert(cloneIgnoreId(dbBrokerageRecord, o -> o.setUserId(null))); - // 测试 bizType 不匹配 - brokerageRecordMapper.insert(cloneIgnoreId(dbBrokerageRecord, o -> o.setBizType(null))); - // 测试 status 不匹配 - brokerageRecordMapper.insert(cloneIgnoreId(dbBrokerageRecord, o -> o.setStatus(null))); - // 测试 createTime 不匹配 - brokerageRecordMapper.insert(cloneIgnoreId(dbBrokerageRecord, o -> o.setCreateTime(null))); - // 准备参数 - BrokerageRecordPageReqVO reqVO = new BrokerageRecordPageReqVO(); - reqVO.setUserId(null); - reqVO.setBizType(null); - reqVO.setStatus(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = brokerageRecordService.getBrokerageRecordPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbBrokerageRecord, pageResult.getList().get(0)); - } - - @Test - public void testCalculatePrice_useFixedPrice() { - // mock 数据 - Integer payPrice = randomInteger(); - Integer percent = randomInt(1, 101); - Integer fixedPrice = randomInt(); - // 调用 - int brokerage = brokerageRecordService.calculatePrice(payPrice, percent, fixedPrice); - // 断言 - assertEquals(brokerage, fixedPrice); - } - - @Test - public void testCalculatePrice_usePercent() { - // mock 数据 - Integer payPrice = randomInteger(); - Integer percent = randomInt(1, 101); - Integer fixedPrice = randomEle(new Integer[]{0, null}); - System.out.println("fixedPrice=" + fixedPrice); - // 调用 - int brokerage = brokerageRecordService.calculatePrice(payPrice, percent, fixedPrice); - // 断言 - assertEquals(brokerage, NumberUtil.div(NumberUtil.mul(payPrice, percent), 100, 0, RoundingMode.DOWN).intValue()); - } - - @Test - public void testCalculatePrice_equalsZero() { - // mock 数据 - Integer payPrice = null; - Integer percent = null; - Integer fixedPrice = null; - // 调用 - int brokerage = brokerageRecordService.calculatePrice(payPrice, percent, fixedPrice); - // 断言 - assertEquals(brokerage, 0); - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImplTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImplTest.java deleted file mode 100644 index d873518d74..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImplTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageUserMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; - -// TODO @芋艿:单测后续看看 -/** - * {@link BrokerageUserServiceImpl} 的单元测试类 - * - * @author owen - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(BrokerageUserServiceImpl.class) -public class BrokerageUserServiceImplTest extends BaseDbUnitTest { - - @Resource - private BrokerageUserServiceImpl brokerageUserService; - - @Resource - private BrokerageUserMapper brokerageUserMapper; - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetBrokerageUserPage() { - // mock 数据 - BrokerageUserDO dbBrokerageUser = randomPojo(BrokerageUserDO.class, o -> { // 等会查询到 - o.setBindUserId(null); - o.setBrokerageEnabled(null); - o.setCreateTime(null); - }); - brokerageUserMapper.insert(dbBrokerageUser); - // 测试 brokerageUserId 不匹配 - brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setBindUserId(null))); - // 测试 brokerageEnabled 不匹配 - brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setBrokerageEnabled(null))); - // 测试 createTime 不匹配 - brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setCreateTime(null))); - // 准备参数 - BrokerageUserPageReqVO reqVO = new BrokerageUserPageReqVO(); - reqVO.setBindUserId(null); - reqVO.setBrokerageEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = brokerageUserService.getBrokerageUserPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbBrokerageUser, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImplTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImplTest.java deleted file mode 100644 index 26cee7fe07..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImplTest.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageWithdrawMapper; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import jakarta.validation.Validator; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; - -// TODO 芋艿:后续 review -/** - * {@link BrokerageWithdrawServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(BrokerageWithdrawServiceImpl.class) -public class BrokerageWithdrawServiceImplTest extends BaseDbUnitTest { - - @Resource - private BrokerageWithdrawServiceImpl brokerageWithdrawService; - - @Resource - private BrokerageWithdrawMapper brokerageWithdrawMapper; - - @MockBean - private BrokerageRecordService brokerageRecordService; - @MockBean - private BrokerageUserService brokerageUserService; - @MockBean - private TradeConfigService tradeConfigService; - - @MockBean - private NotifyMessageSendApi notifyMessageSendApi; - - @Resource - private Validator validator; - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetBrokerageWithdrawPage() { - // mock 数据 - BrokerageWithdrawDO dbBrokerageWithdraw = randomPojo(BrokerageWithdrawDO.class, o -> { // 等会查询到 - o.setUserId(null); - o.setType(null); - o.setName(null); - o.setAccountNo(null); - o.setBankName(null); - o.setStatus(null); - o.setCreateTime(null); - }); - brokerageWithdrawMapper.insert(dbBrokerageWithdraw); - // 测试 userId 不匹配 - brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setUserId(null))); - // 测试 type 不匹配 - brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setType(null))); - // 测试 name 不匹配 - brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setName(null))); - // 测试 accountNo 不匹配 - brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setAccountNo(null))); - // 测试 bankName 不匹配 - brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setBankName(null))); - // 测试 status 不匹配 - brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setStatus(null))); - // 测试 auditReason 不匹配 - brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setAuditReason(null))); - // 测试 auditTime 不匹配 - brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setAuditTime(null))); - // 测试 remark 不匹配 - brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setRemark(null))); - // 测试 createTime 不匹配 - brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setCreateTime(null))); - // 准备参数 - BrokerageWithdrawPageReqVO reqVO = new BrokerageWithdrawPageReqVO(); - reqVO.setUserId(null); - reqVO.setType(null); - reqVO.setName(null); - reqVO.setAccountNo(null); - reqVO.setBankName(null); - reqVO.setStatus(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbBrokerageWithdraw, pageResult.getList().get(0)); - } - - @Test - public void testCalculateFeePrice() { - Integer withdrawPrice = 100; - // 测试手续费比例未设置 - Integer percent = null; - assertEquals(brokerageWithdrawService.calculateFeePrice(withdrawPrice, percent), 0); - // 测试手续费给为0 - percent = 0; - assertEquals(brokerageWithdrawService.calculateFeePrice(withdrawPrice, percent), 0); - // 测试手续费 - percent = 1; - assertEquals(brokerageWithdrawService.calculateFeePrice(withdrawPrice, percent), 1); - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java deleted file mode 100644 index 3f05f55591..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java +++ /dev/null @@ -1,299 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.member.api.address.MemberAddressApi; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderConfig; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.Duration; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link TradeOrderUpdateServiceImpl} 的单元测试类 - * - * @author LeeYan9 - * @since 2022-09-07 - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import({TradeOrderUpdateServiceImpl.class, TradeOrderConfig.class}) -public class TradeOrderUpdateServiceTest extends BaseDbUnitTest { - - @Resource - private TradeOrderUpdateServiceImpl tradeOrderUpdateService; - - @Resource - private TradeOrderMapper tradeOrderMapper; - @Resource - private TradeOrderItemMapper tradeOrderItemMapper; - - @MockBean - private MemberUserApi memberUserApi; - @MockBean - private ProductSpuApi productSpuApi; - @MockBean - private ProductSkuApi productSkuApi; -// @MockBean -// private PriceApi priceApi; - @MockBean - private PayOrderApi payOrderApi; - @MockBean - private MemberAddressApi addressApi; - @MockBean - private CouponApi couponApi; - - @MockBean - private TradeOrderProperties tradeOrderProperties; - - @BeforeEach - public void setUp() { - when(tradeOrderProperties.getAppId()).thenReturn(888L); - when(tradeOrderProperties.getPayExpireTime()).thenReturn(Duration.ofDays(1)); - } - -// @Test -// public void testCreateTradeOrder_success() { -// // 准备参数 -// Long userId = 100L; -// String userIp = "127.0.0.1"; -//// AppTradeOrderCreateReqVO reqVO = new AppTradeOrderCreateReqVO() -//// .setAddressId(10L).setCouponId(101L).setRemark("我是备注").setFromCart(true) -//// .setItems(Arrays.asList(new AppTradeOrderCreateReqVO.Item().setSkuId(1L).setCount(3), -//// new AppTradeOrderCreateReqVO.Item().setSkuId(2L).setCount(4))); -// AppTradeOrderCreateReqVO reqVO = null; -// // TODO 芋艿:重新高下 -// // mock 方法(商品 SKU 检查) -// ProductSkuRespDTO sku01 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(1L).setSpuId(11L) -// .setPrice(50).setStock(100) -// .setProperties(singletonList(new ProductPropertyValueDetailRespDTO().setPropertyId(111L).setValueId(222L)))); -// ProductSkuRespDTO sku02 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(2L).setSpuId(21L) -// .setPrice(20).setStock(50)) -// .setProperties(singletonList(new ProductPropertyValueDetailRespDTO().setPropertyId(333L).setValueId(444L))); -// when(productSkuApi.getSkuList(eq(asSet(1L, 2L)))).thenReturn(Arrays.asList(sku01, sku02)); -// // mock 方法(商品 SPU 检查) -// ProductSpuRespDTO spu01 = randomPojo(ProductSpuRespDTO.class, o -> o.setId(11L) -// .setStatus(ProductSpuStatusEnum.ENABLE.getStatus()).setName("商品 1")); -// ProductSpuRespDTO spu02 = randomPojo(ProductSpuRespDTO.class, o -> o.setId(21L) -// .setStatus(ProductSpuStatusEnum.ENABLE.getStatus())); -// when(productSpuApi.getSpuList(eq(asSet(11L, 21L)))).thenReturn(Arrays.asList(spu01, spu02)); -// // mock 方法(用户收件地址的校验) -// MemberAddressRespDTO addressRespDTO = new MemberAddressRespDTO().setId(10L).setUserId(userId).setName("芋艿") -// .setMobile("15601691300").setAreaId(3306).setDetailAddress("土豆村"); -// when(addressApi.getAddress(eq(10L), eq(userId))).thenReturn(addressRespDTO); -// // mock 方法(价格计算) -// PriceCalculateRespDTO.OrderItem priceOrderItem01 = new PriceCalculateRespDTO.OrderItem() -// .setSpuId(11L).setSkuId(1L).setCount(3).setOriginalPrice(150).setOriginalUnitPrice(50) -// .setDiscountPrice(20).setPayPrice(130).setOrderPartPrice(7).setOrderDividePrice(35); -// PriceCalculateRespDTO.OrderItem priceOrderItem02 = new PriceCalculateRespDTO.OrderItem() -// .setSpuId(21L).setSkuId(2L).setCount(4).setOriginalPrice(80).setOriginalUnitPrice(20) -// .setDiscountPrice(40).setPayPrice(40).setOrderPartPrice(15).setOrderDividePrice(25); -// PriceCalculateRespDTO.Order priceOrder = new PriceCalculateRespDTO.Order() -// .setTotalPrice(230).setDiscountPrice(0).setCouponPrice(30) -// .setPointPrice(10).setDeliveryPrice(20).setPayPrice(80).setCouponId(101L).setCouponPrice(30) -// .setItems(Arrays.asList(priceOrderItem01, priceOrderItem02)); -// when(priceApi.calculatePrice(argThat(priceCalculateReqDTO -> { -// assertEquals(priceCalculateReqDTO.getUserId(), 100L); -// assertEquals(priceCalculateReqDTO.getCouponId(), 101L); -// assertEquals(priceCalculateReqDTO.getItems().get(0).getSkuId(), 1L); -// assertEquals(priceCalculateReqDTO.getItems().get(0).getCount(), 3); -// assertEquals(priceCalculateReqDTO.getItems().get(1).getSkuId(), 2L); -// assertEquals(priceCalculateReqDTO.getItems().get(1).getCount(), 4); -// return true; -// }))).thenReturn(new PriceCalculateRespDTO().setOrder(priceOrder)); -// // mock 方法(创建支付单) -// when(payOrderApi.createOrder(argThat(createReqDTO -> { -// assertEquals(createReqDTO.getAppId(), 888L); -// assertEquals(createReqDTO.getUserIp(), userIp); -// assertNotNull(createReqDTO.getMerchantOrderId()); // 由于 tradeOrderId 后生成,只能校验非空 -// assertEquals(createReqDTO.getSubject(), "商品 1 等多件"); -// assertNull(createReqDTO.getBody()); -// assertEquals(createReqDTO.getPrice(), 80); -// assertNotNull(createReqDTO.getExpireTime()); -// return true; -// }))).thenReturn(1000L); -// -// // 调用方法 -// TradeOrderDO order = tradeOrderUpdateService.createOrder(userId, userIp, reqVO, null); -// // 断言 TradeOrderDO 订单 -// List tradeOrderDOs = tradeOrderMapper.selectList(); -// assertEquals(tradeOrderDOs.size(), 1); -// TradeOrderDO tradeOrderDO = tradeOrderDOs.get(0); -// assertEquals(tradeOrderDO.getId(), order.getId()); -// assertNotNull(tradeOrderDO.getNo()); -// assertEquals(tradeOrderDO.getType(), TradeOrderTypeEnum.NORMAL.getType()); -// assertEquals(tradeOrderDO.getTerminal(), TerminalEnum.H5.getTerminal()); -// assertEquals(tradeOrderDO.getUserId(), userId); -// assertEquals(tradeOrderDO.getUserIp(), userIp); -// assertEquals(tradeOrderDO.getStatus(), TradeOrderStatusEnum.UNPAID.getStatus()); -// assertEquals(tradeOrderDO.getProductCount(), 7); -// assertNull(tradeOrderDO.getFinishTime()); -// assertNull(tradeOrderDO.getCancelTime()); -// assertNull(tradeOrderDO.getCancelType()); -// assertEquals(tradeOrderDO.getUserRemark(), "我是备注"); -// assertNull(tradeOrderDO.getRemark()); -// assertFalse(tradeOrderDO.getPayStatus()); -// assertNull(tradeOrderDO.getPayTime()); -// assertEquals(tradeOrderDO.getTotalPrice(), 230); -// assertEquals(tradeOrderDO.getDiscountPrice(), 0); -// assertEquals(tradeOrderDO.getAdjustPrice(), 0); -// assertEquals(tradeOrderDO.getPayPrice(), 80); -// assertEquals(tradeOrderDO.getPayOrderId(), 1000L); -// assertNull(tradeOrderDO.getPayChannelCode()); -// assertNull(tradeOrderDO.getLogisticsId()); -// assertNull(tradeOrderDO.getDeliveryTime()); -// assertNull(tradeOrderDO.getReceiveTime()); -// assertEquals(tradeOrderDO.getReceiverName(), "芋艿"); -// assertEquals(tradeOrderDO.getReceiverMobile(), "15601691300"); -// assertEquals(tradeOrderDO.getReceiverAreaId(), 3306); -// assertEquals(tradeOrderDO.getReceiverDetailAddress(), "土豆村"); -// assertEquals(tradeOrderDO.getRefundStatus(), TradeOrderRefundStatusEnum.NONE.getStatus()); -// assertEquals(tradeOrderDO.getRefundPrice(), 0); -// assertEquals(tradeOrderDO.getCouponPrice(), 30); -// assertEquals(tradeOrderDO.getPointPrice(), 10); -// // 断言 TradeOrderItemDO 订单(第 1 个) -// List tradeOrderItemDOs = tradeOrderItemMapper.selectList(); -// assertEquals(tradeOrderItemDOs.size(), 2); -// TradeOrderItemDO tradeOrderItemDO01 = tradeOrderItemDOs.get(0); -// assertNotNull(tradeOrderItemDO01.getId()); -// assertEquals(tradeOrderItemDO01.getUserId(), userId); -// assertEquals(tradeOrderItemDO01.getOrderId(), order.getId()); -// assertEquals(tradeOrderItemDO01.getSpuId(), 11L); -// assertEquals(tradeOrderItemDO01.getSkuId(), 1L); -// assertEquals(tradeOrderItemDO01.getProperties().size(), 1); -// assertEquals(tradeOrderItemDO01.getProperties().get(0).getPropertyId(), 111L); -// assertEquals(tradeOrderItemDO01.getProperties().get(0).getValueId(), 222L); -// //assertEquals(tradeOrderItemDO01.getSpuName(), sku01.getSpuName()); TODO 找不到spuName -// assertEquals(tradeOrderItemDO01.getPicUrl(), sku01.getPicUrl()); -// assertEquals(tradeOrderItemDO01.getCount(), 3); -//// assertEquals(tradeOrderItemDO01.getOriginalPrice(), 150); -// assertEquals(tradeOrderItemDO01.getPrice(), 50); -// assertEquals(tradeOrderItemDO01.getDiscountPrice(), 20); -// assertEquals(tradeOrderItemDO01.getPayPrice(), 130); -// assertEquals(tradeOrderItemDO01.getAfterSaleStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus()); -// // 断言 TradeOrderItemDO 订单(第 2 个) -// TradeOrderItemDO tradeOrderItemDO02 = tradeOrderItemDOs.get(1); -// assertNotNull(tradeOrderItemDO02.getId()); -// assertEquals(tradeOrderItemDO02.getUserId(), userId); -// assertEquals(tradeOrderItemDO02.getOrderId(), order.getId()); -// assertEquals(tradeOrderItemDO02.getSpuId(), 21L); -// assertEquals(tradeOrderItemDO02.getSkuId(), 2L); -// assertEquals(tradeOrderItemDO02.getProperties().size(), 1); -// assertEquals(tradeOrderItemDO02.getProperties().get(0).getPropertyId(), 333L); -// assertEquals(tradeOrderItemDO02.getProperties().get(0).getValueId(), 444L); -// //assertEquals(tradeOrderItemDO02.getSpuName(), sku02.getSpuName()); TODO 找不到spuName -// assertEquals(tradeOrderItemDO02.getPicUrl(), sku02.getPicUrl()); -// assertEquals(tradeOrderItemDO02.getCount(), 4); -//// assertEquals(tradeOrderItemDO02.getOriginalPrice(), 80); -// assertEquals(tradeOrderItemDO02.getPrice(), 20); -// assertEquals(tradeOrderItemDO02.getDiscountPrice(), 40); -// assertEquals(tradeOrderItemDO02.getPayPrice(), 40); -// assertEquals(tradeOrderItemDO02.getAfterSaleStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus()); -// // 校验调用 -// verify(productSkuApi).updateSkuStock(argThat(updateStockReqDTO -> { -// assertEquals(updateStockReqDTO.getItems().size(), 2); -// assertEquals(updateStockReqDTO.getItems().get(0).getId(), 1L); -// assertEquals(updateStockReqDTO.getItems().get(0).getIncrCount(), 3); -// assertEquals(updateStockReqDTO.getItems().get(1).getId(), 2L); -// assertEquals(updateStockReqDTO.getItems().get(1).getIncrCount(), 4); -// return true; -// })); -// verify(couponApi).useCoupon(argThat(reqDTO -> { -// assertEquals(reqDTO.getId(), reqVO.getCouponId()); -// assertEquals(reqDTO.getUserId(), userId); -// assertEquals(reqDTO.getOrderId(), order.getId()); -// return true; -// })); -// } - - @Test - public void testUpdateOrderPaid() { - // mock 数据(TradeOrder) - TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> { - o.setId(1L).setStatus(TradeOrderStatusEnum.UNPAID.getStatus()); - o.setPayOrderId(10L).setPayStatus(false).setPayPrice(100).setPayTime(null); - }); - tradeOrderMapper.insert(order); - // 准备参数 - Long id = 1L; - Long payOrderId = 10L; - // mock 方法(支付单) - when(payOrderApi.getOrder(eq(10L))).thenReturn(randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()).setChannelCode("wx_pub") - .setMerchantOrderId("1")).setPrice(100)); - - // 调用 - tradeOrderUpdateService.updateOrderPaid(id, payOrderId); - // 断言 - TradeOrderDO dbOrder = tradeOrderMapper.selectById(id); - assertEquals(dbOrder.getStatus(), TradeOrderStatusEnum.UNDELIVERED.getStatus()); - assertTrue(dbOrder.getPayStatus()); - assertNotNull(dbOrder.getPayTime()); - assertEquals(dbOrder.getPayChannelCode(), "wx_pub"); - } - - @Test - public void testDeliveryOrder() { - // mock 数据(TradeOrder) - TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> { - o.setId(1L).setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()); - o.setLogisticsId(null).setLogisticsNo(null).setDeliveryTime(null); - }); - tradeOrderMapper.insert(order); - // 准备参数 - TradeOrderDeliveryReqVO deliveryReqVO = new TradeOrderDeliveryReqVO().setId(1L) - .setLogisticsId(10L).setLogisticsNo("100"); - // mock 方法(支付单) - - // 调用 - tradeOrderUpdateService.deliveryOrder(deliveryReqVO); - // 断言 - TradeOrderDO dbOrder = tradeOrderMapper.selectById(1L); - assertEquals(dbOrder.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus()); - assertPojoEquals(dbOrder, deliveryReqVO); - assertNotNull(dbOrder.getDeliveryTime()); - } - - @Test - public void testReceiveOrder() { - // mock 数据(TradeOrder) - TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> { - o.setId(1L).setUserId(10L).setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()); - o.setReceiveTime(null); - }); - tradeOrderMapper.insert(order); - // 准备参数 - Long id = 1L; - Long userId = 10L; - // mock 方法(支付单) - - // 调用 - tradeOrderUpdateService.receiveOrderByMember(userId, id); - // 断言 - TradeOrderDO dbOrder = tradeOrderMapper.selectById(1L); - assertEquals(dbOrder.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus()); - assertNotNull(dbOrder.getReceiveTime()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImplTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImplTest.java deleted file mode 100644 index b3900e04b9..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImplTest.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculator; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; - -import java.util.Arrays; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.when; - -/** - * {@link TradePriceServiceImpl} 的单元测试 - * - * @author 芋道源码 - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -public class TradePriceServiceImplTest extends BaseMockitoUnitTest { - - @InjectMocks - private TradePriceServiceImpl tradePriceService; - - @Mock - private ProductSkuApi productSkuApi; - @Mock - private ProductSpuApi productSpuApi; - @Mock - private List priceCalculators; - - @Test - public void testCalculatePrice() { - // 准备参数 - TradePriceCalculateReqBO calculateReqBO = new TradePriceCalculateReqBO() - .setUserId(10L) - .setCouponId(20L).setAddressId(30L) - .setItems(Arrays.asList( - new TradePriceCalculateReqBO.Item().setSkuId(100L).setCount(1).setSelected(true), - new TradePriceCalculateReqBO.Item().setSkuId(200L).setCount(3).setSelected(true), - new TradePriceCalculateReqBO.Item().setSkuId(300L).setCount(6).setCartId(233L).setSelected(false) - )); - // mock 方法 - List skuList = Arrays.asList( - new ProductSkuRespDTO().setId(100L).setStock(500).setPrice(1000).setPicUrl("https://t.cn/1.png").setSpuId(1001L) - .setProperties(singletonList(new ProductPropertyValueDetailRespDTO().setPropertyId(1L).setPropertyName("颜色") - .setValueId(2L).setValueName("红色"))), - new ProductSkuRespDTO().setId(200L).setStock(400).setPrice(2000).setPicUrl("https://t.cn/2.png").setSpuId(1001L) - .setProperties(singletonList(new ProductPropertyValueDetailRespDTO().setPropertyId(1L).setPropertyName("颜色") - .setValueId(3L).setValueName("黄色"))), - new ProductSkuRespDTO().setId(300L).setStock(600).setPrice(3000).setPicUrl("https://t.cn/3.png").setSpuId(1001L) - .setProperties(singletonList(new ProductPropertyValueDetailRespDTO().setPropertyId(1L).setPropertyName("颜色") - .setValueId(4L).setValueName("黑色"))) - ); - when(productSkuApi.getSkuList(Mockito.eq(asSet(100L, 200L, 300L)))).thenReturn(skuList); - when(productSpuApi.getSpuList(Mockito.eq(asSet(1001L)))) - .thenReturn(singletonList(new ProductSpuRespDTO().setId(1001L).setName("小菜").setCategoryId(666L) - .setStatus(ProductSpuStatusEnum.ENABLE.getStatus()))); - - // 调用 - TradePriceCalculateRespBO calculateRespBO = tradePriceService.calculatePrice(calculateReqBO); - // 断言 - assertEquals(TradeOrderTypeEnum.NORMAL.getType(), calculateRespBO.getType()); - assertEquals(0, calculateRespBO.getPromotions().size()); - assertNull(calculateRespBO.getCouponId()); - // 断言:订单价格 - assertEquals(7000, calculateRespBO.getPrice().getTotalPrice()); - assertEquals(0, calculateRespBO.getPrice().getDiscountPrice()); - assertEquals(0, calculateRespBO.getPrice().getDeliveryPrice()); - assertEquals(0, calculateRespBO.getPrice().getCouponPrice()); - assertEquals(0, calculateRespBO.getPrice().getPointPrice()); - assertEquals(7000, calculateRespBO.getPrice().getPayPrice()); - // 断言:SKU 1 - assertEquals(1001L, calculateRespBO.getItems().get(0).getSpuId()); - assertEquals(100L, calculateRespBO.getItems().get(0).getSkuId()); - assertEquals(1, calculateRespBO.getItems().get(0).getCount()); - assertNull(calculateRespBO.getItems().get(0).getCartId()); - assertTrue(calculateRespBO.getItems().get(0).getSelected()); - assertEquals(1000, calculateRespBO.getItems().get(0).getPrice()); - assertEquals(0, calculateRespBO.getItems().get(0).getDiscountPrice()); - assertEquals(0, calculateRespBO.getItems().get(0).getDeliveryPrice()); - assertEquals(0, calculateRespBO.getItems().get(0).getCouponPrice()); - assertEquals(0, calculateRespBO.getItems().get(0).getPointPrice()); - assertEquals(1000, calculateRespBO.getItems().get(0).getPayPrice()); - assertEquals("小菜", calculateRespBO.getItems().get(0).getSpuName()); - assertEquals("https://t.cn/1.png", calculateRespBO.getItems().get(0).getPicUrl()); - assertEquals(666L, calculateRespBO.getItems().get(0).getCategoryId()); - assertEquals(skuList.get(0).getProperties(), calculateRespBO.getItems().get(0).getProperties()); - // 断言:SKU 2 - assertEquals(1001L, calculateRespBO.getItems().get(1).getSpuId()); - assertEquals(200L, calculateRespBO.getItems().get(1).getSkuId()); - assertEquals(3, calculateRespBO.getItems().get(1).getCount()); - assertNull(calculateRespBO.getItems().get(1).getCartId()); - assertTrue(calculateRespBO.getItems().get(1).getSelected()); - assertEquals(2000, calculateRespBO.getItems().get(1).getPrice()); - assertEquals(0, calculateRespBO.getItems().get(1).getDiscountPrice()); - assertEquals(0, calculateRespBO.getItems().get(1).getDeliveryPrice()); - assertEquals(0, calculateRespBO.getItems().get(1).getCouponPrice()); - assertEquals(0, calculateRespBO.getItems().get(1).getPointPrice()); - assertEquals(6000, calculateRespBO.getItems().get(1).getPayPrice()); - assertEquals("小菜", calculateRespBO.getItems().get(1).getSpuName()); - assertEquals("https://t.cn/2.png", calculateRespBO.getItems().get(1).getPicUrl()); - assertEquals(666L, calculateRespBO.getItems().get(1).getCategoryId()); - assertEquals(skuList.get(1).getProperties(), calculateRespBO.getItems().get(1).getProperties()); - // 断言:SKU 3 - assertEquals(1001L, calculateRespBO.getItems().get(2).getSpuId()); - assertEquals(300L, calculateRespBO.getItems().get(2).getSkuId()); - assertEquals(6, calculateRespBO.getItems().get(2).getCount()); - assertEquals(233L, calculateRespBO.getItems().get(2).getCartId()); - assertFalse(calculateRespBO.getItems().get(2).getSelected()); - assertEquals(3000, calculateRespBO.getItems().get(2).getPrice()); - assertEquals(0, calculateRespBO.getItems().get(2).getDiscountPrice()); - assertEquals(0, calculateRespBO.getItems().get(2).getDeliveryPrice()); - assertEquals(0, calculateRespBO.getItems().get(2).getCouponPrice()); - assertEquals(0, calculateRespBO.getItems().get(2).getPointPrice()); - assertEquals(18000, calculateRespBO.getItems().get(2).getPayPrice()); - assertEquals("小菜", calculateRespBO.getItems().get(2).getSpuName()); - assertEquals("https://t.cn/3.png", calculateRespBO.getItems().get(2).getPicUrl()); - assertEquals(666L, calculateRespBO.getItems().get(2).getCategoryId()); - assertEquals(skuList.get(2).getProperties(), calculateRespBO.getItems().get(2).getProperties()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculatorTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculatorTest.java deleted file mode 100644 index 06655e0b21..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculatorTest.java +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.ArrayList; - -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link TradeCouponPriceCalculator} 的单元测试类 - * - * @author 芋道源码 - */ -public class TradeCouponPriceCalculatorTest extends BaseMockitoUnitTest { - - @InjectMocks - private TradeCouponPriceCalculator tradeCouponPriceCalculator; - - @Mock - private CouponApi couponApi; - - @Test - public void testCalculate() { - // 准备参数 - TradePriceCalculateReqBO param = new TradePriceCalculateReqBO() - .setUserId(233L).setCouponId(1024L) - .setItems(asList( - new TradePriceCalculateReqBO.Item().setSkuId(10L).setCount(2).setSelected(true), // 匹配优惠劵 - new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(true), // 匹配优惠劵 - new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(4).setSelected(true), // 不匹配优惠劵 - new TradePriceCalculateReqBO.Item().setSkuId(40L).setCount(5).setSelected(false) // 匹配优惠劵,但是未选中 - )); - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO() - .setType(TradeOrderTypeEnum.NORMAL.getType()) - .setPrice(new TradePriceCalculateRespBO.Price()) - .setPromotions(new ArrayList<>()) - .setItems(asList( - new TradePriceCalculateRespBO.OrderItem().setSkuId(10L).setCount(2).setSelected(true) - .setPrice(100).setSpuId(1L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(20L).setCount(3).setSelected(true) - .setPrice(50).setSpuId(2L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(30L).setCount(4).setSelected(true) - .setPrice(30).setSpuId(3L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(40L).setCount(5).setSelected(false) - .setPrice(60).setSpuId(1L) - )); - // 保证价格被初始化上 - TradePriceCalculatorHelper.recountPayPrice(result.getItems()); - TradePriceCalculatorHelper.recountAllPrice(result); - - // mock 方法(优惠劵 Coupon 信息) - CouponRespDTO coupon = randomPojo(CouponRespDTO.class, o -> o.setId(1024L).setName("程序员节") - .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductScopeValues(asList(1L, 2L)) - .setUsePrice(350).setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()) - .setDiscountPercent(50).setDiscountLimitPrice(70)); - when(couponApi.validateCoupon(eq(new CouponValidReqDTO().setId(1024L).setUserId(233L)))).thenReturn(coupon); - - // 调用 - tradeCouponPriceCalculator.calculate(param, result); - // 断言 - assertEquals(result.getCouponId(), 1024L); - // 断言:Price 部分 - TradePriceCalculateRespBO.Price price = result.getPrice(); - assertEquals(price.getTotalPrice(), 470); - assertEquals(price.getDiscountPrice(), 0); - assertEquals(price.getPointPrice(), 0); - assertEquals(price.getDeliveryPrice(), 0); - assertEquals(price.getCouponPrice(), 70); - assertEquals(price.getPayPrice(), 400); - // 断言:SKU 1 - TradePriceCalculateRespBO.OrderItem orderItem01 = result.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getPrice(), 100); - assertEquals(orderItem01.getDiscountPrice(), 0); - assertEquals(orderItem01.getDeliveryPrice(), 0); - assertEquals(orderItem01.getCouponPrice(), 40); - assertEquals(orderItem01.getPointPrice(), 0); - assertEquals(orderItem01.getPayPrice(), 160); - // 断言:SKU 2 - TradePriceCalculateRespBO.OrderItem orderItem02 = result.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getPrice(), 50); - assertEquals(orderItem02.getDiscountPrice(), 0); - assertEquals(orderItem02.getDeliveryPrice(), 0); - assertEquals(orderItem02.getCouponPrice(), 30); - assertEquals(orderItem02.getPointPrice(), 0); - assertEquals(orderItem02.getPayPrice(), 120); - // 断言:SKU 3 - TradePriceCalculateRespBO.OrderItem orderItem03 = result.getItems().get(2); - assertEquals(orderItem03.getSkuId(), 30L); - assertEquals(orderItem03.getCount(), 4); - assertEquals(orderItem03.getPrice(), 30); - assertEquals(orderItem03.getDiscountPrice(), 0); - assertEquals(orderItem03.getCouponPrice(), 0); - assertEquals(orderItem03.getPointPrice(), 0); - assertEquals(orderItem03.getPayPrice(), 120); - // 断言:SKU 4 - TradePriceCalculateRespBO.OrderItem orderItem04 = result.getItems().get(3); - assertEquals(orderItem04.getSkuId(), 40L); - assertEquals(orderItem04.getCount(), 5); - assertEquals(orderItem04.getPrice(), 60); - assertEquals(orderItem04.getDiscountPrice(), 0); - assertEquals(orderItem04.getCouponPrice(), 0); - assertEquals(orderItem04.getPointPrice(), 0); - assertEquals(orderItem04.getPayPrice(), 300); - // 断言:Promotion 部分 - assertEquals(result.getPromotions().size(), 1); - TradePriceCalculateRespBO.Promotion promotion01 = result.getPromotions().get(0); - assertEquals(promotion01.getId(), 1024L); - assertEquals(promotion01.getName(), "程序员节"); - assertEquals(promotion01.getType(), PromotionTypeEnum.COUPON.getType()); - assertEquals(promotion01.getTotalPrice(), 350); - assertEquals(promotion01.getDiscountPrice(), 70); - assertTrue(promotion01.getMatch()); - assertEquals(promotion01.getDescription(), "优惠劵:省 0.70 元"); - assertEquals(promotion01.getItems().size(), 2); - TradePriceCalculateRespBO.PromotionItem promotionItem011 = promotion01.getItems().get(0); - assertEquals(promotionItem011.getSkuId(), 10L); - assertEquals(promotionItem011.getTotalPrice(), 200); - assertEquals(promotionItem011.getDiscountPrice(), 40); - TradePriceCalculateRespBO.PromotionItem promotionItem012 = promotion01.getItems().get(1); - assertEquals(promotionItem012.getSkuId(), 20L); - assertEquals(promotionItem012.getTotalPrice(), 150); - assertEquals(promotionItem012.getDiscountPrice(), 30); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculatorTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculatorTest.java deleted file mode 100644 index 9441e473f2..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculatorTest.java +++ /dev/null @@ -1,193 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.member.api.address.MemberAddressApi; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryExpressChargeModeEnum; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressTemplateService; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.ArrayList; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link TradeDeliveryPriceCalculator} 的单元测试 - * - * @author jason - */ -public class TradeDeliveryPriceCalculatorTest extends BaseMockitoUnitTest { - - @InjectMocks - private TradeDeliveryPriceCalculator calculator; - - @Mock - private MemberAddressApi addressApi; - - @Mock - private DeliveryExpressTemplateService deliveryExpressTemplateService; - @Mock - private TradeConfigService tradeConfigService; - - private TradePriceCalculateReqBO reqBO; - private TradePriceCalculateRespBO resultBO; - - private DeliveryExpressTemplateRespBO templateRespBO; - private DeliveryExpressTemplateRespBO.Charge chargeBO; - private DeliveryExpressTemplateRespBO.Free freeBO; - - @BeforeEach - public void init(){ - // 准备参数 - reqBO = new TradePriceCalculateReqBO() - .setDeliveryType(DeliveryTypeEnum.EXPRESS.getType()) - .setAddressId(10L) - .setUserId(1L) - .setItems(asList( - new TradePriceCalculateReqBO.Item().setSkuId(10L).setCount(2).setSelected(true), - new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(10).setSelected(true), - new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(4).setSelected(false) // 未选中 - )); - resultBO = new TradePriceCalculateRespBO() - .setPrice(new TradePriceCalculateRespBO.Price()) - .setPromotions(new ArrayList<>()) - .setItems(asList( - new TradePriceCalculateRespBO.OrderItem().setDeliveryTemplateId(1L).setSkuId(10L).setCount(2).setSelected(true) - .setWeight(10d).setVolume(10d).setPrice(100), - new TradePriceCalculateRespBO.OrderItem().setDeliveryTemplateId(1L).setSkuId(20L).setCount(10).setSelected(true) - .setWeight(10d).setVolume(10d).setPrice(200), - new TradePriceCalculateRespBO.OrderItem().setDeliveryTemplateId(1L).setSkuId(30L).setCount(1).setSelected(false) - .setWeight(10d).setVolume(10d).setPrice(300) - )); - // 保证价格被初始化上 - TradePriceCalculatorHelper.recountPayPrice(resultBO.getItems()); - TradePriceCalculatorHelper.recountAllPrice(resultBO); - - // 准备收件地址数据 - MemberAddressRespDTO addressResp = randomPojo(MemberAddressRespDTO.class, item -> item.setAreaId(10)); - when(addressApi.getAddress(eq(10L), eq(1L))).thenReturn(addressResp); - - // 准备运费模板费用配置数据 - chargeBO = randomPojo(DeliveryExpressTemplateRespBO.Charge.class, - item -> item.setStartCount(10D).setStartPrice(1000).setExtraCount(10D).setExtraPrice(2000)); - // 准备运费模板包邮配置数据:订单总件数 < 包邮件数时 12 < 20 - freeBO = randomPojo(DeliveryExpressTemplateRespBO.Free.class, - item -> item.setFreeCount(20).setFreePrice(100)); - // 准备 SP 运费模板数据 - templateRespBO = randomPojo(DeliveryExpressTemplateRespBO.class, - item -> item.setChargeMode(DeliveryExpressChargeModeEnum.COUNT.getType()) - .setCharge(chargeBO).setFree(freeBO)); - } - - @Test - @DisplayName("全场包邮") - public void testCalculate_expressGlobalFree() { - // mock 方法(全场包邮) - when(tradeConfigService.getTradeConfig()).thenReturn(new TradeConfigDO().setDeliveryExpressFreeEnabled(true) - .setDeliveryExpressFreePrice(2200)); - - // 调用 - calculator.calculate(reqBO, resultBO); - TradePriceCalculateRespBO.Price price = resultBO.getPrice(); - assertThat(price) - .extracting("totalPrice","discountPrice","couponPrice","pointPrice","deliveryPrice","payPrice") - .containsExactly(2200, 0, 0, 0, 0, 2200); - assertThat(resultBO.getItems()).hasSize(3); - // 断言:SKU1 - assertThat(resultBO.getItems().get(0)) - .extracting("price", "count","discountPrice" ,"couponPrice", "pointPrice","deliveryPrice","payPrice") - .containsExactly(100, 2, 0, 0, 0, 0, 200); - // 断言:SKU2 - assertThat(resultBO.getItems().get(1)) - .extracting("price", "count","discountPrice" ,"couponPrice", "pointPrice","deliveryPrice","payPrice") - .containsExactly(200, 10, 0, 0, 0, 0, 2000); - // 断言:SKU3 未选中 - assertThat(resultBO.getItems().get(2)) - .extracting("price", "count","discountPrice" ,"couponPrice", "pointPrice","deliveryPrice","payPrice") - .containsExactly(300, 1, 0, 0, 0, 0, 300); - } - - @Test - @DisplayName("按件计算运费不包邮的情况") - public void testCalculate_expressTemplateCharge() { - // SKU 1 : 100 * 2 = 200 - // SKU 2 :200 * 10 = 2000 - // 运费 首件 1000 + 续件 2000 = 3000 - // mock 方法 - when(deliveryExpressTemplateService.getExpressTemplateMapByIdsAndArea(eq(asSet(1L)), eq(10))) - .thenReturn(MapUtil.of(1L, templateRespBO)); - - // 调用 - calculator.calculate(reqBO, resultBO); - // 断言 - TradePriceCalculateRespBO.Price price = resultBO.getPrice(); - assertThat(price) - .extracting("totalPrice","discountPrice","couponPrice","pointPrice","deliveryPrice","payPrice") - .containsExactly(2200, 0, 0, 0, 3000, 5200); - assertThat(resultBO.getItems()).hasSize(3); - // 断言:SKU1 - assertThat(resultBO.getItems().get(0)) - .extracting("price", "count","discountPrice" ,"couponPrice", "pointPrice","deliveryPrice","payPrice") - .containsExactly(100, 2, 0, 0, 0, 500, 700); - // 断言:SKU2 - assertThat(resultBO.getItems().get(1)) - .extracting("price", "count","discountPrice" ,"couponPrice", "pointPrice","deliveryPrice","payPrice") - .containsExactly(200, 10, 0, 0, 0, 2500, 4500); - // 断言:SKU3 未选中 - assertThat(resultBO.getItems().get(2)) - .extracting("price", "count","discountPrice" ,"couponPrice", "pointPrice","deliveryPrice","payPrice") - .containsExactly(300, 1, 0, 0, 0, 0, 300); - } - - @Test - @DisplayName("按件计算运费包邮的情况") - public void testCalculate_expressTemplateFree() { - // SKU 1 : 100 * 2 = 200 - // SKU 2 :200 * 10 = 2000 - // 运费 0 - // mock 方法 - // 准备运费模板包邮配置数据 包邮 订单总件数 > 包邮件数时 12 > 10 - templateRespBO.setFree(randomPojo(DeliveryExpressTemplateRespBO.Free.class, - item -> item.setFreeCount(10).setFreePrice(1000))); - when(deliveryExpressTemplateService.getExpressTemplateMapByIdsAndArea(eq(asSet(1L)), eq(10))) - .thenReturn(MapUtil.of(1L, templateRespBO)); - - // 调用 - calculator.calculate(reqBO, resultBO); - // 断言 - TradePriceCalculateRespBO.Price price = resultBO.getPrice(); - assertThat(price) - .extracting("totalPrice","discountPrice","couponPrice","pointPrice","deliveryPrice","payPrice") - .containsExactly(2200, 0, 0, 0, 0, 2200); - assertThat(resultBO.getItems()).hasSize(3); - // 断言:SKU1 - assertThat(resultBO.getItems().get(0)) - .extracting("price", "count","discountPrice" ,"couponPrice", "pointPrice","deliveryPrice","payPrice") - .containsExactly(100, 2, 0, 0, 0, 0, 200); - // 断言:SKU2 - assertThat(resultBO.getItems().get(1)) - .extracting("price", "count","discountPrice" ,"couponPrice", "pointPrice","deliveryPrice","payPrice") - .containsExactly(200, 10, 0, 0, 0, 0, 2000); - // 断言:SKU3 未选中 - assertThat(resultBO.getItems().get(2)) - .extracting("price", "count","discountPrice" ,"couponPrice", "pointPrice","deliveryPrice","payPrice") - .containsExactly(300, 1, 0, 0, 0, 0, 300); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDiscountActivityPriceCalculatorTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDiscountActivityPriceCalculatorTest.java deleted file mode 100644 index 21760217c2..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDiscountActivityPriceCalculatorTest.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.promotion.api.discount.DiscountActivityApi; -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.ArrayList; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link TradeDiscountActivityPriceCalculator} 的单元测试类 - * - * @author 芋道源码 - */ -public class TradeDiscountActivityPriceCalculatorTest extends BaseMockitoUnitTest { - - @InjectMocks - private TradeDiscountActivityPriceCalculator tradeDiscountActivityPriceCalculator; - - @Mock - private DiscountActivityApi discountActivityApi; - - @Test - public void testCalculate() { - // 准备参数 - TradePriceCalculateReqBO param = new TradePriceCalculateReqBO() - .setItems(asList( - new TradePriceCalculateReqBO.Item().setSkuId(10L).setCount(2).setSelected(true), // 匹配活动,且已选中 - new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(false) // 匹配活动,但未选中 - )); - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO() - .setType(TradeOrderTypeEnum.NORMAL.getType()) - .setPrice(new TradePriceCalculateRespBO.Price()) - .setPromotions(new ArrayList<>()) - .setItems(asList( - new TradePriceCalculateRespBO.OrderItem().setSkuId(10L).setCount(2).setSelected(true) - .setPrice(100), - new TradePriceCalculateRespBO.OrderItem().setSkuId(20L).setCount(3).setSelected(false) - .setPrice(50) - )); - // 保证价格被初始化上 - TradePriceCalculatorHelper.recountPayPrice(result.getItems()); - TradePriceCalculatorHelper.recountAllPrice(result); - - // mock 方法(限时折扣活动) - when(discountActivityApi.getMatchDiscountProductList(eq(asSet(10L, 20L)))).thenReturn(asList( - randomPojo(DiscountProductRespDTO.class, o -> o.setActivityId(1000L) - .setActivityName("活动 1000 号").setSkuId(10L) - .setDiscountType(PromotionDiscountTypeEnum.PRICE.getType()).setDiscountPrice(40)), - randomPojo(DiscountProductRespDTO.class, o -> o.setActivityId(2000L) - .setActivityName("活动 2000 号").setSkuId(20L) - .setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()).setDiscountPercent(60)) - )); - // 10L: 100 * 2 - 40 * 2 = 120 - // 20L:50 * 3 - 50 * 3 * 0.4 = 90 - - // 调用 - tradeDiscountActivityPriceCalculator.calculate(param, result); - // 断言:Price 部分 - TradePriceCalculateRespBO.Price price = result.getPrice(); - assertEquals(price.getTotalPrice(), 200); - assertEquals(price.getDiscountPrice(), 80); - assertEquals(price.getPointPrice(), 0); - assertEquals(price.getDeliveryPrice(), 0); - assertEquals(price.getCouponPrice(), 0); - assertEquals(price.getPayPrice(), 120); - assertNull(result.getCouponId()); - // 断言:SKU 1 - assertEquals(result.getItems().size(), 2); - TradePriceCalculateRespBO.OrderItem orderItem01 = result.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getPrice(), 100); - assertEquals(orderItem01.getDiscountPrice(), 80); - assertEquals(orderItem01.getDeliveryPrice(), 0); - assertEquals(orderItem01.getCouponPrice(), 0); - assertEquals(orderItem01.getPointPrice(), 0); - assertEquals(orderItem01.getPayPrice(), 120); - // 断言:SKU 2 - TradePriceCalculateRespBO.OrderItem orderItem02 = result.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getPrice(), 50); - assertEquals(orderItem02.getDiscountPrice(), 60); - assertEquals(orderItem02.getDeliveryPrice(), 0); - assertEquals(orderItem02.getCouponPrice(), 0); - assertEquals(orderItem02.getPointPrice(), 0); - assertEquals(orderItem02.getPayPrice(), 90); - // 断言:Promotion 部分 - assertEquals(result.getPromotions().size(), 1); - TradePriceCalculateRespBO.Promotion promotion01 = result.getPromotions().get(0); - assertEquals(promotion01.getId(), 1000L); - assertEquals(promotion01.getName(), "活动 1000 号"); - assertEquals(promotion01.getType(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType()); - assertEquals(promotion01.getTotalPrice(), 200); - assertEquals(promotion01.getDiscountPrice(), 80); - assertTrue(promotion01.getMatch()); - assertEquals(promotion01.getDescription(), "限时折扣:省 0.80 元"); - TradePriceCalculateRespBO.PromotionItem promotionItem01 = promotion01.getItems().get(0); - assertEquals(promotion01.getItems().size(), 1); - assertEquals(promotionItem01.getSkuId(), 10L); - assertEquals(promotionItem01.getTotalPrice(), 200); - assertEquals(promotionItem01.getDiscountPrice(), 80); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeMemberLevelPriceCalculatorTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeMemberLevelPriceCalculatorTest.java deleted file mode 100644 index 44e783103d..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeMemberLevelPriceCalculatorTest.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.ArrayList; - -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link TradeMemberLevelPriceCalculator} 的单元测试类 - * - * @author 芋道源码 - */ -public class TradeMemberLevelPriceCalculatorTest extends BaseMockitoUnitTest { - - @InjectMocks - private TradeMemberLevelPriceCalculator memberLevelPriceCalculator; - - @Mock - private MemberLevelApi memberLevelApi; - @Mock - private MemberUserApi memberUserApi; - - @Test - public void testCalculate() { - // 准备参数 - TradePriceCalculateReqBO param = new TradePriceCalculateReqBO() - .setUserId(1024L) - .setItems(asList( - new TradePriceCalculateReqBO.Item().setSkuId(10L).setCount(2).setSelected(true), // 匹配活动,且已选中 - new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(false) // 匹配活动,但未选中 - )); - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO() - .setType(TradeOrderTypeEnum.NORMAL.getType()) - .setPrice(new TradePriceCalculateRespBO.Price()) - .setPromotions(new ArrayList<>()) - .setItems(asList( - new TradePriceCalculateRespBO.OrderItem().setSkuId(10L).setCount(2).setSelected(true) - .setPrice(100), - new TradePriceCalculateRespBO.OrderItem().setSkuId(20L).setCount(3).setSelected(false) - .setPrice(50) - )); - // 保证价格被初始化上 - TradePriceCalculatorHelper.recountPayPrice(result.getItems()); - TradePriceCalculatorHelper.recountAllPrice(result); - - // mock 方法(会员等级) - when(memberUserApi.getUser(eq(1024L))).thenReturn(new MemberUserRespDTO().setLevelId(2048L)); - when(memberLevelApi.getMemberLevel(eq(2048L))).thenReturn( - new MemberLevelRespDTO().setId(2048L).setName("VIP 会员").setDiscountPercent(60)); - - // 调用 - memberLevelPriceCalculator.calculate(param, result); - // 断言:Price 部分 - TradePriceCalculateRespBO.Price price = result.getPrice(); - assertEquals(price.getTotalPrice(), 200); - assertEquals(price.getDiscountPrice(), 0); - assertEquals(price.getPointPrice(), 0); - assertEquals(price.getDeliveryPrice(), 0); - assertEquals(price.getCouponPrice(), 0); - assertEquals(price.getVipPrice(), 80); - assertEquals(price.getPayPrice(), 120); - assertNull(result.getCouponId()); - // 断言:SKU 1 - assertEquals(result.getItems().size(), 2); - TradePriceCalculateRespBO.OrderItem orderItem01 = result.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getPrice(), 100); - assertEquals(orderItem01.getDiscountPrice(), 0); - assertEquals(orderItem01.getDeliveryPrice(), 0); - assertEquals(orderItem01.getCouponPrice(), 0); - assertEquals(orderItem01.getPointPrice(), 0); - assertEquals(orderItem01.getVipPrice(), 80); - assertEquals(orderItem01.getPayPrice(), 120); - // 断言:SKU 2 - TradePriceCalculateRespBO.OrderItem orderItem02 = result.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getPrice(), 50); - assertEquals(orderItem02.getDiscountPrice(), 0); - assertEquals(orderItem02.getDeliveryPrice(), 0); - assertEquals(orderItem02.getCouponPrice(), 0); - assertEquals(orderItem02.getPointPrice(), 0); - assertEquals(orderItem02.getVipPrice(), 60); - assertEquals(orderItem02.getPayPrice(), 90); - // 断言:Promotion 部分 - assertEquals(result.getPromotions().size(), 1); - TradePriceCalculateRespBO.Promotion promotion01 = result.getPromotions().get(0); - assertEquals(promotion01.getId(), 2048L); - assertEquals(promotion01.getName(), "VIP 会员"); - assertEquals(promotion01.getType(), PromotionTypeEnum.MEMBER_LEVEL.getType()); - assertEquals(promotion01.getTotalPrice(), 200); - assertEquals(promotion01.getDiscountPrice(), 80); - assertTrue(promotion01.getMatch()); - assertEquals(promotion01.getDescription(), "会员等级折扣:省 0.80 元"); - TradePriceCalculateRespBO.PromotionItem promotionItem01 = promotion01.getItems().get(0); - assertEquals(promotion01.getItems().size(), 1); - assertEquals(promotionItem01.getSkuId(), 10L); - assertEquals(promotionItem01.getTotalPrice(), 200); - assertEquals(promotionItem01.getDiscountPrice(), 80); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointGiveCalculatorTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointGiveCalculatorTest.java deleted file mode 100644 index 910639ec15..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointGiveCalculatorTest.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.member.api.config.MemberConfigApi; -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.ArrayList; - -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.when; - -// TODO 芋艿:晚点 review -/** - * {@link TradePointGiveCalculator} 的单元测试类 - * - * @author owen - */ -public class TradePointGiveCalculatorTest extends BaseMockitoUnitTest { - - @InjectMocks - private TradePointGiveCalculator tradePointGiveCalculator; - - @Mock - private MemberConfigApi memberConfigApi; - - @Test - public void testCalculate() { - - // 准备参数 - TradePriceCalculateReqBO param = new TradePriceCalculateReqBO() - .setUserId(233L) - .setItems(asList( - new TradePriceCalculateReqBO.Item().setSkuId(10L).setCount(2).setSelected(true), // 全局积分 - new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(true), // 全局积分 + SKU 积分 - new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(4).setSelected(false), // 全局积分,但是未选中 - new TradePriceCalculateReqBO.Item().setSkuId(40L).setCount(5).setSelected(false) // 全局积分 + SKU 积分,但是未选中 - )); - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO() - .setType(TradeOrderTypeEnum.NORMAL.getType()) - .setPrice(new TradePriceCalculateRespBO.Price()) - .setPromotions(new ArrayList<>()) - .setItems(asList( - new TradePriceCalculateRespBO.OrderItem().setSkuId(10L).setCount(2).setSelected(true) - .setPrice(100).setSpuId(1L).setGivePoint(0), - new TradePriceCalculateRespBO.OrderItem().setSkuId(20L).setCount(3).setSelected(true) - .setPrice(50).setSpuId(2L).setGivePoint(100), - new TradePriceCalculateRespBO.OrderItem().setSkuId(30L).setCount(4).setSelected(false) - .setPrice(30).setSpuId(3L).setGivePoint(0), - new TradePriceCalculateRespBO.OrderItem().setSkuId(40L).setCount(5).setSelected(false) - .setPrice(60).setSpuId(1L).setGivePoint(100) - )); - // 保证价格被初始化上 - TradePriceCalculatorHelper.recountPayPrice(result.getItems()); - TradePriceCalculatorHelper.recountAllPrice(result); - - // mock 方法(积分配置 信息) - MemberConfigRespDTO memberConfig = randomPojo(MemberConfigRespDTO.class, - o -> o.setPointTradeDeductEnable(true) // 启用积分折扣 - .setPointTradeGivePoint(100)); // 1 元赠送多少分 - when(memberConfigApi.getConfig()).thenReturn(memberConfig); - - // 调用 - tradePointGiveCalculator.calculate(param, result); - // 断言:Price 部分 - assertEquals(result.getGivePoint(), 2 * 100 + 3 * 50 + 100); - // 断言:SKU 1 - TradePriceCalculateRespBO.OrderItem orderItem01 = result.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getPrice(), 100); - assertEquals(orderItem01.getGivePoint(), 2 * 100); // 全局积分 - // 断言:SKU 2 - TradePriceCalculateRespBO.OrderItem orderItem02 = result.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getPrice(), 50); - assertEquals(orderItem02.getGivePoint(), 3 * 50 + 100); // 全局积分 + SKU 积分 - // 断言:SKU 3 - TradePriceCalculateRespBO.OrderItem orderItem03 = result.getItems().get(2); - assertEquals(orderItem03.getSkuId(), 30L); - assertEquals(orderItem03.getCount(), 4); - assertEquals(orderItem03.getPrice(), 30); - assertEquals(orderItem03.getGivePoint(), 0); // 全局积分,但是未选中 - // 断言:SKU 4 - TradePriceCalculateRespBO.OrderItem orderItem04 = result.getItems().get(3); - assertEquals(orderItem04.getSkuId(), 40L); - assertEquals(orderItem04.getCount(), 5); - assertEquals(orderItem04.getPrice(), 60); - assertEquals(orderItem04.getGivePoint(), 100); // 全局积分 + SKU 积分,但是未选中 - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointUsePriceCalculatorTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointUsePriceCalculatorTest.java deleted file mode 100644 index fe679b408e..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointUsePriceCalculatorTest.java +++ /dev/null @@ -1,333 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.member.api.config.MemberConfigApi; -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.ArrayList; - -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.when; - -// TODO 芋艿:晚点 review -/** - * {@link TradePointUsePriceCalculator } 的单元测试类 - * - * @author owen - */ -public class TradePointUsePriceCalculatorTest extends BaseMockitoUnitTest { - - @InjectMocks - private TradePointUsePriceCalculator tradePointUsePriceCalculator; - - @Mock - private MemberConfigApi memberConfigApi; - @Mock - private MemberUserApi memberUserApi; - - @Test - public void testCalculate_success() { - // 准备参数 - TradePriceCalculateReqBO param = new TradePriceCalculateReqBO() - .setUserId(233L).setPointStatus(true) // 是否使用积分 - .setItems(asList( - new TradePriceCalculateReqBO.Item().setSkuId(10L).setCount(2).setSelected(true), // 使用积分 - new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(true), // 使用积分 - new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(5).setSelected(false) // 未选中,不使用积分 - )); - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO() - .setType(TradeOrderTypeEnum.NORMAL.getType()) - .setPrice(new TradePriceCalculateRespBO.Price()) - .setPromotions(new ArrayList<>()) - .setItems(asList( - new TradePriceCalculateRespBO.OrderItem().setSkuId(10L).setCount(2).setSelected(true) - .setPrice(100).setSpuId(1L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(20L).setCount(3).setSelected(true) - .setPrice(50).setSpuId(2L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(30L).setCount(5).setSelected(false) - .setPrice(30).setSpuId(3L) - )); - // 保证价格被初始化上 - TradePriceCalculatorHelper.recountPayPrice(result.getItems()); - TradePriceCalculatorHelper.recountAllPrice(result); - - // mock 方法(积分配置 信息) - MemberConfigRespDTO memberConfig = randomPojo(MemberConfigRespDTO.class, - o -> o.setPointTradeDeductEnable(true) // 启用积分折扣 - .setPointTradeDeductUnitPrice(1) // 1 积分抵扣多少金额(单位分) - .setPointTradeDeductMaxPrice(100)); // 积分抵扣最大值 - when(memberConfigApi.getConfig()).thenReturn(memberConfig); - // mock 方法(会员 信息) - MemberUserRespDTO user = randomPojo(MemberUserRespDTO.class, o -> o.setId(param.getUserId()).setPoint(100)); - when(memberUserApi.getUser(user.getId())).thenReturn(user); - - // 调用 - tradePointUsePriceCalculator.calculate(param, result); - // 断言:使用了多少积分 - assertEquals(result.getUsePoint(), 100); - // 断言:Price 部分 - TradePriceCalculateRespBO.Price price = result.getPrice(); - assertEquals(price.getTotalPrice(), 350); - assertEquals(price.getPayPrice(), 250); - assertEquals(price.getPointPrice(), 100); - // 断言:SKU 1 - TradePriceCalculateRespBO.OrderItem orderItem01 = result.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getPrice(), 100); - assertEquals(orderItem01.getPointPrice(), 57); - assertEquals(orderItem01.getPayPrice(), 143); - // 断言:SKU 2 - TradePriceCalculateRespBO.OrderItem orderItem02 = result.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getPrice(), 50); - assertEquals(orderItem02.getPointPrice(), 43); - assertEquals(orderItem02.getPayPrice(), 107); - // 断言:SKU 3 - TradePriceCalculateRespBO.OrderItem orderItem03 = result.getItems().get(2); - assertEquals(orderItem03.getSkuId(), 30L); - assertEquals(orderItem03.getCount(), 5); - assertEquals(orderItem03.getPrice(), 30); - assertEquals(orderItem03.getPointPrice(), 0); - assertEquals(orderItem03.getPayPrice(), 150); - // 断言:Promotion 部分 - assertEquals(result.getPromotions().size(), 1); - TradePriceCalculateRespBO.Promotion promotion01 = result.getPromotions().get(0); - assertEquals(promotion01.getId(), user.getId()); - assertEquals(promotion01.getName(), "积分抵扣"); - assertEquals(promotion01.getType(), PromotionTypeEnum.POINT.getType()); - assertEquals(promotion01.getTotalPrice(), 350); - assertEquals(promotion01.getDiscountPrice(), 100); - assertTrue(promotion01.getMatch()); - assertEquals(promotion01.getDescription(), "积分抵扣:省 1.00 元"); - assertEquals(promotion01.getItems().size(), 2); - TradePriceCalculateRespBO.PromotionItem promotionItem011 = promotion01.getItems().get(0); - assertEquals(promotionItem011.getSkuId(), 10L); - assertEquals(promotionItem011.getTotalPrice(), 200); - assertEquals(promotionItem011.getDiscountPrice(), 57); - TradePriceCalculateRespBO.PromotionItem promotionItem012 = promotion01.getItems().get(1); - assertEquals(promotionItem012.getSkuId(), 20L); - assertEquals(promotionItem012.getTotalPrice(), 150); - assertEquals(promotionItem012.getDiscountPrice(), 43); - } - - /** - * 当用户积分充足时,抵扣的金额为:配置表的“积分抵扣最大值” - */ - @Test - public void testCalculate_TradeDeductMaxPrice() { - // 准备参数 - TradePriceCalculateReqBO param = new TradePriceCalculateReqBO() - .setUserId(233L).setPointStatus(true) // 是否使用积分 - .setItems(asList( - new TradePriceCalculateReqBO.Item().setSkuId(10L).setCount(2).setSelected(true), // 使用积分 - new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(true), // 使用积分 - new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(5).setSelected(false) // 未选中,不使用积分 - )); - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO() - .setType(TradeOrderTypeEnum.NORMAL.getType()) - .setPrice(new TradePriceCalculateRespBO.Price()) - .setPromotions(new ArrayList<>()) - .setItems(asList( - new TradePriceCalculateRespBO.OrderItem().setSkuId(10L).setCount(2).setSelected(true) - .setPrice(100).setSpuId(1L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(20L).setCount(3).setSelected(true) - .setPrice(50).setSpuId(2L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(30L).setCount(5).setSelected(false) - .setPrice(30).setSpuId(3L) - )); - // 保证价格被初始化上 - TradePriceCalculatorHelper.recountPayPrice(result.getItems()); - TradePriceCalculatorHelper.recountAllPrice(result); - - // mock 方法(积分配置 信息) - MemberConfigRespDTO memberConfig = randomPojo(MemberConfigRespDTO.class, - o -> o.setPointTradeDeductEnable(true) // 启用积分折扣 - .setPointTradeDeductUnitPrice(1) // 1 积分抵扣多少金额(单位分) - .setPointTradeDeductMaxPrice(50)); // 积分抵扣最大值 - when(memberConfigApi.getConfig()).thenReturn(memberConfig); - // mock 方法(会员 信息) - MemberUserRespDTO user = randomPojo(MemberUserRespDTO.class, o -> o.setId(param.getUserId()).setPoint(100)); - when(memberUserApi.getUser(user.getId())).thenReturn(user); - - // 调用 - tradePointUsePriceCalculator.calculate(param, result); - // 断言:使用了多少积分 - assertEquals(result.getUsePoint(), 50); - // 断言:Price 部分 - TradePriceCalculateRespBO.Price price = result.getPrice(); - assertEquals(price.getTotalPrice(), 350); - assertEquals(price.getPayPrice(), 300); - assertEquals(price.getPointPrice(), 50); - // 断言:SKU 1 - TradePriceCalculateRespBO.OrderItem orderItem01 = result.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getPrice(), 100); - assertEquals(orderItem01.getPointPrice(), 28); - assertEquals(orderItem01.getPayPrice(), 172); - // 断言:SKU 2 - TradePriceCalculateRespBO.OrderItem orderItem02 = result.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getPrice(), 50); - assertEquals(orderItem02.getPointPrice(), 22); - assertEquals(orderItem02.getPayPrice(), 128); - // 断言:SKU 3 - TradePriceCalculateRespBO.OrderItem orderItem03 = result.getItems().get(2); - assertEquals(orderItem03.getSkuId(), 30L); - assertEquals(orderItem03.getCount(), 5); - assertEquals(orderItem03.getPrice(), 30); - assertEquals(orderItem03.getPointPrice(), 0); - assertEquals(orderItem03.getPayPrice(), 150); - // 断言:Promotion 部分 - assertEquals(result.getPromotions().size(), 1); - TradePriceCalculateRespBO.Promotion promotion01 = result.getPromotions().get(0); - assertEquals(promotion01.getId(), user.getId()); - assertEquals(promotion01.getName(), "积分抵扣"); - assertEquals(promotion01.getType(), PromotionTypeEnum.POINT.getType()); - assertEquals(promotion01.getTotalPrice(), 350); - assertEquals(promotion01.getDiscountPrice(), 50); - assertTrue(promotion01.getMatch()); - assertEquals(promotion01.getDescription(), "积分抵扣:省 0.50 元"); - assertEquals(promotion01.getItems().size(), 2); - TradePriceCalculateRespBO.PromotionItem promotionItem011 = promotion01.getItems().get(0); - assertEquals(promotionItem011.getSkuId(), 10L); - assertEquals(promotionItem011.getTotalPrice(), 200); - assertEquals(promotionItem011.getDiscountPrice(), 28); - TradePriceCalculateRespBO.PromotionItem promotionItem012 = promotion01.getItems().get(1); - assertEquals(promotionItem012.getSkuId(), 20L); - assertEquals(promotionItem012.getTotalPrice(), 150); - assertEquals(promotionItem012.getDiscountPrice(), 22); - } - - /** - * 订单不使用积分,不会产生优惠 - */ - @Test - public void testCalculate_PointStatusFalse() { - // 准备参数 - TradePriceCalculateReqBO param = new TradePriceCalculateReqBO() - .setUserId(233L).setPointStatus(false) // 是否使用积分 - .setItems(asList( - new TradePriceCalculateReqBO.Item().setSkuId(10L).setCount(2).setSelected(true), // 使用积分 - new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(true), // 使用积分 - new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(5).setSelected(false) // 未选中,不使用积分 - )); - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO() - .setType(TradeOrderTypeEnum.NORMAL.getType()) - .setPrice(new TradePriceCalculateRespBO.Price()) - .setPromotions(new ArrayList<>()) - .setItems(asList( - new TradePriceCalculateRespBO.OrderItem().setSkuId(10L).setCount(2).setSelected(true) - .setPrice(100).setSpuId(1L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(20L).setCount(3).setSelected(true) - .setPrice(50).setSpuId(2L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(30L).setCount(5).setSelected(false) - .setPrice(30).setSpuId(3L) - )); - // 保证价格被初始化上 - TradePriceCalculatorHelper.recountPayPrice(result.getItems()); - TradePriceCalculatorHelper.recountAllPrice(result); - - // 调用 - tradePointUsePriceCalculator.calculate(param, result); - // 断言:没有使用积分 - assertNotUsePoint(result); - } - - /** - * 会员积分不足,不会产生优惠 - */ - @Test - public void testCalculate_UserPointNotEnough() { - // 准备参数 - TradePriceCalculateReqBO param = new TradePriceCalculateReqBO() - .setUserId(233L).setPointStatus(true) // 是否使用积分 - .setItems(asList( - new TradePriceCalculateReqBO.Item().setSkuId(10L).setCount(2).setSelected(true), // 使用积分 - new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(true), // 使用积分 - new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(5).setSelected(false) // 未选中,不使用积分 - )); - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO() - .setType(TradeOrderTypeEnum.NORMAL.getType()) - .setPrice(new TradePriceCalculateRespBO.Price()) - .setPromotions(new ArrayList<>()) - .setItems(asList( - new TradePriceCalculateRespBO.OrderItem().setSkuId(10L).setCount(2).setSelected(true) - .setPrice(100).setSpuId(1L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(20L).setCount(3).setSelected(true) - .setPrice(50).setSpuId(2L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(30L).setCount(5).setSelected(false) - .setPrice(30).setSpuId(3L) - )); - // 保证价格被初始化上 - TradePriceCalculatorHelper.recountPayPrice(result.getItems()); - TradePriceCalculatorHelper.recountAllPrice(result); - - // mock 方法(积分配置 信息) - MemberConfigRespDTO memberConfig = randomPojo(MemberConfigRespDTO.class, - o -> o.setPointTradeDeductEnable(true) // 启用积分折扣 - .setPointTradeDeductUnitPrice(1) // 1 积分抵扣多少金额(单位分) - .setPointTradeDeductMaxPrice(100)); // 积分抵扣最大值 - when(memberConfigApi.getConfig()).thenReturn(memberConfig); - // mock 方法(会员 信息) - MemberUserRespDTO user = randomPojo(MemberUserRespDTO.class, o -> o.setId(param.getUserId()).setPoint(0)); - when(memberUserApi.getUser(user.getId())).thenReturn(user); - - // 调用 - tradePointUsePriceCalculator.calculate(param, result); - - // 断言:没有使用积分 - assertNotUsePoint(result); - } - - /** - * 断言:没有使用积分 - */ - private static void assertNotUsePoint(TradePriceCalculateRespBO result) { - // 断言:使用了多少积分 - assertEquals(result.getUsePoint(), 0); - // 断言:Price 部分 - TradePriceCalculateRespBO.Price price = result.getPrice(); - assertEquals(price.getTotalPrice(), 350); - assertEquals(price.getPayPrice(), 350); - assertEquals(price.getPointPrice(), 0); - // 断言:SKU 1 - TradePriceCalculateRespBO.OrderItem orderItem01 = result.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getPrice(), 100); - assertEquals(orderItem01.getPointPrice(), 0); - assertEquals(orderItem01.getPayPrice(), 200); - // 断言:SKU 2 - TradePriceCalculateRespBO.OrderItem orderItem02 = result.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getPrice(), 50); - assertEquals(orderItem02.getPointPrice(), 0); - assertEquals(orderItem02.getPayPrice(), 150); - // 断言:SKU 3 - TradePriceCalculateRespBO.OrderItem orderItem03 = result.getItems().get(2); - assertEquals(orderItem03.getSkuId(), 30L); - assertEquals(orderItem03.getCount(), 5); - assertEquals(orderItem03.getPrice(), 30); - assertEquals(orderItem03.getPointPrice(), 0); - assertEquals(orderItem03.getPayPrice(), 150); - // 断言:Promotion 部分 - assertEquals(result.getPromotions().size(), 0); - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculatorTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculatorTest.java deleted file mode 100644 index de72ed6162..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculatorTest.java +++ /dev/null @@ -1,235 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.promotion.api.reward.RewardActivityApi; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.ArrayList; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link TradeRewardActivityPriceCalculator} 的单元测试类 - * - * @author 芋道源码 - */ -public class TradeRewardActivityPriceCalculatorTest extends BaseMockitoUnitTest { - - @InjectMocks - private TradeRewardActivityPriceCalculator tradeRewardActivityPriceCalculator; - - @Mock - private RewardActivityApi rewardActivityApi; - - @Test - public void testCalculate_match() { - // 准备参数 - TradePriceCalculateReqBO param = new TradePriceCalculateReqBO() - .setItems(asList( - new TradePriceCalculateReqBO.Item().setSkuId(10L).setCount(2).setSelected(true), // 匹配活动 1 - new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(true), // 匹配活动 1 - new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(4).setSelected(true) // 匹配活动 2 - )); - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO() - .setType(TradeOrderTypeEnum.NORMAL.getType()) - .setPrice(new TradePriceCalculateRespBO.Price()) - .setPromotions(new ArrayList<>()) - .setItems(asList( - new TradePriceCalculateRespBO.OrderItem().setSkuId(10L).setCount(2).setSelected(true) - .setPrice(100).setSpuId(1L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(20L).setCount(3).setSelected(true) - .setPrice(50).setSpuId(2L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(30L).setCount(4).setSelected(true) - .setPrice(30).setSpuId(3L) - )); - // 保证价格被初始化上 - TradePriceCalculatorHelper.recountPayPrice(result.getItems()); - TradePriceCalculatorHelper.recountAllPrice(result); - - // mock 方法(限时折扣 DiscountActivity 信息) - when(rewardActivityApi.getMatchRewardActivityList(eq(asSet(1L, 2L, 3L)))).thenReturn(asList( - randomPojo(RewardActivityMatchRespDTO.class, o -> o.setId(1000L).setName("活动 1000 号") - .setSpuIds(asList(1L, 2L)).setConditionType(PromotionConditionTypeEnum.PRICE.getType()) - .setRules(singletonList(new RewardActivityMatchRespDTO.Rule().setLimit(200).setDiscountPrice(70)))), - randomPojo(RewardActivityMatchRespDTO.class, o -> o.setId(2000L).setName("活动 2000 号") - .setSpuIds(singletonList(3L)).setConditionType(PromotionConditionTypeEnum.COUNT.getType()) - .setRules(asList(new RewardActivityMatchRespDTO.Rule().setLimit(1).setDiscountPrice(10), - new RewardActivityMatchRespDTO.Rule().setLimit(2).setDiscountPrice(60), // 最大可满足,因为是 4 个 - new RewardActivityMatchRespDTO.Rule().setLimit(10).setDiscountPrice(100)))) - )); - - // 调用 - tradeRewardActivityPriceCalculator.calculate(param, result); - // 断言 Order 部分 - TradePriceCalculateRespBO.Price price = result.getPrice(); - assertEquals(price.getTotalPrice(), 470); - assertEquals(price.getDiscountPrice(), 130); - assertEquals(price.getPointPrice(), 0); - assertEquals(price.getDeliveryPrice(), 0); - assertEquals(price.getCouponPrice(), 0); - assertEquals(price.getPayPrice(), 340); - assertNull(result.getCouponId()); - // 断言:SKU 1 - assertEquals(result.getItems().size(), 3); - TradePriceCalculateRespBO.OrderItem orderItem01 = result.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getPrice(), 100); - assertEquals(orderItem01.getDiscountPrice(), 40); - assertEquals(orderItem01.getDeliveryPrice(), 0); - assertEquals(orderItem01.getCouponPrice(), 0); - assertEquals(orderItem01.getPointPrice(), 0); - assertEquals(orderItem01.getPayPrice(), 160); - // 断言:SKU 2 - TradePriceCalculateRespBO.OrderItem orderItem02 = result.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getPrice(), 50); - assertEquals(orderItem02.getDiscountPrice(), 30); - assertEquals(orderItem02.getDeliveryPrice(), 0); - assertEquals(orderItem02.getCouponPrice(), 0); - assertEquals(orderItem02.getPointPrice(), 0); - assertEquals(orderItem02.getPayPrice(), 120); - // 断言:SKU 3 - TradePriceCalculateRespBO.OrderItem orderItem03 = result.getItems().get(2); - assertEquals(orderItem03.getSkuId(), 30L); - assertEquals(orderItem03.getCount(), 4); - assertEquals(orderItem03.getPrice(), 30); - assertEquals(orderItem03.getDiscountPrice(), 60); - assertEquals(orderItem03.getDeliveryPrice(), 0); - assertEquals(orderItem03.getCouponPrice(), 0); - assertEquals(orderItem03.getPointPrice(), 0); - assertEquals(orderItem03.getPayPrice(), 60); - // 断言:Promotion 部分(第一个) - assertEquals(result.getPromotions().size(), 2); - TradePriceCalculateRespBO.Promotion promotion01 = result.getPromotions().get(0); - assertEquals(promotion01.getId(), 1000L); - assertEquals(promotion01.getName(), "活动 1000 号"); - assertEquals(promotion01.getType(), PromotionTypeEnum.REWARD_ACTIVITY.getType()); - assertEquals(promotion01.getTotalPrice(), 350); - assertEquals(promotion01.getDiscountPrice(), 70); - assertTrue(promotion01.getMatch()); - assertEquals(promotion01.getDescription(), "满减送:省 0.70 元"); - assertEquals(promotion01.getItems().size(), 2); - TradePriceCalculateRespBO.PromotionItem promotionItem011 = promotion01.getItems().get(0); - assertEquals(promotionItem011.getSkuId(), 10L); - assertEquals(promotionItem011.getTotalPrice(), 200); - assertEquals(promotionItem011.getDiscountPrice(), 40); - TradePriceCalculateRespBO.PromotionItem promotionItem012 = promotion01.getItems().get(1); - assertEquals(promotionItem012.getSkuId(), 20L); - assertEquals(promotionItem012.getTotalPrice(), 150); - assertEquals(promotionItem012.getDiscountPrice(), 30); - // 断言:Promotion 部分(第二个) - TradePriceCalculateRespBO.Promotion promotion02 = result.getPromotions().get(1); - assertEquals(promotion02.getId(), 2000L); - assertEquals(promotion02.getName(), "活动 2000 号"); - assertEquals(promotion02.getType(), PromotionTypeEnum.REWARD_ACTIVITY.getType()); - assertEquals(promotion02.getTotalPrice(), 120); - assertEquals(promotion02.getDiscountPrice(), 60); - assertTrue(promotion02.getMatch()); - assertEquals(promotion02.getDescription(), "满减送:省 0.60 元"); - TradePriceCalculateRespBO.PromotionItem promotionItem02 = promotion02.getItems().get(0); - assertEquals(promotion02.getItems().size(), 1); - assertEquals(promotionItem02.getSkuId(), 30L); - assertEquals(promotionItem02.getTotalPrice(), 120); - assertEquals(promotionItem02.getDiscountPrice(), 60); - } - - @Test - public void testCalculate_notMatch() { - // 准备参数 - TradePriceCalculateReqBO param = new TradePriceCalculateReqBO() - .setItems(asList( - new TradePriceCalculateReqBO.Item().setSkuId(10L).setCount(2).setSelected(true), - new TradePriceCalculateReqBO.Item().setSkuId(20L).setCount(3).setSelected(true), - new TradePriceCalculateReqBO.Item().setSkuId(30L).setCount(4).setSelected(true) - )); - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO() - .setType(TradeOrderTypeEnum.NORMAL.getType()) - .setPrice(new TradePriceCalculateRespBO.Price()) - .setPromotions(new ArrayList<>()) - .setItems(asList( - new TradePriceCalculateRespBO.OrderItem().setSkuId(10L).setCount(2).setSelected(true) - .setPrice(100).setSpuId(1L), - new TradePriceCalculateRespBO.OrderItem().setSkuId(20L).setCount(3).setSelected(true) - .setPrice(50).setSpuId(2L) - )); - // 保证价格被初始化上 - TradePriceCalculatorHelper.recountPayPrice(result.getItems()); - TradePriceCalculatorHelper.recountAllPrice(result); - - // mock 方法(限时折扣 DiscountActivity 信息) - when(rewardActivityApi.getMatchRewardActivityList(eq(asSet(1L, 2L)))).thenReturn(singletonList( - randomPojo(RewardActivityMatchRespDTO.class, o -> o.setId(1000L).setName("活动 1000 号") - .setSpuIds(asList(1L, 2L)).setConditionType(PromotionConditionTypeEnum.PRICE.getType()) - .setRules(singletonList(new RewardActivityMatchRespDTO.Rule().setLimit(351).setDiscountPrice(70)))) - )); - - // 调用 - tradeRewardActivityPriceCalculator.calculate(param, result); - // 断言 Order 部分 - TradePriceCalculateRespBO.Price price = result.getPrice(); - assertEquals(price.getTotalPrice(), 350); - assertEquals(price.getDiscountPrice(), 0); - assertEquals(price.getPointPrice(), 0); - assertEquals(price.getDeliveryPrice(), 0); - assertEquals(price.getCouponPrice(), 0); - assertEquals(price.getPayPrice(), 350); - assertNull(result.getCouponId()); - // 断言:SKU 1 - assertEquals(result.getItems().size(), 2); - TradePriceCalculateRespBO.OrderItem orderItem01 = result.getItems().get(0); - assertEquals(orderItem01.getSkuId(), 10L); - assertEquals(orderItem01.getCount(), 2); - assertEquals(orderItem01.getPrice(), 100); - assertEquals(orderItem01.getDiscountPrice(), 0); - assertEquals(orderItem01.getDeliveryPrice(), 0); - assertEquals(orderItem01.getCouponPrice(), 0); - assertEquals(orderItem01.getPointPrice(), 0); - assertEquals(orderItem01.getPayPrice(), 200); - // 断言:SKU 2 - TradePriceCalculateRespBO.OrderItem orderItem02 = result.getItems().get(1); - assertEquals(orderItem02.getSkuId(), 20L); - assertEquals(orderItem02.getCount(), 3); - assertEquals(orderItem02.getPrice(), 50); - assertEquals(orderItem02.getDiscountPrice(), 0); - assertEquals(orderItem02.getDeliveryPrice(), 0); - assertEquals(orderItem02.getCouponPrice(), 0); - assertEquals(orderItem02.getPointPrice(), 0); - assertEquals(orderItem02.getPayPrice(), 150); - // 断言 Promotion 部分 - assertEquals(result.getPromotions().size(), 1); - TradePriceCalculateRespBO.Promotion promotion01 = result.getPromotions().get(0); - assertEquals(promotion01.getId(), 1000L); - assertEquals(promotion01.getName(), "活动 1000 号"); - assertEquals(promotion01.getType(), PromotionTypeEnum.REWARD_ACTIVITY.getType()); - assertEquals(promotion01.getTotalPrice(), 350); - assertEquals(promotion01.getDiscountPrice(), 0); - assertFalse(promotion01.getMatch()); - assertEquals(promotion01.getDescription(), "TODO"); // TODO 芋艿:后面再想想 - assertEquals(promotion01.getItems().size(), 2); - TradePriceCalculateRespBO.PromotionItem promotionItem011 = promotion01.getItems().get(0); - assertEquals(promotionItem011.getSkuId(), 10L); - assertEquals(promotionItem011.getTotalPrice(), 200); - assertEquals(promotionItem011.getDiscountPrice(), 0); - TradePriceCalculateRespBO.PromotionItem promotionItem012 = promotion01.getItems().get(1); - assertEquals(promotionItem012.getSkuId(), 20L); - assertEquals(promotionItem012.getTotalPrice(), 150); - assertEquals(promotionItem012.getDiscountPrice(), 0); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 0aa14e897a..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,62 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module - trade: - order: - app-id: 1 - merchant-order-id: 1 - express: - kd-niao: - api-key: xxxx - business-id: xxxxx - kd100: - customer: xxxxx - key: xxxxx - client: not_provide \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/logback.xml b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff0..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index f7f3477cc3..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,7 +0,0 @@ -DELETE FROM trade_order; -DELETE FROM trade_order_item; -DELETE FROM trade_after_sale; -DELETE FROM trade_after_sale_log; -DELETE FROM trade_brokerage_user; -DELETE FROM trade_brokerage_record; -DELETE FROM "trade_brokerage_withdraw"; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index d263fdfb92..0000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,191 +0,0 @@ -CREATE TABLE IF NOT EXISTS "trade_order" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "no" varchar NOT NULL, - "type" int NOT NULL, - "terminal" int NOT NULL, - "user_id" bigint NOT NULL, - "user_ip" varchar NOT NULL, - "user_remark" varchar, - "status" int NOT NULL, - "product_count" int NOT NULL, - "cancel_type" int, - "remark" varchar, - "pay_status" bit NOT NULL, - "pay_time" datetime, - "finish_time" datetime, - "cancel_time" datetime, - "original_price" int NOT NULL, - "order_price" int NOT NULL, - "discount_price" int NOT NULL, - "delivery_price" int NOT NULL, - "adjust_price" int NOT NULL, - "pay_price" int NOT NULL, - "pay_order_id" bigint, - "pay_channel_code" varchar, - "delivery_template_id" bigint, - "logistics_id" bigint, - "logistics_no" varchar, - "delivery_time" datetime, - "receive_time" datetime, - "receiver_name" varchar NOT NULL, - "receiver_mobile" varchar NOT NULL, - "receiver_area_id" int NOT NULL, - "receiver_post_code" int, - "receiver_detail_address" varchar NOT NULL, - "after_sale_status" int NOT NULL, - "refund_price" int NOT NULL, - "coupon_id" bigint NOT NULL, - "coupon_price" int NOT NULL, - "point_price" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易订单表'; - -CREATE TABLE IF NOT EXISTS "trade_order_item" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "order_id" bigint NOT NULL, - "spu_id" bigint NOT NULL, - "spu_name" varchar NOT NULL, - "sku_id" bigint NOT NULL, - "properties" varchar, - "pic_url" varchar, - "count" int NOT NULL, - "original_price" int NOT NULL, - "original_unit_price" int NOT NULL, - "discount_price" int NOT NULL, - "pay_price" int NOT NULL, - "order_part_price" int NOT NULL, - "order_divide_price" int NOT NULL, - "after_sale_status" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易订单明细表'; - -CREATE TABLE IF NOT EXISTS "trade_after_sale" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "no" varchar NOT NULL, - "status" int NOT NULL, - "type" int NOT NULL, - "way" int NOT NULL, - "user_id" bigint NOT NULL, - "apply_reason" varchar NOT NULL, - "apply_description" varchar, - "apply_pic_urls" varchar, - "order_id" bigint NOT NULL, - "order_no" varchar NOT NULL, - "order_item_id" bigint NOT NULL, - "spu_id" bigint NOT NULL, - "spu_name" varchar NOT NULL, - "sku_id" bigint NOT NULL, - "properties" varchar, - "pic_url" varchar, - "count" int NOT NULL, - "audit_time" varchar, - "audit_user_id" bigint, - "audit_reason" varchar, - "refund_price" int NOT NULL, - "pay_refund_id" bigint, - "refund_time" varchar, - "logistics_id" bigint, - "logistics_no" varchar, - "delivery_time" varchar, - "receive_time" varchar, - "receive_reason" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易售后表'; - -CREATE TABLE IF NOT EXISTS "trade_after_sale_log" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" int NOT NULL, - "after_sale_id" bigint NOT NULL, - "order_id" bigint NOT NULL, - "order_item_id" bigint NOT NULL, - "before_status" int, - "after_status" int NOT NULL, - "content" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易售后日志'; - -CREATE TABLE IF NOT EXISTS "trade_brokerage_user" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "bind_user_id" bigint NOT NULL, - "bind_user_time" varchar, - "brokerage_enabled" bit NOT NULL, - "brokerage_time" varchar, - "price" int NOT NULL, - "frozen_price" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL DEFAULT '0', - PRIMARY KEY ("id") -) COMMENT '分销用户'; -CREATE TABLE IF NOT EXISTS "trade_brokerage_record" -( - "id" int NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "biz_id" varchar NOT NULL, - "biz_type" varchar NOT NULL, - "title" varchar NOT NULL, - "price" int NOT NULL, - "total_price" int NOT NULL, - "description" varchar NOT NULL, - "status" varchar NOT NULL, - "frozen_days" int NOT NULL, - "unfreeze_time" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '佣金记录'; -CREATE TABLE IF NOT EXISTS "trade_brokerage_withdraw" -( - "id" int NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "price" int NOT NULL, - "fee_price" int NOT NULL, - "total_price" int NOT NULL, - "type" varchar NOT NULL, - "name" varchar, - "account_no" varchar, - "bank_name" varchar, - "bank_address" varchar, - "account_qr_code_url" varchar, - "status" varchar NOT NULL, - "audit_reason" varchar, - "audit_time" varchar, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '佣金提现'; \ No newline at end of file diff --git a/yudao-module-member/pom.xml b/yudao-module-member/pom.xml deleted file mode 100644 index ea65199add..0000000000 --- a/yudao-module-member/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - cn.iocoder.boot - yudao - ${revision} - - 4.0.0 - - yudao-module-member-api - yudao-module-member-biz - - yudao-module-member - pom - - ${project.artifactId} - - member 模块,我们放会员业务。 - 例如说:会员中心等等 - - - diff --git a/yudao-module-member/yudao-module-member-api/pom.xml b/yudao-module-member/yudao-module-member-api/pom.xml deleted file mode 100644 index 1f60cd0fc3..0000000000 --- a/yudao-module-member/yudao-module-member-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-member - ${revision} - - 4.0.0 - yudao-module-member-api - jar - - ${project.artifactId} - - member 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/MemberAddressApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/MemberAddressApi.java deleted file mode 100644 index 913316f968..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/MemberAddressApi.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.member.api.address; - -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; - -/** - * 用户收件地址 API 接口 - * - * @author 芋道源码 - */ -public interface MemberAddressApi { - - /** - * 获得用户收件地址 - * - * @param id 收件地址编号 - * @param userId 用户编号 - * @return 用户收件地址 - */ - MemberAddressRespDTO getAddress(Long id, Long userId); - - /** - * 获得用户默认收件地址 - * - * @param userId 用户编号 - * @return 用户收件地址 - */ - MemberAddressRespDTO getDefaultAddress(Long userId); - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/dto/MemberAddressRespDTO.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/dto/MemberAddressRespDTO.java deleted file mode 100644 index 969e868a44..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/dto/MemberAddressRespDTO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.member.api.address.dto; - -import lombok.Data; - -/** - * 用户收件地址 Response DTO - * - * @author 芋道源码 - */ -@Data -public class MemberAddressRespDTO { - - /** - * 编号 - */ - private Long id; - /** - * 用户编号 - */ - private Long userId; - /** - * 收件人名称 - */ - private String name; - /** - * 手机号 - */ - private String mobile; - /** - * 地区编号 - */ - private Integer areaId; - /** - * 收件详细地址 - */ - private String detailAddress; - /** - * 是否默认 - */ - private Boolean defaultStatus; - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/config/MemberConfigApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/config/MemberConfigApi.java deleted file mode 100644 index dab7f68776..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/config/MemberConfigApi.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.member.api.config; - -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; - -/** - * 用户配置 API 接口 - * - * @author owen - */ -public interface MemberConfigApi { - - /** - * 获得积分配置 - * - * @return 积分配置 - */ - MemberConfigRespDTO getConfig(); -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/config/dto/MemberConfigRespDTO.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/config/dto/MemberConfigRespDTO.java deleted file mode 100644 index 59aab53f98..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/config/dto/MemberConfigRespDTO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.member.api.config.dto; - -import lombok.Data; - -/** - * 用户信息 Response DTO - * - * @author 芋道源码 - */ -@Data -public class MemberConfigRespDTO { - - /** - * 积分抵扣开关 - */ - private Boolean pointTradeDeductEnable; - /** - * 积分抵扣,单位:分 - *

- * 1 积分抵扣多少分 - */ - private Integer pointTradeDeductUnitPrice; - /** - * 积分抵扣最大值 - */ - private Integer pointTradeDeductMaxPrice; - /** - * 1 元赠送多少分 - */ - private Integer pointTradeGivePoint; - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApi.java deleted file mode 100644 index 587683797b..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApi.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.member.api.level; - -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; - -/** - * 会员等级 API 接口 - * - * @author owen - */ -public interface MemberLevelApi { - - /** - * 获得会员等级 - * - * @param id 会员等级编号 - * @return 会员等级 - */ - MemberLevelRespDTO getMemberLevel(Long id); - - /** - * 增加会员经验 - * - * @param userId 会员ID - * @param experience 经验 - * @param bizType 业务类型 {@link MemberExperienceBizTypeEnum} - * @param bizId 业务编号 - */ - void addExperience(Long userId, Integer experience, Integer bizType, String bizId); - - /** - * 扣减会员经验 - * - * @param userId 会员ID - * @param experience 经验 - * @param bizType 业务类型 {@link MemberExperienceBizTypeEnum} - * @param bizId 业务编号 - */ - void reduceExperience(Long userId, Integer experience, Integer bizType, String bizId); - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/dto/MemberLevelRespDTO.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/dto/MemberLevelRespDTO.java deleted file mode 100644 index a72d65f238..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/dto/MemberLevelRespDTO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.member.api.level.dto; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import lombok.Data; - -/** - * 会员等级 Resp DTO - * - * @author 芋道源码 - */ -@Data -public class MemberLevelRespDTO { - - /** - * 编号 - */ - private Long id; - /** - * 等级名称 - */ - private String name; - /** - * 等级 - */ - private Integer level; - /** - * 升级经验 - */ - private Integer experience; - /** - * 享受折扣 - */ - private Integer discountPercent; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/package-info.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/package-info.java deleted file mode 100644 index 56cd9857f8..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * member API 包,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.member.api; diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApi.java deleted file mode 100644 index e9120a36a8..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApi.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.member.api.point; - -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; - -import jakarta.validation.constraints.Min; - -/** - * 用户积分的 API 接口 - * - * @author owen - */ -public interface MemberPointApi { - - /** - * 增加用户积分 - * - * @param userId 用户编号 - * @param point 积分 - * @param bizType 业务类型 {@link MemberPointBizTypeEnum} - * @param bizId 业务编号 - */ - void addPoint(Long userId, @Min(value = 1L, message = "积分必须是正数") Integer point, - Integer bizType, String bizId); - - /** - * 减少用户积分 - * - * @param userId 用户编号 - * @param point 积分 - * @param bizType 业务类型 {@link MemberPointBizTypeEnum} - * @param bizId 业务编号 - */ - void reducePoint(Long userId, @Min(value = 1L, message = "积分必须是正数") Integer point, - Integer bizType, String bizId); - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java deleted file mode 100644 index c9fb801007..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.member.api.user; - -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 会员用户的 API 接口 - * - * @author 芋道源码 - */ -public interface MemberUserApi { - - /** - * 获得会员用户信息 - * - * @param id 用户编号 - * @return 用户信息 - */ - MemberUserRespDTO getUser(Long id); - - /** - * 获得会员用户信息们 - * - * @param ids 用户编号的数组 - * @return 用户信息们 - */ - List getUserList(Collection ids); - - /** - * 获得会员用户 Map - * - * @param ids 用户编号的数组 - * @return 会员用户 Map - */ - default Map getUserMap(Collection ids) { - List list = getUserList(ids); - return convertMap(list, MemberUserRespDTO::getId); - } - - /** - * 基于用户昵称,模糊匹配用户列表 - * - * @param nickname 用户昵称,模糊匹配 - * @return 用户信息的列表 - */ - List getUserListByNickname(String nickname); - - /** - * 基于手机号,精准匹配用户 - * - * @param mobile 手机号 - * @return 用户信息 - */ - MemberUserRespDTO getUserByMobile(String mobile); -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/MemberUserRespDTO.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/MemberUserRespDTO.java deleted file mode 100644 index 50548f935a..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/MemberUserRespDTO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.member.api.user.dto; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 用户信息 Response DTO - * - * @author 芋道源码 - */ -@Data -public class MemberUserRespDTO { - - /** - * 用户ID - */ - private Long id; - /** - * 用户昵称 - */ - private String nickname; - /** - * 帐号状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 用户头像 - */ - private String avatar; - /** - * 手机 - */ - private String mobile; - /** - * 创建时间(注册时间) - */ - private LocalDateTime createTime; - - // ========== 其它信息 ========== - - /** - * 会员级别编号 - */ - private Long levelId; - - /** - * 积分 - */ - private Integer point; - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/DictTypeConstants.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/DictTypeConstants.java deleted file mode 100644 index c87cbb901d..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/DictTypeConstants.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.member.enums; - -/** - * Member 字典类型的枚举类 - * - * @author owen - */ -public interface DictTypeConstants { - - /** - * 会员经验记录 - 业务类型 - */ - String MEMBER_EXPERIENCE_BIZ_TYPE = "member_experience_biz_type"; - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java deleted file mode 100644 index c7dc8b749e..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.member.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Member 错误码枚举类 - *

- * member 系统,使用 1-004-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 用户相关 1-004-001-000 ============ - ErrorCode USER_NOT_EXISTS = new ErrorCode(1_004_001_000, "用户不存在"); - ErrorCode USER_MOBILE_NOT_EXISTS = new ErrorCode(1_004_001_001, "手机号未注册用户"); - ErrorCode USER_MOBILE_USED = new ErrorCode(1_004_001_002, "修改手机失败,该手机号({})已经被使用"); - ErrorCode USER_POINT_NOT_ENOUGH = new ErrorCode(1_004_001_003, "用户积分余额不足"); - - // ========== AUTH 模块 1-004-003-000 ========== - ErrorCode AUTH_LOGIN_BAD_CREDENTIALS = new ErrorCode(1_004_003_000, "登录失败,账号密码不正确"); - ErrorCode AUTH_LOGIN_USER_DISABLED = new ErrorCode(1_004_003_001, "登录失败,账号被禁用"); - ErrorCode AUTH_THIRD_LOGIN_NOT_BIND = new ErrorCode(1_004_003_005, "未绑定账号,需要进行绑定"); - ErrorCode AUTH_MOBILE_USED = new ErrorCode(1_004_003_007, "手机号已经被使用"); - - // ========== 用户收件地址 1-004-004-000 ========== - ErrorCode ADDRESS_NOT_EXISTS = new ErrorCode(1_004_004_000, "用户收件地址不存在"); - - //========== 用户标签 1-004-006-000 ========== - ErrorCode TAG_NOT_EXISTS = new ErrorCode(1_004_006_000, "用户标签不存在"); - ErrorCode TAG_NAME_EXISTS = new ErrorCode(1_004_006_001, "用户标签已经存在"); - ErrorCode TAG_HAS_USER = new ErrorCode(1_004_006_002, "用户标签下存在用户,无法删除"); - - //========== 积分配置 1-004-007-000 ========== - - //========== 积分记录 1-004-008-000 ========== - ErrorCode POINT_RECORD_BIZ_NOT_SUPPORT = new ErrorCode(1_004_008_000, "用户积分记录业务类型不支持"); - - //========== 签到配置 1-004-009-000 ========== - ErrorCode SIGN_IN_CONFIG_NOT_EXISTS = new ErrorCode(1_004_009_000, "签到天数规则不存在"); - ErrorCode SIGN_IN_CONFIG_EXISTS = new ErrorCode(1_004_009_001, "签到天数规则已存在"); - - //========== 签到配置 1-004-010-000 ========== - ErrorCode SIGN_IN_RECORD_TODAY_EXISTS = new ErrorCode(1_004_010_000, "今日已签到,请勿重复签到"); - - //========== 用户等级 1-004-011-000 ========== - ErrorCode LEVEL_NOT_EXISTS = new ErrorCode(1_004_011_000, "用户等级不存在"); - ErrorCode LEVEL_NAME_EXISTS = new ErrorCode(1_004_011_001, "用户等级名称[{}]已被使用"); - ErrorCode LEVEL_VALUE_EXISTS = new ErrorCode(1_004_011_002, "用户等级值[{}]已被[{}]使用"); - ErrorCode LEVEL_EXPERIENCE_MIN = new ErrorCode(1_004_011_003, "升级经验必须大于上一个等级[{}]设置的升级经验[{}]"); - ErrorCode LEVEL_EXPERIENCE_MAX = new ErrorCode(1_004_011_004, "升级经验必须小于下一个等级[{}]设置的升级经验[{}]"); - ErrorCode LEVEL_HAS_USER = new ErrorCode(1_004_011_005, "用户等级下存在用户,无法删除"); - - ErrorCode EXPERIENCE_BIZ_NOT_SUPPORT = new ErrorCode(1_004_011_201, "用户经验业务类型不支持"); - - //========== 用户分组 1-004-012-000 ========== - ErrorCode GROUP_NOT_EXISTS = new ErrorCode(1_004_012_000, "用户分组不存在"); - ErrorCode GROUP_HAS_USER = new ErrorCode(1_004_012_001, "用户分组下存在用户,无法删除"); - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/MemberExperienceBizTypeEnum.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/MemberExperienceBizTypeEnum.java deleted file mode 100644 index 3038dba316..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/MemberExperienceBizTypeEnum.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.member.enums; - -import cn.hutool.core.util.EnumUtil; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 会员经验 - 业务类型 - * - * @author owen - */ -@Getter -@AllArgsConstructor -public enum MemberExperienceBizTypeEnum { - - /** - * 管理员调整、邀请新用户、下单、退单、签到、抽奖 - */ - ADMIN(0, "管理员调整", "管理员调整获得 {} 经验", true), - INVITE_REGISTER(1, "邀新奖励", "邀请好友获得 {} 经验", true), - SIGN_IN(4, "签到奖励", "签到获得 {} 经验", true), - LOTTERY(5, "抽奖奖励", "抽奖获得 {} 经验", true), - ORDER_GIVE(11, "下单奖励", "下单获得 {} 经验", true), - ORDER_GIVE_CANCEL(12, "下单奖励(整单取消)", "取消订单获得 {} 经验", false), // ORDER_GIVE 的取消 - ORDER_GIVE_CANCEL_ITEM(13, "下单奖励(单个退款)", "退款订单获得 {} 经验", false), // ORDER_GIVE 的取消 - ; - - /** - * 业务类型 - */ - private final int type; - /** - * 标题 - */ - private final String title; - /** - * 描述 - */ - private final String description; - /** - * 是否为扣减积分 - */ - private final boolean add; - - public static MemberExperienceBizTypeEnum getByType(Integer type) { - return EnumUtil.getBy(MemberExperienceBizTypeEnum.class, - e -> Objects.equals(type, e.getType())); - } -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/point/MemberPointBizTypeEnum.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/point/MemberPointBizTypeEnum.java deleted file mode 100644 index ef491f42a7..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/point/MemberPointBizTypeEnum.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.member.enums.point; - -import cn.hutool.core.util.EnumUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 会员积分的业务类型枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum MemberPointBizTypeEnum implements IntArrayValuable { - - SIGN(1, "签到", "签到获得 {} 积分", true), - ADMIN(2, "管理员修改", "管理员修改 {} 积分", true), - - ORDER_USE(11, "订单积分抵扣", "下单使用 {} 积分", false), // 下单时,扣减积分 - ORDER_USE_CANCEL(12, "订单积分抵扣(整单取消)", "订单取消,退还 {} 积分", true), // ORDER_USE 的取消 - ORDER_USE_CANCEL_ITEM(13, "订单积分抵扣(单个退款)", "订单退款,退还 {} 积分", true), // ORDER_USE 的取消 - - ORDER_GIVE(21, "订单积分奖励", "下单获得 {} 积分", true), // 支付订单时,赠送积分 - ORDER_GIVE_CANCEL(22, "订单积分奖励(整单取消)", "订单取消,退还 {} 积分", false), // ORDER_GIVE 的取消 - ORDER_GIVE_CANCEL_ITEM(23, "订单积分奖励(单个退款)", "订单退款,扣除赠送的 {} 积分", false) // ORDER_GIVE 的取消 - ; - - /** - * 类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - /** - * 描述 - */ - private final String description; - /** - * 是否为扣减积分 - */ - private final boolean add; - - @Override - public int[] array() { - return new int[0]; - } - - public static MemberPointBizTypeEnum getByType(Integer type) { - return EnumUtil.getBy(MemberPointBizTypeEnum.class, - e -> Objects.equals(type, e.getType())); - } - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/message/package-info.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/message/package-info.java deleted file mode 100644 index 6ae3b64481..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/message/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的消息 - */ -package cn.iocoder.yudao.module.member.message; diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/message/user/MemberUserCreateMessage.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/message/user/MemberUserCreateMessage.java deleted file mode 100644 index 7409705c4e..0000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/message/user/MemberUserCreateMessage.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.member.message.user; - -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 会员用户创建消息 - * - * @author owen - */ -@Data -public class MemberUserCreateMessage { - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - -} diff --git a/yudao-module-member/yudao-module-member-biz/pom.xml b/yudao-module-member/yudao-module-member-biz/pom.xml deleted file mode 100644 index 249c061ae0..0000000000 --- a/yudao-module-member/yudao-module-member-biz/pom.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-member - ${revision} - - 4.0.0 - yudao-module-member-biz - jar - - ${project.artifactId} - - member 模块,我们放会员业务。 - 例如说:会员中心等等 - - - - - cn.iocoder.boot - yudao-module-member-api - ${revision} - - - cn.iocoder.boot - yudao-module-system-api - ${revision} - - - cn.iocoder.boot - yudao-module-infra-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - org.springframework.boot - spring-boot-starter-validation - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.boot - yudao-spring-boot-starter-redis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mq - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - - - - - cn.iocoder.boot - yudao-spring-boot-starter-excel - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-ip - - - - - diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/MemberAddressApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/MemberAddressApiImpl.java deleted file mode 100644 index 0793c09edc..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/MemberAddressApiImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.member.api.address; - -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.member.convert.address.AddressConvert; -import cn.iocoder.yudao.module.member.service.address.AddressService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -/** - * 用户收件地址 API 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class MemberAddressApiImpl implements MemberAddressApi { - - @Resource - private AddressService addressService; - - @Override - public MemberAddressRespDTO getAddress(Long id, Long userId) { - return AddressConvert.INSTANCE.convert02(addressService.getAddress(userId, id)); - } - - @Override - public MemberAddressRespDTO getDefaultAddress(Long userId) { - return AddressConvert.INSTANCE.convert02(addressService.getDefaultUserAddress(userId)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/config/MemberConfigApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/config/MemberConfigApiImpl.java deleted file mode 100644 index 8e07e0ba4a..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/config/MemberConfigApiImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.member.api.config; - -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.member.convert.config.MemberConfigConvert; -import cn.iocoder.yudao.module.member.service.config.MemberConfigService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -/** - * 用户配置 API 实现类 - * - * @author owen - */ -@Service -@Validated -public class MemberConfigApiImpl implements MemberConfigApi { - - @Resource - private MemberConfigService memberConfigService; - - @Override - public MemberConfigRespDTO getConfig() { - return MemberConfigConvert.INSTANCE.convert01(memberConfigService.getConfig()); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApiImpl.java deleted file mode 100644 index 022a33344e..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApiImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.member.api.level; - -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import cn.iocoder.yudao.module.member.service.level.MemberLevelService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.EXPERIENCE_BIZ_NOT_SUPPORT; - -/** - * 会员等级 API 实现类 - * - * @author owen - */ -@Service -@Validated -public class MemberLevelApiImpl implements MemberLevelApi { - - @Resource - private MemberLevelService memberLevelService; - - @Override - public MemberLevelRespDTO getMemberLevel(Long id) { - return MemberLevelConvert.INSTANCE.convert02(memberLevelService.getLevel(id)); - } - - @Override - public void addExperience(Long userId, Integer experience, Integer bizType, String bizId) { - MemberExperienceBizTypeEnum bizTypeEnum = MemberExperienceBizTypeEnum.getByType(bizType); - if (bizTypeEnum == null) { - throw exception(EXPERIENCE_BIZ_NOT_SUPPORT); - } - memberLevelService.addExperience(userId, experience, bizTypeEnum, bizId); - } - - @Override - public void reduceExperience(Long userId, Integer experience, Integer bizType, String bizId) { - addExperience(userId, -experience, bizType, bizId); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/package-info.java deleted file mode 100644 index 5f97979b88..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.member.api; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApiImpl.java deleted file mode 100644 index ba94e6cda3..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApiImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.member.api.point; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.POINT_RECORD_BIZ_NOT_SUPPORT; - -/** - * 用户积分的 API 实现类 - * - * @author owen - */ -@Service -@Validated -public class MemberPointApiImpl implements MemberPointApi { - - @Resource - private MemberPointRecordService memberPointRecordService; - - @Override - public void addPoint(Long userId, Integer point, Integer bizType, String bizId) { - Assert.isTrue(point > 0); - MemberPointBizTypeEnum bizTypeEnum = MemberPointBizTypeEnum.getByType(bizType); - if (bizTypeEnum == null) { - throw exception(POINT_RECORD_BIZ_NOT_SUPPORT); - } - memberPointRecordService.createPointRecord(userId, point, bizTypeEnum, bizId); - } - - @Override - public void reducePoint(Long userId, Integer point, Integer bizType, String bizId) { - Assert.isTrue(point > 0); - MemberPointBizTypeEnum bizTypeEnum = MemberPointBizTypeEnum.getByType(bizType); - if (bizTypeEnum == null) { - throw exception(POINT_RECORD_BIZ_NOT_SUPPORT); - } - memberPointRecordService.createPointRecord(userId, -point, bizTypeEnum, bizId); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java deleted file mode 100644 index 659c39b577..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.member.api.user; - -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -/** - * 会员用户的 API 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class MemberUserApiImpl implements MemberUserApi { - - @Resource - private MemberUserService userService; - - @Override - public MemberUserRespDTO getUser(Long id) { - MemberUserDO user = userService.getUser(id); - return MemberUserConvert.INSTANCE.convert2(user); - } - - @Override - public List getUserList(Collection ids) { - return MemberUserConvert.INSTANCE.convertList2(userService.getUserList(ids)); - } - - @Override - public List getUserListByNickname(String nickname) { - return MemberUserConvert.INSTANCE.convertList2(userService.getUserListByNickname(nickname)); - } - - @Override - public MemberUserRespDTO getUserByMobile(String mobile) { - return MemberUserConvert.INSTANCE.convert2(userService.getUserByMobile(mobile)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/AddressController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/AddressController.java deleted file mode 100644 index 273d82fa09..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/AddressController.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.address; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressRespVO; -import cn.iocoder.yudao.module.member.convert.address.AddressConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; -import cn.iocoder.yudao.module.member.service.address.AddressService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 用户收件地址") -@RestController -@RequestMapping("/member/address") -@Validated -public class AddressController { - - @Resource - private AddressService addressService; - - @GetMapping("/list") - @Operation(summary = "获得用户收件地址列表") - @Parameter(name = "userId", description = "用户编号", required = true) - @PreAuthorize("@ss.hasPermission('member:user:query')") - public CommonResult> getAddressList(@RequestParam("userId") Long userId) { - List list = addressService.getAddressList(userId); - return success(AddressConvert.INSTANCE.convertList2(list)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/package-info.java deleted file mode 100644 index 652bbb6f19..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.address; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressBaseVO.java deleted file mode 100644 index e19609a8bc..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressBaseVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.address.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.*; -import jakarta.validation.constraints.*; - -/** - * 用户收件地址 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class AddressBaseVO { - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @NotNull(message = "收件人名称不能为空") - private String name; - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "手机号不能为空") - private String mobile; - - @Schema(description = "地区编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "15716") - @NotNull(message = "地区编码不能为空") - private Long areaId; - - @Schema(description = "收件详细地址", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "收件详细地址不能为空") - private String detailAddress; - - @Schema(description = "是否默认", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "是否默认不能为空") - private Boolean defaultStatus; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressRespVO.java deleted file mode 100644 index 26a4988af7..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.address.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户收件地址 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AddressRespVO extends AddressBaseVO { - - @Schema(description = "收件地址编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7380") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/MemberConfigController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/MemberConfigController.java deleted file mode 100644 index cad9884251..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/MemberConfigController.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.config; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigRespVO; -import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigSaveReqVO; -import cn.iocoder.yudao.module.member.convert.config.MemberConfigConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.config.MemberConfigDO; -import cn.iocoder.yudao.module.member.service.config.MemberConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员设置") -@RestController -@RequestMapping("/member/config") -@Validated -public class MemberConfigController { - - @Resource - private MemberConfigService memberConfigService; - - @PutMapping("/save") - @Operation(summary = "保存会员配置") - @PreAuthorize("@ss.hasPermission('member:config:save')") - public CommonResult saveConfig(@Valid @RequestBody MemberConfigSaveReqVO saveReqVO) { - memberConfigService.saveConfig(saveReqVO); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得会员配置") - @PreAuthorize("@ss.hasPermission('member:config:query')") - public CommonResult getConfig() { - MemberConfigDO config = memberConfigService.getConfig(); - return success(MemberConfigConvert.INSTANCE.convert(config)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigBaseVO.java deleted file mode 100644 index 2be07e5fea..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigBaseVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 会员配置 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberConfigBaseVO { - - @Schema(description = "积分抵扣开关", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "积分抵扣开发不能为空") - private Boolean pointTradeDeductEnable; - - @Schema(description = "积分抵扣,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "13506") - @NotNull(message = "积分抵扣不能为空") - private Integer pointTradeDeductUnitPrice; - - @Schema(description = "积分抵扣最大值", requiredMode = Schema.RequiredMode.REQUIRED, example = "32428") - @NotNull(message = "积分抵扣最大值不能为空") - private Integer pointTradeDeductMaxPrice; - - @Schema(description = "1 元赠送多少分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "1 元赠送积分不能为空") - private Integer pointTradeGivePoint; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigRespVO.java deleted file mode 100644 index 04f14f3d1e..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 会员配置 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberConfigRespVO extends MemberConfigBaseVO { - - @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigSaveReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigSaveReqVO.java deleted file mode 100644 index 8348f1f3c1..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigSaveReqVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 会员配置保存 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberConfigSaveReqVO extends MemberConfigBaseVO { -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/MemberGroupController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/MemberGroupController.java deleted file mode 100644 index cebfebefad..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/MemberGroupController.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.*; -import cn.iocoder.yudao.module.member.convert.group.MemberGroupConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import cn.iocoder.yudao.module.member.service.group.MemberGroupService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - - -@Tag(name = "管理后台 - 用户分组") -@RestController -@RequestMapping("/member/group") -@Validated -public class MemberGroupController { - - @Resource - private MemberGroupService groupService; - - @PostMapping("/create") - @Operation(summary = "创建用户分组") - @PreAuthorize("@ss.hasPermission('member:group:create')") - public CommonResult createGroup(@Valid @RequestBody MemberGroupCreateReqVO createReqVO) { - return success(groupService.createGroup(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新用户分组") - @PreAuthorize("@ss.hasPermission('member:group:update')") - public CommonResult updateGroup(@Valid @RequestBody MemberGroupUpdateReqVO updateReqVO) { - groupService.updateGroup(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除用户分组") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('member:group:delete')") - public CommonResult deleteGroup(@RequestParam("id") Long id) { - groupService.deleteGroup(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得用户分组") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:group:query')") - public CommonResult getGroup(@RequestParam("id") Long id) { - MemberGroupDO group = groupService.getGroup(id); - return success(MemberGroupConvert.INSTANCE.convert(group)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取会员分组精简信息列表", description = "只包含被开启的会员分组,主要用于前端的下拉选项") - public CommonResult> getSimpleGroupList() { - // 获用户列表,只要开启状态的 - List list = groupService.getEnableGroupList(); - return success(MemberGroupConvert.INSTANCE.convertSimpleList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得用户分组分页") - @PreAuthorize("@ss.hasPermission('member:group:query')") - public CommonResult> getGroupPage(@Valid MemberGroupPageReqVO pageVO) { - PageResult pageResult = groupService.getGroupPage(pageVO); - return success(MemberGroupConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupBaseVO.java deleted file mode 100644 index 281abe8d76..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupBaseVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 用户分组 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberGroupBaseVO { - - @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "购物达人") - @NotNull(message = "名称不能为空") - private String name; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String remark; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupCreateReqVO.java deleted file mode 100644 index ef3f833436..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 用户分组创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberGroupCreateReqVO extends MemberGroupBaseVO { - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupPageReqVO.java deleted file mode 100644 index ae67d5f6c8..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 用户分组分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberGroupPageReqVO extends PageParam { - - @Schema(description = "名称", example = "购物达人") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupRespVO.java deleted file mode 100644 index 97365382a8..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户分组 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberGroupRespVO extends MemberGroupBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20357") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupSimpleRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupSimpleRespVO.java deleted file mode 100644 index ee7d905d0a..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupSimpleRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 用户分组 Response VO") -@Data -@ToString(callSuper = true) -public class MemberGroupSimpleRespVO { - - @Schema(description = "编号", example = "6103") - private Long id; - - @Schema(description = "等级名称", example = "芋艿") - private String name; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupUpdateReqVO.java deleted file mode 100644 index f808808625..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 用户分组更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberGroupUpdateReqVO extends MemberGroupBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20357") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberExperienceRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberExperienceRecordController.java deleted file mode 100644 index c0766daf24..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberExperienceRecordController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordRespVO; -import cn.iocoder.yudao.module.member.convert.level.MemberExperienceRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; -import cn.iocoder.yudao.module.member.service.level.MemberExperienceRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员经验记录") -@RestController -@RequestMapping("/member/experience-record") -@Validated -public class MemberExperienceRecordController { - - @Resource - private MemberExperienceRecordService experienceLogService; - - @GetMapping("/get") - @Operation(summary = "获得会员经验记录") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:experience-record:query')") - public CommonResult getExperienceRecord(@RequestParam("id") Long id) { - MemberExperienceRecordDO experienceLog = experienceLogService.getExperienceRecord(id); - return success(MemberExperienceRecordConvert.INSTANCE.convert(experienceLog)); - } - - @GetMapping("/page") - @Operation(summary = "获得会员经验记录分页") - @PreAuthorize("@ss.hasPermission('member:experience-record:query')") - public CommonResult> getExperienceRecordPage( - @Valid MemberExperienceRecordPageReqVO pageVO) { - PageResult pageResult = experienceLogService.getExperienceRecordPage(pageVO); - return success(MemberExperienceRecordConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelController.java deleted file mode 100644 index 3384112ec3..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelController.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.*; -import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.service.level.MemberLevelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员等级") -@RestController -@RequestMapping("/member/level") -@Validated -public class MemberLevelController { - - @Resource - private MemberLevelService levelService; - - @PostMapping("/create") - @Operation(summary = "创建会员等级") - @PreAuthorize("@ss.hasPermission('member:level:create')") - public CommonResult createLevel(@Valid @RequestBody MemberLevelCreateReqVO createReqVO) { - return success(levelService.createLevel(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新会员等级") - @PreAuthorize("@ss.hasPermission('member:level:update')") - public CommonResult updateLevel(@Valid @RequestBody MemberLevelUpdateReqVO updateReqVO) { - levelService.updateLevel(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除会员等级") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('member:level:delete')") - public CommonResult deleteLevel(@RequestParam("id") Long id) { - levelService.deleteLevel(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得会员等级") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:level:query')") - public CommonResult getLevel(@RequestParam("id") Long id) { - MemberLevelDO level = levelService.getLevel(id); - return success(MemberLevelConvert.INSTANCE.convert(level)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取会员等级精简信息列表", description = "只包含被开启的会员等级,主要用于前端的下拉选项") - public CommonResult> getSimpleLevelList() { - // 获用户列表,只要开启状态的 - List list = levelService.getEnableLevelList(); - // 排序后,返回给前端 - return success(MemberLevelConvert.INSTANCE.convertSimpleList(list)); - } - - @GetMapping("/list") - @Operation(summary = "获得会员等级列表") - @PreAuthorize("@ss.hasPermission('member:level:query')") - public CommonResult> getLevelList(@Valid MemberLevelListReqVO listReqVO) { - List result = levelService.getLevelList(listReqVO); - return success(MemberLevelConvert.INSTANCE.convertList(result)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelRecordController.java deleted file mode 100644 index a837261378..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelRecordController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.record.MemberLevelRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.record.MemberLevelRecordRespVO; -import cn.iocoder.yudao.module.member.convert.level.MemberLevelRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; -import cn.iocoder.yudao.module.member.service.level.MemberLevelRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员等级记录") -@RestController -@RequestMapping("/member/level-record") -@Validated -public class MemberLevelRecordController { - - @Resource - private MemberLevelRecordService levelLogService; - - @GetMapping("/get") - @Operation(summary = "获得会员等级记录") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:level-record:query')") - public CommonResult getLevelRecord(@RequestParam("id") Long id) { - MemberLevelRecordDO levelLog = levelLogService.getLevelRecord(id); - return success(MemberLevelRecordConvert.INSTANCE.convert(levelLog)); - } - - @GetMapping("/page") - @Operation(summary = "获得会员等级记录分页") - @PreAuthorize("@ss.hasPermission('member:level-record:query')") - public CommonResult> getLevelRecordPage( - @Valid MemberLevelRecordPageReqVO pageVO) { - PageResult pageResult = levelLogService.getLevelRecordPage(pageVO); - return success(MemberLevelRecordConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordBaseVO.java deleted file mode 100644 index 82f84ea746..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordBaseVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 会员经验记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberExperienceRecordBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3638") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12164") - @NotNull(message = "业务编号不能为空") - private String bizId; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "业务类型不能为空") - private Integer bizType; - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "增加经验") - @NotNull(message = "标题不能为空") - private String title; - - @Schema(description = "经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "经验不能为空") - private Integer experience; - - @Schema(description = "变更后的经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - @NotNull(message = "变更后的经验不能为空") - private Integer totalExperience; - - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "下单增加 100 经验") - @NotNull(message = "描述不能为空") - private String description; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordPageReqVO.java deleted file mode 100644 index d18201d7c7..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员经验记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberExperienceRecordPageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "3638") - private Long userId; - - @Schema(description = "业务编号", example = "12164") - private String bizId; - - @Schema(description = "业务类型", example = "1") - private Integer bizType; - - @Schema(description = "标题", example = "增加经验") - private String title; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordRespVO.java deleted file mode 100644 index 5e652fcf04..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 会员经验记录 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberExperienceRecordRespVO extends MemberExperienceRecordBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19610") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelBaseVO.java deleted file mode 100644 index 9f3083ef5a..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelBaseVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.Range; -import org.hibernate.validator.constraints.URL; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Positive; - -/** - * 会员等级 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberLevelBaseVO { - - @Schema(description = "等级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @NotBlank(message = "等级名称不能为空") - private String name; - - @Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "升级经验不能为空") - @Positive(message = "升级经验必须大于 0") - private Integer experience; - - @Schema(description = "等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "等级不能为空") - @Positive(message = "等级必须大于 0") - private Integer level; - - @Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "98") - @NotNull(message = "享受折扣不能为空") - @Range(min = 0, max = 100, message = "享受折扣的范围为 0-100") - private Integer discountPercent; - - @Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg") - @URL(message = "等级图标必须是 URL 格式") - private String icon; - - @Schema(description = "等级背景图", example = "https://www.iocoder.cn/yudao.jpg") - @URL(message = "等级背景图必须是 URL 格式") - private String backgroundUrl; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelCreateReqVO.java deleted file mode 100644 index f51a7d9675..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 会员等级创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberLevelCreateReqVO extends MemberLevelBaseVO { - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelListReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelListReqVO.java deleted file mode 100644 index 348e78e8ec..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelListReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 会员等级列表筛选 Request VO") -@Data -@ToString(callSuper = true) -public class MemberLevelListReqVO { - - @Schema(description = "等级名称", example = "芋艿") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelRespVO.java deleted file mode 100644 index df91a814f6..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 会员等级 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberLevelRespVO extends MemberLevelBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6103") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelSimpleRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelSimpleRespVO.java deleted file mode 100644 index 96c515c8b4..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelSimpleRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 会员等级 Response VO") -@Data -@ToString(callSuper = true) -public class MemberLevelSimpleRespVO { - - @Schema(description = "编号", example = "6103") - private Long id; - - @Schema(description = "等级名称", example = "芋艿") - private String name; - - @Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg") - private String icon; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelUpdateReqVO.java deleted file mode 100644 index dad6c973b5..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 会员等级更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberLevelUpdateReqVO extends MemberLevelBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6103") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordBaseVO.java deleted file mode 100644 index 75371781f6..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordBaseVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 会员等级记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberLevelRecordBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25923") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "等级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25985") - @NotNull(message = "等级编号不能为空") - private Long levelId; - - @Schema(description = "会员等级", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "会员等级不能为空") - private Integer level; - - @Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "13319") - @NotNull(message = "享受折扣不能为空") - private Integer discountPercent; - - @Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "13319") - @NotNull(message = "升级经验不能为空") - private Integer experience; - - @Schema(description = "会员此时的经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "13319") - @NotNull(message = "会员此时的经验不能为空") - private Integer userExperience; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "推广需要") - @NotNull(message = "备注不能为空") - private String remark; - - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "升级为金牌会员") - @NotNull(message = "描述不能为空") - private String description; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordPageReqVO.java deleted file mode 100644 index 2590cfba6b..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员等级记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberLevelRecordPageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "25923") - private Long userId; - - @Schema(description = "等级编号", example = "25985") - private Long levelId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordRespVO.java deleted file mode 100644 index caf98ea4e9..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 会员等级记录 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberLevelRecordRespVO extends MemberLevelRecordBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8741") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/MemberPointRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/MemberPointRecordController.java deleted file mode 100644 index 7b63d79005..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/MemberPointRecordController.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.point; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordRespVO; -import cn.iocoder.yudao.module.member.convert.point.MemberPointRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.util.CollectionUtils; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 签到记录") -@RestController -@RequestMapping("/member/point/record") -@Validated -public class MemberPointRecordController { - - @Resource - private MemberPointRecordService pointRecordService; - - @Resource - private MemberUserService memberUserService; - - @GetMapping("/page") - @Operation(summary = "获得用户积分记录分页") - @PreAuthorize("@ss.hasPermission('point:record:query')") - public CommonResult> getPointRecordPage(@Valid MemberPointRecordPageReqVO pageVO) { - // 执行分页查询 - PageResult pageResult = pointRecordService.getPointRecordPage(pageVO); - if (CollectionUtils.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接结果返回 - List users = memberUserService.getUserList( - convertSet(pageResult.getList(), MemberPointRecordDO::getUserId)); - return success(MemberPointRecordConvert.INSTANCE.convertPage(pageResult, users)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordPageReqVO.java deleted file mode 100644 index 63cc800063..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 用户积分记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberPointRecordPageReqVO extends PageParam { - - @Schema(description = "用户昵称", example = "张三") - private String nickname; - - @Schema(description = "用户编号", example = "123") - private Long userId; - - @Schema(description = "业务类型", example = "1") - private Integer bizType; - - @Schema(description = "积分标题", example = "呵呵") - private String title; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordRespVO.java deleted file mode 100644 index 6714aa87fa..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordRespVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户积分记录 Response VO") -@Data -public class MemberPointRecordRespVO { - - @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31457") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userId; - - @Schema(description = "昵称", example = "张三") - private String nickname; - - @Schema(description = "业务编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "22706") - private String bizId; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer bizType; - - @Schema(description = "积分标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String title; - - @Schema(description = "积分描述", example = "你猜") - private String description; - - @Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer point; - - @Schema(description = "变动后的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer totalPoint; - - @Schema(description = "发生时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInConfigController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInConfigController.java deleted file mode 100644 index f6776f6f64..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInConfigController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigRespVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import cn.iocoder.yudao.module.member.service.signin.MemberSignInConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -// TODO 芋艿:url -@Tag(name = "管理后台 - 签到规则") -@RestController -@RequestMapping("/member/sign-in/config") -@Validated -public class MemberSignInConfigController { - - @Resource - private MemberSignInConfigService signInConfigService; - - @PostMapping("/create") - @Operation(summary = "创建签到规则") - @PreAuthorize("@ss.hasPermission('point:sign-in-config:create')") - public CommonResult createSignInConfig(@Valid @RequestBody MemberSignInConfigCreateReqVO createReqVO) { - return success(signInConfigService.createSignInConfig(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新签到规则") - @PreAuthorize("@ss.hasPermission('point:sign-in-config:update')") - public CommonResult updateSignInConfig(@Valid @RequestBody MemberSignInConfigUpdateReqVO updateReqVO) { - signInConfigService.updateSignInConfig(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除签到规则") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('point:sign-in-config:delete')") - public CommonResult deleteSignInConfig(@RequestParam("id") Long id) { - signInConfigService.deleteSignInConfig(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得签到规则") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('point:sign-in-config:query')") - public CommonResult getSignInConfig(@RequestParam("id") Long id) { - MemberSignInConfigDO signInConfig = signInConfigService.getSignInConfig(id); - return success(MemberSignInConfigConvert.INSTANCE.convert(signInConfig)); - } - - @GetMapping("/list") - @Operation(summary = "获得签到规则列表") - @PreAuthorize("@ss.hasPermission('point:sign-in-config:query')") - public CommonResult> getSignInConfigList() { - List list = signInConfigService.getSignInConfigList(); - return success(MemberSignInConfigConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java deleted file mode 100644 index 48a83b0a42..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordRespVO; -import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.service.signin.MemberSignInRecordService; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.util.CollectionUtils; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 签到记录") -@RestController -@RequestMapping("/member/sign-in/record") -@Validated -public class MemberSignInRecordController { - - @Resource - private MemberSignInRecordService signInRecordService; - - @Resource - private MemberUserService memberUserService; - - @GetMapping("/page") - @Operation(summary = "获得签到记录分页") - @PreAuthorize("@ss.hasPermission('point:sign-in-record:query')") - public CommonResult> getSignInRecordPage(@Valid MemberSignInRecordPageReqVO pageVO) { - // 执行分页查询 - PageResult pageResult = signInRecordService.getSignInRecordPage(pageVO); - if (CollectionUtils.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接结果返回 - List users = memberUserService.getUserList( - convertSet(pageResult.getList(), MemberSignInRecordDO::getUserId)); - return success(MemberSignInRecordConvert.INSTANCE.convertPage(pageResult, users)); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigBaseVO.java deleted file mode 100644 index 0169ba61e7..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigBaseVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.AssertTrue; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.PositiveOrZero; - -/** - * 签到规则 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberSignInConfigBaseVO { - - @Schema(description = "签到第 x 天", requiredMode = Schema.RequiredMode.REQUIRED, example = "7") - @NotNull(message = "签到天数不能为空") - private Integer day; - - @Schema(description = "奖励积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "奖励积分不能为空") - @PositiveOrZero(message = "奖励积分不能小于 0") - private Integer point; - - @Schema(description = "奖励经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "奖励经验不能为空") - @PositiveOrZero(message = "奖励经验不能小于 0") - private Integer experience; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @AssertTrue(message = "签到奖励积分和经验不能同时为空") - @JsonIgnore - public boolean isConfigAward() { - return ObjUtil.notEqual(point, 0) || ObjUtil.notEqual(experience, 0); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigCreateReqVO.java deleted file mode 100644 index 7ca03fa933..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "管理后台 - 签到规则创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberSignInConfigCreateReqVO extends MemberSignInConfigBaseVO { - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigRespVO.java deleted file mode 100644 index 8d423b25c5..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 签到规则 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberSignInConfigRespVO extends MemberSignInConfigBaseVO { - - @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "20937") - private Integer id; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigUpdateReqVO.java deleted file mode 100644 index 69daba9bd1..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigUpdateReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import jakarta.validation.constraints.*; - -@Schema(description = "管理后台 - 签到规则更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberSignInConfigUpdateReqVO extends MemberSignInConfigBaseVO { - - @Schema(description = "规则自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "13653") - @NotNull(message = "规则自增主键不能为空") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordPageReqVO.java deleted file mode 100644 index b46712b6e9..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordPageReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 签到记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberSignInRecordPageReqVO extends PageParam { - - @Schema(description = "签到用户", example = "土豆") - private String nickname; - - @Schema(description = "第几天签到", example = "10") - private Integer day; - - @Schema(description = "用户编号", example = "123") - private Long userId; - - @Schema(description = "签到时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordRespVO.java deleted file mode 100644 index b5755ba53c..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 签到记录 Response VO") -@Data -public class MemberSignInRecordRespVO { - - @Schema(description = "签到自增 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11903") - private Long id; - - @Schema(description = "签到用户", requiredMode = Schema.RequiredMode.REQUIRED, example = "6507") - private Long userId; - - @Schema(description = "昵称", example = "张三") - private String nickname; - - @Schema(description = "第几天签到", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer day; - - @Schema(description = "签到的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer point; - - @Schema(description = "签到时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/MemberTagController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/MemberTagController.java deleted file mode 100644 index e4772954cf..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/MemberTagController.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.tag; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagRespVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.tag.MemberTagConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import cn.iocoder.yudao.module.member.service.tag.MemberTagService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员标签") -@RestController -@RequestMapping("/member/tag") -@Validated -public class MemberTagController { - - @Resource - private MemberTagService tagService; - - @PostMapping("/create") - @Operation(summary = "创建会员标签") - @PreAuthorize("@ss.hasPermission('member:tag:create')") - public CommonResult createTag(@Valid @RequestBody MemberTagCreateReqVO createReqVO) { - return success(tagService.createTag(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新会员标签") - @PreAuthorize("@ss.hasPermission('member:tag:update')") - public CommonResult updateTag(@Valid @RequestBody MemberTagUpdateReqVO updateReqVO) { - tagService.updateTag(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除会员标签") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('member:tag:delete')") - public CommonResult deleteTag(@RequestParam("id") Long id) { - tagService.deleteTag(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得会员标签") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:tag:query')") - public CommonResult getMemberTag(@RequestParam("id") Long id) { - MemberTagDO tag = tagService.getTag(id); - return success(MemberTagConvert.INSTANCE.convert(tag)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取会员标签精简信息列表", description = "只包含被开启的会员标签,主要用于前端的下拉选项") - public CommonResult> getSimpleTagList() { - // 获用户列表,只要开启状态的 - List list = tagService.getTagList(); - // 排序后,返回给前端 - return success(MemberTagConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/list") - @Operation(summary = "获得会员标签列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('member:tag:query')") - public CommonResult> getMemberTagList(@RequestParam("ids") Collection ids) { - List list = tagService.getTagList(ids); - return success(MemberTagConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得会员标签分页") - @PreAuthorize("@ss.hasPermission('member:tag:query')") - public CommonResult> getTagPage(@Valid MemberTagPageReqVO pageVO) { - PageResult pageResult = tagService.getTagPage(pageVO); - return success(MemberTagConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagBaseVO.java deleted file mode 100644 index 3f2277a30e..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagBaseVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 会员标签 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberTagBaseVO { - - @Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "标签名称不能为空") - private String name; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagCreateReqVO.java deleted file mode 100644 index b61f26bb20..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 会员标签创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberTagCreateReqVO extends MemberTagBaseVO { - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagPageReqVO.java deleted file mode 100644 index 99f59b068a..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.tag.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员标签分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberTagPageReqVO extends PageParam { - - @Schema(description = "标签名称", example = "李四") - private String name; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagRespVO.java deleted file mode 100644 index 2c21f53e3e..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 会员标签 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberTagRespVO extends MemberTagBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "907") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagUpdateReqVO.java deleted file mode 100644 index 58c58c8f1c..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 会员标签更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberTagUpdateReqVO extends MemberTagBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "907") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java deleted file mode 100644 index c9c6c06e03..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java +++ /dev/null @@ -1,121 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.*; -import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import cn.iocoder.yudao.module.member.service.group.MemberGroupService; -import cn.iocoder.yudao.module.member.service.level.MemberLevelService; -import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; -import cn.iocoder.yudao.module.member.service.tag.MemberTagService; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 会员用户") -@RestController -@RequestMapping("/member/user") -@Validated -public class MemberUserController { - - @Resource - private MemberUserService memberUserService; - @Resource - private MemberTagService memberTagService; - @Resource - private MemberLevelService memberLevelService; - @Resource - private MemberGroupService memberGroupService; - @Resource - private MemberPointRecordService memberPointRecordService; - - @PutMapping("/update") - @Operation(summary = "更新会员用户") - @PreAuthorize("@ss.hasPermission('member:user:update')") - public CommonResult updateUser(@Valid @RequestBody MemberUserUpdateReqVO updateReqVO) { - memberUserService.updateUser(updateReqVO); - return success(true); - } - - @PutMapping("/update-level") - @Operation(summary = "更新会员用户等级") - @PreAuthorize("@ss.hasPermission('member:user:update-level')") - public CommonResult updateUserLevel(@Valid @RequestBody MemberUserUpdateLevelReqVO updateReqVO) { - memberLevelService.updateUserLevel(updateReqVO); - return success(true); - } - - @PutMapping("/update-point") - @Operation(summary = "更新会员用户积分") - @PreAuthorize("@ss.hasPermission('member:user:update-point')") - public CommonResult updateUserPoint(@Valid @RequestBody MemberUserUpdatePointReqVO updateReqVO) { - memberPointRecordService.createPointRecord(updateReqVO.getId(), updateReqVO.getPoint(), - MemberPointBizTypeEnum.ADMIN, String.valueOf(getLoginUserId())); - return success(true); - } - - @PutMapping("/update-balance") - @Operation(summary = "更新会员用户余额") - @PreAuthorize("@ss.hasPermission('member:user:update-balance')") - public CommonResult updateUserBalance(@Valid @RequestBody Long id) { - // todo @jason:增加一个【修改余额】 - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得会员用户") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:user:query')") - public CommonResult getUser(@RequestParam("id") Long id) { - MemberUserDO user = memberUserService.getUser(id); - return success(MemberUserConvert.INSTANCE.convert03(user)); - } - - @GetMapping("/page") - @Operation(summary = "获得会员用户分页") - @PreAuthorize("@ss.hasPermission('member:user:query')") - public CommonResult> getUserPage(@Valid MemberUserPageReqVO pageVO) { - PageResult pageResult = memberUserService.getUserPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 处理用户标签返显 - Set tagIds = pageResult.getList().stream() - .map(MemberUserDO::getTagIds) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .collect(Collectors.toSet()); - List tags = memberTagService.getTagList(tagIds); - // 处理用户级别返显 - List levels = memberLevelService.getLevelList( - convertSet(pageResult.getList(), MemberUserDO::getLevelId)); - // 处理用户分组返显 - List groups = memberGroupService.getGroupList( - convertSet(pageResult.getList(), MemberUserDO::getGroupId)); - return success(MemberUserConvert.INSTANCE.convertPage(pageResult, tags, levels, groups)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserBaseVO.java deleted file mode 100644 index db8c809d08..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserBaseVO.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.URL; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -/** - * 会员用户 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberUserBaseVO { - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") - @NotNull(message = "手机号不能为空") - private String mobile; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "状态不能为空") - private Byte status; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "用户昵称不能为空") - private String nickname; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/x.png") - @URL(message = "头像必须是 URL 格式") - private String avatar; - - @Schema(description = "用户昵称", example = "李四") - private String name; - - @Schema(description = "用户性别", example = "1") - private Byte sex; - - @Schema(description = "所在地编号", example = "4371") - private Long areaId; - - @Schema(description = "所在地全程", example = "上海上海市普陀区") - private String areaName; - - @Schema(description = "出生日期", example = "2023-03-12") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) - private LocalDateTime birthday; - - @Schema(description = "会员备注", example = "我是小备注") - private String mark; - - @Schema(description = "会员标签", example = "[1, 2]") - private List tagIds; - - @Schema(description = "会员等级编号", example = "1") - private Long levelId; - - @Schema(description = "用户分组编号", example = "1") - private Long groupId; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserPageReqVO.java deleted file mode 100644 index abb94285e8..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserPageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员用户分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberUserPageReqVO extends PageParam { - - @Schema(description = "手机号", example = "15601691300") - private String mobile; - - @Schema(description = "用户昵称", example = "李四") - private String nickname; - - @Schema(description = "最后登录时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] loginDate; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "会员标签编号列表", example = "[1, 2]") - private List tagIds; - - @Schema(description = "会员等级编号", example = "1") - private Long levelId; - - @Schema(description = "用户分组编号", example = "1") - private Long groupId; - - // TODO 芋艿:注册用户类型; - - // TODO 芋艿:登录用户类型; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserRespVO.java deleted file mode 100644 index 1cd228335e..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserRespVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 会员用户 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberUserRespVO extends MemberUserBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23788") - private Long id; - - @Schema(description = "注册 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - private String registerIp; - - @Schema(description = "最后登录IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - private String loginIp; - - @Schema(description = "最后登录时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime loginDate; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 其它信息 ========== - - @Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer point; - - @Schema(description = "总积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - private Integer totalPoint; - - @Schema(description = "会员标签", example = "[红色, 快乐]") - private List tagNames; - - @Schema(description = "会员等级", example = "黄金会员") - private String levelName; - - @Schema(description = "用户分组", example = "购物达人") - private String groupName; - - @Schema(description = "用户经验值", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer experience; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateLevelReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateLevelReqVO.java deleted file mode 100644 index f69dfa7069..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateLevelReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 用户修改等级 Request VO") -@Data -@ToString(callSuper = true) -public class MemberUserUpdateLevelReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23788") - @NotNull(message = "用户编号不能为空") - private Long id; - - /** - * 取消用户等级时,值为空 - */ - @Schema(description = "用户等级编号", example = "1") - private Long levelId; - - @Schema(description = "修改原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "推广需要") - @NotBlank(message = "修改原因不能为空") - private String reason; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdatePointReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdatePointReqVO.java deleted file mode 100644 index 66ac7f2357..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdatePointReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 用户修改积分 Request VO") -@Data -@ToString(callSuper = true) -public class MemberUserUpdatePointReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23788") - @NotNull(message = "用户编号不能为空") - private Long id; - - @Schema(description = "变动积分,正数为增加,负数为减少", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "变动积分不能为空") - private Integer point; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateReqVO.java deleted file mode 100644 index f956a1977d..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 会员用户更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberUserUpdateReqVO extends MemberUserBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23788") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/AppAddressController.http b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/AppAddressController.http deleted file mode 100644 index 6bae7c7ebe..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/AppAddressController.http +++ /dev/null @@ -1,54 +0,0 @@ -### 请求 /create 接口 => 成功 -POST {{appApi}}//member/address/create -Content-Type: application/json -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -{ - "name": "yunai", - "mobile": "15601691300", - "areaId": "610632", - "postCode": "200000", - "detailAddress": "芋道源码 233 号 666 室", - "defaulted": true -} - -### 请求 /update 接口 => 成功 -PUT {{appApi}}//member/address/update -Content-Type: application/json -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -{ - "id": "1", - "name": "yunai888", - "mobile": "15601691300", - "areaId": "610632", - "postCode": "200000", - "detailAddress": "芋道源码 233 号 666 室", - "defaulted": false -} - -### 请求 /delete 接口 => 成功 -DELETE {{appApi}}//member/address/delete?id=2 -Content-Type: application/json -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /get 接口 => 成功 -GET {{appApi}}//member/address/get?id=1 -Content-Type: application/json -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /get-default 接口 => 成功 -GET {{appApi}}//member/address/get-default -Content-Type: application/json -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /list 接口 => 成功 -GET {{appApi}}//member/address/list -Content-Type: application/json -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/AppAddressController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/AppAddressController.java deleted file mode 100644 index 73c9dbf5ea..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/AppAddressController.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.address; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressRespVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.address.AddressConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; -import cn.iocoder.yudao.module.member.service.address.AddressService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 用户收件地址") -@RestController -@RequestMapping("/member/address") -@Validated -public class AppAddressController { - - @Resource - private AddressService addressService; - - @PostMapping("/create") - @Operation(summary = "创建用户收件地址") - @PreAuthenticated - public CommonResult createAddress(@Valid @RequestBody AppAddressCreateReqVO createReqVO) { - return success(addressService.createAddress(getLoginUserId(), createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新用户收件地址") - @PreAuthenticated - public CommonResult updateAddress(@Valid @RequestBody AppAddressUpdateReqVO updateReqVO) { - addressService.updateAddress(getLoginUserId(), updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除用户收件地址") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthenticated - public CommonResult deleteAddress(@RequestParam("id") Long id) { - addressService.deleteAddress(getLoginUserId(), id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得用户收件地址") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthenticated - public CommonResult getAddress(@RequestParam("id") Long id) { - MemberAddressDO address = addressService.getAddress(getLoginUserId(), id); - return success(AddressConvert.INSTANCE.convert(address)); - } - - @GetMapping("/get-default") - @Operation(summary = "获得默认的用户收件地址") - @PreAuthenticated - public CommonResult getDefaultUserAddress() { - MemberAddressDO address = addressService.getDefaultUserAddress(getLoginUserId()); - return success(AddressConvert.INSTANCE.convert(address)); - } - - @GetMapping("/list") - @Operation(summary = "获得用户收件地址列表") - @PreAuthenticated - public CommonResult> getAddressList() { - List list = addressService.getAddressList(getLoginUserId()); - return success(AddressConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressBaseVO.java deleted file mode 100644 index b3f87442f7..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressBaseVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.address.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -// TODO 芋艿:example 缺失 -/** -* 用户收件地址 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class AppAddressBaseVO { - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "收件人名称不能为空") - private String name; - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "手机号不能为空") - private String mobile; - - @Schema(description = "地区编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "地区编号不能为空") - private Long areaId; - - @Schema(description = "收件详细地址", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "收件详细地址不能为空") - private String detailAddress; - - @Schema(description = "是否默认地址", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "是否默认地址不能为空") - private Boolean defaultStatus; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressCreateReqVO.java deleted file mode 100644 index c92687f27b..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressCreateReqVO.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.address.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -@Schema(description = "用户 APP - 用户收件地址创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppAddressCreateReqVO extends AppAddressBaseVO { - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressRespVO.java deleted file mode 100644 index d3e2f9ffd5..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.address.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 APP - 用户收件地址 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppAddressRespVO extends AppAddressBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海上海市普陀区") - private String areaName; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressUpdateReqVO.java deleted file mode 100644 index 30b2febe16..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressUpdateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.address.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import jakarta.validation.constraints.*; - -@Schema(description = "用户 APP - 用户收件地址更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppAddressUpdateReqVO extends AppAddressBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.http b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.http deleted file mode 100644 index 5b68d69845..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.http +++ /dev/null @@ -1,67 +0,0 @@ -### 请求 /login 接口 => 成功 -POST {{appApi}}/member/auth/login -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "mobile": "15601691388", - "password": "admin123" -} - -### 请求 /send-sms-code 接口 => 成功 -POST {{appApi}}/member/auth/send-sms-code -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "mobile": "15601691388", - "scene": 1 -} - -### 请求 /sms-login 接口 => 成功 -POST {{appApi}}/member/auth/sms-login -Content-Type: application/json -tenant-id: {{appTenentId}} -terminal: 30 - -{ - "mobile": "15601691388", - "code": 9999 -} - -### 请求 /social-login 接口 => 成功 -POST {{appApi}}/member/auth/social-login -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "type": 34, - "code": "0e1oc9000CTjFQ1oim200bhtb61oc90g", - "state": "default" -} - -### 请求 /weixin-mini-app-login 接口 => 成功 -POST {{appApi}}/member/auth/weixin-mini-app-login -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "phoneCode": "618e6412e0c728f5b8fc7164497463d0158a923c9e7fd86af8bba393b9decbc5", - "loginCode": "001frTkl21JUf94VGxol2hSlff1frTkR" -} - -### 请求 /logout 接口 => 成功 -POST {{appApi}}/member/auth/logout -Content-Type: application/json -Authorization: Bearer c1b76bdaf2c146c581caa4d7fd81ee66 -tenant-id: {{appTenentId}} - -### 请求 /auth/refresh-token 接口 => 成功 -POST {{appApi}}/member/auth/refresh-token?refreshToken=bc43d929094849a28b3a69f6e6940d70 -Content-Type: application/json -tenant-id: {{appTenentId}} - -### 请求 /auth/create-weixin-jsapi-signature 接口 => 成功 -POST {{appApi}}/member/auth/create-weixin-jsapi-signature?url=http://www.iocoder.cn -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.java deleted file mode 100644 index 503ff13bd8..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.java +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.framework.security.config.SecurityProperties; -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import cn.iocoder.yudao.module.member.controller.app.auth.vo.*; -import cn.iocoder.yudao.module.member.convert.auth.AuthConvert; -import cn.iocoder.yudao.module.member.service.auth.MemberAuthService; -import cn.iocoder.yudao.module.system.api.social.SocialClientApi; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.annotation.security.PermitAll; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 认证") -@RestController -@RequestMapping("/member/auth") -@Validated -@Slf4j -public class AppAuthController { - - @Resource - private MemberAuthService authService; - - @Resource - private SocialClientApi socialClientApi; - - @Resource - private SecurityProperties securityProperties; - - @PostMapping("/login") - @Operation(summary = "使用手机 + 密码登录") - public CommonResult login(@RequestBody @Valid AppAuthLoginReqVO reqVO) { - return success(authService.login(reqVO)); - } - - @PostMapping("/logout") - @PermitAll - @Operation(summary = "登出系统") - public CommonResult logout(HttpServletRequest request) { - String token = SecurityFrameworkUtils.obtainAuthorization(request, - securityProperties.getTokenHeader(), securityProperties.getTokenParameter()); - if (StrUtil.isNotBlank(token)) { - authService.logout(token); - } - return success(true); - } - - @PostMapping("/refresh-token") - @Operation(summary = "刷新令牌") - @Parameter(name = "refreshToken", description = "刷新令牌", required = true) - @OperateLog(enable = false) // 避免 Post 请求被记录操作日志 - public CommonResult refreshToken(@RequestParam("refreshToken") String refreshToken) { - return success(authService.refreshToken(refreshToken)); - } - - // ========== 短信登录相关 ========== - - @PostMapping("/sms-login") - @Operation(summary = "使用手机 + 验证码登录") - public CommonResult smsLogin(@RequestBody @Valid AppAuthSmsLoginReqVO reqVO, - @RequestHeader Integer terminal) { - return success(authService.smsLogin(reqVO, terminal)); - } - - @PostMapping("/send-sms-code") - @Operation(summary = "发送手机验证码") - public CommonResult sendSmsCode(@RequestBody @Valid AppAuthSmsSendReqVO reqVO) { - authService.sendSmsCode(getLoginUserId(), reqVO); - return success(true); - } - - @PostMapping("/validate-sms-code") - @Operation(summary = "校验手机验证码") - public CommonResult validateSmsCode(@RequestBody @Valid AppAuthSmsValidateReqVO reqVO) { - authService.validateSmsCode(getLoginUserId(), reqVO); - return success(true); - } - - // ========== 社交登录相关 ========== - - @GetMapping("/social-auth-redirect") - @Operation(summary = "社交授权的跳转") - @Parameters({ - @Parameter(name = "type", description = "社交类型", required = true), - @Parameter(name = "redirectUri", description = "回调路径") - }) - public CommonResult socialAuthRedirect(@RequestParam("type") Integer type, - @RequestParam("redirectUri") String redirectUri) { - return CommonResult.success(authService.getSocialAuthorizeUrl(type, redirectUri)); - } - - @PostMapping("/social-login") - @Operation(summary = "社交快捷登录,使用 code 授权码", description = "适合未登录的用户,但是社交账号已绑定用户") - public CommonResult socialLogin(@RequestBody @Valid AppAuthSocialLoginReqVO reqVO) { - return success(authService.socialLogin(reqVO)); - } - - @PostMapping("/weixin-mini-app-login") - @Operation(summary = "微信小程序的一键登录") - public CommonResult weixinMiniAppLogin(@RequestBody @Valid AppAuthWeixinMiniAppLoginReqVO reqVO) { - return success(authService.weixinMiniAppLogin(reqVO)); - } - - @PostMapping("/create-weixin-jsapi-signature") - @Operation(summary = "创建微信 JS SDK 初始化所需的签名", - description = "参考 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html 文档") - public CommonResult createWeixinMpJsapiSignature(@RequestParam("url") String url) { - SocialWxJsapiSignatureRespDTO signature = socialClientApi.createWxMpJsapiSignature( - UserTypeEnum.MEMBER.getValue(), url); - return success(AuthConvert.INSTANCE.convert(signature)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthCheckCodeReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthCheckCodeReqVO.java deleted file mode 100644 index e32968e1bd..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthCheckCodeReqVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Pattern; - -// TODO 芋艿:code review 相关逻辑 -@Schema(description = "用户 APP - 校验验证码 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppAuthCheckCodeReqVO { - - @Schema(description = "手机号", example = "15601691234") - @NotBlank(message = "手机号不能为空") - @Mobile - private String mobile; - - @Schema(description = "手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotBlank(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - - @Schema(description = "发送场景,对应 SmsSceneEnum 枚举", example = "1") - @NotNull(message = "发送场景不能为空") - @InEnum(SmsSceneEnum.class) - private Integer scene; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthLoginReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthLoginReqVO.java deleted file mode 100644 index 463f3bb218..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthLoginReqVO.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import jakarta.validation.constraints.AssertTrue; -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "用户 APP - 手机 + 密码登录 Request VO,如果登录并绑定社交用户,需要传递 social 开头的参数") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppAuthLoginReqVO { - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") - @NotEmpty(message = "手机号不能为空") - @Mobile - private String mobile; - - @Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao") - @NotEmpty(message = "密码不能为空") - @Length(min = 4, max = 16, message = "密码长度为 4-16 位") - private String password; - - // ========== 绑定社交登录时,需要传递如下参数 ========== - - @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @InEnum(SocialTypeEnum.class) - private Integer socialType; - - @Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String socialCode; - - @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") - private String socialState; - - @AssertTrue(message = "授权码不能为空") - public boolean isSocialCodeValid() { - return socialType == null || StrUtil.isNotEmpty(socialCode); - } - - @AssertTrue(message = "授权 state 不能为空") - public boolean isSocialState() { - return socialType == null || StrUtil.isNotEmpty(socialState); - } - -} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthLoginRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthLoginRespVO.java deleted file mode 100644 index 072ec9e4b8..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthLoginRespVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.time.LocalDateTime; - -@Schema(description = "用户 APP - 登录 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppAuthLoginRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userId; - - @Schema(description = "访问令牌", requiredMode = Schema.RequiredMode.REQUIRED, example = "happy") - private String accessToken; - - @Schema(description = "刷新令牌", requiredMode = Schema.RequiredMode.REQUIRED, example = "nice") - private String refreshToken; - - @Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime expiresTime; - - /** - * 仅社交登录、社交绑定时会返回 - * - * 为什么需要返回?微信公众号、微信小程序支付需要传递 openid 给支付接口 - */ - @Schema(description = "社交用户 openid", example = "qq768") - private String openid; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java deleted file mode 100644 index c4948c4c1b..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import jakarta.validation.constraints.AssertTrue; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.Pattern; - -@Schema(description = "用户 APP - 手机 + 验证码登录 Request VO,如果登录并绑定社交用户,需要传递 social 开头的参数") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppAuthSmsLoginReqVO { - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") - @NotEmpty(message = "手机号不能为空") - @Mobile - private String mobile; - - @Schema(description = "手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - - // ========== 绑定社交登录时,需要传递如下参数 ========== - - @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @InEnum(SocialTypeEnum.class) - private Integer socialType; - - @Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String socialCode; - - @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") - private String socialState; - - @AssertTrue(message = "授权码不能为空") - public boolean isSocialCodeValid() { - return socialType == null || StrUtil.isNotEmpty(socialCode); - } - - @AssertTrue(message = "授权 state 不能为空") - public boolean isSocialState() { - return socialType == null || StrUtil.isNotEmpty(socialState); - } - -} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsSendReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsSendReqVO.java deleted file mode 100644 index 318a189b07..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsSendReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 APP - 发送手机验证码 Request VO") -@Data -@Accessors(chain = true) -public class AppAuthSmsSendReqVO { - - @Schema(description = "手机号", example = "15601691234") - @Mobile - private String mobile; - - @Schema(description = "发送场景,对应 SmsSceneEnum 枚举", example = "1") - @NotNull(message = "发送场景不能为空") - @InEnum(SmsSceneEnum.class) - private Integer scene; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsValidateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsValidateReqVO.java deleted file mode 100644 index bf9a6831ba..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsValidateReqVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; -import org.hibernate.validator.constraints.Length; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Pattern; - -@Schema(description = "用户 APP - 校验手机验证码 Request VO") -@Data -@Accessors(chain = true) -public class AppAuthSmsValidateReqVO { - - @Schema(description = "手机号", example = "15601691234") - @Mobile - private String mobile; - - @Schema(description = "发送场景,对应 SmsSceneEnum 枚举", example = "1") - @NotNull(message = "发送场景不能为空") - @InEnum(SmsSceneEnum.class) - private Integer scene; - - @Schema(description = "手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSocialLoginReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSocialLoginReqVO.java deleted file mode 100644 index 8fd06e4bc2..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSocialLoginReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 APP - 社交快捷登录 Request VO,使用 code 授权码") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppAuthSocialLoginReqVO { - - @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @InEnum(SocialTypeEnum.class) - @NotNull(message = "社交平台的类型不能为空") - private Integer type; - - @Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "授权码不能为空") - private String code; - - @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") - @NotEmpty(message = "state 不能为空") - private String state; - -} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthWeixinMiniAppLoginReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthWeixinMiniAppLoginReqVO.java deleted file mode 100644 index fa8724cd05..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthWeixinMiniAppLoginReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "用户 APP - 微信小程序手机登录 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppAuthWeixinMiniAppLoginReqVO { - - @Schema(description = "手机 code,小程序通过 wx.getPhoneNumber 方法获得", requiredMode = Schema.RequiredMode.REQUIRED, example = "hello") - @NotEmpty(message = "手机 code 不能为空") - private String phoneCode; - - @Schema(description = "登录 code,小程序通过 wx.login 方法获得", requiredMode = Schema.RequiredMode.REQUIRED, example = "word") - @NotEmpty(message = "登录 code 不能为空") - private String loginCode; - - @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") - @NotEmpty(message = "state 不能为空") - private String state; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AuthWeixinJsapiSignatureRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AuthWeixinJsapiSignatureRespVO.java deleted file mode 100644 index 37e63652b9..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AuthWeixinJsapiSignatureRespVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "用户 APP - 微信公众号 JSAPI 签名 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AuthWeixinJsapiSignatureRespVO { - - @Schema(description = "微信公众号的 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "hello") - private String appId; - - @Schema(description = "匿名串", requiredMode = Schema.RequiredMode.REQUIRED, example = "world") - private String nonceStr; - - @Schema(description = "时间戳", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long timestamp; - - @Schema(description = "URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") - private String url; - - @Schema(description = "签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "阿巴阿巴") - private String signature; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/AppMemberExperienceRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/AppMemberExperienceRecordController.java deleted file mode 100644 index a0eac0c7d1..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/AppMemberExperienceRecordController.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.level; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.level.vo.experience.AppMemberExperienceRecordRespVO; -import cn.iocoder.yudao.module.member.convert.level.MemberExperienceRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; -import cn.iocoder.yudao.module.member.service.level.MemberExperienceRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 会员经验记录") -@RestController -@RequestMapping("/member/experience-record") -@Validated -public class AppMemberExperienceRecordController { - - @Resource - private MemberExperienceRecordService experienceLogService; - - @GetMapping("/page") - @Operation(summary = "获得会员经验记录分页") - @PreAuthenticated - public CommonResult> getExperienceRecordPage( - @Valid PageParam pageParam) { - PageResult pageResult = experienceLogService.getExperienceRecordPage( - getLoginUserId(), pageParam); - return success(MemberExperienceRecordConvert.INSTANCE.convertPage02(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/AppMemberLevelController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/AppMemberLevelController.java deleted file mode 100644 index d31f579773..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/AppMemberLevelController.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.level; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.controller.app.level.vo.level.AppMemberLevelRespVO; -import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.service.level.MemberLevelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 会员等级") -@RestController -@RequestMapping("/member/level") -@Validated -public class AppMemberLevelController { - - @Resource - private MemberLevelService levelService; - - @GetMapping("/list") - @Operation(summary = "获得会员等级列表") - public CommonResult> getLevelList() { - List result = levelService.getEnableLevelList(); - return success(MemberLevelConvert.INSTANCE.convertList02(result)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/vo/experience/AppMemberExperienceRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/vo/experience/AppMemberExperienceRecordRespVO.java deleted file mode 100644 index e2d7bb0c35..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/vo/experience/AppMemberExperienceRecordRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.level.vo.experience; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 会员经验记录 Response VO") -@Data -public class AppMemberExperienceRecordRespVO { - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "增加经验") - private String title; - - @Schema(description = "经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer experience; - - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "下单增加 100 经验") - private String description; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/vo/level/AppMemberLevelRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/vo/level/AppMemberLevelRespVO.java deleted file mode 100644 index fdade172f9..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/vo/level/AppMemberLevelRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.level.vo.level; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 会员等级 Response VO") -@Data -public class AppMemberLevelRespVO { - - @Schema(description = "等级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String name; - - @Schema(description = "等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer level; - - @Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer experience; - - @Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "98") - private Integer discountPercent; - - @Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg") - private String icon; - - @Schema(description = "等级背景图", example = "https://www.iocoder.cn/yudao.jpg") - private String backgroundUrl; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/AppMemberPointRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/AppMemberPointRecordController.java deleted file mode 100644 index d57d195c06..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/AppMemberPointRecordController.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.point; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.point.vo.AppMemberPointRecordRespVO; -import cn.iocoder.yudao.module.member.convert.point.MemberPointRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; -import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 签到记录") -@RestController -@RequestMapping("/member/point/record") -@Validated -public class AppMemberPointRecordController { - - @Resource - private MemberPointRecordService pointRecordService; - - @GetMapping("/page") - @Operation(summary = "获得用户积分记录分页") - @PreAuthenticated - public CommonResult> getPointRecordPage(@Valid PageParam pageVO) { - PageResult pageResult = pointRecordService.getPointRecordPage(getLoginUserId(), pageVO); - return success(MemberPointRecordConvert.INSTANCE.convertPage02(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordRespVO.java deleted file mode 100644 index ec95b2e025..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.point.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 用户积分记录 Response VO") -@Data -public class AppMemberPointRecordRespVO { - - @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31457") - private Long id;; - - @Schema(description = "积分标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String title; - - @Schema(description = "积分描述", example = "你猜") - private String description; - - @Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer point; - - @Schema(description = "发生时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInConfigController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInConfigController.java deleted file mode 100644 index c55bf5197d..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInConfigController.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.signin; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.config.AppMemberSignInConfigRespVO; -import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import cn.iocoder.yudao.module.member.service.signin.MemberSignInConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 签到规则") -@RestController -@RequestMapping("/member/sign-in/config") -@Validated -public class AppMemberSignInConfigController { - - @Resource - private MemberSignInConfigService signInConfigService; - - @GetMapping("/list") - @Operation(summary = "获得签到规则列表") - public CommonResult> getSignInConfigList() { - List pageResult = signInConfigService.getSignInConfigList(CommonStatusEnum.ENABLE.getStatus()); - return success(MemberSignInConfigConvert.INSTANCE.convertList02(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInRecordController.java deleted file mode 100644 index bb7292611b..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInRecordController.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.signin; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.record.AppMemberSignInRecordRespVO; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.record.AppMemberSignInRecordSummaryRespVO; -import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; -import cn.iocoder.yudao.module.member.service.signin.MemberSignInRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 签到记录") -@RestController -@RequestMapping("/member/sign-in/record") -@Validated -public class AppMemberSignInRecordController { - - @Resource - private MemberSignInRecordService signInRecordService; - - @GetMapping("/get-summary") - @Operation(summary = "获得个人签到统计") - @PreAuthenticated - public CommonResult getSignInRecordSummary() { - return success(signInRecordService.getSignInRecordSummary(getLoginUserId())); - } - - @PostMapping("/create") - @Operation(summary = "签到") - @PreAuthenticated - public CommonResult createSignInRecord() { - MemberSignInRecordDO recordDO = signInRecordService.createSignRecord(getLoginUserId()); - return success(MemberSignInRecordConvert.INSTANCE.coverRecordToAppRecordVo(recordDO)); - } - - @GetMapping("/page") - @Operation(summary = "获得签到记录分页") - @PreAuthenticated - public CommonResult> getSignRecordPage(PageParam pageParam) { - PageResult pageResult = signInRecordService.getSignRecordPage(getLoginUserId(), pageParam); - return success(MemberSignInRecordConvert.INSTANCE.convertPage02(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/config/AppMemberSignInConfigRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/config/AppMemberSignInConfigRespVO.java deleted file mode 100644 index a18d3a28e0..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/config/AppMemberSignInConfigRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.signin.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 签到规则 Response VO") -@Data -public class AppMemberSignInConfigRespVO { - - @Schema(description = "签到第 x 天", requiredMode = Schema.RequiredMode.REQUIRED, example = "7") - private Integer day; - - @Schema(description = "奖励积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer point; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/record/AppMemberSignInRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/record/AppMemberSignInRecordRespVO.java deleted file mode 100644 index 2d910d0c6f..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/record/AppMemberSignInRecordRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.signin.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 签到记录 Response VO") -@Data -public class AppMemberSignInRecordRespVO { - - @Schema(description = "第几天签到", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer day; - - @Schema(description = "签到的分数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer point; - - @Schema(description = "签到的经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer experience; - - @Schema(description = "签到时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/record/AppMemberSignInRecordSummaryRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/record/AppMemberSignInRecordSummaryRespVO.java deleted file mode 100644 index 30fb66a153..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/record/AppMemberSignInRecordSummaryRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.signin.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 个人签到统计 Response VO") -@Data -public class AppMemberSignInRecordSummaryRespVO { - - @Schema(description = "总签到天数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer totalDay; - - @Schema(description = "连续签到第 x 天", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") - private Integer continuousDay; - - @Schema(description = "今天是否已签到", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean todaySignIn; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java deleted file mode 100644 index 00a27610b2..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.social; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserBindReqVO; -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserUnbindReqVO; -import cn.iocoder.yudao.module.member.convert.social.SocialUserConvert; -import cn.iocoder.yudao.module.system.api.social.SocialUserApi; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 社交用户") -@RestController -@RequestMapping("/system/social-user") -@Validated -public class AppSocialUserController { - - @Resource - private SocialUserApi socialUserApi; - - @PostMapping("/bind") - @Operation(summary = "社交绑定,使用 code 授权码") - public CommonResult socialBind(@RequestBody @Valid AppSocialUserBindReqVO reqVO) { - socialUserApi.bindSocialUser(SocialUserConvert.INSTANCE.convert(getLoginUserId(), UserTypeEnum.MEMBER.getValue(), reqVO)); - return CommonResult.success(true); - } - - @DeleteMapping("/unbind") - @Operation(summary = "取消社交绑定") - @PreAuthenticated - public CommonResult socialUnbind(@RequestBody AppSocialUserUnbindReqVO reqVO) { - socialUserApi.unbindSocialUser(SocialUserConvert.INSTANCE.convert(getLoginUserId(), UserTypeEnum.MEMBER.getValue(), reqVO)); - return CommonResult.success(true); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserBindReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserBindReqVO.java deleted file mode 100644 index 3c0080c21a..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserBindReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.social.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 APP - 社交绑定 Request VO,使用 code 授权码") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppSocialUserBindReqVO { - - @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @InEnum(SocialTypeEnum.class) - @NotNull(message = "社交平台的类型不能为空") - private Integer type; - - @Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "授权码不能为空") - private String code; - - @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") - @NotEmpty(message = "state 不能为空") - private String state; - -} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserUnbindReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserUnbindReqVO.java deleted file mode 100644 index 43bf067b45..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserUnbindReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.social.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "用户 APP - 取消社交绑定 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppSocialUserUnbindReqVO { - - @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @InEnum(SocialTypeEnum.class) - @NotNull(message = "社交平台的类型不能为空") - private Integer type; - - @Schema(description = "社交用户的 openid", requiredMode = Schema.RequiredMode.REQUIRED, example = "IPRmJ0wvBptiPIlGEZiPewGwiEiE") - @NotEmpty(message = "社交用户的 openid 不能为空") - private String openid; - -} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.http b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.http deleted file mode 100644 index 745556f75a..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.http +++ /dev/null @@ -1,4 +0,0 @@ -### 请求 /member/user/profile/get 接口 => 没有权限 -GET {{appApi}}/member/user/get -Authorization: Bearer test245 -tenant-id: {{appTenentId}} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.java deleted file mode 100644 index c4e53fef18..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.user.vo.*; -import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.service.level.MemberLevelService; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 用户个人中心") -@RestController -@RequestMapping("/member/user") -@Validated -@Slf4j -public class AppMemberUserController { - - @Resource - private MemberUserService userService; - @Resource - private MemberLevelService levelService; - - @GetMapping("/get") - @Operation(summary = "获得基本信息") - @PreAuthenticated - public CommonResult getUserInfo() { - MemberUserDO user = userService.getUser(getLoginUserId()); - MemberLevelDO level = levelService.getLevel(user.getLevelId()); - return success(MemberUserConvert.INSTANCE.convert(user, level)); - } - - @PutMapping("/update") - @Operation(summary = "修改基本信息") - @PreAuthenticated - public CommonResult updateUser(@RequestBody @Valid AppMemberUserUpdateReqVO reqVO) { - userService.updateUser(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/update-mobile") - @Operation(summary = "修改用户手机") - @PreAuthenticated - public CommonResult updateUserMobile(@RequestBody @Valid AppMemberUserUpdateMobileReqVO reqVO) { - userService.updateUserMobile(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/update-password") - @Operation(summary = "修改用户密码", description = "用户修改密码时使用") - @PreAuthenticated - public CommonResult updatePassword(@RequestBody @Valid AppMemberUserUpdatePasswordReqVO reqVO) { - userService.updateUserPassword(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/reset-password") - @Operation(summary = "重置密码", description = "用户忘记密码时使用") - public CommonResult resetPassword(@RequestBody @Valid AppMemberUserResetPasswordReqVO reqVO) { - userService.resetUserPassword(reqVO); - return success(true); - } - -} - diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserInfoRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserInfoRespVO.java deleted file mode 100644 index 25cceedc27..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserInfoRespVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "用户 APP - 用户个人信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class AppMemberUserInfoRespVO { - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.png") - private String avatar; - - @Schema(description = "用户手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") - private String mobile; - - @Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer point; - - @Schema(description = "经验值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer experience; - - @Schema(description = "用户等级") - private Level level; - - @Schema(description = "是否成为推广员", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean brokerageEnabled; - - @Schema(description = "用户 App - 会员等级") - @Data - public static class Level { - - @Schema(description = "等级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "等级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String name; - - @Schema(description = "等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer level; - - @Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg") - private String icon; - - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserResetPasswordReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserResetPasswordReqVO.java deleted file mode 100644 index 043c881fd1..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserResetPasswordReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user.vo; - -import cn.iocoder.yudao.framework.common.validation.Mobile; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.Pattern; - -@Schema(description = "用户 APP - 重置密码 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppMemberUserResetPasswordReqVO { - - @Schema(description = "新密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao") - @NotEmpty(message = "新密码不能为空") - @Length(min = 4, max = 16, message = "密码长度为 4-16 位") - private String password; - - @Schema(description = "手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - - @Schema(description = "手机号",requiredMode = Schema.RequiredMode.REQUIRED,example = "15878962356") - @NotBlank(message = "手机号不能为空") - @Mobile - private String mobile; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateMobileReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateMobileReqVO.java deleted file mode 100644 index 06d27cbfd8..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateMobileReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user.vo; - -import cn.iocoder.yudao.framework.common.validation.Mobile; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.Pattern; - -@Schema(description = "用户 APP - 修改手机 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppMemberUserUpdateMobileReqVO { - - @Schema(description = "手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - - @Schema(description = "手机号",requiredMode = Schema.RequiredMode.REQUIRED,example = "15823654487") - @NotBlank(message = "手机号不能为空") - @Length(min = 8, max = 11, message = "手机号码长度为 8-11 位") - @Mobile - private String mobile; - - @Schema(description = "原手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "原手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String oldCode; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdatePasswordReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdatePasswordReqVO.java deleted file mode 100644 index 5319d727ea..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdatePasswordReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.Pattern; - -@Schema(description = "用户 APP - 修改密码 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppMemberUserUpdatePasswordReqVO { - - @Schema(description = "新密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao") - @NotEmpty(message = "新密码不能为空") - @Length(min = 4, max = 16, message = "密码长度为 4-16 位") - private String password; - - @Schema(description = "手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateReqVO.java deleted file mode 100644 index a676f62564..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.URL; - -@Schema(description = "用户 App - 会员用户更新 Request VO") -@Data -public class AppMemberUserUpdateReqVO { - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String nickname; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/x.png") - @URL(message = "头像必须是 URL 格式") - private String avatar; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/package-info.java deleted file mode 100644 index 9e2888c69c..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.member.controller; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java deleted file mode 100644 index 39dc9fa987..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.address; - -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressRespVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressRespVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 用户收件地址 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface AddressConvert { - - AddressConvert INSTANCE = Mappers.getMapper(AddressConvert.class); - - MemberAddressDO convert(AppAddressCreateReqVO bean); - - MemberAddressDO convert(AppAddressUpdateReqVO bean); - - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") - AppAddressRespVO convert(MemberAddressDO bean); - - List convertList(List list); - - MemberAddressRespDTO convert02(MemberAddressDO bean); - - @Named("convertAreaIdToAreaName") - default String convertAreaIdToAreaName(Integer areaId) { - return AreaUtils.format(areaId); - } - - List convertList2(List list); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/auth/AuthConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/auth/AuthConvert.java deleted file mode 100644 index 29e8f4fdce..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/auth/AuthConvert.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.auth; - -import cn.iocoder.yudao.module.member.controller.app.auth.vo.*; -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserUnbindReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserResetPasswordReqVO; -import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeSendReqDTO; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeValidateReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserUnbindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface AuthConvert { - - AuthConvert INSTANCE = Mappers.getMapper(AuthConvert.class); - - SocialUserBindReqDTO convert(Long userId, Integer userType, AppAuthSocialLoginReqVO reqVO); - SocialUserUnbindReqDTO convert(Long userId, Integer userType, AppSocialUserUnbindReqVO reqVO); - - SmsCodeSendReqDTO convert(AppAuthSmsSendReqVO reqVO); - SmsCodeUseReqDTO convert(AppMemberUserResetPasswordReqVO reqVO, SmsSceneEnum scene, String usedIp); - SmsCodeUseReqDTO convert(AppAuthSmsLoginReqVO reqVO, Integer scene, String usedIp); - - AppAuthLoginRespVO convert(OAuth2AccessTokenRespDTO bean, String openid); - - SmsCodeValidateReqDTO convert(AppAuthSmsValidateReqVO bean); - - SocialWxJsapiSignatureRespDTO convert(SocialWxJsapiSignatureRespDTO bean); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/config/MemberConfigConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/config/MemberConfigConvert.java deleted file mode 100644 index 9847645f9a..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/config/MemberConfigConvert.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.config; - -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigRespVO; -import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigSaveReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.config.MemberConfigDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 会员配置 Convert - * - * @author QingX - */ -@Mapper -public interface MemberConfigConvert { - - MemberConfigConvert INSTANCE = Mappers.getMapper(MemberConfigConvert.class); - - MemberConfigRespVO convert(MemberConfigDO bean); - - MemberConfigDO convert(MemberConfigSaveReqVO bean); - - MemberConfigRespDTO convert01(MemberConfigDO config); -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/group/MemberGroupConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/group/MemberGroupConvert.java deleted file mode 100644 index 06f49d60c6..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/group/MemberGroupConvert.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.group; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupRespVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupSimpleRespVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 用户分组 Convert - * - * @author owen - */ -@Mapper -public interface MemberGroupConvert { - - MemberGroupConvert INSTANCE = Mappers.getMapper(MemberGroupConvert.class); - - MemberGroupDO convert(MemberGroupCreateReqVO bean); - - MemberGroupDO convert(MemberGroupUpdateReqVO bean); - - MemberGroupRespVO convert(MemberGroupDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertSimpleList(List list); -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberExperienceRecordConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberExperienceRecordConvert.java deleted file mode 100644 index 93f864f08a..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberExperienceRecordConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.level; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordRespVO; -import cn.iocoder.yudao.module.member.controller.app.level.vo.experience.AppMemberExperienceRecordRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 会员经验记录 Convert - * - * @author owen - */ -@Mapper -public interface MemberExperienceRecordConvert { - - MemberExperienceRecordConvert INSTANCE = Mappers.getMapper(MemberExperienceRecordConvert.class); - - MemberExperienceRecordRespVO convert(MemberExperienceRecordDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - MemberExperienceRecordDO convert(Long userId, Integer experience, Integer totalExperience, - String bizId, Integer bizType, - String title, String description); - - PageResult convertPage02(PageResult page); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelConvert.java deleted file mode 100644 index f2282815ee..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelConvert.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.level; - -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelRespVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelSimpleRespVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.app.level.vo.level.AppMemberLevelRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 会员等级 Convert - * - * @author owen - */ -@Mapper -public interface MemberLevelConvert { - - MemberLevelConvert INSTANCE = Mappers.getMapper(MemberLevelConvert.class); - - MemberLevelDO convert(MemberLevelCreateReqVO bean); - - MemberLevelDO convert(MemberLevelUpdateReqVO bean); - - MemberLevelRespVO convert(MemberLevelDO bean); - - List convertList(List list); - - List convertSimpleList(List list); - - List convertList02(List list); - - MemberLevelRespDTO convert02(MemberLevelDO bean); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelRecordConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelRecordConvert.java deleted file mode 100644 index d01f1b63c4..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelRecordConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.level; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.record.MemberLevelRecordRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 会员等级记录 Convert - * - * @author owen - */ -@Mapper -public interface MemberLevelRecordConvert { - - MemberLevelRecordConvert INSTANCE = Mappers.getMapper(MemberLevelRecordConvert.class); - - MemberLevelRecordRespVO convert(MemberLevelRecordDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default MemberLevelRecordDO copyTo(MemberLevelDO from, MemberLevelRecordDO to) { - if (from != null) { - to.setLevelId(from.getId()); - to.setLevel(from.getLevel()); - to.setDiscountPercent(from.getDiscountPercent()); - to.setExperience(from.getExperience()); - } - return to; - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/package-info.java deleted file mode 100644 index 6523a66567..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.member.convert; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointRecordConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointRecordConvert.java deleted file mode 100644 index 018670c513..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointRecordConvert.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.point; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordRespVO; -import cn.iocoder.yudao.module.member.controller.app.point.vo.AppMemberPointRecordRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 用户积分记录 Convert - * - * @author QingX - */ -@Mapper -public interface MemberPointRecordConvert { - - MemberPointRecordConvert INSTANCE = Mappers.getMapper(MemberPointRecordConvert.class); - - default PageResult convertPage(PageResult pageResult, List users) { - PageResult voPageResult = convertPage(pageResult); - // user 拼接 - Map userMap = convertMap(users, MemberUserDO::getId); - voPageResult.getList().forEach(record -> MapUtils.findAndThen(userMap, record.getUserId(), - memberUserRespDTO -> record.setNickname(memberUserRespDTO.getNickname()))); - return voPageResult; - } - PageResult convertPage(PageResult pageResult); - - PageResult convertPage02(PageResult pageResult); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInConfigConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInConfigConvert.java deleted file mode 100644 index 5acd871511..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInConfigConvert.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.signin; - -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigRespVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.config.AppMemberSignInConfigRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 签到规则 Convert - * - * @author QingX - */ -@Mapper -public interface MemberSignInConfigConvert { - - MemberSignInConfigConvert INSTANCE = Mappers.getMapper(MemberSignInConfigConvert.class); - - MemberSignInConfigDO convert(MemberSignInConfigCreateReqVO bean); - - MemberSignInConfigDO convert(MemberSignInConfigUpdateReqVO bean); - - MemberSignInConfigRespVO convert(MemberSignInConfigDO bean); - - List convertList(List list); - - List convertList02(List list); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java deleted file mode 100644 index 63193b0296..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.signin; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordRespVO; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.record.AppMemberSignInRecordRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 签到记录 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface MemberSignInRecordConvert { - - MemberSignInRecordConvert INSTANCE = Mappers.getMapper(MemberSignInRecordConvert.class); - - default PageResult convertPage(PageResult pageResult, List users) { - PageResult voPageResult = convertPage(pageResult); - // user 拼接 - Map userMap = convertMap(users, MemberUserDO::getId); - voPageResult.getList().forEach(record -> MapUtils.findAndThen(userMap, record.getUserId(), - memberUserRespDTO -> record.setNickname(memberUserRespDTO.getNickname()))); - return voPageResult; - } - - PageResult convertPage(PageResult pageResult); - - PageResult convertPage02(PageResult pageResult); - - AppMemberSignInRecordRespVO coverRecordToAppRecordVo(MemberSignInRecordDO memberSignInRecordDO); - - default MemberSignInRecordDO convert(Long userId, MemberSignInRecordDO lastRecord, List configs) { - // 1. 计算是第几天签到 - configs.sort(Comparator.comparing(MemberSignInConfigDO::getDay)); - MemberSignInConfigDO lastConfig = CollUtil.getLast(configs); // 最大签到天数配置 - // 1.2. 计算今天是第几天签到 - int day = 1; - // TODO @puhui999:要判断是不是昨天签到的;是否是昨天的判断,可以抽个方法到 util 里 - if (lastRecord != null) { - day = lastRecord.getDay() + 1; - } - // 1.3 判断是否超出了最大签到配置 - if (day > lastConfig.getDay()) { - day = 1; // 超过最大配置的天数,重置到第一天。(也就是说开启下一轮签到) - } - - // 2.1 初始化签到信息 - MemberSignInRecordDO record = new MemberSignInRecordDO().setUserId(userId) - .setDay(day).setPoint(0).setExperience(0); - // 2.2 获取签到对应的积分 - MemberSignInConfigDO config = CollUtil.findOne(configs, item -> ObjUtil.equal(item.getDay(), record.getDay())); - if (config == null) { - return record; - } - record.setPoint(config.getPoint()); - record.setExperience(config.getExperience()); - return record; - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/social/SocialUserConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/social/SocialUserConvert.java deleted file mode 100644 index 3c9288ba86..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/social/SocialUserConvert.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.social; - -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserBindReqVO; -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserUnbindReqVO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserUnbindReqDTO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface SocialUserConvert { - - SocialUserConvert INSTANCE = Mappers.getMapper(SocialUserConvert.class); - - SocialUserBindReqDTO convert(Long userId, Integer userType, AppSocialUserBindReqVO reqVO); - - SocialUserUnbindReqDTO convert(Long userId, Integer userType, AppSocialUserUnbindReqVO reqVO); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/tag/MemberTagConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/tag/MemberTagConvert.java deleted file mode 100644 index 9d3a41f1ae..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/tag/MemberTagConvert.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagRespVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 会员标签 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface MemberTagConvert { - - MemberTagConvert INSTANCE = Mappers.getMapper(MemberTagConvert.class); - - MemberTagDO convert(MemberTagCreateReqVO bean); - - MemberTagDO convert(MemberTagUpdateReqVO bean); - - MemberTagRespVO convert(MemberTagDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java deleted file mode 100644 index aae9a76013..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.user; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserRespVO; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserInfoRespVO; -import cn.iocoder.yudao.module.member.convert.address.AddressConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -@Mapper(uses = {AddressConvert.class}) -public interface MemberUserConvert { - - MemberUserConvert INSTANCE = Mappers.getMapper(MemberUserConvert.class); - - AppMemberUserInfoRespVO convert(MemberUserDO bean); - - @Mapping(source = "level", target = "level") - @Mapping(source = "bean.experience", target = "experience") - AppMemberUserInfoRespVO convert(MemberUserDO bean, MemberLevelDO level); - - MemberUserRespDTO convert2(MemberUserDO bean); - - List convertList2(List list); - - MemberUserDO convert(MemberUserUpdateReqVO bean); - - PageResult convertPage(PageResult page); - - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") - MemberUserRespVO convert03(MemberUserDO bean); - - default PageResult convertPage(PageResult pageResult, - List tags, - List levels, - List groups) { - PageResult result = convertPage(pageResult); - // 处理关联数据 - Map tagMap = convertMap(tags, MemberTagDO::getId, MemberTagDO::getName); - Map levelMap = convertMap(levels, MemberLevelDO::getId, MemberLevelDO::getName); - Map groupMap = convertMap(groups, MemberGroupDO::getId, MemberGroupDO::getName); - // 填充关联数据 - result.getList().forEach(user -> { - user.setTagNames(convertList(user.getTagIds(), tagMap::get)); - user.setLevelName(levelMap.get(user.getLevelId())); - user.setGroupName(groupMap.get(user.getGroupId())); - }); - return result; - } - -} diff --git "a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" "b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" deleted file mode 100644 index 8153487b72..0000000000 --- "a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/MemberAddressDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/MemberAddressDO.java deleted file mode 100644 index f2e43b563e..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/MemberAddressDO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.address; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 用户收件地址 DO - * - * @author 芋道源码 - */ -@TableName("member_address") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberAddressDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - */ - private Long userId; - /** - * 收件人名称 - */ - private String name; - /** - * 手机号 - */ - private String mobile; - /** - * 地区编号 - */ - private Long areaId; - /** - * 收件详细地址 - */ - private String detailAddress; - /** - * 是否默认 - * - * true - 默认收件地址 - */ - private Boolean defaultStatus; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/config/MemberConfigDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/config/MemberConfigDO.java deleted file mode 100644 index 6efb4a1c05..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/config/MemberConfigDO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.config; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 会员配置 DO - * - * @author QingX - */ -@TableName(value = "member_config", autoResultMap = true) -@KeySequence("member_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberConfigDO extends BaseDO { - - /** - * 自增主键 - */ - @TableId - private Long id; - /** - * 积分抵扣开关 - */ - private Boolean pointTradeDeductEnable; - /** - * 积分抵扣,单位:分 - * - * 1 积分抵扣多少分 - */ - private Integer pointTradeDeductUnitPrice; - /** - * 积分抵扣最大值 - */ - private Integer pointTradeDeductMaxPrice; - /** - * 1 元赠送多少分 - */ - private Integer pointTradeGivePoint; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/group/MemberGroupDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/group/MemberGroupDO.java deleted file mode 100644 index c9a82ab5d7..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/group/MemberGroupDO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.group; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 用户分组 DO - * - * @author owen - */ -@TableName("member_group") -@KeySequence("member_group_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberGroupDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名称 - */ - private String name; - /** - * 备注 - */ - private String remark; - /** - * 状态 - *

- * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberExperienceRecordDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberExperienceRecordDO.java deleted file mode 100644 index d7c06d4bab..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberExperienceRecordDO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.level; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 会员经验记录 DO - * - * @author owen - */ -@TableName("member_experience_record") -@KeySequence("member_experience_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberExperienceRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 {@link MemberUserDO#getId()} 字段 - */ - private Long userId; - /** - * 业务类型 - *

- * 枚举 {@link MemberExperienceBizTypeEnum} - */ - private Integer bizType; - /** - * 业务编号 - */ - private String bizId; - /** - * 标题 - */ - private String title; - /** - * 描述 - */ - private String description; - /** - * 经验 - */ - private Integer experience; - /** - * 变更后的经验 - */ - private Integer totalExperience; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelDO.java deleted file mode 100644 index 05035ffe53..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelDO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.level; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 会员等级 DO - * - * 配置每个等级需要的积分 - * - * @author owen - */ -@TableName("member_level") -@KeySequence("member_level_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberLevelDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 等级名称 - */ - private String name; - /** - * 等级 - */ - private Integer level; - /** - * 升级经验 - */ - private Integer experience; - /** - * 享受折扣 - */ - private Integer discountPercent; - - /** - * 等级图标 - */ - private String icon; - /** - * 等级背景图 - */ - private String backgroundUrl; - /** - * 状态 - *

- * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelRecordDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelRecordDO.java deleted file mode 100644 index 8b5451d45c..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelRecordDO.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.level; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 会员等级记录 DO - * - * 用户每次等级发生变更时,记录一条日志 - * - * @author owen - */ -@TableName("member_level_record") -@KeySequence("member_level_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberLevelRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 {@link MemberUserDO#getId()} 字段 - */ - private Long userId; - /** - * 等级编号 - * - * 关联 {@link MemberLevelDO#getId()} 字段 - */ - private Long levelId; - /** - * 会员等级 - * - * 冗余 {@link MemberLevelDO#getLevel()} 字段 - */ - private Integer level; - /** - * 享受折扣 - */ - private Integer discountPercent; - /** - * 升级经验 - */ - private Integer experience; - /** - * 会员此时的经验 - */ - private Integer userExperience; - /** - * 备注 - */ - private String remark; - /** - * 描述 - */ - private String description; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointRecordDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointRecordDO.java deleted file mode 100644 index f884f08d82..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointRecordDO.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.point; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 用户积分记录 DO - * - * @author QingX - */ -@TableName("member_point_record") -@KeySequence("member_point_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberPointRecordDO extends BaseDO { - - /** - * 自增主键 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 对应 MemberUserDO 的 id 属性 - */ - private Long userId; - - /** - * 业务编码 - */ - private String bizId; - /** - * 业务类型 - * - * 枚举 {@link MemberPointBizTypeEnum} - */ - private Integer bizType; - - /** - * 积分标题 - */ - private String title; - /** - * 积分描述 - */ - private String description; - - /** - * 变动积分 - * - * 1、正数表示获得积分 - * 2、负数表示消耗积分 - */ - private Integer point; - /** - * 变动后的积分 - */ - private Integer totalPoint; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInConfigDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInConfigDO.java deleted file mode 100644 index 76d55c9bfa..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInConfigDO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.signin; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 签到规则 DO - * - * @author QingX - */ -@TableName("member_sign_in_config") -@KeySequence("member_sign_in_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberSignInConfigDO extends BaseDO { - - /** - * 规则自增主键 - */ - @TableId - private Long id; - /** - * 签到第 x 天 - */ - private Integer day; - /** - * 奖励积分 - */ - private Integer point; - /** - * 奖励经验 - */ - private Integer experience; - - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInRecordDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInRecordDO.java deleted file mode 100644 index b07b5efbc9..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInRecordDO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.signin; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 签到记录 DO - * - * @author 芋道源码 - */ -@TableName("member_sign_in_record") -@KeySequence("member_sign_in_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberSignInRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 签到用户 - */ - private Long userId; - /** - * 第几天签到 - */ - private Integer day; - /** - * 签到的积分 - */ - private Integer point; - /** - * 签到的经验 - */ - private Integer experience; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/tag/MemberTagDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/tag/MemberTagDO.java deleted file mode 100644 index b984064e0e..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/tag/MemberTagDO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.tag; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 会员标签 DO - * - * @author 芋道源码 - */ -@TableName("member_tag") -@KeySequence("member_tag_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberTagDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 标签名称 - */ - private String name; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java deleted file mode 100644 index 97ddc191de..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.user; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.system.enums.common.SexEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 会员用户 DO - * - * uk_mobile 索引:基于 {@link #mobile} 字段 - * - * @author 芋道源码 - */ -@TableName(value = "member_user", autoResultMap = true) -@KeySequence("member_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberUserDO extends TenantBaseDO { - - // ========== 账号信息 ========== - - /** - * 用户ID - */ - @TableId - private Long id; - /** - * 手机 - */ - private String mobile; - /** - * 加密后的密码 - * - * 因为目前使用 {@link BCryptPasswordEncoder} 加密器,所以无需自己处理 salt 盐 - */ - private String password; - /** - * 帐号状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 注册 IP - */ - private String registerIp; - /** - * 注册终端 - * 枚举 {@link TerminalEnum} - */ - private Integer registerTerminal; - /** - * 最后登录IP - */ - private String loginIp; - /** - * 最后登录时间 - */ - private LocalDateTime loginDate; - - // ========== 基础信息 ========== - - /** - * 用户昵称 - */ - private String nickname; - /** - * 用户头像 - */ - private String avatar; - - /** - * 真实名字 - */ - private String name; - /** - * 性别 - * - * 枚举 {@link SexEnum} - */ - private Integer sex; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 所在地 - * - * 关联 {@link Area#getId()} 字段 - */ - private Integer areaId; - /** - * 用户备注 - */ - private String mark; - - // ========== 其它信息 ========== - - /** - * 积分 - */ - private Integer point; - // TODO 疯狂:增加一个 totalPoint;个人信息接口要返回 - - /** - * 会员标签列表,以逗号分隔 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List tagIds; - - /** - * 会员级别编号 - * - * 关联 {@link MemberLevelDO#getId()} 字段 - */ - private Long levelId; - /** - * 会员经验 - */ - private Integer experience; - /** - * 用户分组编号 - * - * 关联 {@link MemberGroupDO#getId()} 字段 - */ - private Long groupId; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/MemberAddressMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/MemberAddressMapper.java deleted file mode 100644 index 3df68c51a7..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/MemberAddressMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.address; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MemberAddressMapper extends BaseMapperX { - - default MemberAddressDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(MemberAddressDO::getId, id, MemberAddressDO::getUserId, userId); - } - - default List selectListByUserIdAndDefaulted(Long userId, Boolean defaulted) { - return selectList(new LambdaQueryWrapperX().eq(MemberAddressDO::getUserId, userId) - .eqIfPresent(MemberAddressDO::getDefaultStatus, defaulted)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/config/MemberConfigMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/config/MemberConfigMapper.java deleted file mode 100644 index e039383784..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/config/MemberConfigMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.config; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.member.dal.dataobject.config.MemberConfigDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 积分设置 Mapper - * - * @author QingX - */ -@Mapper -public interface MemberConfigMapper extends BaseMapperX { -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/group/MemberGroupMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/group/MemberGroupMapper.java deleted file mode 100644 index da4f7b7a80..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/group/MemberGroupMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.group; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 用户分组 Mapper - * - * @author owen - */ -@Mapper -public interface MemberGroupMapper extends BaseMapperX { - - default PageResult selectPage(MemberGroupPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(MemberGroupDO::getName, reqVO.getName()) - .eqIfPresent(MemberGroupDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(MemberGroupDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MemberGroupDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(MemberGroupDO::getStatus, status); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberExperienceRecordMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberExperienceRecordMapper.java deleted file mode 100644 index 4e5f6f567d..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberExperienceRecordMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.level; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * 会员经验记录 Mapper - * - * @author owen - */ -@Mapper -public interface MemberExperienceRecordMapper extends BaseMapperX { - - default PageResult selectPage(MemberExperienceRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MemberExperienceRecordDO::getUserId, reqVO.getUserId()) - .eqIfPresent(MemberExperienceRecordDO::getBizId, reqVO.getBizId()) - .eqIfPresent(MemberExperienceRecordDO::getBizType, reqVO.getBizType()) - .eqIfPresent(MemberExperienceRecordDO::getTitle, reqVO.getTitle()) - .betweenIfPresent(MemberExperienceRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MemberExperienceRecordDO::getId)); - } - - default PageResult selectPage(Long userId, PageParam pageParam) { - return selectPage(pageParam, new LambdaQueryWrapper() - .eq(MemberExperienceRecordDO::getUserId, userId) - .orderByDesc(MemberExperienceRecordDO::getId)); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelMapper.java deleted file mode 100644 index d2dcb6cb48..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.level; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelListReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 会员等级 Mapper - * - * @author owen - */ -@Mapper -public interface MemberLevelMapper extends BaseMapperX { - - default List selectList(MemberLevelListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(MemberLevelDO::getName, reqVO.getName()) - .eqIfPresent(MemberLevelDO::getStatus, reqVO.getStatus()) - .orderByAsc(MemberLevelDO::getLevel)); - } - - - default List selectListByStatus(Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(MemberLevelDO::getStatus, status) - .orderByAsc(MemberLevelDO::getLevel)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelRecordMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelRecordMapper.java deleted file mode 100644 index 6808b957a3..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelRecordMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.level; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.record.MemberLevelRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 会员等级记录 Mapper - * - * @author owen - */ -@Mapper -public interface MemberLevelRecordMapper extends BaseMapperX { - - default PageResult selectPage(MemberLevelRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MemberLevelRecordDO::getUserId, reqVO.getUserId()) - .eqIfPresent(MemberLevelRecordDO::getLevelId, reqVO.getLevelId()) - .betweenIfPresent(MemberLevelRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MemberLevelRecordDO::getId)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/point/MemberPointRecordMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/point/MemberPointRecordMapper.java deleted file mode 100644 index 5c33709296..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/point/MemberPointRecordMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.point; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Set; - -/** - * 用户积分记录 Mapper - * - * @author QingX - */ -@Mapper -public interface MemberPointRecordMapper extends BaseMapperX { - - default PageResult selectPage(MemberPointRecordPageReqVO reqVO, Set userIds) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .inIfPresent(MemberPointRecordDO::getUserId, userIds) - .eqIfPresent(MemberPointRecordDO::getUserId, reqVO.getUserId()) - .eqIfPresent(MemberPointRecordDO::getBizType, reqVO.getBizType()) - .likeIfPresent(MemberPointRecordDO::getTitle, reqVO.getTitle()) - .orderByDesc(MemberPointRecordDO::getId)); - } - - default PageResult selectPage(Long userId, PageParam pageVO) { - return selectPage(pageVO, new LambdaQueryWrapperX() - .eq(MemberPointRecordDO::getUserId, userId) - .orderByDesc(MemberPointRecordDO::getId)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInConfigMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInConfigMapper.java deleted file mode 100644 index 211ead33d1..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInConfigMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.signin; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 签到规则 Mapper - * - * @author QingX - */ -@Mapper -public interface MemberSignInConfigMapper extends BaseMapperX { - - default MemberSignInConfigDO selectByDay(Integer day) { - return selectOne(MemberSignInConfigDO::getDay, day); - } - - default List selectListByStatus(Integer status) { - return selectList(MemberSignInConfigDO::getStatus, status); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java deleted file mode 100644 index 36400b81a5..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.signin; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.Set; - -/** - * 签到记录 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface MemberSignInRecordMapper extends BaseMapperX { - - default PageResult selectPage(MemberSignInRecordPageReqVO reqVO, Set userIds) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .inIfPresent(MemberSignInRecordDO::getUserId, userIds) - .eqIfPresent(MemberSignInRecordDO::getUserId, reqVO.getUserId()) - .eqIfPresent(MemberSignInRecordDO::getDay, reqVO.getDay()) - .betweenIfPresent(MemberSignInRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MemberSignInRecordDO::getId)); - } - - default PageResult selectPage(Long userId, PageParam pageParam) { - return selectPage(pageParam, new LambdaQueryWrapperX() - .eq(MemberSignInRecordDO::getUserId, userId) - .orderByDesc(MemberSignInRecordDO::getId)); - } - - /** - * 获取用户最近的签到记录信息,根据签到时间倒序 - * - * @param userId 用户编号 - * @return 签到记录列表 - */ - default MemberSignInRecordDO selectLastRecordByUserId(Long userId) { - return selectOne(new QueryWrapper() - .eq("user_id", userId) - .orderByDesc("create_time") - .last("limit 1")); - } - - default Long selectCountByUserId(Long userId) { - return selectCount(MemberSignInRecordDO::getUserId, userId); - } - - /** - * 获取用户的签到记录列表信息 - * - * @param userId 用户编号 - * @return 签到记录信息 - */ - default List selectListByUserId(Long userId) { - return selectList(MemberSignInRecordDO::getUserId, userId); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/tag/MemberTagMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/tag/MemberTagMapper.java deleted file mode 100644 index f4723e2829..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/tag/MemberTagMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 会员标签 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface MemberTagMapper extends BaseMapperX { - - default PageResult selectPage(MemberTagPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(MemberTagDO::getName, reqVO.getName()) - .betweenIfPresent(MemberTagDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MemberTagDO::getId)); - } - - default MemberTagDO selelctByName(String name) { - return selectOne(MemberTagDO::getName, name); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java deleted file mode 100644 index 3f871020c4..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.user; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * 会员 User Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface MemberUserMapper extends BaseMapperX { - - default MemberUserDO selectByMobile(String mobile) { - return selectOne(MemberUserDO::getMobile, mobile); - } - - default List selectListByNicknameLike(String nickname) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(MemberUserDO::getNickname, nickname)); - } - - default PageResult selectPage(MemberUserPageReqVO reqVO) { - // 处理 tagIds 过滤条件 - String tagIdSql = ""; - if (CollUtil.isNotEmpty(reqVO.getTagIds())) { - tagIdSql = reqVO.getTagIds().stream() - .map(tagId -> "FIND_IN_SET(" + tagId + ", tag_ids)") - .collect(Collectors.joining(" OR ")); - } - // 分页查询 - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(MemberUserDO::getMobile, reqVO.getMobile()) - .betweenIfPresent(MemberUserDO::getLoginDate, reqVO.getLoginDate()) - .likeIfPresent(MemberUserDO::getNickname, reqVO.getNickname()) - .betweenIfPresent(MemberUserDO::getCreateTime, reqVO.getCreateTime()) - .eqIfPresent(MemberUserDO::getLevelId, reqVO.getLevelId()) - .eqIfPresent(MemberUserDO::getGroupId, reqVO.getGroupId()) - .apply(StrUtil.isNotEmpty(tagIdSql), tagIdSql) - .orderByDesc(MemberUserDO::getId)); - } - - default Long selectCountByGroupId(Long groupId) { - return selectCount(MemberUserDO::getGroupId, groupId); - } - - default Long selectCountByLevelId(Long levelId) { - return selectCount(MemberUserDO::getLevelId, levelId); - } - - default Long selectCountByTagId(Long tagId) { - return selectCount(new LambdaQueryWrapperX() - .apply("FIND_IN_SET({0}, tag_ids)", tagId)); - } - - /** - * 更新用户积分(增加) - * - * @param id 用户编号 - * @param incrCount 增加积分(正数) - */ - default void updatePointIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" point = point + " + incrCount) - .eq(MemberUserDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户积分(减少) - * - * @param id 用户编号 - * @param incrCount 增加积分(负数) - * @return 更新行数 - */ - default int updatePointDecr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" point = point + " + incrCount) // 负数,所以使用 + 号 - .eq(MemberUserDO::getId, id); - return update(null, lambdaUpdateWrapper); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/package-info.java deleted file mode 100644 index a45c2a1613..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * DAL = Data Access Layer 数据访问层 - * 1. data object:数据对象 - * 2. redis:Redis 的 CRUD 操作 - * 3. mysql:MySQL 的 CRUD 操作 - * - * 其中,MySQL 的表以 member_ 作为前缀 - */ -package cn.iocoder.yudao.module.member.dal; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/redis/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/redis/package-info.java deleted file mode 100644 index 8dfa9fb20d..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/redis/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位,后续有类后,可以删除,避免 package 无法提交到 Git 上 - */ -package cn.iocoder.yudao.module.member.dal.redis; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/package-info.java deleted file mode 100644 index 7e9ca95de3..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 member 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.member.framework; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/web/config/MemberWebConfiguration.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/web/config/MemberWebConfiguration.java deleted file mode 100644 index 5e3dc3f376..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/web/config/MemberWebConfiguration.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.member.framework.web.config; - -import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration; -import org.springdoc.core.models.GroupedOpenApi; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * member 模块的 web 组件的 Configuration - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -public class MemberWebConfiguration { - - /** - * member 模块的 API 分组 - */ - @Bean - public GroupedOpenApi memberGroupedOpenApi() { - return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("member"); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/web/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/web/package-info.java deleted file mode 100644 index 3a964cfc29..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/web/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * member 模块的 web 配置 - */ -package cn.iocoder.yudao.module.member.framework.web; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/package-info.java deleted file mode 100644 index 521f60b8c4..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的消费者 - */ -package cn.iocoder.yudao.module.member.mq.consumer; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/message/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/message/package-info.java deleted file mode 100644 index 6489394a16..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/message/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的消息 - */ -package cn.iocoder.yudao.module.member.mq.message; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/producer/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/producer/package-info.java deleted file mode 100644 index dff4c99a95..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/producer/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的生产者 - */ -package cn.iocoder.yudao.module.member.mq.producer; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/producer/user/MemberUserProducer.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/producer/user/MemberUserProducer.java deleted file mode 100644 index ab63ebc791..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/producer/user/MemberUserProducer.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.mq.producer.user; - -import cn.iocoder.yudao.module.member.message.user.MemberUserCreateMessage; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -/** - * 会员用户 Producer - * - * @author owen - */ -@Slf4j -@Component -public class MemberUserProducer { - - @Resource - private ApplicationContext applicationContext; - - /** - * 发送 {@link MemberUserCreateMessage} 消息 - * - * @param userId 用户编号 - */ - public void sendUserCreateMessage(Long userId) { - applicationContext.publishEvent(new MemberUserCreateMessage().setUserId(userId)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/package-info.java deleted file mode 100644 index 405aa4cbf6..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * member 模块,我们放会员业务。 - * 例如说:会员中心等等 - * - * 1. Controller URL:以 /member/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 member_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.member; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressService.java deleted file mode 100644 index c429da0e72..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressService.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.member.service.address; - -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * 用户收件地址 Service 接口 - * - * @author 芋道源码 - */ -public interface AddressService { - - /** - * 创建用户收件地址 - * - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createAddress(Long userId, @Valid AppAddressCreateReqVO createReqVO); - - /** - * 更新用户收件地址 - * - * @param userId 用户编号 - * @param updateReqVO 更新信息 - */ - void updateAddress(Long userId, @Valid AppAddressUpdateReqVO updateReqVO); - - /** - * 删除用户收件地址 - * - * @param userId 用户编号 - * @param id 编号 - */ - void deleteAddress(Long userId, Long id); - - /** - * 获得用户收件地址 - * - * @param id 编号 - * @return 用户收件地址 - */ - MemberAddressDO getAddress(Long userId, Long id); - - /** - * 获得用户收件地址列表 - * - * @param userId 用户编号 - * @return 用户收件地址列表 - */ - List getAddressList(Long userId); - - /** - * 获得用户默认的收件地址 - * - * @param userId 用户编号 - * @return 用户收件地址 - */ - MemberAddressDO getDefaultUserAddress(Long userId); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java deleted file mode 100644 index aae955c483..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.member.service.address; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.address.AddressConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; -import cn.iocoder.yudao.module.member.dal.mysql.address.MemberAddressMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.ADDRESS_NOT_EXISTS; - -/** - * 用户收件地址 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class AddressServiceImpl implements AddressService { - - @Resource - private MemberAddressMapper memberAddressMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createAddress(Long userId, AppAddressCreateReqVO createReqVO) { - // 如果添加的是默认收件地址,则将原默认地址修改为非默认 - if (Boolean.TRUE.equals(createReqVO.getDefaultStatus())) { - List addresses = memberAddressMapper.selectListByUserIdAndDefaulted(userId, true); - addresses.forEach(address -> memberAddressMapper.updateById(new MemberAddressDO().setId(address.getId()).setDefaultStatus(false))); - } - - // 插入 - MemberAddressDO address = AddressConvert.INSTANCE.convert(createReqVO); - address.setUserId(userId); - memberAddressMapper.insert(address); - // 返回 - return address.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateAddress(Long userId, AppAddressUpdateReqVO updateReqVO) { - // 校验存在,校验是否能够操作 - validAddressExists(userId, updateReqVO.getId()); - - // 如果修改的是默认收件地址,则将原默认地址修改为非默认 - if (Boolean.TRUE.equals(updateReqVO.getDefaultStatus())) { - List addresses = memberAddressMapper.selectListByUserIdAndDefaulted(userId, true); - addresses.stream().filter(u -> !u.getId().equals(updateReqVO.getId())) // 排除自己 - .forEach(address -> memberAddressMapper.updateById(new MemberAddressDO().setId(address.getId()).setDefaultStatus(false))); - } - - // 更新 - MemberAddressDO updateObj = AddressConvert.INSTANCE.convert(updateReqVO); - memberAddressMapper.updateById(updateObj); - } - - @Override - public void deleteAddress(Long userId, Long id) { - // 校验存在,校验是否能够操作 - validAddressExists(userId, id); - // 删除 - memberAddressMapper.deleteById(id); - } - - private void validAddressExists(Long userId, Long id) { - MemberAddressDO addressDO = getAddress(userId, id); - if (addressDO == null) { - throw exception(ADDRESS_NOT_EXISTS); - } - } - - @Override - public MemberAddressDO getAddress(Long userId, Long id) { - return memberAddressMapper.selectByIdAndUserId(id, userId); - } - - @Override - public List getAddressList(Long userId) { - return memberAddressMapper.selectListByUserIdAndDefaulted(userId, null); - } - - @Override - public MemberAddressDO getDefaultUserAddress(Long userId) { - List addresses = memberAddressMapper.selectListByUserIdAndDefaulted(userId, true); - return CollUtil.getFirst(addresses); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java deleted file mode 100644 index 46bc048dc5..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.member.service.auth; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.module.member.controller.app.auth.vo.*; - -import jakarta.validation.Valid; - -/** - * 会员的认证 Service 接口 - * - * 提供用户的账号密码登录、token 的校验等认证相关的功能 - * - * @author 芋道源码 - */ -public interface MemberAuthService { - - /** - * 手机 + 密码登录 - * - * @param reqVO 登录信息 - * @return 登录结果 - */ - AppAuthLoginRespVO login(@Valid AppAuthLoginReqVO reqVO); - - /** - * 基于 token 退出登录 - * - * @param token token - */ - void logout(String token); - - /** - * 手机 + 验证码登陆 - * - * @param reqVO 登陆信息 - * @param terminal 终端 {@link TerminalEnum} - * @return 登录结果 - */ - AppAuthLoginRespVO smsLogin(@Valid AppAuthSmsLoginReqVO reqVO, Integer terminal); - - /** - * 社交登录,使用 code 授权码 - * - * @param reqVO 登录信息 - * @return 登录结果 - */ - AppAuthLoginRespVO socialLogin(@Valid AppAuthSocialLoginReqVO reqVO); - - /** - * 微信小程序的一键登录 - * - * @param reqVO 登录信息 - * @return 登录结果 - */ - AppAuthLoginRespVO weixinMiniAppLogin(AppAuthWeixinMiniAppLoginReqVO reqVO); - - /** - * 获得社交认证 URL - * - * @param type 社交平台类型 - * @param redirectUri 跳转地址 - * @return 认证 URL - */ - String getSocialAuthorizeUrl(Integer type, String redirectUri); - - /** - * 给用户发送短信验证码 - * - * @param userId 用户编号 - * @param reqVO 发送信息 - */ - void sendSmsCode(Long userId, AppAuthSmsSendReqVO reqVO); - - /** - * 校验短信验证码是否正确 - * - * @param userId 用户编号 - * @param reqVO 校验信息 - */ - void validateSmsCode(Long userId, AppAuthSmsValidateReqVO reqVO); - - /** - * 刷新访问令牌 - * - * @param refreshToken 刷新令牌 - * @return 登录结果 - */ - AppAuthLoginRespVO refreshToken(String refreshToken); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java deleted file mode 100644 index dd0f9fb1f7..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java +++ /dev/null @@ -1,264 +0,0 @@ -package cn.iocoder.yudao.module.member.service.auth; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; -import cn.iocoder.yudao.module.member.controller.app.auth.vo.*; -import cn.iocoder.yudao.module.member.convert.auth.AuthConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import cn.iocoder.yudao.module.system.api.logger.LoginLogApi; -import cn.iocoder.yudao.module.system.api.logger.dto.LoginLogCreateReqDTO; -import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; -import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCreateReqDTO; -import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; -import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; -import cn.iocoder.yudao.module.system.api.social.SocialClientApi; -import cn.iocoder.yudao.module.system.api.social.SocialUserApi; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO; -import cn.iocoder.yudao.module.system.enums.logger.LoginLogTypeEnum; -import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum; -import cn.iocoder.yudao.module.system.enums.oauth2.OAuth2ClientConstants; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import jakarta.annotation.Resource; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; - -/** - * 会员的认证 Service 接口 - * - * @author 芋道源码 - */ -@Service -@Slf4j -public class MemberAuthServiceImpl implements MemberAuthService { - - @Resource - private MemberUserService userService; - @Resource - private SmsCodeApi smsCodeApi; - @Resource - private LoginLogApi loginLogApi; - @Resource - private SocialUserApi socialUserApi; - @Resource - private SocialClientApi socialClientApi; - @Resource - private OAuth2TokenApi oauth2TokenApi; - - @Override - public AppAuthLoginRespVO login(AppAuthLoginReqVO reqVO) { - // 使用手机 + 密码,进行登录。 - MemberUserDO user = login0(reqVO.getMobile(), reqVO.getPassword()); - - // 如果 socialType 非空,说明需要绑定社交用户 - String openid = null; - if (reqVO.getSocialType() != null) { - openid = socialUserApi.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(), - reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState())); - } - - // 创建 Token 令牌,记录登录日志 - return createTokenAfterLoginSuccess(user, reqVO.getMobile(), LoginLogTypeEnum.LOGIN_MOBILE, openid); - } - - @Override - @Transactional - public AppAuthLoginRespVO smsLogin(AppAuthSmsLoginReqVO reqVO, Integer terminal) { - // 校验验证码 - String userIp = getClientIP(); - smsCodeApi.useSmsCode(AuthConvert.INSTANCE.convert(reqVO, SmsSceneEnum.MEMBER_LOGIN.getScene(), userIp)); - - // 获得获得注册用户 - MemberUserDO user = userService.createUserIfAbsent(reqVO.getMobile(), userIp, terminal); - Assert.notNull(user, "获取用户失败,结果为空"); - - // 如果 socialType 非空,说明需要绑定社交用户 - String openid = null; - if (reqVO.getSocialType() != null) { - openid = socialUserApi.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(), - reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState())); - } - - // 创建 Token 令牌,记录登录日志 - return createTokenAfterLoginSuccess(user, reqVO.getMobile(), LoginLogTypeEnum.LOGIN_SMS, openid); - } - - @Override - public AppAuthLoginRespVO socialLogin(AppAuthSocialLoginReqVO reqVO) { - // 使用 code 授权码,进行登录。然后,获得到绑定的用户编号 - SocialUserRespDTO socialUser = socialUserApi.getSocialUser(UserTypeEnum.MEMBER.getValue(), reqVO.getType(), - reqVO.getCode(), reqVO.getState()); - if (socialUser == null) { - throw exception(AUTH_THIRD_LOGIN_NOT_BIND); - } - - // 自动登录 - MemberUserDO user = userService.getUser(socialUser.getUserId()); - if (user == null) { - throw exception(USER_NOT_EXISTS); - } - - // 创建 Token 令牌,记录登录日志 - return createTokenAfterLoginSuccess(user, user.getMobile(), LoginLogTypeEnum.LOGIN_SOCIAL, socialUser.getOpenid()); - } - - @Override - public AppAuthLoginRespVO weixinMiniAppLogin(AppAuthWeixinMiniAppLoginReqVO reqVO) { - // 获得对应的手机号信息 - SocialWxPhoneNumberInfoRespDTO phoneNumberInfo = socialClientApi.getWxMaPhoneNumberInfo( - UserTypeEnum.MEMBER.getValue(), reqVO.getPhoneCode()); - Assert.notNull(phoneNumberInfo, "获得手机信息失败,结果为空"); - - // 获得获得注册用户 - MemberUserDO user = userService.createUserIfAbsent(phoneNumberInfo.getPurePhoneNumber(), - getClientIP(), TerminalEnum.WECHAT_MINI_PROGRAM.getTerminal()); - Assert.notNull(user, "获取用户失败,结果为空"); - - // 绑定社交用户 - String openid = socialUserApi.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(), - SocialTypeEnum.WECHAT_MINI_APP.getType(), reqVO.getLoginCode(), reqVO.getState())); - - // 创建 Token 令牌,记录登录日志 - return createTokenAfterLoginSuccess(user, user.getMobile(), LoginLogTypeEnum.LOGIN_SOCIAL, openid); - } - - private AppAuthLoginRespVO createTokenAfterLoginSuccess(MemberUserDO user, String mobile, - LoginLogTypeEnum logType, String openid) { - // 插入登陆日志 - createLoginLog(user.getId(), mobile, logType, LoginResultEnum.SUCCESS); - // 创建 Token 令牌 - OAuth2AccessTokenRespDTO accessTokenRespDTO = oauth2TokenApi.createAccessToken(new OAuth2AccessTokenCreateReqDTO() - .setUserId(user.getId()).setUserType(getUserType().getValue()) - .setClientId(OAuth2ClientConstants.CLIENT_ID_DEFAULT)); - // 构建返回结果 - return AuthConvert.INSTANCE.convert(accessTokenRespDTO, openid); - } - - @Override - public String getSocialAuthorizeUrl(Integer type, String redirectUri) { - return socialClientApi.getAuthorizeUrl(type, UserTypeEnum.MEMBER.getValue(), redirectUri); - } - - private MemberUserDO login0(String mobile, String password) { - final LoginLogTypeEnum logTypeEnum = LoginLogTypeEnum.LOGIN_MOBILE; - // 校验账号是否存在 - MemberUserDO user = userService.getUserByMobile(mobile); - if (user == null) { - createLoginLog(null, mobile, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS); - throw exception(AUTH_LOGIN_BAD_CREDENTIALS); - } - if (!userService.isPasswordMatch(password, user.getPassword())) { - createLoginLog(user.getId(), mobile, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS); - throw exception(AUTH_LOGIN_BAD_CREDENTIALS); - } - // 校验是否禁用 - if (ObjectUtil.notEqual(user.getStatus(), CommonStatusEnum.ENABLE.getStatus())) { - createLoginLog(user.getId(), mobile, logTypeEnum, LoginResultEnum.USER_DISABLED); - throw exception(AUTH_LOGIN_USER_DISABLED); - } - return user; - } - - private void createLoginLog(Long userId, String mobile, LoginLogTypeEnum logType, LoginResultEnum loginResult) { - // 插入登录日志 - LoginLogCreateReqDTO reqDTO = new LoginLogCreateReqDTO(); - reqDTO.setLogType(logType.getType()); - reqDTO.setTraceId(TracerUtils.getTraceId()); - reqDTO.setUserId(userId); - reqDTO.setUserType(getUserType().getValue()); - reqDTO.setUsername(mobile); - reqDTO.setUserAgent(ServletUtils.getUserAgent()); - reqDTO.setUserIp(getClientIP()); - reqDTO.setResult(loginResult.getResult()); - loginLogApi.createLoginLog(reqDTO); - // 更新最后登录时间 - if (userId != null && Objects.equals(LoginResultEnum.SUCCESS.getResult(), loginResult.getResult())) { - userService.updateUserLogin(userId, getClientIP()); - } - } - - @Override - public void logout(String token) { - // 删除访问令牌 - OAuth2AccessTokenRespDTO accessTokenRespDTO = oauth2TokenApi.removeAccessToken(token); - if (accessTokenRespDTO == null) { - return; - } - // 删除成功,则记录登出日志 - createLogoutLog(accessTokenRespDTO.getUserId()); - } - - @Override - public void sendSmsCode(Long userId, AppAuthSmsSendReqVO reqVO) { - // 情况 1:如果是修改手机场景,需要校验新手机号是否已经注册,说明不能使用该手机了 - if (Objects.equals(reqVO.getScene(), SmsSceneEnum.MEMBER_UPDATE_MOBILE.getScene())) { - MemberUserDO user = userService.getUserByMobile(reqVO.getMobile()); - if (user != null && !Objects.equals(user.getId(), userId)) { - throw exception(AUTH_MOBILE_USED); - } - } - // 情况 2:如果是重置密码场景,需要校验手机号是存在的 - if (Objects.equals(reqVO.getScene(), SmsSceneEnum.MEMBER_RESET_PASSWORD.getScene())) { - MemberUserDO user= userService.getUserByMobile(reqVO.getMobile()); - if (user == null) { - throw exception(USER_MOBILE_NOT_EXISTS); - } - } - - // 执行发送 - smsCodeApi.sendSmsCode(AuthConvert.INSTANCE.convert(reqVO).setCreateIp(getClientIP())); - } - - @Override - public void validateSmsCode(Long userId, AppAuthSmsValidateReqVO reqVO) { - smsCodeApi.validateSmsCode(AuthConvert.INSTANCE.convert(reqVO)); - } - - @Override - public AppAuthLoginRespVO refreshToken(String refreshToken) { - OAuth2AccessTokenRespDTO accessTokenDO = oauth2TokenApi.refreshAccessToken(refreshToken, - OAuth2ClientConstants.CLIENT_ID_DEFAULT); - return AuthConvert.INSTANCE.convert(accessTokenDO, null); - } - - private void createLogoutLog(Long userId) { - LoginLogCreateReqDTO reqDTO = new LoginLogCreateReqDTO(); - reqDTO.setLogType(LoginLogTypeEnum.LOGOUT_SELF.getType()); - reqDTO.setTraceId(TracerUtils.getTraceId()); - reqDTO.setUserId(userId); - reqDTO.setUserType(getUserType().getValue()); - reqDTO.setUsername(getMobile(userId)); - reqDTO.setUserAgent(ServletUtils.getUserAgent()); - reqDTO.setUserIp(getClientIP()); - reqDTO.setResult(LoginResultEnum.SUCCESS.getResult()); - loginLogApi.createLoginLog(reqDTO); - } - - private String getMobile(Long userId) { - if (userId == null) { - return null; - } - MemberUserDO user = userService.getUser(userId); - return user != null ? user.getMobile() : null; - } - - private UserTypeEnum getUserType() { - return UserTypeEnum.MEMBER; - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/config/MemberConfigService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/config/MemberConfigService.java deleted file mode 100644 index 84961bcc1f..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/config/MemberConfigService.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.member.service.config; - -import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigSaveReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.config.MemberConfigDO; - -import jakarta.validation.Valid; - -/** - * 会员配置 Service 接口 - * - * @author QingX - */ -public interface MemberConfigService { - - /** - * 保存会员配置 - * - * @param saveReqVO 更新信息 - */ - void saveConfig(@Valid MemberConfigSaveReqVO saveReqVO); - - /** - * 获得会员配置 - * - * @return 积分配置 - */ - MemberConfigDO getConfig(); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/config/MemberConfigServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/config/MemberConfigServiceImpl.java deleted file mode 100644 index 16edd1f933..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/config/MemberConfigServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.member.service.config; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigSaveReqVO; -import cn.iocoder.yudao.module.member.convert.config.MemberConfigConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.config.MemberConfigDO; -import cn.iocoder.yudao.module.member.dal.mysql.config.MemberConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - -/** - * 会员配置 Service 实现类 - * - * @author QingX - */ -@Service -@Validated -public class MemberConfigServiceImpl implements MemberConfigService { - - @Resource - private MemberConfigMapper memberConfigMapper; - - @Override - public void saveConfig(MemberConfigSaveReqVO saveReqVO) { - // 存在,则进行更新 - MemberConfigDO dbConfig = getConfig(); - if (dbConfig != null) { - memberConfigMapper.updateById(MemberConfigConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId())); - return; - } - // 不存在,则进行插入 - memberConfigMapper.insert(MemberConfigConvert.INSTANCE.convert(saveReqVO)); - } - - @Override - public MemberConfigDO getConfig() { - List list = memberConfigMapper.selectList(); - return CollectionUtils.getFirst(list); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/group/MemberGroupService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/group/MemberGroupService.java deleted file mode 100644 index aab428f2f9..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/group/MemberGroupService.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.member.service.group; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 用户分组 Service 接口 - * - * @author owen - */ -public interface MemberGroupService { - - /** - * 创建用户分组 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createGroup(@Valid MemberGroupCreateReqVO createReqVO); - - /** - * 更新用户分组 - * - * @param updateReqVO 更新信息 - */ - void updateGroup(@Valid MemberGroupUpdateReqVO updateReqVO); - - /** - * 删除用户分组 - * - * @param id 编号 - */ - void deleteGroup(Long id); - - /** - * 获得用户分组 - * - * @param id 编号 - * @return 用户分组 - */ - MemberGroupDO getGroup(Long id); - - /** - * 获得用户分组列表 - * - * @param ids 编号 - * @return 用户分组列表 - */ - List getGroupList(Collection ids); - - /** - * 获得用户分组分页 - * - * @param pageReqVO 分页查询 - * @return 用户分组分页 - */ - PageResult getGroupPage(MemberGroupPageReqVO pageReqVO); - - - /** - * 获得指定状态的用户分组列表 - * - * @param status 状态 - * @return 用户分组列表 - */ - List getGroupListByStatus(Integer status); - - - /** - * 获得开启状态的用户分组列表 - * - * @return 用户分组列表 - */ - default List getEnableGroupList() { - return getGroupListByStatus(CommonStatusEnum.ENABLE.getStatus()); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/group/MemberGroupServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/group/MemberGroupServiceImpl.java deleted file mode 100644 index 8d4277b17b..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/group/MemberGroupServiceImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.member.service.group; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.group.MemberGroupConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import cn.iocoder.yudao.module.member.dal.mysql.group.MemberGroupMapper; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.GROUP_HAS_USER; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.GROUP_NOT_EXISTS; - -/** - * 用户分组 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class MemberGroupServiceImpl implements MemberGroupService { - - @Resource - private MemberGroupMapper memberGroupMapper; - - @Resource - private MemberUserService memberUserService; - - @Override - public Long createGroup(MemberGroupCreateReqVO createReqVO) { - // 插入 - MemberGroupDO group = MemberGroupConvert.INSTANCE.convert(createReqVO); - memberGroupMapper.insert(group); - // 返回 - return group.getId(); - } - - @Override - public void updateGroup(MemberGroupUpdateReqVO updateReqVO) { - // 校验存在 - validateGroupExists(updateReqVO.getId()); - // 更新 - MemberGroupDO updateObj = MemberGroupConvert.INSTANCE.convert(updateReqVO); - memberGroupMapper.updateById(updateObj); - } - - @Override - public void deleteGroup(Long id) { - // 校验存在 - validateGroupExists(id); - // 校验分组下是否有用户 - validateGroupHasUser(id); - // 删除 - memberGroupMapper.deleteById(id); - } - - void validateGroupExists(Long id) { - if (memberGroupMapper.selectById(id) == null) { - throw exception(GROUP_NOT_EXISTS); - } - } - - void validateGroupHasUser(Long id) { - Long count = memberUserService.getUserCountByGroupId(id); - if (count > 0) { - throw exception(GROUP_HAS_USER); - } - } - - @Override - public MemberGroupDO getGroup(Long id) { - return memberGroupMapper.selectById(id); - } - - @Override - public List getGroupList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return memberGroupMapper.selectBatchIds(ids); - } - - @Override - public PageResult getGroupPage(MemberGroupPageReqVO pageReqVO) { - return memberGroupMapper.selectPage(pageReqVO); - } - - @Override - public List getGroupListByStatus(Integer status) { - return memberGroupMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberExperienceRecordService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberExperienceRecordService.java deleted file mode 100644 index 76470f72af..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberExperienceRecordService.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; - -/** - * 会员经验记录 Service 接口 - * - * @author owen - */ -public interface MemberExperienceRecordService { - - /** - * 获得会员经验记录 - * - * @param id 编号 - * @return 会员经验记录 - */ - MemberExperienceRecordDO getExperienceRecord(Long id); - - /** - * 【管理员】获得会员经验记录分页 - * - * @param pageReqVO 分页查询 - * @return 会员经验记录分页 - */ - PageResult getExperienceRecordPage(MemberExperienceRecordPageReqVO pageReqVO); - - /** - * 【会员】获得会员经验记录分页 - * - * @param userId 用户编号 - * @param pageParam 分页查询 - * @return 会员经验记录分页 - */ - PageResult getExperienceRecordPage(Long userId, PageParam pageParam); - - /** - * 根据业务类型, 创建 经验变动记录 - * - * @param userId 会员编号 - * @param experience 变动经验值 - * @param totalExperience 会员当前的经验 - * @param bizType 业务类型 - * @param bizId 业务ID - */ - void createExperienceRecord(Long userId, Integer experience, Integer totalExperience, - MemberExperienceBizTypeEnum bizType, String bizId); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberExperienceRecordServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberExperienceRecordServiceImpl.java deleted file mode 100644 index 37602866ee..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberExperienceRecordServiceImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordPageReqVO; -import cn.iocoder.yudao.module.member.convert.level.MemberExperienceRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; -import cn.iocoder.yudao.module.member.dal.mysql.level.MemberExperienceRecordMapper; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -/** - * 会员经验记录 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class MemberExperienceRecordServiceImpl implements MemberExperienceRecordService { - - @Resource - private MemberExperienceRecordMapper experienceLogMapper; - - @Override - public MemberExperienceRecordDO getExperienceRecord(Long id) { - return experienceLogMapper.selectById(id); - } - - @Override - public PageResult getExperienceRecordPage(MemberExperienceRecordPageReqVO pageReqVO) { - return experienceLogMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getExperienceRecordPage(Long userId, PageParam pageParam) { - return experienceLogMapper.selectPage(userId, pageParam); - } - - @Override - public void createExperienceRecord(Long userId, Integer experience, Integer totalExperience, - MemberExperienceBizTypeEnum bizType, String bizId) { - String description = StrUtil.format(bizType.getDescription(), experience); - MemberExperienceRecordDO record = MemberExperienceRecordConvert.INSTANCE.convert( - userId, experience, totalExperience, - bizId, bizType.getType(), bizType.getTitle(), description); - experienceLogMapper.insert(record); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelRecordService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelRecordService.java deleted file mode 100644 index b5e4f669e6..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelRecordService.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.record.MemberLevelRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; - -/** - * 会员等级记录 Service 接口 - * - * @author owen - */ -public interface MemberLevelRecordService { - - /** - * 获得会员等级记录 - * - * @param id 编号 - * @return 会员等级记录 - */ - MemberLevelRecordDO getLevelRecord(Long id); - - /** - * 获得会员等级记录分页 - * - * @param pageReqVO 分页查询 - * @return 会员等级记录分页 - */ - PageResult getLevelRecordPage(MemberLevelRecordPageReqVO pageReqVO); - - /** - * 创建会员等级记录 - * - * @param levelRecord 会员等级记录 - */ - void createLevelRecord(MemberLevelRecordDO levelRecord); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelRecordServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelRecordServiceImpl.java deleted file mode 100644 index a8593b12e5..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelRecordServiceImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.record.MemberLevelRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; -import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelRecordMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -/** - * 会员等级记录 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class MemberLevelRecordServiceImpl implements MemberLevelRecordService { - - @Resource - private MemberLevelRecordMapper levelLogMapper; - - @Override - public MemberLevelRecordDO getLevelRecord(Long id) { - return levelLogMapper.selectById(id); - } - - @Override - public PageResult getLevelRecordPage(MemberLevelRecordPageReqVO pageReqVO) { - return levelLogMapper.selectPage(pageReqVO); - } - - @Override - public void createLevelRecord(MemberLevelRecordDO levelRecord) { - levelLogMapper.insert(levelRecord); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelService.java deleted file mode 100644 index ef4de28266..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelListReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateLevelReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 会员等级 Service 接口 - * - * @author owen - */ -public interface MemberLevelService { - - /** - * 创建会员等级 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createLevel(@Valid MemberLevelCreateReqVO createReqVO); - - /** - * 更新会员等级 - * - * @param updateReqVO 更新信息 - */ - void updateLevel(@Valid MemberLevelUpdateReqVO updateReqVO); - - /** - * 删除会员等级 - * - * @param id 编号 - */ - void deleteLevel(Long id); - - /** - * 获得会员等级 - * - * @param id 编号 - * @return 会员等级 - */ - MemberLevelDO getLevel(Long id); - - /** - * 获得会员等级列表 - * - * @param ids 编号 - * @return 会员等级列表 - */ - List getLevelList(Collection ids); - - /** - * 获得会员等级列表 - * - * @param listReqVO 查询参数 - * @return 会员等级列表 - */ - List getLevelList(MemberLevelListReqVO listReqVO); - - /** - * 获得指定状态的会员等级列表 - * - * @param status 状态 - * @return 会员等级列表 - */ - List getLevelListByStatus(Integer status); - - /** - * 获得开启状态的会员等级列表 - * - * @return 会员等级列表 - */ - default List getEnableLevelList() { - return getLevelListByStatus(CommonStatusEnum.ENABLE.getStatus()); - } - - /** - * 修改会员的等级 - * - * @param updateReqVO 修改参数 - */ - void updateUserLevel(MemberUserUpdateLevelReqVO updateReqVO); - - /** - * 增加会员经验 - * - * @param userId 会员ID - * @param experience 经验 - * @param bizType 业务类型 - * @param bizId 业务编号 - */ - void addExperience(Long userId, Integer experience, MemberExperienceBizTypeEnum bizType, String bizId); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImpl.java deleted file mode 100644 index a5add8ad00..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImpl.java +++ /dev/null @@ -1,300 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.NumberUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelListReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateLevelReqVO; -import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; -import cn.iocoder.yudao.module.member.convert.level.MemberLevelRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelMapper; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; - -/** - * 会员等级 Service 实现类 - * - * @author owen - */ -@Slf4j -@Service -@Validated -public class MemberLevelServiceImpl implements MemberLevelService { - - @Resource - private MemberLevelMapper memberLevelMapper; - - @Resource - private MemberLevelRecordService memberLevelRecordService; - @Resource - private MemberExperienceRecordService memberExperienceRecordService; - @Resource - private MemberUserService memberUserService; - - @Override - public Long createLevel(MemberLevelCreateReqVO createReqVO) { - // 校验配置是否有效 - validateConfigValid(null, createReqVO.getName(), createReqVO.getLevel(), createReqVO.getExperience()); - - // 插入 - MemberLevelDO level = MemberLevelConvert.INSTANCE.convert(createReqVO); - memberLevelMapper.insert(level); - // 返回 - return level.getId(); - } - - @Override - public void updateLevel(MemberLevelUpdateReqVO updateReqVO) { - // 校验存在 - validateLevelExists(updateReqVO.getId()); - // 校验配置是否有效 - validateConfigValid(updateReqVO.getId(), updateReqVO.getName(), updateReqVO.getLevel(), updateReqVO.getExperience()); - - // 更新 - MemberLevelDO updateObj = MemberLevelConvert.INSTANCE.convert(updateReqVO); - memberLevelMapper.updateById(updateObj); - } - - @Override - public void deleteLevel(Long id) { - // 校验存在 - validateLevelExists(id); - // 校验分组下是否有用户 - validateLevelHasUser(id); - // 删除 - memberLevelMapper.deleteById(id); - } - - @VisibleForTesting - MemberLevelDO validateLevelExists(Long id) { - MemberLevelDO levelDO = memberLevelMapper.selectById(id); - if (levelDO == null) { - throw exception(LEVEL_NOT_EXISTS); - } - return levelDO; - } - - @VisibleForTesting - void validateNameUnique(List list, Long id, String name) { - for (MemberLevelDO levelDO : list) { - if (ObjUtil.notEqual(levelDO.getName(), name)) { - continue; - } - if (id == null || !id.equals(levelDO.getId())) { - throw exception(LEVEL_NAME_EXISTS, levelDO.getName()); - } - } - } - - @VisibleForTesting - void validateLevelUnique(List list, Long id, Integer level) { - for (MemberLevelDO levelDO : list) { - if (ObjUtil.notEqual(levelDO.getLevel(), level)) { - continue; - } - - if (id == null || !id.equals(levelDO.getId())) { - throw exception(LEVEL_VALUE_EXISTS, levelDO.getLevel(), levelDO.getName()); - } - } - } - - @VisibleForTesting - void validateExperienceOutRange(List list, Long id, Integer level, Integer experience) { - for (MemberLevelDO levelDO : list) { - if (levelDO.getId().equals(id)) { - continue; - } - - if (levelDO.getLevel() < level) { - // 经验大于前一个等级 - if (experience <= levelDO.getExperience()) { - throw exception(LEVEL_EXPERIENCE_MIN, levelDO.getName(), levelDO.getExperience()); - } - } else if (levelDO.getLevel() > level) { - //小于下一个级别 - if (experience >= levelDO.getExperience()) { - throw exception(LEVEL_EXPERIENCE_MAX, levelDO.getName(), levelDO.getExperience()); - } - } - } - } - - @VisibleForTesting - void validateConfigValid(Long id, String name, Integer level, Integer experience) { - List list = memberLevelMapper.selectList(); - // 校验名称唯一 - validateNameUnique(list, id, name); - // 校验等级唯一 - validateLevelUnique(list, id, level); - // 校验升级所需经验是否有效: 大于前一个等级,小于下一个级别 - validateExperienceOutRange(list, id, level, experience); - } - - @VisibleForTesting - void validateLevelHasUser(Long id) { - Long count = memberUserService.getUserCountByLevelId(id); - if (count > 0) { - throw exception(LEVEL_HAS_USER); - } - } - - @Override - public MemberLevelDO getLevel(Long id) { - return id != null && id > 0 ? memberLevelMapper.selectById(id) : null; - } - - @Override - public List getLevelList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return memberLevelMapper.selectBatchIds(ids); - } - - @Override - public List getLevelList(MemberLevelListReqVO listReqVO) { - return memberLevelMapper.selectList(listReqVO); - } - - @Override - public List getLevelListByStatus(Integer status) { - return memberLevelMapper.selectListByStatus(status); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateUserLevel(MemberUserUpdateLevelReqVO updateReqVO) { - MemberUserDO user = memberUserService.getUser(updateReqVO.getId()); - if (user == null) { - throw exception(USER_NOT_EXISTS); - } - // 等级未发生变化 - if (ObjUtil.equal(user.getLevelId(), updateReqVO.getLevelId())) { - return; - } - - // 1. 记录等级变动 - MemberLevelRecordDO levelRecord = new MemberLevelRecordDO() - .setUserId(user.getId()).setRemark(updateReqVO.getReason()); - MemberLevelDO memberLevel = null; - if (updateReqVO.getLevelId() == null) { - // 取消用户等级时,需要扣减经验 - levelRecord.setExperience(-user.getExperience()); - levelRecord.setUserExperience(0); - levelRecord.setDescription("管理员取消了等级"); - } else { - // 复制等级配置 - memberLevel = validateLevelExists(updateReqVO.getLevelId()); - MemberLevelRecordConvert.INSTANCE.copyTo(memberLevel, levelRecord); - // 变动经验值 = 等级的升级经验 - 会员当前的经验;正数为增加经验,负数为扣减经验 - levelRecord.setExperience(memberLevel.getExperience() - user.getExperience()); - levelRecord.setUserExperience(memberLevel.getExperience()); // 会员当前的经验 = 等级的升级经验 - levelRecord.setDescription("管理员调整为:" + memberLevel.getName()); - } - memberLevelRecordService.createLevelRecord(levelRecord); - - // 2. 记录会员经验变动 - memberExperienceRecordService.createExperienceRecord(user.getId(), - levelRecord.getExperience(), levelRecord.getUserExperience(), - MemberExperienceBizTypeEnum.ADMIN, String.valueOf(MemberExperienceBizTypeEnum.ADMIN.getType())); - - // 3. 更新会员表上的等级编号、经验值 - memberUserService.updateUserLevel(user.getId(), updateReqVO.getLevelId(), - levelRecord.getUserExperience()); - - // 4. 给会员发送等级变动消息 - notifyMemberLevelChange(user.getId(), memberLevel); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void addExperience(Long userId, Integer experience, MemberExperienceBizTypeEnum bizType, String bizId) { - if (experience == 0) { - return; - } - if (!bizType.isAdd() && experience > 0) { - experience = -experience; - } - - // 1. 创建经验记录 - MemberUserDO user = memberUserService.getUser(userId); - Integer userExperience = ObjUtil.defaultIfNull(user.getExperience(), 0); - userExperience = NumberUtil.max(userExperience + experience, 0); // 防止扣出负数 - MemberLevelRecordDO levelRecord = new MemberLevelRecordDO() - .setUserId(user.getId()) - .setExperience(experience) - .setUserExperience(userExperience); - memberExperienceRecordService.createExperienceRecord(userId, experience, userExperience, - bizType, bizId); - - // 2.1 保存等级变更记录 - MemberLevelDO newLevel = calculateNewLevel(user, userExperience); - if (newLevel != null) { - MemberLevelRecordConvert.INSTANCE.copyTo(newLevel, levelRecord); - memberLevelRecordService.createLevelRecord(levelRecord); - - // 2.2 给会员发送等级变动消息 - notifyMemberLevelChange(userId, newLevel); - } - - // 3. 更新会员表上的等级编号、经验值 - memberUserService.updateUserLevel(user.getId(), levelRecord.getLevelId(), userExperience); - } - - /** - * 计算会员等级 - * - * @param user 会员 - * @param userExperience 会员当前的经验值 - * @return 会员新的等级,null表示无变化 - */ - private MemberLevelDO calculateNewLevel(MemberUserDO user, int userExperience) { - List list = getEnableLevelList(); - if (CollUtil.isEmpty(list)) { - log.warn("计算会员等级失败:会员等级配置不存在"); - return null; - } - - MemberLevelDO matchLevel = list.stream() - .filter(level -> userExperience >= level.getExperience()) - .max(Comparator.nullsFirst(Comparator.comparing(MemberLevelDO::getLevel))) - .orElse(null); - if (matchLevel == null) { - log.warn("计算会员等级失败:未找到会员{}经验{}对应的等级配置", user.getId(), userExperience); - return null; - } - - // 等级没有变化 - if (ObjectUtil.equal(matchLevel.getId(), user.getLevelId())) { - return null; - } - - return matchLevel; - } - - private void notifyMemberLevelChange(Long userId, MemberLevelDO level) { - //todo: 给会员发消息 - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordService.java deleted file mode 100644 index 74e91880f2..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordService.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.member.service.point; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; - -/** - * 用户积分记录 Service 接口 - * - * @author QingX - */ -public interface MemberPointRecordService { - - /** - * 【管理员】获得积分记录分页 - * - * @param pageReqVO 分页查询 - * @return 签到记录分页 - */ - PageResult getPointRecordPage(MemberPointRecordPageReqVO pageReqVO); - - /** - * 【会员】获得积分记录分页 - * - * @param userId 用户编号 - * @param pageVO 分页查询 - * @return 签到记录分页 - */ - PageResult getPointRecordPage(Long userId, PageParam pageVO); - - /** - * 创建用户积分记录 - * - * @param userId 用户ID - * @param point 变动积分 - * @param bizType 业务类型 - * @param bizId 业务编号 - */ - void createPointRecord(Long userId, Integer point, MemberPointBizTypeEnum bizType, String bizId); -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java deleted file mode 100644 index 8a54914315..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.member.service.point; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.dal.mysql.point.MemberPointRecordMapper; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.USER_POINT_NOT_ENOUGH; - - -/** - * 积分记录 Service 实现类 - * - * @author QingX - */ -@Slf4j -@Service -@Validated -public class MemberPointRecordServiceImpl implements MemberPointRecordService { - - @Resource - private MemberPointRecordMapper memberPointRecordMapper; - - @Resource - private MemberUserService memberUserService; - - @Override - public PageResult getPointRecordPage(MemberPointRecordPageReqVO pageReqVO) { - // 根据用户昵称查询出用户 ids - Set userIds = null; - if (StringUtils.isNotBlank(pageReqVO.getNickname())) { - List users = memberUserService.getUserListByNickname(pageReqVO.getNickname()); - // 如果查询用户结果为空直接返回无需继续查询 - if (CollectionUtils.isEmpty(users)) { - return PageResult.empty(); - } - userIds = convertSet(users, MemberUserDO::getId); - } - // 执行查询 - return memberPointRecordMapper.selectPage(pageReqVO, userIds); - } - - @Override - public PageResult getPointRecordPage(Long userId, PageParam pageVO) { - return memberPointRecordMapper.selectPage(userId, pageVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void createPointRecord(Long userId, Integer point, MemberPointBizTypeEnum bizType, String bizId) { - if (point == 0) { - return; - } - // 1. 校验用户积分余额 - MemberUserDO user = memberUserService.getUser(userId); - Integer userPoint = ObjectUtil.defaultIfNull(user.getPoint(), 0); - int totalPoint = userPoint + point; // 用户变动后的积分 - if (totalPoint < 0) { - throw exception(USER_POINT_NOT_ENOUGH); - } - - // 2. 更新用户积分 - boolean success = memberUserService.updateUserPoint(userId, point); - if (!success) { - throw exception(USER_POINT_NOT_ENOUGH); - } - - // 3. 增加积分记录 - MemberPointRecordDO record = new MemberPointRecordDO() - .setUserId(userId).setBizId(bizId).setBizType(bizType.getType()) - .setTitle(bizType.getName()).setDescription(StrUtil.format(bizType.getDescription(), point)) - .setPoint(point).setTotalPoint(totalPoint); - memberPointRecordMapper.insert(record); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigService.java deleted file mode 100644 index bc1c77177c..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigService.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.member.service.signin; - -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * 签到规则 Service 接口 - * - * @author QingX - */ -public interface MemberSignInConfigService { - - /** - * 创建签到规则 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSignInConfig(@Valid MemberSignInConfigCreateReqVO createReqVO); - - /** - * 更新签到规则 - * - * @param updateReqVO 更新信息 - */ - void updateSignInConfig(@Valid MemberSignInConfigUpdateReqVO updateReqVO); - - /** - * 删除签到规则 - * - * @param id 编号 - */ - void deleteSignInConfig(Long id); - - /** - * 获得签到规则 - * - * @param id 编号 - * @return 签到规则 - */ - MemberSignInConfigDO getSignInConfig(Long id); - - /** - * 获得签到规则列表 - * - * @return 签到规则分页 - */ - List getSignInConfigList(); - - /** - * 获得签到规则列表 - * - * @param status 状态 - * @return 签到规则分页 - */ - List getSignInConfigList(Integer status); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigServiceImpl.java deleted file mode 100644 index 24d7422a7e..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.member.service.signin; - -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_EXISTS; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_NOT_EXISTS; - -/** - * 签到规则 Service 实现类 - * - * @author QingX - */ -@Service -@Validated -public class MemberSignInConfigServiceImpl implements MemberSignInConfigService { - - @Resource - private MemberSignInConfigMapper memberSignInConfigMapper; - - @Override - public Long createSignInConfig(MemberSignInConfigCreateReqVO createReqVO) { - // 判断是否重复插入签到天数 - validateSignInConfigDayDuplicate(createReqVO.getDay(), null); - - // 插入 - MemberSignInConfigDO signInConfig = MemberSignInConfigConvert.INSTANCE.convert(createReqVO); - memberSignInConfigMapper.insert(signInConfig); - // 返回 - return signInConfig.getId(); - } - - @Override - public void updateSignInConfig(MemberSignInConfigUpdateReqVO updateReqVO) { - // 校验存在 - validateSignInConfigExists(updateReqVO.getId()); - // 判断是否重复插入签到天数 - validateSignInConfigDayDuplicate(updateReqVO.getDay(), updateReqVO.getId()); - - // 判断更新 - MemberSignInConfigDO updateObj = MemberSignInConfigConvert.INSTANCE.convert(updateReqVO); - memberSignInConfigMapper.updateById(updateObj); - } - - @Override - public void deleteSignInConfig(Long id) { - // 校验存在 - validateSignInConfigExists(id); - // 删除 - memberSignInConfigMapper.deleteById(id); - } - - private void validateSignInConfigExists(Long id) { - if (memberSignInConfigMapper.selectById(id) == null) { - throw exception(SIGN_IN_CONFIG_NOT_EXISTS); - } - } - - /** - * 校验 day 是否重复 - * - * @param day 天 - * @param id 编号,只有更新的时候会传递 - */ - private void validateSignInConfigDayDuplicate(Integer day, Long id) { - MemberSignInConfigDO config = memberSignInConfigMapper.selectByDay(day); - // 1. 新增时,config 非空,则说明重复 - if (id == null && config != null) { - throw exception(SIGN_IN_CONFIG_EXISTS); - } - // 2. 更新时,如果 config 非空,且 id 不相等,则说明重复 - if (id != null && config != null && !config.getId().equals(id)) { - throw exception(SIGN_IN_CONFIG_EXISTS); - } - } - - @Override - public MemberSignInConfigDO getSignInConfig(Long id) { - return memberSignInConfigMapper.selectById(id); - } - - @Override - public List getSignInConfigList() { - List list = memberSignInConfigMapper.selectList(); - list.sort(Comparator.comparing(MemberSignInConfigDO::getDay)); - return list; - } - - @Override - public List getSignInConfigList(Integer status) { - List list = memberSignInConfigMapper.selectListByStatus(status); - list.sort(Comparator.comparing(MemberSignInConfigDO::getDay)); - return list; - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordService.java deleted file mode 100644 index b22ceed1a6..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordService.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.member.service.signin; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.record.AppMemberSignInRecordSummaryRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; - -/** - * 签到记录 Service 接口 - * - * @author 芋道源码 - */ -public interface MemberSignInRecordService { - - /** - * 【管理员】获得签到记录分页 - * - * @param pageReqVO 分页查询 - * @return 签到记录分页 - */ - PageResult getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO); - - /** - * 【会员】获得签到记录分页 - * - * @param userId 用户编号 - * @param pageParam 分页查询 - * @return 签到记录分页 - */ - PageResult getSignRecordPage(Long userId, PageParam pageParam); - - /** - * 创建签到记录 - * - * @param userId 用户编号 - * @return 签到记录 - */ - MemberSignInRecordDO createSignRecord(Long userId); - - /** - * 根据用户编号,获得个人签到统计信息 - * - * @param userId 用户编号 - * @return 个人签到统计信息 - */ - AppMemberSignInRecordSummaryRespVO getSignInRecordSummary(Long userId); - - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordServiceImpl.java deleted file mode 100644 index 79f7c8729d..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordServiceImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -package cn.iocoder.yudao.module.member.service.signin; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.record.AppMemberSignInRecordSummaryRespVO; -import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInRecordMapper; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import cn.iocoder.yudao.module.member.service.level.MemberLevelService; -import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDate; -import java.util.Comparator; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_RECORD_TODAY_EXISTS; - -/** - * 签到记录 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class MemberSignInRecordServiceImpl implements MemberSignInRecordService { - - @Resource - private MemberSignInRecordMapper signInRecordMapper; - @Resource - private MemberSignInConfigService signInConfigService; - @Resource - private MemberPointRecordService pointRecordService; - @Resource - private MemberLevelService memberLevelService; - - @Resource - private MemberUserService memberUserService; - - @Override - public AppMemberSignInRecordSummaryRespVO getSignInRecordSummary(Long userId) { - // 1. 初始化默认返回信息 - AppMemberSignInRecordSummaryRespVO summary = new AppMemberSignInRecordSummaryRespVO(); - summary.setTotalDay(0); - summary.setContinuousDay(0); - summary.setTodaySignIn(false); - - // 2. 获取用户签到的记录数 - Long signCount = signInRecordMapper.selectCountByUserId(userId); - if (ObjUtil.equal(signCount, 0L)) { - return summary; - } - summary.setTotalDay(signCount.intValue()); // 设置总签到天数 - - // 3. 校验当天是否有签到 - MemberSignInRecordDO lastRecord = signInRecordMapper.selectLastRecordByUserId(userId); - if (lastRecord == null) { - return summary; - } - summary.setTodaySignIn(DateUtils.isToday(lastRecord.getCreateTime())); - - // 4. 校验今天是否签到,没有签到则直接返回 - if (!summary.getTodaySignIn()) { - return summary; - } - // 4.1. 判断连续签到天数 - // TODO @puhui999:连续签到,可以基于 lastRecord 的 day 和当前时间判断呀?按 day 统计连续签到天数可能不准确 - // 1. day 只是记录第几天签到的有可能不连续,比如第一次签到是周一,第二次签到是周三这样 lastRecord 的 day 为 2 但是并不是连续的两天 - // 2. day 超出签到规则的最大天数会重置到从第一天开始签到(我理解为开始下一轮,类似一周签到七天七天结束下周又从周一开始签到) - // 1. 回复:周三签到,day 要归 1 呀。连续签到哈; - List signInRecords = signInRecordMapper.selectListByUserId(userId); - signInRecords.sort(Comparator.comparing(MemberSignInRecordDO::getCreateTime).reversed()); // 根据签到时间倒序 - summary.setContinuousDay(calculateConsecutiveDays(signInRecords)); - return summary; - } - - /** - * 计算连续签到天数 - * - * @param signInRecords 签到记录列表 - * @return int 连续签到天数 - */ - public int calculateConsecutiveDays(List signInRecords) { - int consecutiveDays = 1; // 初始连续天数为1 - LocalDate previousDate = null; - - for (MemberSignInRecordDO record : signInRecords) { - LocalDate currentDate = record.getCreateTime().toLocalDate(); - - if (previousDate != null) { - // 检查相邻两个日期是否连续 - if (currentDate.minusDays(1).isEqual(previousDate)) { - consecutiveDays++; - } else { - // 如果日期不连续,停止遍历 - break; - } - } - - previousDate = currentDate; - } - - return consecutiveDays; - } - - @Override - public PageResult getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO) { - // 根据用户昵称查询出用户ids - Set userIds = null; - if (StringUtils.isNotBlank(pageReqVO.getNickname())) { - List users = memberUserService.getUserListByNickname(pageReqVO.getNickname()); - // 如果查询用户结果为空直接返回无需继续查询 - if (CollUtil.isEmpty(users)) { - return PageResult.empty(); - } - userIds = convertSet(users, MemberUserDO::getId); - } - // 分页查询 - return signInRecordMapper.selectPage(pageReqVO, userIds); - } - - @Override - public PageResult getSignRecordPage(Long userId, PageParam pageParam) { - return signInRecordMapper.selectPage(userId, pageParam); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public MemberSignInRecordDO createSignRecord(Long userId) { - // 1. 获取当前用户最近的签到 - MemberSignInRecordDO lastRecord = signInRecordMapper.selectLastRecordByUserId(userId); - // 1.1. 判断是否重复签到 - validateSigned(lastRecord); - - // 2.1. 获取所有的签到规则 - List signInConfigs = signInConfigService.getSignInConfigList(CommonStatusEnum.ENABLE.getStatus()); - // 2.2. 组合数据 - MemberSignInRecordDO record = MemberSignInRecordConvert.INSTANCE.convert(userId, lastRecord, signInConfigs); - - // 3. 插入签到记录 - signInRecordMapper.insert(record); - - // 4. 增加积分 - if (!ObjectUtils.equalsAny(record.getPoint(), null, 0)) { - pointRecordService.createPointRecord(userId, record.getPoint(), MemberPointBizTypeEnum.SIGN, String.valueOf(record.getId())); - } - // 5. 增加经验 - if (!ObjectUtils.equalsAny(record.getExperience(), null, 0)) { - memberLevelService.addExperience(userId, record.getExperience(), MemberExperienceBizTypeEnum.SIGN_IN, String.valueOf(record.getId())); - } - return record; - } - - private void validateSigned(MemberSignInRecordDO signInRecordDO) { - if (signInRecordDO == null) { - return; - } - if (DateUtils.isToday(signInRecordDO.getCreateTime())) { - throw exception(SIGN_IN_RECORD_TODAY_EXISTS); - } - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagService.java deleted file mode 100644 index f787353589..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagService.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.member.service.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 会员标签 Service 接口 - * - * @author 芋道源码 - */ -public interface MemberTagService { - - /** - * 创建会员标签 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createTag(@Valid MemberTagCreateReqVO createReqVO); - - /** - * 更新会员标签 - * - * @param updateReqVO 更新信息 - */ - void updateTag(@Valid MemberTagUpdateReqVO updateReqVO); - - /** - * 删除会员标签 - * - * @param id 编号 - */ - void deleteTag(Long id); - - /** - * 获得会员标签 - * - * @param id 编号 - * @return 会员标签 - */ - MemberTagDO getTag(Long id); - - /** - * 获得会员标签列表 - * - * @param ids 编号 - * @return 会员标签列表 - */ - List getTagList(Collection ids); - - /** - * 获得会员标签分页 - * - * @param pageReqVO 分页查询 - * @return 会员标签分页 - */ - PageResult getTagPage(MemberTagPageReqVO pageReqVO); - - /** - * 获取标签列表 - * - * @return 标签列表 - */ - List getTagList(); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImpl.java deleted file mode 100644 index 252f101dec..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImpl.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.iocoder.yudao.module.member.service.tag; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.tag.MemberTagConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import cn.iocoder.yudao.module.member.dal.mysql.tag.MemberTagMapper; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; - -/** - * 会员标签 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class MemberTagServiceImpl implements MemberTagService { - - @Resource - private MemberTagMapper memberTagMapper; - - @Resource - private MemberUserService memberUserService; - - @Override - public Long createTag(MemberTagCreateReqVO createReqVO) { - // 校验名称唯一 - validateTagNameUnique(null, createReqVO.getName()); - // 插入 - MemberTagDO tag = MemberTagConvert.INSTANCE.convert(createReqVO); - memberTagMapper.insert(tag); - // 返回 - return tag.getId(); - } - - @Override - public void updateTag(MemberTagUpdateReqVO updateReqVO) { - // 校验存在 - validateTagExists(updateReqVO.getId()); - // 校验名称唯一 - validateTagNameUnique(updateReqVO.getId(), updateReqVO.getName()); - // 更新 - MemberTagDO updateObj = MemberTagConvert.INSTANCE.convert(updateReqVO); - memberTagMapper.updateById(updateObj); - } - - @Override - public void deleteTag(Long id) { - // 校验存在 - validateTagExists(id); - // 校验标签下是否有用户 - validateTagHasUser(id); - // 删除 - memberTagMapper.deleteById(id); - } - - private void validateTagExists(Long id) { - if (memberTagMapper.selectById(id) == null) { - throw exception(TAG_NOT_EXISTS); - } - } - - private void validateTagNameUnique(Long id, String name) { - if (StrUtil.isBlank(name)) { - return; - } - MemberTagDO tag = memberTagMapper.selelctByName(name); - if (tag == null) { - return; - } - - // 如果 id 为空,说明不用比较是否为相同 id 的标签 - if (id == null) { - throw exception(TAG_NAME_EXISTS); - } - if (!tag.getId().equals(id)) { - throw exception(TAG_NAME_EXISTS); - } - } - - void validateTagHasUser(Long id) { - Long count = memberUserService.getUserCountByTagId(id); - if (count > 0) { - throw exception(TAG_HAS_USER); - } - } - - @Override - public MemberTagDO getTag(Long id) { - return memberTagMapper.selectById(id); - } - - @Override - public List getTagList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return memberTagMapper.selectBatchIds(ids); - } - - @Override - public PageResult getTagPage(MemberTagPageReqVO pageReqVO) { - return memberTagMapper.selectPage(pageReqVO); - } - - @Override - public List getTagList() { - return memberTagMapper.selectList(); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java deleted file mode 100644 index 1305c5ae3a..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java +++ /dev/null @@ -1,172 +0,0 @@ -package cn.iocoder.yudao.module.member.service.user; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserResetPasswordReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdateMobileReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdatePasswordReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 会员用户 Service 接口 - * - * @author 芋道源码 - */ -public interface MemberUserService { - - /** - * 通过手机查询用户 - * - * @param mobile 手机 - * @return 用户对象 - */ - MemberUserDO getUserByMobile(String mobile); - - /** - * 基于用户昵称,模糊匹配用户列表 - * - * @param nickname 用户昵称,模糊匹配 - * @return 用户信息的列表 - */ - List getUserListByNickname(String nickname); - - /** - * 基于手机号创建用户。 - * 如果用户已经存在,则直接进行返回 - * - * @param mobile 手机号 - * @param registerIp 注册 IP - * @param terminal 终端 {@link TerminalEnum} - * @return 用户对象 - */ - MemberUserDO createUserIfAbsent(@Mobile String mobile, String registerIp, Integer terminal); - - /** - * 更新用户的最后登陆信息 - * - * @param id 用户编号 - * @param loginIp 登陆 IP - */ - void updateUserLogin(Long id, String loginIp); - - /** - * 通过用户 ID 查询用户 - * - * @param id 用户ID - * @return 用户对象信息 - */ - MemberUserDO getUser(Long id); - - /** - * 通过用户 ID 查询用户们 - * - * @param ids 用户 ID - * @return 用户对象信息数组 - */ - List getUserList(Collection ids); - - /** - * 【会员】修改基本信息 - * - * @param userId 用户编号 - * @param reqVO 基本信息 - */ - void updateUser(Long userId, AppMemberUserUpdateReqVO reqVO); - - /** - * 【会员】修改手机 - * - * @param userId 用户编号 - * @param reqVO 请求信息 - */ - void updateUserMobile(Long userId, AppMemberUserUpdateMobileReqVO reqVO); - - /** - * 【会员】修改密码 - * - * @param userId 用户编号 - * @param reqVO 请求信息 - */ - void updateUserPassword(Long userId, AppMemberUserUpdatePasswordReqVO reqVO); - - /** - * 【会员】忘记密码 - * - * @param reqVO 请求信息 - */ - void resetUserPassword(AppMemberUserResetPasswordReqVO reqVO); - - /** - * 判断密码是否匹配 - * - * @param rawPassword 未加密的密码 - * @param encodedPassword 加密后的密码 - * @return 是否匹配 - */ - boolean isPasswordMatch(String rawPassword, String encodedPassword); - - /** - * 【管理员】更新会员用户 - * - * @param updateReqVO 更新信息 - */ - void updateUser(@Valid MemberUserUpdateReqVO updateReqVO); - - /** - * 【管理员】获得会员用户分页 - * - * @param pageReqVO 分页查询 - * @return 会员用户分页 - */ - PageResult getUserPage(MemberUserPageReqVO pageReqVO); - - /** - * 更新用户的等级和经验 - * - * @param id 用户编号 - * @param levelId 用户等级 - * @param experience 用户经验 - */ - void updateUserLevel(Long id, Long levelId, Integer experience); - - /** - * 获得指定用户分组下的用户数量 - * - * @param groupId 用户分组编号 - * @return 用户数量 - */ - Long getUserCountByGroupId(Long groupId); - - /** - * 获得指定用户等级下的用户数量 - * - * @param levelId 用户等级编号 - * @return 用户数量 - */ - Long getUserCountByLevelId(Long levelId); - - /** - * 获得指定会员标签下的用户数量 - * - * @param tagId 用户标签编号 - * @return 用户数量 - */ - Long getUserCountByTagId(Long tagId); - - /** - * 更新用户的积分 - * - * @param userId 用户编号 - * @param point 积分数量 - * @return 更新结果 - */ - boolean updateUserPoint(Long userId, Integer point); -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java deleted file mode 100644 index a7466d22c6..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java +++ /dev/null @@ -1,287 +0,0 @@ -package cn.iocoder.yudao.module.member.service.user; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserResetPasswordReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdateMobileReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdatePasswordReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.auth.AuthConvert; -import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper; -import cn.iocoder.yudao.module.member.mq.producer.user.MemberUserProducer; -import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; - -/** - * 会员 User Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Valid -@Slf4j -public class MemberUserServiceImpl implements MemberUserService { - - @Resource - private MemberUserMapper memberUserMapper; - - @Resource - private SmsCodeApi smsCodeApi; - - @Resource - private PasswordEncoder passwordEncoder; - - @Resource - private MemberUserProducer memberUserProducer; - - @Override - public MemberUserDO getUserByMobile(String mobile) { - return memberUserMapper.selectByMobile(mobile); - } - - @Override - public List getUserListByNickname(String nickname) { - return memberUserMapper.selectListByNicknameLike(nickname); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public MemberUserDO createUserIfAbsent(String mobile, String registerIp, Integer terminal) { - // 用户已经存在 - MemberUserDO user = memberUserMapper.selectByMobile(mobile); - if (user != null) { - return user; - } - // 用户不存在,则进行创建 - return createUser(mobile, registerIp, terminal); - } - - private MemberUserDO createUser(String mobile, String registerIp, Integer terminal) { - // 生成密码 - String password = IdUtil.fastSimpleUUID(); - // 插入用户 - MemberUserDO user = new MemberUserDO(); - user.setMobile(mobile); - user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 - user.setPassword(encodePassword(password)); // 加密密码 - user.setRegisterIp(registerIp); - user.setRegisterTerminal(terminal); - memberUserMapper.insert(user); - - // 发送 MQ 消息:用户创建 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - - @Override - public void afterCommit() { - memberUserProducer.sendUserCreateMessage(user.getId()); - } - - }); - return user; - } - - @Override - public void updateUserLogin(Long id, String loginIp) { - memberUserMapper.updateById(new MemberUserDO().setId(id) - .setLoginIp(loginIp).setLoginDate(LocalDateTime.now())); - } - - @Override - public MemberUserDO getUser(Long id) { - return memberUserMapper.selectById(id); - } - - @Override - public List getUserList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return memberUserMapper.selectBatchIds(ids); - } - - @Override - public void updateUser(Long userId, AppMemberUserUpdateReqVO reqVO) { - memberUserMapper.updateById(new MemberUserDO().setId(userId) - .setNickname(reqVO.getNickname()).setAvatar(reqVO.getAvatar())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateUserMobile(Long userId, AppMemberUserUpdateMobileReqVO reqVO) { - // 检测用户是否存在 - MemberUserDO user = validateUserExists(userId); - // 校验新手机是否已经被绑定 - validateMobileUnique(null, reqVO.getMobile()); - - // 校验旧手机和旧验证码 - smsCodeApi.useSmsCode(new SmsCodeUseReqDTO().setMobile(user.getMobile()).setCode(reqVO.getOldCode()) - .setScene(SmsSceneEnum.MEMBER_UPDATE_MOBILE.getScene()).setUsedIp(getClientIP())); - // 使用新验证码 - smsCodeApi.useSmsCode(new SmsCodeUseReqDTO().setMobile(reqVO.getMobile()).setCode(reqVO.getCode()) - .setScene(SmsSceneEnum.MEMBER_UPDATE_MOBILE.getScene()).setUsedIp(getClientIP())); - - // 更新用户手机 - memberUserMapper.updateById(MemberUserDO.builder().id(userId).mobile(reqVO.getMobile()).build()); - } - - @Override - public void updateUserPassword(Long userId, AppMemberUserUpdatePasswordReqVO reqVO) { - // 检测用户是否存在 - MemberUserDO user = validateUserExists(userId); - // 校验验证码 - smsCodeApi.useSmsCode(new SmsCodeUseReqDTO().setMobile(user.getMobile()).setCode(reqVO.getCode()) - .setScene(SmsSceneEnum.MEMBER_UPDATE_PASSWORD.getScene()).setUsedIp(getClientIP())); - - // 更新用户密码 - memberUserMapper.updateById(MemberUserDO.builder().id(userId) - .password(passwordEncoder.encode(reqVO.getPassword())).build()); - } - - @Override - public void resetUserPassword(AppMemberUserResetPasswordReqVO reqVO) { - // 检验用户是否存在 - MemberUserDO user = validateUserExists(reqVO.getMobile()); - - // 使用验证码 - smsCodeApi.useSmsCode(AuthConvert.INSTANCE.convert(reqVO, SmsSceneEnum.MEMBER_RESET_PASSWORD, - getClientIP())); - - // 更新密码 - memberUserMapper.updateById(MemberUserDO.builder().id(user.getId()) - .password(passwordEncoder.encode(reqVO.getPassword())).build()); - } - - private MemberUserDO validateUserExists(String mobile) { - MemberUserDO user = memberUserMapper.selectByMobile(mobile); - if (user == null) { - throw exception(USER_MOBILE_NOT_EXISTS); - } - return user; - } - - @Override - public boolean isPasswordMatch(String rawPassword, String encodedPassword) { - return passwordEncoder.matches(rawPassword, encodedPassword); - } - - /** - * 对密码进行加密 - * - * @param password 密码 - * @return 加密后的密码 - */ - private String encodePassword(String password) { - return passwordEncoder.encode(password); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateUser(MemberUserUpdateReqVO updateReqVO) { - // 校验存在 - validateUserExists(updateReqVO.getId()); - // 校验手机唯一 - validateMobileUnique(updateReqVO.getId(), updateReqVO.getMobile()); - - // 更新 - MemberUserDO updateObj = MemberUserConvert.INSTANCE.convert(updateReqVO); - memberUserMapper.updateById(updateObj); - } - - @VisibleForTesting - MemberUserDO validateUserExists(Long id) { - if (id == null) { - return null; - } - MemberUserDO user = memberUserMapper.selectById(id); - if (user == null) { - throw exception(USER_NOT_EXISTS); - } - return user; - } - - @VisibleForTesting - void validateMobileUnique(Long id, String mobile) { - if (StrUtil.isBlank(mobile)) { - return; - } - MemberUserDO user = memberUserMapper.selectByMobile(mobile); - if (user == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的用户 - if (id == null) { - throw exception(USER_MOBILE_USED, mobile); - } - if (!user.getId().equals(id)) { - throw exception(USER_MOBILE_USED, mobile); - } - } - - @Override - public PageResult getUserPage(MemberUserPageReqVO pageReqVO) { - return memberUserMapper.selectPage(pageReqVO); - } - - @Override - public void updateUserLevel(Long id, Long levelId, Integer experience) { - // 0 代表无等级:防止UpdateById时,会被过滤掉的问题 - levelId = ObjectUtil.defaultIfNull(levelId, 0L); - memberUserMapper.updateById(new MemberUserDO() - .setId(id) - .setLevelId(levelId).setExperience(experience) - ); - } - - @Override - public Long getUserCountByGroupId(Long groupId) { - return memberUserMapper.selectCountByGroupId(groupId); - } - - @Override - public Long getUserCountByLevelId(Long levelId) { - return memberUserMapper.selectCountByLevelId(levelId); - } - - @Override - public Long getUserCountByTagId(Long tagId) { - return memberUserMapper.selectCountByTagId(tagId); - } - - @Override - public boolean updateUserPoint(Long id, Integer point) { - if (point > 0) { - memberUserMapper.updatePointIncr(id, point); - } else if (point < 0) { - return memberUserMapper.updatePointDecr(id, point) > 0; - } - return true; - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/address/MemberAddressServiceImplTest.java b/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/address/MemberAddressServiceImplTest.java deleted file mode 100644 index 2af6408e59..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/address/MemberAddressServiceImplTest.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.member.service.address; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; -import cn.iocoder.yudao.module.member.dal.mysql.address.MemberAddressMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.ADDRESS_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; - -/** - * {@link AddressServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(AddressServiceImpl.class) -public class MemberAddressServiceImplTest extends BaseDbUnitTest { - - @Resource - private AddressServiceImpl addressService; - - @Resource - private MemberAddressMapper addressMapper; - - @Test - public void testCreateAddress_success() { - // 准备参数 - AppAddressCreateReqVO reqVO = randomPojo(AppAddressCreateReqVO.class); - - // 调用 - Long addressId = addressService.createAddress(randomLongId(), reqVO); - // 断言 - assertNotNull(addressId); - // 校验记录的属性是否正确 - MemberAddressDO address = addressMapper.selectById(addressId); - assertPojoEquals(reqVO, address); - } - - @Test - public void testUpdateAddress_success() { - // mock 数据 - MemberAddressDO dbAddress = randomPojo(MemberAddressDO.class); - addressMapper.insert(dbAddress);// @Sql: 先插入出一条存在的数据 - // 准备参数 - AppAddressUpdateReqVO reqVO = randomPojo(AppAddressUpdateReqVO.class, o -> { - o.setId(dbAddress.getId()); // 设置更新的 ID - }); - - // 调用 - addressService.updateAddress(dbAddress.getUserId(), reqVO); - // 校验是否更新正确 - MemberAddressDO address = addressMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, address); - } - - @Test - public void testUpdateAddress_notExists() { - // 准备参数 - AppAddressUpdateReqVO reqVO = randomPojo(AppAddressUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> addressService.updateAddress(randomLongId(), reqVO), ADDRESS_NOT_EXISTS); - } - - @Test - public void testDeleteAddress_success() { - // mock 数据 - MemberAddressDO dbAddress = randomPojo(MemberAddressDO.class); - addressMapper.insert(dbAddress);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbAddress.getId(); - - // 调用 - addressService.deleteAddress(dbAddress.getUserId(), id); - // 校验数据不存在了 - assertNull(addressMapper.selectById(id)); - } - - @Test - public void testDeleteAddress_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> addressService.deleteAddress(randomLongId(), id), ADDRESS_NOT_EXISTS); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceTest.java b/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceTest.java deleted file mode 100644 index 04f894905d..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceTest.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.member.service.auth; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import cn.iocoder.yudao.module.system.api.logger.LoginLogApi; -import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; -import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; -import cn.iocoder.yudao.module.system.api.social.SocialUserApi; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.security.crypto.password.PasswordEncoder; - -import jakarta.annotation.Resource; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; - -// TODO @芋艿:单测的 review,等逻辑都达成一致后 -/** - * {@link MemberAuthService} 的单元测试类 - * - * @author 宋天 - */ -@Import({MemberAuthServiceImpl.class, YudaoRedisAutoConfiguration.class}) -public class MemberAuthServiceTest extends BaseDbAndRedisUnitTest { - - // TODO @芋艿:登录相关的单测,待补全 - - @Resource - private MemberAuthServiceImpl authService; - - @MockBean - private MemberUserService userService; - @MockBean - private SmsCodeApi smsCodeApi; - @MockBean - private LoginLogApi loginLogApi; - @MockBean - private OAuth2TokenApi oauth2TokenApi; - @MockBean - private SocialUserApi socialUserApi; - @MockBean - private PasswordEncoder passwordEncoder; - - @Resource - private MemberUserMapper memberUserMapper; - - // TODO 芋艿:后续重构这个单测 -// @Test -// public void testUpdatePassword_success(){ -// // 准备参数 -// MemberUserDO userDO = randomUserDO(); -// memberUserMapper.insert(userDO); -// -// // 新密码 -// String newPassword = randomString(); -// -// // 请求实体 -// AppMemberUserUpdatePasswordReqVO reqVO = AppMemberUserUpdatePasswordReqVO.builder() -// .oldPassword(userDO.getPassword()) -// .password(newPassword) -// .build(); -// -// // 测试桩 -// // 这两个相等是为了返回ture这个结果 -// when(passwordEncoder.matches(reqVO.getOldPassword(),reqVO.getOldPassword())).thenReturn(true); -// when(passwordEncoder.encode(newPassword)).thenReturn(newPassword); -// -// // 更新用户密码 -// authService.updatePassword(userDO.getId(), reqVO); -// assertEquals(memberUserMapper.selectById(userDO.getId()).getPassword(),newPassword); -// } - - // TODO 芋艿:后续重构这个单测 -// @Test -// public void testResetPassword_success(){ -// // 准备参数 -// MemberUserDO userDO = randomUserDO(); -// memberUserMapper.insert(userDO); -// -// // 随机密码 -// String password = randomNumbers(11); -// // 随机验证码 -// String code = randomNumbers(4); -// -// // mock -// when(passwordEncoder.encode(password)).thenReturn(password); -// -// // 更新用户密码 -// AppMemberUserResetPasswordReqVO reqVO = new AppMemberUserResetPasswordReqVO(); -// reqVO.setMobile(userDO.getMobile()); -// reqVO.setPassword(password); -// reqVO.setCode(code); -// -// authService.resetPassword(reqVO); -// assertEquals(memberUserMapper.selectById(userDO.getId()).getPassword(),password); -// } - - // ========== 随机对象 ========== - - @SafeVarargs - private static MemberUserDO randomUserDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setPassword(randomString()); - }; - return randomPojo(MemberUserDO.class, ArrayUtils.append(consumer, consumers)); - } - - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/group/MemberGroupServiceImplTest.java b/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/group/MemberGroupServiceImplTest.java deleted file mode 100644 index 3762b0f3b6..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/group/MemberGroupServiceImplTest.java +++ /dev/null @@ -1,160 +0,0 @@ -package cn.iocoder.yudao.module.member.service.group; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import cn.iocoder.yudao.module.member.dal.mysql.group.MemberGroupMapper; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.GROUP_HAS_USER; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.GROUP_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -// TODO 芋艿:完全 review 完,在去 review 单测 -/** - * {@link MemberGroupServiceImpl} 的单元测试类 - * - * @author owen - */ -@Import(MemberGroupServiceImpl.class) -public class MemberGroupServiceImplTest extends BaseDbUnitTest { - - @Resource - private MemberGroupServiceImpl groupService; - - @Resource - private MemberGroupMapper groupMapper; - - @MockBean - private MemberUserService memberUserService; - - @Test - public void testCreateGroup_success() { - // 准备参数 - MemberGroupCreateReqVO reqVO = randomPojo(MemberGroupCreateReqVO.class, - o -> o.setStatus(randomCommonStatus())); - - // 调用 - Long groupId = groupService.createGroup(reqVO); - // 断言 - assertNotNull(groupId); - // 校验记录的属性是否正确 - MemberGroupDO group = groupMapper.selectById(groupId); - assertPojoEquals(reqVO, group); - } - - @Test - public void testUpdateGroup_success() { - // mock 数据 - MemberGroupDO dbGroup = randomPojo(MemberGroupDO.class); - groupMapper.insert(dbGroup);// @Sql: 先插入出一条存在的数据 - // 准备参数 - MemberGroupUpdateReqVO reqVO = randomPojo(MemberGroupUpdateReqVO.class, o -> { - o.setId(dbGroup.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - }); - - // 调用 - groupService.updateGroup(reqVO); - // 校验是否更新正确 - MemberGroupDO group = groupMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, group); - } - - @Test - public void testUpdateGroup_notExists() { - // 准备参数 - MemberGroupUpdateReqVO reqVO = randomPojo(MemberGroupUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> groupService.updateGroup(reqVO), GROUP_NOT_EXISTS); - } - - @Test - public void testDeleteGroup_success() { - // mock 数据 - MemberGroupDO dbGroup = randomPojo(MemberGroupDO.class); - groupMapper.insert(dbGroup);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbGroup.getId(); - - // 调用 - groupService.deleteGroup(id); - // 校验数据不存在了 - assertNull(groupMapper.selectById(id)); - } - - @Test - public void testDeleteGroup_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> groupService.deleteGroup(id), GROUP_NOT_EXISTS); - } - - @Test - public void testDeleteGroup_hasUser() { - // mock 数据 - MemberGroupDO dbGroup = randomPojo(MemberGroupDO.class); - groupMapper.insert(dbGroup);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbGroup.getId(); - - // mock 会员数据 - when(memberUserService.getUserCountByGroupId(eq(id))).thenReturn(1L); - - // 调用, 并断言异常 - assertServiceException(() -> groupService.deleteGroup(id), GROUP_HAS_USER); - } - - @Test - public void testGetGroupPage() { - String name = randomString(); - int status = CommonStatusEnum.ENABLE.getStatus(); - - // mock 数据 - MemberGroupDO dbGroup = randomPojo(MemberGroupDO.class, o -> { // 等会查询到 - o.setName(name); - o.setStatus(status); - o.setCreateTime(buildTime(2023, 2, 18)); - }); - groupMapper.insert(dbGroup); - // 测试 name 不匹配 - groupMapper.insert(cloneIgnoreId(dbGroup, o -> o.setName(""))); - // 测试 status 不匹配 - groupMapper.insert(cloneIgnoreId(dbGroup, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - groupMapper.insert(cloneIgnoreId(dbGroup, o -> o.setCreateTime(null))); - // 准备参数 - MemberGroupPageReqVO reqVO = new MemberGroupPageReqVO(); - reqVO.setName(name); - reqVO.setStatus(status); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = groupService.getGroupPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbGroup, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImplTest.java b/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImplTest.java deleted file mode 100644 index 9986b4a718..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImplTest.java +++ /dev/null @@ -1,268 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelListReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelMapper; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomInt; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; - -// TODO 芋艿:完全 review 完,在去 review 单测 -/** - * {@link MemberLevelServiceImpl} 的单元测试类 - * - * @author owen - */ -@Import(MemberLevelServiceImpl.class) -public class MemberLevelServiceImplTest extends BaseDbUnitTest { - - @Resource - private MemberLevelServiceImpl levelService; - - @Resource - private MemberLevelMapper memberlevelMapper; - - @MockBean - private MemberLevelRecordService memberLevelRecordService; - @MockBean - private MemberExperienceRecordService memberExperienceRecordService; - @MockBean - private MemberUserService memberUserService; - - @Test - public void testCreateLevel_success() { - // 准备参数 - MemberLevelCreateReqVO reqVO = randomPojo(MemberLevelCreateReqVO.class, o -> { - o.setDiscountPercent(randomInt()); - o.setIcon(randomURL()); - o.setBackgroundUrl(randomURL()); - o.setStatus(randomCommonStatus()); - }); - - // 调用 - Long levelId = levelService.createLevel(reqVO); - // 断言 - assertNotNull(levelId); - // 校验记录的属性是否正确 - MemberLevelDO level = memberlevelMapper.selectById(levelId); - assertPojoEquals(reqVO, level); - } - - @Test - public void testUpdateLevel_success() { - // mock 数据 - MemberLevelDO dbLevel = randomPojo(MemberLevelDO.class); - memberlevelMapper.insert(dbLevel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - MemberLevelUpdateReqVO reqVO = randomPojo(MemberLevelUpdateReqVO.class, o -> { - o.setId(dbLevel.getId()); // 设置更新的 ID - //以下要保持一致 - o.setName(dbLevel.getName()); - o.setLevel(dbLevel.getLevel()); - o.setExperience(dbLevel.getExperience()); - //以下是要修改的字段 - o.setDiscountPercent(randomInt()); - o.setIcon(randomURL()); - o.setBackgroundUrl(randomURL()); - o.setStatus(randomCommonStatus()); - }); - - // 调用 - levelService.updateLevel(reqVO); - // 校验是否更新正确 - MemberLevelDO level = memberlevelMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, level); - } - - @Test - public void testUpdateLevel_notExists() { - // 准备参数 - MemberLevelUpdateReqVO reqVO = randomPojo(MemberLevelUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> levelService.updateLevel(reqVO), LEVEL_NOT_EXISTS); - } - - @Test - public void testDeleteLevel_success() { - // mock 数据 - MemberLevelDO dbLevel = randomPojo(MemberLevelDO.class); - memberlevelMapper.insert(dbLevel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbLevel.getId(); - - // 调用 - levelService.deleteLevel(id); - // 校验数据不存在了 - assertNull(memberlevelMapper.selectById(id)); - } - - @Test - public void testDeleteLevel_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> levelService.deleteLevel(id), LEVEL_NOT_EXISTS); - } - - @Test - public void testGetLevelList() { - // mock 数据 - MemberLevelDO dbLevel = randomPojo(MemberLevelDO.class, o -> { // 等会查询到 - o.setName("黄金会员"); - o.setStatus(1); - }); - memberlevelMapper.insert(dbLevel); - // 测试 name 不匹配 - memberlevelMapper.insert(cloneIgnoreId(dbLevel, o -> o.setName(""))); - // 测试 status 不匹配 - memberlevelMapper.insert(cloneIgnoreId(dbLevel, o -> o.setStatus(0))); - // 准备参数 - MemberLevelListReqVO reqVO = new MemberLevelListReqVO(); - reqVO.setName("黄金会员"); - reqVO.setStatus(1); - - // 调用 - List list = levelService.getLevelList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbLevel, list.get(0)); - } - - @Test - public void testCreateLevel_nameUnique() { - // 准备参数 - String name = randomString(); - - // mock 数据 - memberlevelMapper.insert(randomLevelDO(o -> o.setName(name))); - - // 调用,校验异常 - List list = memberlevelMapper.selectList(); - assertServiceException(() -> levelService.validateNameUnique(list, null, name), LEVEL_NAME_EXISTS, name); - } - - @Test - public void testUpdateLevel_nameUnique() { - // 准备参数 - Long id = randomLongId(); - String name = randomString(); - - // mock 数据 - memberlevelMapper.insert(randomLevelDO(o -> o.setName(name))); - - // 调用,校验异常 - List list = memberlevelMapper.selectList(); - assertServiceException(() -> levelService.validateNameUnique(list, id, name), LEVEL_NAME_EXISTS, name); - } - - @Test - public void testCreateLevel_levelUnique() { - // 准备参数 - Integer level = randomInteger(); - String name = randomString(); - - // mock 数据 - memberlevelMapper.insert(randomLevelDO(o -> { - o.setLevel(level); - o.setName(name); - })); - - // 调用,校验异常 - List list = memberlevelMapper.selectList(); - assertServiceException(() -> levelService.validateLevelUnique(list, null, level), LEVEL_VALUE_EXISTS, level, name); - } - - @Test - public void testUpdateLevel_levelUnique() { - // 准备参数 - Long id = randomLongId(); - Integer level = randomInteger(); - String name = randomString(); - - // mock 数据 - memberlevelMapper.insert(randomLevelDO(o -> { - o.setLevel(level); - o.setName(name); - })); - - // 调用,校验异常 - List list = memberlevelMapper.selectList(); - assertServiceException(() -> levelService.validateLevelUnique(list, id, level), LEVEL_VALUE_EXISTS, level, name); - } - - @Test - public void testCreateLevel_experienceOutRange() { - // 准备参数 - int level = 10; - int experience = 10; - String name = randomString(); - - // mock 数据 - memberlevelMapper.insert(randomLevelDO(o -> { - o.setLevel(level); - o.setExperience(experience); - o.setName(name); - })); - List list = memberlevelMapper.selectList(); - - // 调用,校验异常 - assertServiceException(() -> levelService.validateExperienceOutRange(list, null, level + 1, experience - 1), LEVEL_EXPERIENCE_MIN, name, level); - // 调用,校验异常 - assertServiceException(() -> levelService.validateExperienceOutRange(list, null, level - 1, experience + 1), LEVEL_EXPERIENCE_MAX, name, level); - } - - @Test - public void testUpdateLevel_experienceOutRange() { - // 准备参数 - int level = 10; - int experience = 10; - Long id = randomLongId(); - String name = randomString(); - - // mock 数据 - memberlevelMapper.insert(randomLevelDO(o -> { - o.setLevel(level); - o.setExperience(experience); - o.setName(name); - })); - List list = memberlevelMapper.selectList(); - - // 调用,校验异常 - assertServiceException(() -> levelService.validateExperienceOutRange(list, id, level + 1, experience - 1), LEVEL_EXPERIENCE_MIN, name, level); - // 调用,校验异常 - assertServiceException(() -> levelService.validateExperienceOutRange(list, id, level - 1, experience + 1), LEVEL_EXPERIENCE_MAX, name, level); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static MemberLevelDO randomLevelDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setDiscountPercent(randomInt(0, 100)); - o.setIcon(randomURL()); - o.setBackgroundUrl(randomURL()); - }; - return randomPojo(MemberLevelDO.class, ArrayUtils.append(consumer, consumers)); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImplTest.java b/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImplTest.java deleted file mode 100644 index 1bc361cd09..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImplTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.module.member.service.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import cn.iocoder.yudao.module.member.dal.mysql.tag.MemberTagMapper; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.TAG_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -// TODO 芋艿:完全 review 完,在去 review 单测 -/** - * {@link MemberTagServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(MemberTagServiceImpl.class) -public class MemberTagServiceImplTest extends BaseDbUnitTest { - - @Resource - private MemberTagServiceImpl tagService; - - @Resource - private MemberTagMapper tagMapper; - - @MockBean - private MemberUserService memberUserService; - - @Test - public void testCreateTag_success() { - // 准备参数 - MemberTagCreateReqVO reqVO = randomPojo(MemberTagCreateReqVO.class); - - // 调用 - Long tagId = tagService.createTag(reqVO); - // 断言 - assertNotNull(tagId); - // 校验记录的属性是否正确 - MemberTagDO tag = tagMapper.selectById(tagId); - assertPojoEquals(reqVO, tag); - } - - @Test - public void testUpdateTag_success() { - // mock 数据 - MemberTagDO dbTag = randomPojo(MemberTagDO.class); - tagMapper.insert(dbTag);// @Sql: 先插入出一条存在的数据 - // 准备参数 - MemberTagUpdateReqVO reqVO = randomPojo(MemberTagUpdateReqVO.class, o -> { - o.setId(dbTag.getId()); // 设置更新的 ID - }); - - // 调用 - tagService.updateTag(reqVO); - // 校验是否更新正确 - MemberTagDO tag = tagMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, tag); - } - - @Test - public void testUpdateTag_notExists() { - // 准备参数 - MemberTagUpdateReqVO reqVO = randomPojo(MemberTagUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> tagService.updateTag(reqVO), TAG_NOT_EXISTS); - } - - @Test - public void testDeleteTag_success() { - // mock 数据 - MemberTagDO dbTag = randomPojo(MemberTagDO.class); - tagMapper.insert(dbTag);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbTag.getId(); - - // 调用 - tagService.deleteTag(id); - // 校验数据不存在了 - assertNull(tagMapper.selectById(id)); - } - - @Test - public void testDeleteTag_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> tagService.deleteTag(id), TAG_NOT_EXISTS); - } - - @Test - public void testGetTagPage() { - // mock 数据 - MemberTagDO dbTag = randomPojo(MemberTagDO.class, o -> { // 等会查询到 - o.setName("test"); - o.setCreateTime(buildTime(2023, 2, 18)); - }); - tagMapper.insert(dbTag); - // 测试 name 不匹配 - tagMapper.insert(cloneIgnoreId(dbTag, o -> o.setName("ne"))); - // 测试 createTime 不匹配 - tagMapper.insert(cloneIgnoreId(dbTag, o -> o.setCreateTime(null))); - // 准备参数 - MemberTagPageReqVO reqVO = new MemberTagPageReqVO(); - reqVO.setName("test"); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = tagService.getTagPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbTag, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImplTest.java b/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImplTest.java deleted file mode 100644 index 45cfb6a0b1..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImplTest.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.member.service.user; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest; -import cn.iocoder.yudao.module.infra.api.file.FileApi; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdateMobileReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper; -import cn.iocoder.yudao.module.member.service.auth.MemberAuthServiceImpl; -import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.security.crypto.password.PasswordEncoder; - -import jakarta.annotation.Resource; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.hutool.core.util.RandomUtil.randomNumbers; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; - -// TODO @芋艿:单测的 review,等逻辑都达成一致后 -/** - * {@link MemberUserServiceImpl} 的单元测试类 - * - * @author 宋天 - */ -@Disabled -@Import({MemberUserServiceImpl.class, YudaoRedisAutoConfiguration.class}) -public class MemberUserServiceImplTest extends BaseDbAndRedisUnitTest { - - @Resource - private MemberUserServiceImpl memberUserService; - - @Resource - private StringRedisTemplate stringRedisTemplate; - - @Resource - private MemberUserMapper userMapper; - - @MockBean - private MemberAuthServiceImpl authService; - - @MockBean - private PasswordEncoder passwordEncoder; - - @MockBean - private SmsCodeApi smsCodeApi; - @MockBean - private FileApi fileApi; - - // TODO 芋艿:后续重构这个单测 -// @Test -// public void testUpdateNickName_success(){ -// // mock 数据 -// MemberUserDO userDO = randomUserDO(); -// userMapper.insert(userDO); -// -// // 随机昵称 -// String newNickName = randomString(); -// -// // 调用接口修改昵称 -// memberUserService.updateUser(userDO.getId(),newNickName); -// // 查询新修改后的昵称 -// String nickname = memberUserService.getUser(userDO.getId()).getNickname(); -// // 断言 -// assertEquals(newNickName,nickname); -// } -// -// @Test -// public void testUpdateAvatar_success() throws Exception { -// // mock 数据 -// MemberUserDO dbUser = randomUserDO(); -// userMapper.insert(dbUser); -// -// // 准备参数 -// Long userId = dbUser.getId(); -// byte[] avatarFileBytes = randomBytes(10); -// ByteArrayInputStream avatarFile = new ByteArrayInputStream(avatarFileBytes); -// // mock 方法 -// String avatar = randomString(); -// when(fileApi.createFile(eq(avatarFileBytes))).thenReturn(avatar); -// // 调用 -// String str = memberUserService.updateUserAvatar(userId, avatarFile); -// // 断言 -// assertEquals(avatar, str); -// } - - @Test - @Disabled // TODO 芋艿:后续再修复 - public void updateMobile_success(){ - // mock数据 - String oldMobile = randomNumbers(11); - MemberUserDO userDO = randomUserDO(); - userDO.setMobile(oldMobile); - userMapper.insert(userDO); - - // TODO 芋艿:需要修复该单元测试,重构多模块带来的 - // 旧手机和旧验证码 -// SmsCodeDO codeDO = new SmsCodeDO(); - String oldCode = RandomUtil.randomString(4); -// codeDO.setMobile(userDO.getMobile()); -// codeDO.setCode(oldCode); -// codeDO.setScene(SmsSceneEnum.MEMBER_UPDATE_MOBILE.getScene()); -// codeDO.setUsed(Boolean.FALSE); -// when(smsCodeService.checkCodeIsExpired(codeDO.getMobile(),codeDO.getCode(),codeDO.getScene())).thenReturn(codeDO); - - // 更新手机号 - String newMobile = randomNumbers(11); - String newCode = randomNumbers(4); - AppMemberUserUpdateMobileReqVO reqVO = new AppMemberUserUpdateMobileReqVO(); - reqVO.setMobile(newMobile); - reqVO.setCode(newCode); - reqVO.setOldCode(oldCode); - memberUserService.updateUserMobile(userDO.getId(),reqVO); - - assertEquals(memberUserService.getUser(userDO.getId()).getMobile(),newMobile); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static MemberUserDO randomUserDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - }; - return randomPojo(MemberUserDO.class, ArrayUtils.append(consumer, consumers)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/test/resources/application-unit-test.yaml b/yudao-module-member/yudao-module-member-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 7b76570fd8..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,50 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module diff --git a/yudao-module-member/yudao-module-member-biz/src/test/resources/logback.xml b/yudao-module-member/yudao-module-member-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff0..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/clean.sql b/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index f972e048d3..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,5 +0,0 @@ -DELETE FROM "member_user"; -DELETE FROM "member_address"; -DELETE FROM "member_tag"; -DELETE FROM "member_level"; -DELETE FROM "member_group"; \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql b/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 782a818107..0000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,113 +0,0 @@ -CREATE TABLE IF NOT EXISTS "member_user" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '编号', - "nickname" varchar(30) NOT NULL DEFAULT '' COMMENT '用户昵称', - "name" varchar(30) NULL COMMENT '真实名字', - sex tinyint null comment '性别', - birthday datetime null comment '出生日期', - area_id int null comment '所在地', - mark varchar(255) null comment '用户备注', - point int default 0 null comment '积分', - "avatar" varchar(255) NOT NULL DEFAULT '' COMMENT '头像', - "status" tinyint NOT NULL COMMENT '状态', - "mobile" varchar(11) NOT NULL COMMENT '手机号', - "password" varchar(100) NOT NULL DEFAULT '' COMMENT '密码', - "register_ip" varchar(32) NOT NULL COMMENT '注册 IP', - "login_ip" varchar(50) NULL DEFAULT '' COMMENT '最后登录IP', - "login_date" datetime NULL DEFAULT NULL COMMENT '最后登录时间', - "tag_ids" varchar(255) NULL DEFAULT NULL COMMENT '用户标签编号列表,以逗号分隔', - "level_id" bigint NULL DEFAULT NULL COMMENT '等级编号', - "experience" bigint NULL DEFAULT NULL COMMENT '经验', - "group_id" bigint NULL DEFAULT NULL COMMENT '用户分组编号', - "creator" varchar(64) NULL DEFAULT '' COMMENT '创建者', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - "updater" varchar(64) NULL DEFAULT '' COMMENT '更新者', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - "deleted" bit(1) NOT NULL DEFAULT '0' COMMENT '是否删除', - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '会员表'; - -CREATE TABLE IF NOT EXISTS "member_address" ( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint(20) NOT NULL, - "name" varchar(10) NOT NULL, - "mobile" varchar(20) NOT NULL, - "area_id" bigint(20) NOT NULL, - "detail_address" varchar(250) NOT NULL, - "default_status" bit NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "creator" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "updater" varchar(64) DEFAULT '', - PRIMARY KEY ("id") -) COMMENT '用户收件地址'; - -CREATE TABLE IF NOT EXISTS "member_tag" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL default '0', - PRIMARY KEY ("id") -) COMMENT '会员标签'; - -CREATE TABLE IF NOT EXISTS "member_level" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "experience" int NOT NULL, - "level" int NOT NULL, - "discount_percent" int NOT NULL, - "icon" varchar NOT NULL, - "background_url" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - "status" tinyint NOT NULL DEFAULT '0', - PRIMARY KEY ("id") -) COMMENT '会员等级'; - -CREATE TABLE IF NOT EXISTS "member_group" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "remark" varchar NOT NULL, - "status" tinyint NOT NULL DEFAULT '0', - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '用户分组'; -CREATE TABLE IF NOT EXISTS "member_brokerage_record" -( - "id" int NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "biz_id" varchar NOT NULL, - "biz_type" varchar NOT NULL, - "title" varchar NOT NULL, - "price" int NOT NULL, - "total_price" int NOT NULL, - "description" varchar NOT NULL, - "status" varchar NOT NULL, - "frozen_days" int NOT NULL, - "unfreeze_time" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '佣金记录'; diff --git a/yudao-module-mp/pom.xml b/yudao-module-mp/pom.xml deleted file mode 100644 index b339c40637..0000000000 --- a/yudao-module-mp/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - yudao - cn.iocoder.boot - ${revision} - - 4.0.0 - - yudao-module-mp - pom - - - wechat 模块,主要实现微信平台的相关业务。 - 例如:微信公众号、企业微信 SCRM 等 - - - yudao-module-mp-api - yudao-module-mp-biz - - - diff --git a/yudao-module-mp/yudao-module-mp-api/pom.xml b/yudao-module-mp/yudao-module-mp-api/pom.xml deleted file mode 100644 index 64b6f50722..0000000000 --- a/yudao-module-mp/yudao-module-mp-api/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - yudao-module-mp - cn.iocoder.boot - ${revision} - - 4.0.0 - yudao-module-mp-api - jar - - ${project.artifactId} - - mp 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - - diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java deleted file mode 100644 index 34c94fd004..0000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.mp.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Mp 错误码枚举类 - * - * mp 系统,使用 1-006-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 公众号账号 1-006-000-000 ============ - ErrorCode ACCOUNT_NOT_EXISTS = new ErrorCode(1_006_000_000, "公众号账号不存在"); - ErrorCode ACCOUNT_GENERATE_QR_CODE_FAIL = new ErrorCode(1_006_000_001, "生成公众号二维码失败,原因:{}"); - ErrorCode ACCOUNT_CLEAR_QUOTA_FAIL = new ErrorCode(1_006_000_002, "清空公众号的 API 配额失败,原因:{}"); - - // ========== 公众号统计 1-006-001-000 ============ - ErrorCode STATISTICS_GET_USER_SUMMARY_FAIL = new ErrorCode(1_006_001_000, "获取粉丝增减数据失败,原因:{}"); - ErrorCode STATISTICS_GET_USER_CUMULATE_FAIL = new ErrorCode(1_006_001_001, "获得粉丝累计数据失败,原因:{}"); - ErrorCode STATISTICS_GET_UPSTREAM_MESSAGE_FAIL = new ErrorCode(1_006_001_002, "获得消息发送概况数据失败,原因:{}"); - ErrorCode STATISTICS_GET_INTERFACE_SUMMARY_FAIL = new ErrorCode(1_006_001_003, "获得接口分析数据失败,原因:{}"); - - // ========== 公众号标签 1-006-002-000 ============ - ErrorCode TAG_NOT_EXISTS = new ErrorCode(1_006_002_000, "标签不存在"); - ErrorCode TAG_CREATE_FAIL = new ErrorCode(1_006_002_001, "创建标签失败,原因:{}"); - ErrorCode TAG_UPDATE_FAIL = new ErrorCode(1_006_002_002, "更新标签失败,原因:{}"); - ErrorCode TAG_DELETE_FAIL = new ErrorCode(1_006_002_003, "删除标签失败,原因:{}"); - ErrorCode TAG_GET_FAIL = new ErrorCode(1_006_002_004, "获得标签失败,原因:{}"); - - // ========== 公众号粉丝 1-006-003-000 ============ - ErrorCode USER_NOT_EXISTS = new ErrorCode(1_006_003_000, "粉丝不存在"); - ErrorCode USER_UPDATE_TAG_FAIL = new ErrorCode(1_006_003_001, "更新粉丝标签失败,原因:{}"); - - // ========== 公众号素材 1-006-004-000 ============ - ErrorCode MATERIAL_NOT_EXISTS = new ErrorCode(1_006_004_000, "素材不存在"); - ErrorCode MATERIAL_UPLOAD_FAIL = new ErrorCode(1_006_004_001, "上传素材失败,原因:{}"); - ErrorCode MATERIAL_IMAGE_UPLOAD_FAIL = new ErrorCode(1_006_004_002, "上传图片失败,原因:{}"); - ErrorCode MATERIAL_DELETE_FAIL = new ErrorCode(1_006_004_003, "删除素材失败,原因:{}"); - - // ========== 公众号消息 1-006-005-000 ============ - ErrorCode MESSAGE_SEND_FAIL = new ErrorCode(1_006_005_000, "发送消息失败,原因:{}"); - - // ========== 公众号发布能力 1-006-006-000 ============ - ErrorCode FREE_PUBLISH_LIST_FAIL = new ErrorCode(1_006_006_000, "获得已成功发布列表失败,原因:{}"); - ErrorCode FREE_PUBLISH_SUBMIT_FAIL = new ErrorCode(1_006_006_001, "提交发布失败,原因:{}"); - ErrorCode FREE_PUBLISH_DELETE_FAIL = new ErrorCode(1_006_006_002, "删除发布失败,原因:{}"); - - // ========== 公众号草稿 1-006-007-000 ============ - ErrorCode DRAFT_LIST_FAIL = new ErrorCode(1_006_007_000, "获得草稿列表失败,原因:{}"); - ErrorCode DRAFT_CREATE_FAIL = new ErrorCode(1_006_007_001, "创建草稿失败,原因:{}"); - ErrorCode DRAFT_UPDATE_FAIL = new ErrorCode(1_006_007_002, "更新草稿失败,原因:{}"); - ErrorCode DRAFT_DELETE_FAIL = new ErrorCode(1_006_007_003, "删除草稿失败,原因:{}"); - - // ========== 公众号菜单 1-006-008-000 ============ - ErrorCode MENU_SAVE_FAIL = new ErrorCode(1_006_008_000, "创建菜单失败,原因:{}"); - ErrorCode MENU_DELETE_FAIL = new ErrorCode(1_006_008_001, "删除菜单失败,原因:{}"); - - // ========== 公众号自动回复 1-006-009-000 ============ - ErrorCode AUTO_REPLY_NOT_EXISTS = new ErrorCode(1_006_009_000, "自动回复不存在"); - ErrorCode AUTO_REPLY_ADD_SUBSCRIBE_FAIL_EXISTS = new ErrorCode(1_006_009_001, "操作失败,原因:已存在关注时的回复"); - ErrorCode AUTO_REPLY_ADD_MESSAGE_FAIL_EXISTS = new ErrorCode(1_006_009_002, "操作失败,原因:已存在该消息类型的回复"); - ErrorCode AUTO_REPLY_ADD_KEYWORD_FAIL_EXISTS = new ErrorCode(1_006_009_003, "操作失败,原因:已关在该关键字的回复"); - -} diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyMatchEnum.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyMatchEnum.java deleted file mode 100644 index a5298dbf3c..0000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyMatchEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.mp.enums.message; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 公众号消息自动回复的匹配模式 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum MpAutoReplyMatchEnum { - - ALL(1, "完全匹配"), - LIKE(2, "半匹配"), - ; - - /** - * 匹配 - */ - private final Integer match; - /** - * 匹配的名字 - */ - private final String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyTypeEnum.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyTypeEnum.java deleted file mode 100644 index 300f1f2ba0..0000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyTypeEnum.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.mp.enums.message; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 公众号消息自动回复的类型 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum MpAutoReplyTypeEnum { - - SUBSCRIBE(1, "关注时回复"), - MESSAGE(2, "收到消息回复"), - KEYWORD(3, "关键词回复"), - ; - - /** - * 来源 - */ - private final Integer type; - /** - * 类型的名字 - */ - private final String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpMessageSendFromEnum.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpMessageSendFromEnum.java deleted file mode 100644 index a2af484a55..0000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpMessageSendFromEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.mp.enums.message; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 微信公众号消息的发送来源 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum MpMessageSendFromEnum { - - USER_TO_MP(1, "粉丝发送给公众号"), - MP_TO_USER(2, "公众号发给粉丝"), - ; - - /** - * 来源 - */ - private final Integer from; - /** - * 来源的名字 - */ - private final String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/package-info.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/package-info.java deleted file mode 100644 index 5987180882..0000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * mp 模块,我们放微信微信公众号。 - * 例如说:提供微信公众号的账号、菜单、粉丝、标签、消息、自动回复、素材、模板通知、运营数据等功能 - * - * 1. Controller URL:以 /mp/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 mp_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.mp; diff --git a/yudao-module-mp/yudao-module-mp-biz/pom.xml b/yudao-module-mp/yudao-module-mp-biz/pom.xml deleted file mode 100644 index c7d1b49730..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/pom.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - yudao-module-mp - cn.iocoder.boot - ${revision} - - 4.0.0 - yudao-module-mp-biz - jar - - ${project.artifactId} - - mp 模块,我们放微信微信公众号。 - 例如说:提供微信公众号的账号、菜单、粉丝、标签、消息、自动回复、素材、模板通知、运营数据等功能 - - - - - cn.iocoder.boot - yudao-module-mp-api - ${revision} - - - cn.iocoder.boot - yudao-module-system-api - ${revision} - - - cn.iocoder.boot - yudao-module-infra-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - org.springframework.boot - spring-boot-starter-validation - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.boot - yudao-spring-boot-starter-redis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mq - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - - - - - cn.iocoder.boot - yudao-spring-boot-starter-excel - - - - - com.github.binarywang - wx-java-mp-spring-boot-starter - - - - diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java deleted file mode 100644 index 8a77a287e6..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.*; -import cn.iocoder.yudao.module.mp.convert.account.MpAccountConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号账号") -@RestController -@RequestMapping("/mp/account") -@Validated -public class MpAccountController { - - @Resource - private MpAccountService mpAccountService; - - @PostMapping("/create") - @Operation(summary = "创建公众号账号") - @PreAuthorize("@ss.hasPermission('mp:account:create')") - public CommonResult createAccount(@Valid @RequestBody MpAccountCreateReqVO createReqVO) { - return success(mpAccountService.createAccount(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新公众号账号") - @PreAuthorize("@ss.hasPermission('mp:account:update')") - public CommonResult updateAccount(@Valid @RequestBody MpAccountUpdateReqVO updateReqVO) { - mpAccountService.updateAccount(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除公众号账号") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:account:delete')") - public CommonResult deleteAccount(@RequestParam("id") Long id) { - mpAccountService.deleteAccount(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得公众号账号") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:account:query')") - public CommonResult getAccount(@RequestParam("id") Long id) { - MpAccountDO wxAccount = mpAccountService.getAccount(id); - return success(MpAccountConvert.INSTANCE.convert(wxAccount)); - } - - @GetMapping("/page") - @Operation(summary = "获得公众号账号分页") - @PreAuthorize("@ss.hasPermission('mp:account:query')") - public CommonResult> getAccountPage(@Valid MpAccountPageReqVO pageVO) { - PageResult pageResult = mpAccountService.getAccountPage(pageVO); - return success(MpAccountConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取公众号账号精简信息列表") - @PreAuthorize("@ss.hasPermission('mp:account:query')") - public CommonResult> getSimpleAccounts() { - List list = mpAccountService.getAccountList(); - return success(MpAccountConvert.INSTANCE.convertList02(list)); - } - - @PutMapping("/generate-qr-code") - @Operation(summary = "生成公众号二维码") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:account:qr-code')") - public CommonResult generateAccountQrCode(@RequestParam("id") Long id) { - mpAccountService.generateAccountQrCode(id); - return success(true); - } - - @PutMapping("/clear-quota") - @Operation(summary = "清空公众号 API 配额") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:account:clear-quota')") - public CommonResult clearAccountQuota(@RequestParam("id") Long id) { - mpAccountService.clearAccountQuota(id); - return success(true); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountBaseVO.java deleted file mode 100644 index 92eecf96c9..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountBaseVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; - -/** - * 公众号账号 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author fengdan - */ -@Data -public class MpAccountBaseVO { - - @Schema(description = "公众号名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @NotEmpty(message = "公众号名称不能为空") - private String name; - - @Schema(description = "公众号微信号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma") - @NotEmpty(message = "公众号微信号不能为空") - private String account; - - @Schema(description = "公众号 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx5b23ba7a5589ecbb") - @NotEmpty(message = "公众号 appId 不能为空") - private String appId; - - @Schema(description = "公众号密钥", requiredMode = Schema.RequiredMode.REQUIRED, example = "3a7b3b20c537e52e74afd395eb85f61f") - @NotEmpty(message = "公众号密钥不能为空") - private String appSecret; - - @Schema(description = "公众号 token", requiredMode = Schema.RequiredMode.REQUIRED, example = "kangdayuzhen") - @NotEmpty(message = "公众号 token 不能为空") - private String token; - - @Schema(description = "加密密钥", example = "gjN+Ksei") - private String aesKey; - - @Schema(description = "备注", example = "请关注芋道源码,学习技术") - private String remark; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountCreateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountCreateReqVO.java deleted file mode 100644 index b864f16c52..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 公众号账号创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAccountCreateReqVO extends MpAccountBaseVO { - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountPageReqVO.java deleted file mode 100644 index 93093dc193..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 公众号账号分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAccountPageReqVO extends PageParam { - - @Schema(name = "公众号名称", description = "模糊匹配") - private String name; - - @Schema(name = "公众号账号", description = "模糊匹配") - private String account; - - @Schema(name = "公众号 appid", description = "模糊匹配") - private String appId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountRespVO.java deleted file mode 100644 index 0f7ca7ebaf..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 公众号账号 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAccountRespVO extends MpAccountBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "二维码图片URL", example = "https://www.iocoder.cn/1024.png") - private String qrCodeUrl; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountSimpleRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountSimpleRespVO.java deleted file mode 100644 index db4594f6d7..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountSimpleRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 公众号账号精简信息 Response VO") -@Data -public class MpAccountSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountUpdateReqVO.java deleted file mode 100644 index a5bec7cbc6..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号账号更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAccountUpdateReqVO extends MpAccountBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.http deleted file mode 100644 index 74b8f40b68..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.http +++ /dev/null @@ -1,5 +0,0 @@ -### 请求 /mp/material/page 接口 => 成功 -GET {{baseUrl}}/mp/material/page?permanent=true&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.java deleted file mode 100644 index 9db08bb22d..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.*; -import cn.iocoder.yudao.module.mp.convert.material.MpMaterialConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import cn.iocoder.yudao.module.mp.service.material.MpMaterialService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.io.IOException; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号素材") -@RestController -@RequestMapping("/mp/material") -@Validated -public class MpMaterialController { - - @Resource - private MpMaterialService mpMaterialService; - - @Operation(summary = "上传临时素材") - @PostMapping("/upload-temporary") - @PreAuthorize("@ss.hasPermission('mp:material:upload-temporary')") - public CommonResult uploadTemporaryMaterial( - @Valid MpMaterialUploadTemporaryReqVO reqVO) throws IOException { - MpMaterialDO material = mpMaterialService.uploadTemporaryMaterial(reqVO); - return success(MpMaterialConvert.INSTANCE.convert(material)); - } - - @Operation(summary = "上传永久素材") - @PostMapping("/upload-permanent") - @PreAuthorize("@ss.hasPermission('mp:material:upload-permanent')") - public CommonResult uploadPermanentMaterial( - @Valid MpMaterialUploadPermanentReqVO reqVO) throws IOException { - MpMaterialDO material = mpMaterialService.uploadPermanentMaterial(reqVO); - return success(MpMaterialConvert.INSTANCE.convert(material)); - } - - @Operation(summary = "删除素材") - @DeleteMapping("/delete-permanent") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:material:delete')") - public CommonResult deleteMaterial(@RequestParam("id") Long id) { - mpMaterialService.deleteMaterial(id); - return success(true); - } - - @Operation(summary = "上传图文内容中的图片") - @PostMapping("/upload-news-image") - @PreAuthorize("@ss.hasPermission('mp:material:upload-news-image')") - public CommonResult uploadNewsImage(@Valid MpMaterialUploadNewsImageReqVO reqVO) - throws IOException { - return success(mpMaterialService.uploadNewsImage(reqVO)); - } - - @Operation(summary = "获得素材分页") - @GetMapping("/page") - @PreAuthorize("@ss.hasPermission('mp:material:query')") - public CommonResult> getMaterialPage(@Valid MpMaterialPageReqVO pageReqVO) { - PageResult pageResult = mpMaterialService.getMaterialPage(pageReqVO); - return success(MpMaterialConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialPageReqVO.java deleted file mode 100644 index 16e6eb579e..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号素材的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMaterialPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "是否永久", example = "true") - private Boolean permanent; - - @Schema(description = "文件类型 参见 WxConsts.MediaFileType 枚举", example = "image") - private String type; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialRespVO.java deleted file mode 100644 index 5aba24edd0..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialRespVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 公众号素材 Response VO") -@Data -public class MpMaterialRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long accountId; - @Schema(description = "公众号账号的 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890") - private String appId; - - @Schema(description = "素材的 media_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "123") - private String mediaId; - - @Schema(description = "文件类型 参见 WxConsts.MediaFileType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "image") - private String type; - - @Schema(description = "是否永久 true - 永久;false - 临时", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean permanent; - - @Schema(description = "素材的 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String url; - - - @Schema(description = "名字", example = "yunai.png") - private String name; - - @Schema(description = "公众号文件 URL 只有【永久素材】使用", example = "https://mmbiz.qpic.cn/xxx.mp3") - private String mpUrl; - - @Schema(description = "视频素材的标题 只有【永久素材】使用", example = "我是标题") - private String title; - @Schema(description = "视频素材的描述 只有【永久素材】使用", example = "我是介绍") - private String introduction; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadNewsImageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadNewsImageReqVO.java deleted file mode 100644 index 070957f1a8..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadNewsImageReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.web.multipart.MultipartFile; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号素材上传图文内容中的图片 Request VO") -@Data -public class MpMaterialUploadNewsImageReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "文件不能为空") - @JsonIgnore // 避免被操作日志,进行序列化,导致报错 - private MultipartFile file; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadPermanentReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadPermanentReqVO.java deleted file mode 100644 index 8f4ff88c40..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadPermanentReqVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import cn.hutool.core.util.ObjectUtil; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; -import org.springframework.web.multipart.MultipartFile; - -import jakarta.validation.constraints.AssertTrue; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号素材上传永久 Request VO") -@Data -public class MpMaterialUploadPermanentReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "文件类型 参见 WxConsts.MediaFileType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "image") - @NotEmpty(message = "文件类型不能为空") - private String type; - - @Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "文件不能为空") - @JsonIgnore // 避免被操作日志,进行序列化,导致报错 - private MultipartFile file; - - @Schema(description = "名字 如果 name 为空,则使用 file 文件名", example = "wechat.mp") - private String name; - - @Schema(description = "视频素材的标题 文件类型为 video 时,必填", example = "视频素材的标题") - private String title; - @Schema(description = "视频素材的描述 文件类型为 video 时,必填", example = "视频素材的描述") - private String introduction; - - @AssertTrue(message = "标题不能为空") - public boolean isTitleValid() { - // 生成场景为管理后台时,必须设置上级菜单,不然生成的菜单 SQL 是无父级菜单的 - return ObjectUtil.notEqual(type, WxConsts.MediaFileType.VIDEO) - || title != null; - } - - @AssertTrue(message = "描述不能为空") - public boolean isIntroductionValid() { - // 生成场景为管理后台时,必须设置上级菜单,不然生成的菜单 SQL 是无父级菜单的 - return ObjectUtil.notEqual(type, WxConsts.MediaFileType.VIDEO) - || introduction != null; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadRespVO.java deleted file mode 100644 index 0174cbcc29..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 公众号素材上传结果 Response VO") -@Data -public class MpMaterialUploadRespVO { - - @Schema(description = "素材的 media_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "123") - private String mediaId; - - @Schema(description = "素材的 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String url; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadTemporaryReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadTemporaryReqVO.java deleted file mode 100644 index 139828e1e5..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadTemporaryReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.web.multipart.MultipartFile; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号素材上传临时 Request VO") -@Data -public class MpMaterialUploadTemporaryReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "文件类型 参见 WxConsts.MediaFileType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "image") - @NotEmpty(message = "文件类型不能为空") - private String type; - - @Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "文件不能为空") - @JsonIgnore // 避免被操作日志,进行序列化,导致报错 - private MultipartFile file; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http deleted file mode 100644 index 2276b3b4f9..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http +++ /dev/null @@ -1,50 +0,0 @@ -### 请求 /mp/menu/save 接口 => 成功 -POST {{baseUrl}}/mp/menu/save -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "accountId": "1", - "menus": [ - { - "type":"click", - "name":"今日歌曲", - "menuKey":"V1001_TODAY_MUSIC" - }, - { - "name":"搜索", - "type":"view", - "url":"https://www.soso.com/" - }, - { - "name": "父按钮", - "children": [ - { - "type":"click", - "name":"归去来兮", - "menuKey":"MUSIC" - }, - { - "name":"不说", - "type":"view", - "url":"https://www.soso.com/" - }] - }] -} - -### 请求 /mp/menu/save 接口 => 成功(清空) -POST {{baseUrl}}/mp/menu/save -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "accountId": "1", - "menus": [] -} - -### 请求 /mp/menu/list 接口 => 成功 -GET {{baseUrl}}/mp/menu/list?accountId=1 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.java deleted file mode 100644 index 28e321a4d1..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.menu; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuSaveReqVO; -import cn.iocoder.yudao.module.mp.convert.menu.MpMenuConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import cn.iocoder.yudao.module.mp.service.menu.MpMenuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号菜单") -@RestController -@RequestMapping("/mp/menu") -@Validated -public class MpMenuController { - - @Resource - private MpMenuService mpMenuService; - - @PostMapping("/save") - @Operation(summary = "保存公众号菜单") - @PreAuthorize("@ss.hasPermission('mp:menu:save')") - public CommonResult saveMenu(@Valid @RequestBody MpMenuSaveReqVO createReqVO) { - mpMenuService.saveMenu(createReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除公众号菜单") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "10") - @PreAuthorize("@ss.hasPermission('mp:menu:delete')") - public CommonResult deleteMenu(@RequestParam("accountId") Long accountId) { - mpMenuService.deleteMenuByAccountId(accountId); - return success(true); - } - - @GetMapping("/list") - @Operation(summary = "获得公众号菜单列表") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "10") - @PreAuthorize("@ss.hasPermission('mp:menu:query')") - public CommonResult> getMenuList(@RequestParam("accountId") Long accountId) { - List list = mpMenuService.getMenuListByAccountId(accountId); - return success(MpMenuConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java deleted file mode 100644 index 8a6974cb20..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java +++ /dev/null @@ -1,115 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; -import org.hibernate.validator.constraints.URL; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -import static cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils.*; - -/** - * 公众号菜单 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MpMenuBaseVO { - - /** - * 菜单名称 - */ - private String name; - /** - * 菜单标识 - * - * 支持多 DB 类型时,无法直接使用 key + @TableField("menuKey") 来实现转换,原因是 "menuKey" AS key 而存在报错 - */ - private String menuKey; - /** - * 父菜单编号 - */ - private Long parentId; - - // ========== 按钮操作 ========== - - /** - * 按钮类型 - * - * 枚举 {@link WxConsts.MenuButtonType} - */ - private String type; - - @Schema(description = "网页链接", example = "https://www.iocoder.cn/") - @NotEmpty(message = "网页链接不能为空", groups = {ViewButtonGroup.class, MiniProgramButtonGroup.class}) - @URL(message = "网页链接必须是 URL 格式") - private String url; - - @Schema(description = "小程序的 appId", example = "wx1234567890") - @NotEmpty(message = "小程序的 appId 不能为空", groups = MiniProgramButtonGroup.class) - private String miniProgramAppId; - - @Schema(description = "小程序的页面路径", example = "pages/index/index") - @NotEmpty(message = "小程序的页面路径不能为空", groups = MiniProgramButtonGroup.class) - private String miniProgramPagePath; - - @Schema(description ="跳转图文的媒体编号", example = "jCQk93AIIgp8ixClWcW_NXXqBKInNWNmq2XnPeDZl7IMVqWiNeL4FfELtggRXd83") - @NotEmpty(message = "跳转图文的媒体编号不能为空", groups = ViewLimitedButtonGroup.class) - private String articleId; - - // ========== 消息内容 ========== - - @Schema(description = "回复的消息类型 枚举 TEXT、IMAGE、VOICE、VIDEO、NEWS、MUSIC", example = "text") - @NotEmpty(message = "回复的消息类型不能为空", groups = {ClickButtonGroup.class, ScanCodeWaitMsgButtonGroup.class}) - private String replyMessageType; - - @Schema(description = "回复的消息内容", example = "欢迎关注") - @NotEmpty(message = "回复的消息内容不能为空", groups = TextMessageGroup.class) - private String replyContent; - - @Schema(description = "回复的媒体 id", example = "123456") - @NotEmpty(message = "回复的消息 mediaId 不能为空", - groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String replyMediaId; - @Schema(description = "回复的媒体 URL", example = "https://www.iocoder.cn/xxx.jpg") - @NotEmpty(message = "回复的消息 mediaId 不能为空", - groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String replyMediaUrl; - - @Schema(description = "缩略图的媒体 id", example = "123456") - @NotEmpty(message = "回复的消息 thumbMediaId 不能为空", groups = {MusicMessageGroup.class}) - private String replyThumbMediaId; - @Schema(description = "缩略图的媒体 URL",example = "https://www.iocoder.cn/xxx.jpg") - @NotEmpty(message = "回复的消息 thumbMedia 地址不能为空", groups = {MusicMessageGroup.class}) - private String replyThumbMediaUrl; - - @Schema(description = "回复的标题", example = "视频标题") - @NotEmpty(message = "回复的消息标题不能为空", groups = VideoMessageGroup.class) - private String replyTitle; - @Schema(description = "回复的描述", example = "视频描述") - @NotEmpty(message = "消息描述不能为空", groups = VideoMessageGroup.class) - private String replyDescription; - - /** - * 回复的图文消息数组 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @NotNull(message = "回复的图文消息不能为空", groups = {NewsMessageGroup.class, ViewLimitedButtonGroup.class}) - @Valid - private List replyArticles; - - @Schema(description = "回复的音乐链接", example = "https://www.iocoder.cn/xxx.mp3") - @NotEmpty(message = "回复的音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "回复的高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String replyMusicUrl; - @Schema(description = "高质量音乐链接", example = "https://www.iocoder.cn/xxx.mp3") - @NotEmpty(message = "回复的高质量音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "回复的高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String replyHqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuRespVO.java deleted file mode 100644 index 5d5495925d..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 公众号菜单 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMenuRespVO extends MpMenuBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long accountId; - - @Schema(description = "公众号 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890ox") - private String appId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java deleted file mode 100644 index 640c2c18bd..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 公众号菜单保存 Request VO") -@Data -public class MpMenuSaveReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @NotEmpty(message = "菜单不能为空") - @Valid - private List

menus; - - @Schema(description = "管理后台 - 公众号菜单保存时的每个菜单") - @Data - public static class Menu extends MpMenuBaseVO { - - /** - * 子菜单数组 - */ - private List children; - - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.http deleted file mode 100644 index dbb3a7b22b..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.http +++ /dev/null @@ -1,5 +0,0 @@ -### 请求 /mp/message/page 接口 => 成功 -GET {{baseUrl}}/mp/auto-reply/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.java deleted file mode 100644 index 0bb7e172b7..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyUpdateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.convert.message.MpAutoReplyConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号自动回复") -@RestController -@RequestMapping("/mp/auto-reply") -@Validated -public class MpAutoReplyController { - - @Resource - private MpAutoReplyService mpAutoReplyService; - - @GetMapping("/page") - @Operation(summary = "获得公众号自动回复分页") - @PreAuthorize("@ss.hasPermission('mp:auto-reply:query')") - public CommonResult> getAutoReplyPage(@Valid MpMessagePageReqVO pageVO) { - PageResult pageResult = mpAutoReplyService.getAutoReplyPage(pageVO); - return success(MpAutoReplyConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/get") - @Operation(summary = "获得公众号自动回复") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:auto-reply:query')") - public CommonResult getAutoReply(@RequestParam("id") Long id) { - MpAutoReplyDO autoReply = mpAutoReplyService.getAutoReply(id); - return success(MpAutoReplyConvert.INSTANCE.convert(autoReply)); - } - - @PostMapping("/create") - @Operation(summary = "创建公众号自动回复") - @PreAuthorize("@ss.hasPermission('mp:auto-reply:create')") - public CommonResult createAutoReply(@Valid @RequestBody MpAutoReplyCreateReqVO createReqVO) { - return success(mpAutoReplyService.createAutoReply(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新公众号自动回复") - @PreAuthorize("@ss.hasPermission('mp:auto-reply:update')") - public CommonResult updateAutoReply(@Valid @RequestBody MpAutoReplyUpdateReqVO updateReqVO) { - mpAutoReplyService.updateAutoReply(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除公众号自动回复") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:auto-reply:delete')") - public CommonResult deleteAutoReply(@RequestParam("id") Long id) { - mpAutoReplyService.deleteAutoReply(id); - return success(true); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.http deleted file mode 100644 index b9f9721c9b..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.http +++ /dev/null @@ -1,33 +0,0 @@ -### 请求 /mp/message/page 接口 => 成功 -GET {{baseUrl}}/mp/message/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/message/send 接口 => 成功(文本) -POST {{baseUrl}}/mp/message/send -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "userId": 3, - "type": "text", - "content": "测试消息" -} - -### 请求 /mp/message/send 接口 => 成功(音乐) -POST {{baseUrl}}/mp/message/send -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "userId": 3, - "type": "music", - "title": "测试音乐标题", - "description": "测试音乐内容", - "musicUrl": "https://www.iocoder.cn/xx.mp3", - "hqMusicUrl": "https://www.iocoder.cn/xx_high.mp3", - "thumbMediaId": "s98Iveeg9vDVFwa9q0u8-zSfdKe3xIzAm7wCrFE4WKGPIo4d9qAhtC-n6qvnyWyH" -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java deleted file mode 100644 index 8c0bd32505..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageSendReqVO; -import cn.iocoder.yudao.module.mp.convert.message.MpMessageConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.service.message.MpMessageService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号消息") -@RestController -@RequestMapping("/mp/message") -@Validated -public class MpMessageController { - - @Resource - private MpMessageService mpMessageService; - - @GetMapping("/page") - @Operation(summary = "获得公众号消息分页") - @PreAuthorize("@ss.hasPermission('mp:message:query')") - public CommonResult> getMessagePage(@Valid MpMessagePageReqVO pageVO) { - PageResult pageResult = mpMessageService.getMessagePage(pageVO); - return success(MpMessageConvert.INSTANCE.convertPage(pageResult)); - } - - @PostMapping("/send") - @Operation(summary = "给粉丝发送消息") - @PreAuthorize("@ss.hasPermission('mp:message:send')") - public CommonResult sendMessage(@Valid @RequestBody MpMessageSendReqVO reqVO) { - MpMessageDO message = mpMessageService.sendKefuMessage(reqVO); - return success(MpMessageConvert.INSTANCE.convert(message)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyBaseVO.java deleted file mode 100644 index fceb5f79d9..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyBaseVO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils.*; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; -import org.hibernate.validator.constraints.URL; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.AssertTrue; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -/** - * 公众号自动回复 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MpAutoReplyBaseVO { - - @Schema(description = "回复类型 参见 MpAutoReplyTypeEnum 枚举", example = "1") - @NotNull(message = "回复类型不能为空") - private Integer type; - - // ==================== 请求消息 ==================== - - @Schema(description = "请求的关键字 当 type 为 MpAutoReplyTypeEnum#KEYWORD 时,必填", example = "关键字") - private String requestKeyword; - @Schema(description = "请求的匹配方式 当 type 为 MpAutoReplyTypeEnum#KEYWORD 时,必填", example = "1") - private Integer requestMatch; - - @Schema(description = "请求的消息类型 当 type 为 MpAutoReplyTypeEnum#MESSAGE 时,必填", example = "text") - private String requestMessageType; - - // ==================== 响应消息 ==================== - - @Schema(description = "回复的消息类型 枚举 TEXT、IMAGE、VOICE、VIDEO、NEWS、MUSIC", example = "text") - @NotEmpty(message = "回复的消息类型不能为空") - private String responseMessageType; - - @Schema(description = "回复的消息内容", example = "欢迎关注") - @NotEmpty(message = "回复的消息内容不能为空", groups = TextMessageGroup.class) - private String responseContent; - - @Schema(description = "回复的媒体 id", example = "123456") - @NotEmpty(message = "回复的消息 mediaId 不能为空", - groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String responseMediaId; - @Schema(description = "回复的媒体 URL", example = "https://www.iocoder.cn/xxx.jpg") - @NotEmpty(message = "回复的消息 mediaId 不能为空", - groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String responseMediaUrl; - - @Schema(description = "缩略图的媒体 id", example = "123456") - @NotEmpty(message = "回复的消息 thumbMediaId 不能为空", groups = {MusicMessageGroup.class}) - private String responseThumbMediaId; - @Schema(description = "缩略图的媒体 URL",example = "https://www.iocoder.cn/xxx.jpg") - @NotEmpty(message = "回复的消息 thumbMedia 地址不能为空", groups = {MusicMessageGroup.class}) - private String responseThumbMediaUrl; - - @Schema(description = "回复的标题", example = "视频标题") - @NotEmpty(message = "回复的消息标题不能为空", groups = VideoMessageGroup.class) - private String responseTitle; - @Schema(description = "回复的描述", example = "视频描述") - @NotEmpty(message = "消息描述不能为空", groups = VideoMessageGroup.class) - private String responseDescription; - - /** - * 回复的图文消息 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @NotNull(message = "回复的图文消息不能为空", groups = {NewsMessageGroup.class, ViewLimitedButtonGroup.class}) - @Valid - private List responseArticles; - - @Schema(description = "回复的音乐链接", example = "https://www.iocoder.cn/xxx.mp3") - @NotEmpty(message = "回复的音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "回复的高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String responseMusicUrl; - @Schema(description = "高质量音乐链接", example = "https://www.iocoder.cn/xxx.mp3") - @NotEmpty(message = "回复的高质量音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "回复的高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String responseHqMusicUrl; - - @AssertTrue(message = "请求的关键字不能为空") - public boolean isRequestKeywordValid() { - return ObjectUtil.notEqual(type, MpAutoReplyTypeEnum.KEYWORD) - || requestKeyword != null; - } - - @AssertTrue(message = "请求的关键字的匹配不能为空") - public boolean isRequestMatchValid() { - return ObjectUtil.notEqual(type, MpAutoReplyTypeEnum.KEYWORD) - || requestMatch != null; - } - - @AssertTrue(message = "请求的消息类型不能为空") - public boolean isRequestMessageTypeValid() { - return ObjectUtil.notEqual(type, MpAutoReplyTypeEnum.MESSAGE) - || requestMessageType != null; - } - - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyCreateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyCreateReqVO.java deleted file mode 100644 index 502c17da33..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyCreateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号自动回复的创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyCreateReqVO extends MpAutoReplyBaseVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyPageReqVO.java deleted file mode 100644 index 70169f4538..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号自动回复的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyRespVO.java deleted file mode 100644 index d1f72f307b..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 公众号自动回复 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyRespVO extends MpAutoReplyBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long accountId; - @Schema(description = "公众号 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890") - private String appId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyUpdateReqVO.java deleted file mode 100644 index 776400c673..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号自动回复的更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyUpdateReqVO extends MpAutoReplyBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "主键不能为空") - private Long id; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessagePageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessagePageReqVO.java deleted file mode 100644 index d9f7cc8761..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessagePageReqVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.message; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 公众号消息分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMessagePageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "消息类型 参见 WxConsts.XmlMsgType 枚举", example = "text") - private String type; - - @Schema(description = "公众号粉丝标识", example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String openid; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java deleted file mode 100644 index 27c85be6bb..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.message; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import com.baomidou.mybatisplus.annotation.TableField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; - -import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; - -@Schema(description = "管理后台 - 公众号消息 Response VO") -@Data -public class MpMessageRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer id; - - @Schema(description = "微信公众号消息 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23953173569869169") - private Long msgId; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long accountId; - @Schema(description = "公众号账号的 appid", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890") - private String appId; - - @Schema(description = "公众号粉丝编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long userId; - @Schema(description = "公众号粉丝标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String openid; - - @Schema(description = "消息类型 参见 WxConsts.XmlMsgType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "text") - private String type; - @Schema(description = "消息来源 参见 MpMessageSendFromEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sendFrom; - - // ========= 普通消息内容 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_standard_messages.html - - @Schema(description = "消息内容 消息类型为 text 时,才有值", example = "你好呀") - private String content; - - @Schema(description = "媒体素材的编号 消息类型为 image、voice、video 时,才有值", example = "1234567890") - private String mediaId; - @Schema(description = "媒体文件的 URL 消息类型为 image、voice、video 时,才有值", example = "https://www.iocoder.cn/xxx.png") - private String mediaUrl; - - @Schema(description = "语音识别后文本 消息类型为 voice 时,才有值", example = "语音识别后文本") - private String recognition; - @Schema(description = "语音格式 消息类型为 voice 时,才有值", example = "amr") - private String format; - - @Schema(description = "标题 消息类型为 video、music、link 时,才有值", example = "我是标题") - private String title; - - @Schema(description = "描述 消息类型为 video、music 时,才有值", example = "我是描述") - private String description; - - @Schema(description = "缩略图的媒体 id 消息类型为 video、music 时,才有值", example = "1234567890") - private String thumbMediaId; - @Schema(description = "缩略图的媒体 URL 消息类型为 video、music 时,才有值", example = "https://www.iocoder.cn/xxx.png") - private String thumbMediaUrl; - - @Schema(description = "点击图文消息跳转链接 消息类型为 link 时,才有值", example = "https://www.iocoder.cn") - private String url; - - @Schema(description = "地理位置维度 消息类型为 location 时,才有值", example = "23.137466") - private Double locationX; - - @Schema(description = "地理位置经度 消息类型为 location 时,才有值", example = "113.352425") - private Double locationY; - - @Schema(description = "地图缩放大小 消息类型为 location 时,才有值", example = "13") - private Double scale; - - @Schema(description = "详细地址 消息类型为 location 时,才有值", example = "杨浦区黄兴路 221-4 号临") - private String label; - - /** - * 图文消息数组 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @TableField(typeHandler = MpMessageDO.ArticleTypeHandler.class) - private List articles; - - @Schema(description = "音乐链接 消息类型为 music 时,才有值", example = "https://www.iocoder.cn/xxx.mp3") - private String musicUrl; - @Schema(description = "高质量音乐链接 消息类型为 music 时,才有值", example = "https://www.iocoder.cn/xxx.mp3") - private String hqMusicUrl; - - // ========= 事件推送 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html - - @Schema(description = "事件类型 参见 WxConsts.EventType 枚举", example = "subscribe") - private String event; - @Schema(description = "事件 Key 参见 WxConsts.EventType 枚举", example = "qrscene_123456") - private String eventKey; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageSendReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageSendReqVO.java deleted file mode 100644 index 0c96392c17..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageSendReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.message; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils.*; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 公众号消息发送 Request VO") -@Data -public class MpMessageSendReqVO { - - @Schema(description = "公众号粉丝的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号粉丝的编号不能为空") - private Long userId; - - // ========== 消息内容 ========== - - @Schema(description = "消息类型 TEXT/IMAGE/VOICE/VIDEO/NEWS", requiredMode = Schema.RequiredMode.REQUIRED, example = "text") - @NotEmpty(message = "消息类型不能为空") - public String type; - - @Schema(description = "消息内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "你好呀") - @NotEmpty(message = "消息内容不能为空", groups = TextMessageGroup.class) - private String content; - - @Schema(description = "媒体 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "qqc_2Fot30Jse-HDoZmo5RrUDijz2nGUkP") - @NotEmpty(message = "消息内容不能为空", groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String mediaId; - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "没有标题") - @NotEmpty(message = "消息内容不能为空", groups = VideoMessageGroup.class) - private String title; - - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - @NotEmpty(message = "消息描述不能为空", groups = VideoMessageGroup.class) - private String description; - - @Schema(description = "缩略图的媒体 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "qqc_2Fot30Jse-HDoZmo5RrUDijz2nGUkP") - @NotEmpty(message = "缩略图的媒体 id 不能为空", groups = MusicMessageGroup.class) - private String thumbMediaId; - - @Schema(description = "图文消息", requiredMode = Schema.RequiredMode.REQUIRED) - @Valid - @NotNull(message = "图文消息不能为空", groups = NewsMessageGroup.class) - private List articles; - - @Schema(description = "音乐链接 消息类型为 MUSIC 时", example = "https://www.iocoder.cn/music.mp3") - private String musicUrl; - - @Schema(description = "高质量音乐链接 消息类型为 MUSIC 时", example = "https://www.iocoder.cn/music.mp3") - private String hqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.http deleted file mode 100644 index 87f9d432a1..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.http +++ /dev/null @@ -1,54 +0,0 @@ -### 请求 /mp/draft/page 接口 => 成功 -GET {{baseUrl}}/mp/draft/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/draft/create 接口 => 成功 -POST {{baseUrl}}/mp/draft/create?accountId=1 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "articles": [ - { - "title": "我是标题", - "author": "我是作者", - "digest": "我是摘要", - "content": "我是内容", - "contentSourceUrl": "https://www.iocoder.cn", - "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn" - }, - { - "title": "我是标题 2", - "author": "我是作者 2", - "digest": "我是摘要 2", - "content": "我是内容 2", - "contentSourceUrl": "https://www.iocoder.cn", - "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn" - } - ] -} - -### 请求 /mp/draft/create 接口 => 成功 -PUT {{baseUrl}}/mp/draft/update?accountId=1&mediaId=r6ryvl6LrxBU0miaST4Y-q-G9pdsmZw0OYG4FzHQkKfpLfEwIH51wy2bxisx8PvW -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -[{ - "title": "我是标题(OOO)", - "author": "我是作者", - "digest": "我是摘要", - "content": "我是内容", - "contentSourceUrl": "https://www.iocoder.cn", - "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn" -}, { - "title": "我是标题(XXX)", - "author": "我是作者", - "digest": "我是摘要", - "content": "我是内容", - "contentSourceUrl": "https://www.iocoder.cn", - "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn" -}] diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.java deleted file mode 100644 index d113cefaed..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.news; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.mp.controller.admin.news.vo.MpDraftPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.material.MpMaterialService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.draft.*; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -@Tag(name = "管理后台 - 公众号草稿") -@RestController -@RequestMapping("/mp/draft") -@Validated -public class MpDraftController { - - @Resource - private MpServiceFactory mpServiceFactory; - - @Resource - private MpMaterialService mpMaterialService; - - @GetMapping("/page") - @Operation(summary = "获得草稿分页") - @PreAuthorize("@ss.hasPermission('mp:draft:query')") - public CommonResult> getDraftPage(MpDraftPageReqVO reqVO) { - // 从公众号查询草稿箱 - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - WxMpDraftList draftList; - try { - draftList = mpService.getDraftService().listDraft(PageUtils.getStart(reqVO), reqVO.getPageSize()); - } catch (WxErrorException e) { - throw exception(DRAFT_LIST_FAIL, e.getError().getErrorMsg()); - } - // 查询对应的图片地址。目的:解决公众号的图片链接无法在我们后台展示 - setDraftThumbUrl(draftList.getItems()); - - // 返回分页 - return success(new PageResult<>(draftList.getItems(), draftList.getTotalCount().longValue())); - } - - private void setDraftThumbUrl(List items) { - // 1.1 获得 mediaId 数组 - Set mediaIds = new HashSet<>(); - items.forEach(item -> item.getContent().getNewsItem().forEach(newsItem -> mediaIds.add(newsItem.getThumbMediaId()))); - if (CollUtil.isEmpty(mediaIds)) { - return; - } - // 1.2 批量查询对应的 Media 素材 - Map materials = CollectionUtils.convertMap(mpMaterialService.getMaterialListByMediaId(mediaIds), - MpMaterialDO::getMediaId); - - // 2. 设置回 WxMpDraftItem 记录 - items.forEach(item -> item.getContent().getNewsItem().forEach(newsItem -> - findAndThen(materials, newsItem.getThumbMediaId(), material -> newsItem.setThumbUrl(material.getUrl())))); - } - - @PostMapping("/create") - @Operation(summary = "创建草稿") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:draft:create')") - public CommonResult deleteDraft(@RequestParam("accountId") Long accountId, - @RequestBody WxMpAddDraft draft) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - String mediaId = mpService.getDraftService().addDraft(draft); - return success(mediaId); - } catch (WxErrorException e) { - throw exception(DRAFT_CREATE_FAIL, e.getError().getErrorMsg()); - } - } - - @PutMapping("/update") - @Operation(summary = "更新草稿") - @Parameters({ - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024"), - @Parameter(name = "mediaId", description = "草稿素材的编号", required = true, example = "xxx") - }) - @PreAuthorize("@ss.hasPermission('mp:draft:update')") - public CommonResult deleteDraft(@RequestParam("accountId") Long accountId, - @RequestParam("mediaId") String mediaId, - @RequestBody List articles) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - for (int i = 0; i < articles.size(); i++) { - WxMpDraftArticles article = articles.get(i); - mpService.getDraftService().updateDraft(new WxMpUpdateDraft(mediaId, i, article)); - } - return success(true); - } catch (WxErrorException e) { - throw exception(DRAFT_UPDATE_FAIL, e.getError().getErrorMsg()); - } - } - - @DeleteMapping("/delete") - @Operation(summary = "删除草稿") - @Parameters({ - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024"), - @Parameter(name = "mediaId", description = "草稿素材的编号", required = true, example = "xxx") - }) - @PreAuthorize("@ss.hasPermission('mp:draft:delete')") - public CommonResult deleteDraft(@RequestParam("accountId") Long accountId, - @RequestParam("mediaId") String mediaId) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - mpService.getDraftService().delDraft(mediaId); - return success(true); - } catch (WxErrorException e) { - throw exception(DRAFT_DELETE_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.http deleted file mode 100644 index 122413200e..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.http +++ /dev/null @@ -1,13 +0,0 @@ -### 请求 /mp/free-publish/page 接口 => 成功 -GET {{baseUrl}}/mp/free-publish/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/free-publish/submit 接口 => 成功 -POST {{baseUrl}}/mp/free-publish/submit?accountId=1&mediaId=r6ryvl6LrxBU0miaST4Y-vilmd7iS51D8IPddxflWrau0hIQ2ovY8YanO5jlgUcM -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.java deleted file mode 100644 index 099677fb64..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.news; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.mp.controller.admin.news.vo.MpFreePublishPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.material.MpMaterialService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishItem; -import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishList; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -@Tag(name = "管理后台 - 公众号发布能力") -@RestController -@RequestMapping("/mp/free-publish") -@Validated -public class MpFreePublishController { - - @Resource - private MpServiceFactory mpServiceFactory; - - @Resource - private MpMaterialService mpMaterialService; - - @GetMapping("/page") - @Operation(summary = "获得已发布的图文分页") - @PreAuthorize("@ss.hasPermission('mp:free-publish:query')") - public CommonResult> getFreePublishPage(MpFreePublishPageReqVO reqVO) { - // 从公众号查询已发布的图文列表 - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - WxMpFreePublishList publicationRecords; - try { - publicationRecords = mpService.getFreePublishService().getPublicationRecords( - PageUtils.getStart(reqVO), reqVO.getPageSize()); - } catch (WxErrorException e) { - throw exception(FREE_PUBLISH_LIST_FAIL, e.getError().getErrorMsg()); - } - // 查询对应的图片地址。目的:解决公众号的图片链接无法在我们后台展示 - setFreePublishThumbUrl(publicationRecords.getItems()); - - // 返回分页 - return success(new PageResult<>(publicationRecords.getItems(), publicationRecords.getTotalCount().longValue())); - } - - private void setFreePublishThumbUrl(List items) { - // 1.1 获得 mediaId 数组 - Set mediaIds = new HashSet<>(); - items.forEach(item -> item.getContent().getNewsItem().forEach(newsItem -> mediaIds.add(newsItem.getThumbMediaId()))); - if (CollUtil.isEmpty(mediaIds)) { - return; - } - // 1.2 批量查询对应的 Media 素材 - Map materials = CollectionUtils.convertMap(mpMaterialService.getMaterialListByMediaId(mediaIds), - MpMaterialDO::getMediaId); - - // 2. 设置回 WxMpFreePublishItem 记录 - items.forEach(item -> item.getContent().getNewsItem().forEach(newsItem -> - findAndThen(materials, newsItem.getThumbMediaId(), material -> newsItem.setThumbUrl(material.getUrl())))); - } - - @PostMapping("/submit") - @Operation(summary = "发布草稿") - @Parameters({ - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024"), - @Parameter(name = "mediaId", description = "要发布的草稿的 media_id", required = true, example = "2048") - }) - @PreAuthorize("@ss.hasPermission('mp:free-publish:submit')") - public CommonResult submitFreePublish(@RequestParam("accountId") Long accountId, - @RequestParam("mediaId") String mediaId) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - String publishId = mpService.getFreePublishService().submit(mediaId); - return success(publishId); - } catch (WxErrorException e) { - throw exception(FREE_PUBLISH_SUBMIT_FAIL, e.getError().getErrorMsg()); - } - } - - @DeleteMapping("/delete") - @Operation(summary = "删除草稿") - @Parameters({ - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024"), - @Parameter(name = "articleId", description = "发布记录的编号", required = true, example = "2048") - }) - @PreAuthorize("@ss.hasPermission('mp:free-publish:delete')") - public CommonResult deleteFreePublish(@RequestParam("accountId") Long accountId, - @RequestParam("articleId") String articleId) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - mpService.getFreePublishService().deletePushAllArticle(articleId); - return success(true); - } catch (WxErrorException e) { - throw exception(FREE_PUBLISH_DELETE_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpDraftPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpDraftPageReqVO.java deleted file mode 100644 index 31802579c3..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpDraftPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.news.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号草稿的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpDraftPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpFreePublishPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpFreePublishPageReqVO.java deleted file mode 100644 index 9f35edb88f..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpFreePublishPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.news.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号已发布列表的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpFreePublishPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/MpOpenController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/MpOpenController.java deleted file mode 100644 index 5cfe6b839e..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/MpOpenController.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.open; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.mp.controller.admin.open.vo.MpOpenCheckSignatureReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.open.vo.MpOpenHandleMessageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.mp.api.WxMpMessageRouter; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import java.util.Objects; - -@Tag(name = "管理后台 - 公众号回调") -@RestController -@RequestMapping("/mp/open") -@Validated -@Slf4j -public class MpOpenController { - - @Resource - private MpServiceFactory mpServiceFactory; - - @Resource - private MpAccountService mpAccountService; - - /** - * 接收微信公众号的校验签名 - * - * 对应 文档 - */ - @Operation(summary = "校验签名") // 参见 - @GetMapping(value = "/{appId}", produces = "text/plain;charset=utf-8") - public String checkSignature(@PathVariable("appId") String appId, - MpOpenCheckSignatureReqVO reqVO) { - log.info("[checkSignature][appId({}) 接收到来自微信服务器的认证消息({})]", appId, reqVO); - // 校验请求签名 - WxMpService wxMpService = mpServiceFactory.getRequiredMpService(appId); - // 校验通过 - if (wxMpService.checkSignature(reqVO.getTimestamp(), reqVO.getNonce(), reqVO.getSignature())) { - return reqVO.getEchostr(); - } - // 校验不通过 - return "非法请求"; - } - - /** - * 接收微信公众号的消息推送 - * - * 文档 - */ - @Operation(summary = "处理消息") - @PostMapping(value = "/{appId}", produces = "application/xml; charset=UTF-8") - @OperateLog(enable = false) // 回调地址,无需记录操作日志 - public String handleMessage(@PathVariable("appId") String appId, - @RequestBody String content, - MpOpenHandleMessageReqVO reqVO) { - log.info("[handleMessage][appId({}) 推送消息,参数({}) 内容({})]", appId, reqVO, content); - - // 处理 appId + 多租户的上下文 - MpAccountDO account = mpAccountService.getAccountFromCache(appId); - Assert.notNull(account, "公众号 appId({}) 不存在", appId); - try { - MpContextHolder.setAppId(appId); - return TenantUtils.execute(account.getTenantId(), - () -> handleMessage0(appId, content, reqVO)); - } finally { - MpContextHolder.clear(); - } - } - - private String handleMessage0(String appId, String content, MpOpenHandleMessageReqVO reqVO) { - // 校验请求签名 - WxMpService mppService = mpServiceFactory.getRequiredMpService(appId); - Assert.isTrue(mppService.checkSignature(reqVO.getTimestamp(), reqVO.getNonce(), reqVO.getSignature()), - "非法请求"); - - // 第一步,解析消息 - WxMpXmlMessage inMessage = null; - if (StrUtil.isBlank(reqVO.getEncrypt_type())) { // 明文模式 - inMessage = WxMpXmlMessage.fromXml(content); - } else if (Objects.equals(reqVO.getEncrypt_type(), MpOpenHandleMessageReqVO.ENCRYPT_TYPE_AES)) { // AES 加密模式 - inMessage = WxMpXmlMessage.fromEncryptedXml(content, mppService.getWxMpConfigStorage(), - reqVO.getTimestamp(), reqVO.getNonce(), reqVO.getMsg_signature()); - } - Assert.notNull(inMessage, "消息解析失败,原因:消息为空"); - - // 第二步,处理消息 - WxMpMessageRouter mpMessageRouter = mpServiceFactory.getRequiredMpMessageRouter(appId); - WxMpXmlOutMessage outMessage = mpMessageRouter.route(inMessage); - if (outMessage == null) { - return ""; - } - - // 第三步,返回消息 - if (StrUtil.isBlank(reqVO.getEncrypt_type())) { // 明文模式 - return outMessage.toXml(); - } else if (Objects.equals(reqVO.getEncrypt_type(), MpOpenHandleMessageReqVO.ENCRYPT_TYPE_AES)) { // AES 加密模式 - return outMessage.toEncryptedXml(mppService.getWxMpConfigStorage()); - } - return ""; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenCheckSignatureReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenCheckSignatureReqVO.java deleted file mode 100644 index 0dd9953b48..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenCheckSignatureReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.open.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 公众号校验签名 Request VO") -@Data -public class MpOpenCheckSignatureReqVO { - - @Schema(description = "微信加密签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "490eb57f448b87bd5f20ccef58aa4de46aa1908e") - @NotEmpty(message = "微信加密签名不能为空") - private String signature; - - @Schema(description = "时间戳", requiredMode = Schema.RequiredMode.REQUIRED, example = "1672587863") - @NotEmpty(message = "时间戳不能为空") - private String timestamp; - - @Schema(description = "随机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1827365808") - @NotEmpty(message = "随机数不能为空") - private String nonce; - - @Schema(description = "随机字符串", requiredMode = Schema.RequiredMode.REQUIRED, example = "2721154047828672511") - @NotEmpty(message = "随机字符串不能为空") - @SuppressWarnings("SpellCheckingInspection") - private String echostr; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenHandleMessageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenHandleMessageReqVO.java deleted file mode 100644 index 11caca0d1e..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenHandleMessageReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.open.vo; - - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 公众号处理消息 Request VO") -@Data -public class MpOpenHandleMessageReqVO { - - public static final String ENCRYPT_TYPE_AES = "aes"; - - @Schema(description = "微信加密签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "490eb57f448b87bd5f20ccef58aa4de46aa1908e") - @NotEmpty(message = "微信加密签名不能为空") - private String signature; - - @Schema(description = "时间戳", requiredMode = Schema.RequiredMode.REQUIRED, example = "1672587863") - @NotEmpty(message = "时间戳不能为空") - private String timestamp; - - @Schema(description = "随机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1827365808") - @NotEmpty(message = "随机数不能为空") - private String nonce; - - @Schema(description = "粉丝 openid", requiredMode = Schema.RequiredMode.REQUIRED, example = "oz-Jdtyn-WGm4C4I5Z-nvBMO_ZfY") - @NotEmpty(message = "粉丝 openid 不能为空") - private String openid; - - @Schema(description = "消息加密类型", example = "aes") - private String encrypt_type; - - @Schema(description = "微信签名", example = "QW5kcm9pZCBUaGUgQmFzZTY0IGlzIGEgZ2VuZXJhdGVkIHN0cmluZw==") - private String msg_signature; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java deleted file mode 100644 index 6c5016ef30..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.*; -import cn.iocoder.yudao.module.mp.convert.statistics.MpStatisticsConvert; -import cn.iocoder.yudao.module.mp.service.statistics.MpStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号统计") -@RestController -@RequestMapping("/mp/statistics") -@Validated -public class MpStatisticsController { - - @Resource - private MpStatisticsService mpStatisticsService; - - @GetMapping("/user-summary") - @Operation(summary = "获得粉丝增减数据") - @PreAuthorize("@ss.hasPermission('mp:statistics:query')") - public CommonResult> getUserSummary(MpStatisticsGetReqVO getReqVO) { - List list = mpStatisticsService.getUserSummary( - getReqVO.getAccountId(), getReqVO.getDate()); - return success(MpStatisticsConvert.INSTANCE.convertList01(list)); - } - - @GetMapping("/user-cumulate") - @Operation(summary = "获得粉丝累计数据") - @PreAuthorize("@ss.hasPermission('mp:statistics:query')") - public CommonResult> getUserCumulate(MpStatisticsGetReqVO getReqVO) { - List list = mpStatisticsService.getUserCumulate( - getReqVO.getAccountId(), getReqVO.getDate()); - return success(MpStatisticsConvert.INSTANCE.convertList02(list)); - } - - @GetMapping("/upstream-message") - @Operation(summary = "获取消息发送概况数据") - @PreAuthorize("@ss.hasPermission('mp:statistics:query')") - public CommonResult> getUpstreamMessage(MpStatisticsGetReqVO getReqVO) { - List list = mpStatisticsService.getUpstreamMessage( - getReqVO.getAccountId(), getReqVO.getDate()); - return success(MpStatisticsConvert.INSTANCE.convertList03(list)); - } - - @GetMapping("/interface-summary") - @Operation(summary = "获取消息发送概况数据") - @PreAuthorize("@ss.hasPermission('mp:statistics:query')") - public CommonResult> getInterfaceSummary(MpStatisticsGetReqVO getReqVO) { - List list = mpStatisticsService.getInterfaceSummary( - getReqVO.getAccountId(), getReqVO.getDate()); - return success(MpStatisticsConvert.INSTANCE.convertList04(list)); - } -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java deleted file mode 100644 index 4d7a84aba9..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 获得统计数据 Request VO") -@Data -public class MpStatisticsGetReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "查询时间范围") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @NotNull(message = "查询时间范围不能为空") - private LocalDateTime[] date; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsInterfaceSummaryRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsInterfaceSummaryRespVO.java deleted file mode 100644 index c7952f42d8..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsInterfaceSummaryRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 某一天的接口分析数据 Response VO") -@Data -public class MpStatisticsInterfaceSummaryRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime refDate; - - @Schema(description = "通过服务器配置地址获得消息后,被动回复粉丝消息的次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer callbackCount; - - @Schema(description = "上述动作的失败次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer failCount; - - @Schema(description = "总耗时,除以 callback_count 即为平均耗时", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") - private Integer totalTimeCost; - - @Schema(description = "最大耗时", requiredMode = Schema.RequiredMode.REQUIRED, example = "40") - private Integer maxTimeCost; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUpstreamMessageRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUpstreamMessageRespVO.java deleted file mode 100644 index f9bba2ce28..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUpstreamMessageRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 某一天的粉丝增减数据 Response VO") -@Data -public class MpStatisticsUpstreamMessageRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime refDate; - - @Schema(description = "上行发送了(向公众号发送了)消息的粉丝数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer messageUser; - - @Schema(description = "上行发送了消息的消息总数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer messageCount; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserCumulateRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserCumulateRespVO.java deleted file mode 100644 index 6503c07808..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserCumulateRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 某一天的消息发送概况数据 Response VO") -@Data -public class MpStatisticsUserCumulateRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime refDate; - - @Schema(description = "累计粉丝量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer cumulateUser; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserSummaryRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserSummaryRespVO.java deleted file mode 100644 index 7a5373c5db..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserSummaryRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 某一天的粉丝增减数据 Response VO") -@Data -public class MpStatisticsUserSummaryRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime refDate; - - @Schema(description = "粉丝来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer userSource; - - @Schema(description = "新关注的粉丝数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer newUser; - - @Schema(description = "取消关注的粉丝数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer cancelUser; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.http deleted file mode 100644 index fe79105ba7..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.http +++ /dev/null @@ -1,39 +0,0 @@ -### 请求 /mp/tag/create 接口 => 成功 -POST {{baseUrl}}/mp/tag/create -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "accountId": "1", - "name": "测试" -} - -### 请求 /mp/tag/update 接口 => 成功 -PUT {{baseUrl}}/mp/tag/update -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "id": "3", - "name": "测试标签啦" -} - -### 请求 /mp/tag/delete 接口 => 成功 -DELETE {{baseUrl}}/mp/tag/delete?id=3 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/tag/page 接口 => 成功 -GET {{baseUrl}}/mp/tag/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/tag/sync 接口 => 成功 -POST {{baseUrl}}/mp/tag/sync?accountId=1 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.java deleted file mode 100644 index dae24ff4b4..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.*; -import cn.iocoder.yudao.module.mp.convert.tag.MpTagConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import cn.iocoder.yudao.module.mp.service.tag.MpTagService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号标签") -@RestController -@RequestMapping("/mp/tag") -@Validated -public class MpTagController { - - @Resource - private MpTagService mpTagService; - - @PostMapping("/create") - @Operation(summary = "创建公众号标签") - @PreAuthorize("@ss.hasPermission('mp:tag:create')") - public CommonResult createTag(@Valid @RequestBody MpTagCreateReqVO createReqVO) { - return success(mpTagService.createTag(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新公众号标签") - @PreAuthorize("@ss.hasPermission('mp:tag:update')") - public CommonResult updateTag(@Valid @RequestBody MpTagUpdateReqVO updateReqVO) { - mpTagService.updateTag(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除公众号标签") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:tag:delete')") - public CommonResult deleteTag(@RequestParam("id") Long id) { - mpTagService.deleteTag(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获取公众号标签详情") - @PreAuthorize("@ss.hasPermission('mp:tag:query')") - public CommonResult get(@RequestParam("id") Long id) { - MpTagDO mpTagDO = mpTagService.get(id); - return success(MpTagConvert.INSTANCE.convert(mpTagDO)); - } - - @GetMapping("/page") - @Operation(summary = "获取公众号标签分页") - @PreAuthorize("@ss.hasPermission('mp:tag:query')") - public CommonResult> getTagPage(MpTagPageReqVO pageReqVO) { - PageResult pageResult = mpTagService.getTagPage(pageReqVO); - return success(MpTagConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取公众号账号精简信息列表") - @PreAuthorize("@ss.hasPermission('mp:account:query')") - public CommonResult> getSimpleTags() { - List list = mpTagService.getTagList(); - return success(MpTagConvert.INSTANCE.convertList02(list)); - } - - @PostMapping("/sync") - @Operation(summary = "同步公众号标签") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:tag:sync')") - public CommonResult syncTag(@RequestParam("accountId") Long accountId) { - mpTagService.syncTag(accountId); - return success(true); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagBaseVO.java deleted file mode 100644 index 68c4ae987c..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagBaseVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; - -/** - * 公众号标签 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author fengdan - */ -@Data -public class MpTagBaseVO { - - @Schema(description = "标签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆") - @NotEmpty(message = "标签名不能为空") - private String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagCreateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagCreateReqVO.java deleted file mode 100644 index 0236dbf21a..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagCreateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号标签创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpTagCreateReqVO extends MpTagBaseVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagPageReqVO.java deleted file mode 100644 index b89cbc54f2..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 公众号标签分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpTagPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotEmpty(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "标签名,模糊匹配", example = "哈哈") - private String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagRespVO.java deleted file mode 100644 index 0da562deee..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 公众号标签 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpTagRespVO extends MpTagBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "此标签下粉丝数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer count; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagSimpleRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagSimpleRespVO.java deleted file mode 100644 index ca23be1c80..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagSimpleRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 公众号标签精简信息 Response VO") -@Data -public class MpTagSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号的标签编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long tagId; - - @Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "快乐") - private String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagUpdateReqVO.java deleted file mode 100644 index 9710cd9467..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号标签更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpTagUpdateReqVO extends MpTagBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.http deleted file mode 100644 index 7c615810fc..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.http +++ /dev/null @@ -1,18 +0,0 @@ -### 请求 /mp/user/sync 接口 => 成功 -POST {{baseUrl}}/mp/user/sync?accountId=1 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/user/update 接口 => 成功 -PUT {{baseUrl}}/mp/user/update -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "id": "3", - "nickname": "test", - "remark": "测试备注", - "tagIds": [103, 104] -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.java deleted file mode 100644 index 4da1cf9e73..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.user; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO; -import cn.iocoder.yudao.module.mp.convert.user.MpUserConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.service.user.MpUserService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号粉丝") -@RestController -@RequestMapping("/mp/user") -@Validated -public class MpUserController { - - @Resource - private MpUserService mpUserService; - - @GetMapping("/page") - @Operation(summary = "获得公众号粉丝分页") - @PreAuthorize("@ss.hasPermission('mp:user:query')") - public CommonResult> getUserPage(@Valid MpUserPageReqVO pageVO) { - PageResult pageResult = mpUserService.getUserPage(pageVO); - return success(MpUserConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/get") - @Operation(summary = "获得公众号粉丝") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:user:query')") - public CommonResult getUser(@RequestParam("id") Long id) { - return success(MpUserConvert.INSTANCE.convert(mpUserService.getUser(id))); - } - - @PutMapping("/update") - @Operation(summary = "更新公众号粉丝") - @PreAuthorize("@ss.hasPermission('mp:user:update')") - public CommonResult updateUser(@Valid @RequestBody MpUserUpdateReqVO updateReqVO) { - mpUserService.updateUser(updateReqVO); - return success(true); - } - - @PostMapping("/sync") - @Operation(summary = "同步公众号粉丝") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:user:sync')") - public CommonResult syncUser(@RequestParam("accountId") Long accountId) { - mpUserService.syncUser(accountId); - return success(true); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserPageReqVO.java deleted file mode 100644 index 2060861d35..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.user.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号粉丝分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpUserPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "公众号粉丝标识,模糊匹配", example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String openid; - - @Schema(description = "公众号粉丝昵称,模糊匹配", example = "芋艿") - private String nickname; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserRespVO.java deleted file mode 100644 index 653171ecbb..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserRespVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; - -@Schema(description = "管理后台 - 公众号粉丝 Response VO") -@Data -public class MpUserRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号粉丝标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String openid; - - @Schema(description = "关注状态 参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer subscribeStatus; - @Schema(description = "关注时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime subscribeTime; - @Schema(description = "取消关注时间") - private LocalDateTime unsubscribeTime; - - @Schema(description = "昵称", example = "芋道") - private String nickname; - @Schema(description = "头像地址", example = "https://www.iocoder.cn/1.png") - private String headImageUrl; - @Schema(description = "语言", example = "zh_CN") - private String language; - @Schema(description = "国家", example = "中国") - private String country; - @Schema(description = "省份", example = "广东省") - private String province; - @Schema(description = "城市", example = "广州市") - private String city; - @Schema(description = "备注", example = "你是一个芋头嘛") - private String remark; - - @Schema(description = "标签编号数组", example = "1,2,3") - private List tagIds; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long accountId; - @Schema(description = "公众号账号的 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890") - private String appId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserUpdateReqVO.java deleted file mode 100644 index 490287e21e..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserUpdateReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 公众号粉丝更新 Request VO") -@Data -public class MpUserUpdateReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "昵称", example = "芋道") - private String nickname; - - @Schema(description = "备注", example = "你是一个芋头嘛") - private String remark; - - @Schema(description = "标签编号数组", example = "1,2,3") - private List tagIds; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/package-info.java deleted file mode 100644 index 31a0577673..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.mp.controller; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java deleted file mode 100644 index 5f8fde36ad..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.account; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountSimpleRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpAccountConvert { - - MpAccountConvert INSTANCE = Mappers.getMapper(MpAccountConvert.class); - - MpAccountDO convert(MpAccountCreateReqVO bean); - - MpAccountDO convert(MpAccountUpdateReqVO bean); - - MpAccountRespVO convert(MpAccountDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/material/MpMaterialConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/material/MpMaterialConvert.java deleted file mode 100644 index ca4f69c3d4..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/material/MpMaterialConvert.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.material; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadRespVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import me.chanjar.weixin.mp.bean.material.WxMpMaterial; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.io.File; - -@Mapper -public interface MpMaterialConvert { - - MpMaterialConvert INSTANCE = Mappers.getMapper(MpMaterialConvert.class); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "account.id", target = "accountId"), - @Mapping(source = "account.appId", target = "appId"), - @Mapping(source = "name", target = "name") - }) - MpMaterialDO convert(String mediaId, String type, String url, MpAccountDO account, - String name); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "account.id", target = "accountId"), - @Mapping(source = "account.appId", target = "appId"), - @Mapping(source = "name", target = "name") - }) - MpMaterialDO convert(String mediaId, String type, String url, MpAccountDO account, - String name, String title, String introduction, String mpUrl); - - MpMaterialUploadRespVO convert(MpMaterialDO bean); - - default WxMpMaterial convert(String name, File file, String title, String introduction) { - return new WxMpMaterial(name, file, title, introduction); - } - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java deleted file mode 100644 index a5ae32a44f..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.menu; - -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuSaveReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import me.chanjar.weixin.common.bean.menu.WxMenuButton; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpMenuConvert { - - MpMenuConvert INSTANCE = Mappers.getMapper(MpMenuConvert.class); - - MpMenuRespVO convert(MpMenuDO bean); - - List convertList(List list); - - @Mappings({ - @Mapping(source = "menu.appId", target = "appId"), - @Mapping(source = "menu.replyMessageType", target = "type"), - @Mapping(source = "menu.replyContent", target = "content"), - @Mapping(source = "menu.replyMediaId", target = "mediaId"), - @Mapping(source = "menu.replyThumbMediaId", target = "thumbMediaId"), - @Mapping(source = "menu.replyTitle", target = "title"), - @Mapping(source = "menu.replyDescription", target = "description"), - @Mapping(source = "menu.replyArticles", target = "articles"), - @Mapping(source = "menu.replyMusicUrl", target = "musicUrl"), - @Mapping(source = "menu.replyHqMusicUrl", target = "hqMusicUrl"), - }) - MpMessageSendOutReqBO convert(String openid, MpMenuDO menu); - - List convert(List list); - - @Mappings({ - @Mapping(source = "menuKey", target = "key"), - @Mapping(source = "children", target = "subButtons"), - @Mapping(source = "miniProgramAppId", target = "appId"), - @Mapping(source = "miniProgramPagePath", target = "pagePath"), - }) - WxMenuButton convert(MpMenuSaveReqVO.Menu bean); - - MpMenuDO convert02(MpMenuSaveReqVO.Menu menu); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java deleted file mode 100644 index c7cf8902ef..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface MpAutoReplyConvert { - - MpAutoReplyConvert INSTANCE = Mappers.getMapper(MpAutoReplyConvert.class); - - @Mappings({ - @Mapping(source = "reply.appId", target = "appId"), - @Mapping(source = "reply.responseMessageType", target = "type"), - @Mapping(source = "reply.responseContent", target = "content"), - @Mapping(source = "reply.responseMediaId", target = "mediaId"), - @Mapping(source = "reply.responseTitle", target = "title"), - @Mapping(source = "reply.responseDescription", target = "description"), - @Mapping(source = "reply.responseArticles", target = "articles"), - }) - MpMessageSendOutReqBO convert(String openid, MpAutoReplyDO reply); - - PageResult convertPage(PageResult page); - - MpAutoReplyRespVO convert(MpAutoReplyDO bean); - - MpAutoReplyDO convert(MpAutoReplyCreateReqVO bean); - - MpAutoReplyDO convert(MpAutoReplyUpdateReqVO bean); -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java deleted file mode 100644 index 8f31a683a2..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java +++ /dev/null @@ -1,172 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageSendReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage; -import me.chanjar.weixin.mp.builder.outxml.BaseBuilder; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpMessageConvert { - - MpMessageConvert INSTANCE = Mappers.getMapper(MpMessageConvert.class); - - MpMessageRespVO convert(MpMessageDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default MpMessageDO convert(WxMpXmlMessage wxMessage, MpAccountDO account, MpUserDO user) { - MpMessageDO message = convert(wxMessage); - if (account != null) { - message.setAccountId(account.getId()).setAppId(account.getAppId()); - } - if (user != null) { - message.setUserId(user.getId()).setOpenid(user.getOpenid()); - } - return message; - } - @Mappings(value = { - @Mapping(source = "msgType", target = "type"), - @Mapping(target = "createTime", ignore = true), - }) - MpMessageDO convert(WxMpXmlMessage bean); - - default MpMessageDO convert(MpMessageSendOutReqBO sendReqBO, MpAccountDO account, MpUserDO user) { - // 构建消息 - MpMessageDO message = new MpMessageDO(); - message.setType(sendReqBO.getType()); - switch (sendReqBO.getType()) { - case WxConsts.XmlMsgType.TEXT: // 1. 文本 - message.setContent(sendReqBO.getContent()); - break; - case WxConsts.XmlMsgType.IMAGE: // 2. 图片 - case WxConsts.XmlMsgType.VOICE: // 3. 语音 - message.setMediaId(sendReqBO.getMediaId()); - break; - case WxConsts.XmlMsgType.VIDEO: // 4. 视频 - message.setMediaId(sendReqBO.getMediaId()) - .setTitle(sendReqBO.getTitle()).setDescription(sendReqBO.getDescription()); - break; - case WxConsts.XmlMsgType.NEWS: // 5. 图文 - message.setArticles(sendReqBO.getArticles()); - case WxConsts.XmlMsgType.MUSIC: // 6. 音乐 - message.setTitle(sendReqBO.getTitle()).setDescription(sendReqBO.getDescription()) - .setMusicUrl(sendReqBO.getMusicUrl()).setHqMusicUrl(sendReqBO.getHqMusicUrl()) - .setThumbMediaId(sendReqBO.getThumbMediaId()); - break; - default: - throw new IllegalArgumentException("不支持的消息类型:" + message.getType()); - } - - // 其它字段 - if (account != null) { - message.setAccountId(account.getId()).setAppId(account.getAppId()); - } - if (user != null) { - message.setUserId(user.getId()).setOpenid(user.getOpenid()); - } - return message; - } - - default WxMpXmlOutMessage convert02(MpMessageDO message, MpAccountDO account) { - BaseBuilder builder; - // 个性化字段 - switch (message.getType()) { - case WxConsts.XmlMsgType.TEXT: - builder = WxMpXmlOutMessage.TEXT().content(message.getContent()); - break; - case WxConsts.XmlMsgType.IMAGE: - builder = WxMpXmlOutMessage.IMAGE().mediaId(message.getMediaId()); - break; - case WxConsts.XmlMsgType.VOICE: - builder = WxMpXmlOutMessage.VOICE().mediaId(message.getMediaId()); - break; - case WxConsts.XmlMsgType.VIDEO: - builder = WxMpXmlOutMessage.VIDEO().mediaId(message.getMediaId()) - .title(message.getTitle()).description(message.getDescription()); - break; - case WxConsts.XmlMsgType.NEWS: - builder = WxMpXmlOutMessage.NEWS().articles(convertList02(message.getArticles())); - break; - case WxConsts.XmlMsgType.MUSIC: - builder = WxMpXmlOutMessage.MUSIC().title(message.getTitle()).description(message.getDescription()) - .musicUrl(message.getMusicUrl()).hqMusicUrl(message.getHqMusicUrl()) - .thumbMediaId(message.getThumbMediaId()); - break; - default: - throw new IllegalArgumentException("不支持的消息类型:" + message.getType()); - } - // 通用字段 - builder.fromUser(account.getAccount()); - builder.toUser(message.getOpenid()); - return builder.build(); - } - List convertList02(List list); - - default WxMpKefuMessage convert(MpMessageSendReqVO sendReqVO, MpUserDO user) { - me.chanjar.weixin.mp.builder.kefu.BaseBuilder builder; - // 个性化字段 - switch (sendReqVO.getType()) { - case WxConsts.KefuMsgType.TEXT: - builder = WxMpKefuMessage.TEXT().content(sendReqVO.getContent()); - break; - case WxConsts.KefuMsgType.IMAGE: - builder = WxMpKefuMessage.IMAGE().mediaId(sendReqVO.getMediaId()); - break; - case WxConsts.KefuMsgType.VOICE: - builder = WxMpKefuMessage.VOICE().mediaId(sendReqVO.getMediaId()); - break; - case WxConsts.KefuMsgType.VIDEO: - builder = WxMpKefuMessage.VIDEO().mediaId(sendReqVO.getMediaId()) - .title(sendReqVO.getTitle()).description(sendReqVO.getDescription()); - break; - case WxConsts.KefuMsgType.NEWS: - builder = WxMpKefuMessage.NEWS().articles(convertList03(sendReqVO.getArticles())); - break; - case WxConsts.KefuMsgType.MUSIC: - builder = WxMpKefuMessage.MUSIC().title(sendReqVO.getTitle()).description(sendReqVO.getDescription()) - .thumbMediaId(sendReqVO.getThumbMediaId()) - .musicUrl(sendReqVO.getMusicUrl()).hqMusicUrl(sendReqVO.getHqMusicUrl()); - break; - default: - throw new IllegalArgumentException("不支持的消息类型:" + sendReqVO.getType()); - } - // 通用字段 - builder.toUser(user.getOpenid()); - return builder.build(); - } - List convertList03(List list); - - default MpMessageDO convert(WxMpKefuMessage wxMessage, MpAccountDO account, MpUserDO user) { - MpMessageDO message = convert(wxMessage); - if (account != null) { - message.setAccountId(account.getId()).setAppId(account.getAppId()); - } - if (user != null) { - message.setUserId(user.getId()).setOpenid(user.getOpenid()); - } - return message; - } - @Mappings(value = { - @Mapping(source = "msgType", target = "type"), - @Mapping(target = "createTime", ignore = true), - }) - MpMessageDO convert(WxMpKefuMessage bean); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java deleted file mode 100644 index 174b0fdc3b..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.statistics; - -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsInterfaceSummaryRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUpstreamMessageRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserCumulateRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserSummaryRespVO; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpStatisticsConvert { - - MpStatisticsConvert INSTANCE = Mappers.getMapper(MpStatisticsConvert.class); - - List convertList01(List list); - - List convertList02(List list); - - List convertList03(List list); - - @Mappings({ - @Mapping(source = "refDate", target = "refDate", dateFormat = "yyyy-MM-dd"), - @Mapping(source = "msgUser", target = "messageUser"), - @Mapping(source = "msgCount", target = "messageCount"), - }) - MpStatisticsUpstreamMessageRespVO convert(WxDataCubeMsgResult bean); - - List convertList04(List list); - - @Mapping(source = "refDate", target = "refDate", dateFormat = "yyyy-MM-dd") - MpStatisticsInterfaceSummaryRespVO convert(WxDataCubeInterfaceResult bean); -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/tag/MpTagConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/tag/MpTagConvert.java deleted file mode 100644 index 727ccd3145..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/tag/MpTagConvert.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagSimpleRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import me.chanjar.weixin.mp.bean.tag.WxUserTag; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpTagConvert { - - MpTagConvert INSTANCE = Mappers.getMapper(MpTagConvert.class); - - WxUserTag convert(MpTagUpdateReqVO bean); - - MpTagRespVO convert(WxUserTag bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "tag.id", target = "tagId"), - @Mapping(source = "tag.name", target = "name"), - @Mapping(source = "tag.count", target = "count"), - @Mapping(source = "account.id", target = "accountId"), - @Mapping(source = "account.appId", target = "appId"), - }) - MpTagDO convert(WxUserTag tag, MpAccountDO account); - - MpTagRespVO convert(MpTagDO mpTagDO); - - List convertList02(List list); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/user/MpUserConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/user/MpUserConvert.java deleted file mode 100644 index 9ad7edf747..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/user/MpUserConvert.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.user; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import me.chanjar.weixin.mp.bean.result.WxMpUser; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpUserConvert { - - MpUserConvert INSTANCE = Mappers.getMapper(MpUserConvert.class); - - MpUserRespVO convert(MpUserDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - @Mappings(value = { - @Mapping(source = "openId", target = "openid"), - @Mapping(source = "headImgUrl", target = "headImageUrl"), - @Mapping(target = "subscribeTime", ignore = true), // 单独转换 - }) - MpUserDO convert(WxMpUser wxMpUser); - - default MpUserDO convert(MpAccountDO account, WxMpUser wxMpUser) { - MpUserDO user = convert(wxMpUser); - user.setSubscribeStatus(wxMpUser.getSubscribe() ? CommonStatusEnum.ENABLE.getStatus() - : CommonStatusEnum.DISABLE.getStatus()); - user.setSubscribeTime(LocalDateTimeUtil.of(wxMpUser.getSubscribeTime() * 1000L)); - if (account != null) { - user.setAccountId(account.getId()); - user.setAppId(account.getAppId()); - } - return user; - } - - default List convertList(MpAccountDO account, List wxUsers) { - return CollectionUtils.convertList(wxUsers, wxUser -> convert(account, wxUser)); - } - - MpUserDO convert(MpUserUpdateReqVO bean); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/account/MpAccountDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/account/MpAccountDO.java deleted file mode 100644 index eddf87ba0b..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/account/MpAccountDO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.account; - -import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 公众号账号 DO - * - * @author 芋道源码 - */ -@TableName("mp_account") -@KeySequence("mp_account_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MpAccountDO extends TenantBaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 公众号名称 - */ - private String name; - /** - * 公众号账号 - */ - private String account; - /** - * 公众号 appid - */ - private String appId; - /** - * 公众号密钥 - */ - private String appSecret; - /** - * 公众号token - */ - private String token; - /** - * 消息加解密密钥 - */ - private String aesKey; - /** - * 二维码图片 URL - */ - private String qrCodeUrl; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/material/MpMaterialDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/material/MpMaterialDO.java deleted file mode 100644 index 735235e311..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/material/MpMaterialDO.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.material; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; -import me.chanjar.weixin.common.api.WxConsts; - -/** - * 公众号素材 DO - * - * 1. 临时素材 - * 2. 永久素材 - * - * @author 芋道源码 - */ -@TableName("mp_material") -@KeySequence("mp_material_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MpMaterialDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - - /** - * 公众号素材 id - */ - private String mediaId; - /** - * 文件类型 - * - * 枚举 {@link WxConsts.MediaFileType} - */ - private String type; - /** - * 是否永久 - * - * true - 永久素材 - * false - 临时素材 - */ - private Boolean permanent; - /** - * 文件服务器的 URL - */ - private String url; - - /** - * 名字 - * - * 永久素材:非空 - * 临时素材:可能为空。 - * 1. 为空的情况:粉丝主动发送的图片、语音等 - * 2. 非空的情况:主动发送给粉丝的图片、语音等 - */ - private String name; - - /** - * 公众号文件 URL - * - * 只有【永久素材】使用 - */ - private String mpUrl; - - /** - * 视频素材的标题 - * - * 只有【永久素材】使用 - */ - private String title; - /** - * 视频素材的描述 - * - * 只有【永久素材】使用 - */ - private String introduction; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java deleted file mode 100644 index 2e6aa73cec..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java +++ /dev/null @@ -1,184 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.menu; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.api.WxConsts.MenuButtonType; - -import java.util.List; - -/** - * 公众号菜单 DO - * - * @author 芋道源码 - */ -@TableName(value = "mp_menu", autoResultMap = true) -@KeySequence("mp_menu_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMenuDO extends BaseDO { - - /** - * 编号 - 顶级菜单 - */ - public static final Long ID_ROOT = 0L; - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - - /** - * 菜单名称 - */ - private String name; - /** - * 菜单标识 - * - * 支持多 DB 类型时,无法直接使用 key + @TableField("menuKey") 来实现转换,原因是 "menuKey" AS key 而存在报错 - */ - private String menuKey; - /** - * 父菜单编号 - */ - private Long parentId; - - // ========== 按钮操作 ========== - - /** - * 按钮类型 - * - * 枚举 {@link MenuButtonType} - */ - private String type; - - /** - * 网页链接 - * - * 粉丝点击菜单可打开链接,不超过 1024 字节 - * - * 类型为 {@link WxConsts.XmlMsgType} 的 VIEW、MINIPROGRAM - */ - private String url; - - /** - * 小程序的 appId - * - * 类型为 {@link MenuButtonType} 的 MINIPROGRAM - */ - private String miniProgramAppId; - /** - * 小程序的页面路径 - * - * 类型为 {@link MenuButtonType} 的 MINIPROGRAM - */ - private String miniProgramPagePath; - - /** - * 跳转图文的媒体编号 - */ - private String articleId; - - // ========== 消息内容 ========== - - /** - * 消息类型 - * - * 当 {@link #type} 为 CLICK、SCANCODE_WAITMSG - * - * 枚举 {@link WxConsts.XmlMsgType} 中的 TEXT、IMAGE、VOICE、VIDEO、NEWS、MUSIC - */ - private String replyMessageType; - - /** - * 回复的消息内容 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 TEXT - */ - private String replyContent; - - /** - * 回复的媒体 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - private String replyMediaId; - /** - * 回复的媒体 URL - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - private String replyMediaUrl; - - /** - * 回复的标题 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - private String replyTitle; - /** - * 回复的描述 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - private String replyDescription; - - /** - * 回复的缩略图的媒体 id,通过素材管理中的接口上传多媒体文件,得到的 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String replyThumbMediaId; - /** - * 回复的缩略图的媒体 URL - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String replyThumbMediaUrl; - - /** - * 回复的图文消息数组 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @TableField(typeHandler = MpMessageDO.ArticleTypeHandler.class) - private List replyArticles; - - /** - * 回复的音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String replyMusicUrl; - /** - * 回复的高质量音乐链接 - * - * WIFI 环境优先使用该链接播放音乐 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String replyHqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java deleted file mode 100644 index 52f4539a45..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java +++ /dev/null @@ -1,164 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.message; - -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyMatchEnum; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.api.WxConsts.XmlMsgType; - -import java.util.List; -import java.util.Set; - -/** - * 公众号消息自动回复 DO - * - * @author 芋道源码 - */ -@TableName(value = "mp_auto_reply", autoResultMap = true) -@KeySequence("mp_auto_reply_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyDO extends BaseDO { - - public static Set REQUEST_MESSAGE_TYPE = SetUtils.asSet(WxConsts.XmlMsgType.TEXT, WxConsts.XmlMsgType.IMAGE, - WxConsts.XmlMsgType.VOICE, WxConsts.XmlMsgType.VIDEO, WxConsts.XmlMsgType.SHORTVIDEO, - WxConsts.XmlMsgType.LOCATION, WxConsts.XmlMsgType.LINK); - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - - /** - * 回复类型 - * - * 枚举 {@link MpAutoReplyTypeEnum} - */ - private Integer type; - - // ==================== 请求消息 ==================== - - /** - * 请求的关键字 - * - * 当 {@link #type} 为 {@link MpAutoReplyTypeEnum#KEYWORD} - */ - private String requestKeyword; - /** - * 请求的关键字的匹配 - * - * 当 {@link #type} 为 {@link MpAutoReplyTypeEnum#KEYWORD} - * - * 枚举 {@link MpAutoReplyMatchEnum} - */ - private Integer requestMatch; - - /** - * 请求的消息类型 - * - * 当 {@link #type} 为 {@link MpAutoReplyTypeEnum#MESSAGE} - * - * 枚举 {@link XmlMsgType} 中的 {@link #REQUEST_MESSAGE_TYPE} - */ - private String requestMessageType; - - // ==================== 响应消息 ==================== - - /** - * 回复的消息类型 - * - * 枚举 {@link XmlMsgType} 中的 TEXT、IMAGE、VOICE、VIDEO、NEWS - */ - private String responseMessageType; - - /** - * 回复的消息内容 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 TEXT - */ - private String responseContent; - - /** - * 回复的媒体 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - private String responseMediaId; - /** - * 回复的媒体 URL - */ - private String responseMediaUrl; - - /** - * 回复的标题 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - private String responseTitle; - /** - * 回复的描述 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - private String responseDescription; - - /** - * 回复的缩略图的媒体 id,通过素材管理中的接口上传多媒体文件,得到的 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String responseThumbMediaId; - /** - * 回复的缩略图的媒体 URL - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String responseThumbMediaUrl; - - /** - * 回复的图文消息 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @TableField(typeHandler = MpMessageDO.ArticleTypeHandler.class) - private List responseArticles; - - /** - * 回复的音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String responseMusicUrl; - /** - * 回复的高质量音乐链接 - * - * WIFI 环境优先使用该链接播放音乐 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String responseHqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java deleted file mode 100644 index 76fe1818aa..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java +++ /dev/null @@ -1,255 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.message; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.enums.message.MpMessageSendFromEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.*; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.builder.kefu.NewsBuilder; - -import jakarta.validation.constraints.NotEmpty; -import java.io.Serializable; -import java.util.List; - -/** - * 公众号消息 DO - * - * @author 芋道源码 - */ -@TableName(value = "mp_message", autoResultMap = true) -@KeySequence("mp_message_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMessageDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 微信公众号消息 id - */ - private Long msgId; - /** - * 公众号账号的 ID - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appid - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - /** - * 公众号粉丝的编号 - * - * 关联 {@link MpUserDO#getId()} - */ - private Long userId; - /** - * 公众号粉丝标志 - * - * 冗余 {@link MpUserDO#getOpenid()} - */ - private String openid; - - /** - * 消息类型 - * - * 枚举 {@link WxConsts.XmlMsgType} - */ - private String type; - /** - * 消息来源 - * - * 枚举 {@link MpMessageSendFromEnum} - */ - private Integer sendFrom; - - // ========= 普通消息内容 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_standard_messages.html - - /** - * 消息内容 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 TEXT - */ - private String content; - - /** - * 媒体文件的编号 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - private String mediaId; - /** - * 媒体文件的 URL - */ - private String mediaUrl; - /** - * 语音识别后文本 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VOICE - */ - private String recognition; - /** - * 语音格式,如 amr,speex 等 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VOICE - */ - private String format; - /** - * 标题 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO、MUSIC、LINK - */ - private String title; - /** - * 描述 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO、MUSIC - */ - private String description; - - /** - * 缩略图的媒体 id,通过素材管理中的接口上传多媒体文件,得到的 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String thumbMediaId; - /** - * 缩略图的媒体 URL - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String thumbMediaUrl; - - /** - * 点击图文消息跳转链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LINK - */ - private String url; - - /** - * 地理位置维度 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LOCATION - */ - private Double locationX; - /** - * 地理位置经度 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LOCATION - */ - private Double locationY; - /** - * 地图缩放大小 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LOCATION - */ - private Double scale; - /** - * 详细地址 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LOCATION - * - * 例如说杨浦区黄兴路 221-4 号临 - */ - private String label; - - /** - * 图文消息数组 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @TableField(typeHandler = ArticleTypeHandler.class) - private List
articles; - - /** - * 音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String musicUrl; - /** - * 高质量音乐链接 - * - * WIFI 环境优先使用该链接播放音乐 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String hqMusicUrl; - - // ========= 事件推送 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html - - /** - * 事件类型 - * - * 枚举 {@link WxConsts.EventType} - */ - private String event; - /** - * 事件 Key - * - * 1. {@link WxConsts.EventType} 的 SCAN:qrscene_ 为前缀,后面为二维码的参数值 - * 2. {@link WxConsts.EventType} 的 CLICK:与自定义菜单接口中 KEY 值对应 - */ - private String eventKey; - - /** - * 文章 - */ - @Data - public static class Article implements Serializable { - - /** - * 图文消息标题 - */ - @NotEmpty(message = "图文消息标题不能为空", groups = NewsBuilder.class) - private String title; - /** - * 图文消息描述 - */ - @NotEmpty(message = "图文消息描述不能为空", groups = NewsBuilder.class) - private String description; - /** - * 图片链接 - * - * 支持 JPG、PNG 格式,较好的效果为大图 360*200,小图 200*200 - */ - @NotEmpty(message = "图片链接不能为空", groups = NewsBuilder.class) - private String picUrl; - /** - * 点击图文消息跳转链接 - */ - @NotEmpty(message = "点击图文消息跳转链接不能为空", groups = NewsBuilder.class) - private String url; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class ArticleTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List
parse(String json) { - return JsonUtils.parseArray(json, Article.class); - } - - @Override - protected String toJson(List
obj) { - return JsonUtils.toJsonString(obj); - } - - } -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/tag/MpTagDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/tag/MpTagDO.java deleted file mode 100644 index 8a5b9f6ebd..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/tag/MpTagDO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.tag; - -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import lombok.*; - -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import me.chanjar.weixin.mp.bean.tag.WxUserTag; - -/** - * 公众号标签 DO - * - * @author 芋道源码 - */ -@TableName("mp_tag") -@KeySequence("mp_tag_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MpTagDO extends BaseDO { - - /** - * 主键 - */ - @TableId(type = IdType.INPUT) - private Long id; - /** - * 公众号标签 id - */ - private Long tagId; - /** - * 标签名 - */ - private String name; - /** - * 此标签下粉丝数 - * - * 冗余:{@link WxUserTag#getCount()} 字段,需要管理员点击【同步】后,更新该字段 - */ - private Integer count; - - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/user/MpUserDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/user/MpUserDO.java deleted file mode 100644 index 0b937759e3..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/user/MpUserDO.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.user; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 微信公众号粉丝 DO - * - * @author 芋道源码 - */ -@TableName(value = "mp_user", autoResultMap = true) -@KeySequence("mp_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MpUserDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 粉丝标识 - */ - private String openid; - /** - * 关注状态 - * - * 枚举 {@link CommonStatusEnum} - * 1. 开启 - 已关注 - * 2. 禁用 - 取消关注 - */ - private Integer subscribeStatus; - /** - * 关注时间 - */ - private LocalDateTime subscribeTime; - /** - * 取消关注时间 - */ - private LocalDateTime unsubscribeTime; - /** - * 昵称 - * - * 注意,2021-12-27 公众号接口不再返回头像和昵称,只能通过微信公众号的网页登录获取 - */ - private String nickname; - /** - * 头像地址 - * - * 注意,2021-12-27 公众号接口不再返回头像和昵称,只能通过微信公众号的网页登录获取 - */ - private String headImageUrl; - /** - * 语言 - */ - private String language; - /** - * 国家 - */ - private String country; - /** - * 省份 - */ - private String province; - /** - * 城市 - */ - private String city; - /** - * 备注 - */ - private String remark; - /** - * 标签编号数组 - * - * 注意,对应的是 {@link MpTagDO#getTagId()} 字段 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List tagIds; - - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/account/MpAccountMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/account/MpAccountMapper.java deleted file mode 100644 index 30c54fd515..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/account/MpAccountMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.account; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; - -@Mapper -public interface MpAccountMapper extends BaseMapperX { - - default PageResult selectPage(MpAccountPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(MpAccountDO::getName, reqVO.getName()) - .likeIfPresent(MpAccountDO::getAccount, reqVO.getAccount()) - .likeIfPresent(MpAccountDO::getAppId, reqVO.getAppId()) - .orderByDesc(MpAccountDO::getId)); - } - - default MpAccountDO selectByAppId(String appId) { - return selectOne(MpAccountDO::getAppId, appId); - } - - @Select("SELECT COUNT(*) FROM mp_account WHERE update_time > #{maxUpdateTime}") - Long selectCountByUpdateTimeGt(LocalDateTime maxUpdateTime); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/material/MpMaterialMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/material/MpMaterialMapper.java deleted file mode 100644 index ca3c6b3a99..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/material/MpMaterialMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.material; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface MpMaterialMapper extends BaseMapperX { - - default MpMaterialDO selectByAccountIdAndMediaId(Long accountId, String mediaId) { - return selectOne(MpMaterialDO::getAccountId, accountId, - MpMaterialDO::getMediaId, mediaId); - } - - default PageResult selectPage(MpMaterialPageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(MpMaterialDO::getAccountId, pageReqVO.getAccountId()) - .eqIfPresent(MpMaterialDO::getPermanent, pageReqVO.getPermanent()) - .eqIfPresent(MpMaterialDO::getType, pageReqVO.getType()) - .orderByDesc(MpMaterialDO::getId)); - } - - default List selectListByMediaId(Collection mediaIds) { - return selectList(MpMaterialDO::getMediaId, mediaIds); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/menu/MpMenuMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/menu/MpMenuMapper.java deleted file mode 100644 index fccd7f2d92..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/menu/MpMenuMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.menu; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MpMenuMapper extends BaseMapperX { - - default MpMenuDO selectByAppIdAndMenuKey(String appId, String menuKey) { - return selectOne(MpMenuDO::getAppId, appId, - MpMenuDO::getMenuKey, menuKey); - } - - default List selectListByAccountId(Long accountId) { - return selectList(MpMenuDO::getAccountId, accountId); - } - - default void deleteByAccountId(Long accountId) { - delete(new LambdaQueryWrapperX().eq(MpMenuDO::getAccountId, accountId)); - } -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java deleted file mode 100644 index c8260e8c73..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyMatchEnum; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MpAutoReplyMapper extends BaseMapperX { - - default PageResult selectPage(MpMessagePageReqVO pageVO) { - return selectPage(pageVO, new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAccountId, pageVO.getAccountId()) - .eqIfPresent(MpAutoReplyDO::getType, pageVO.getType())); - } - - default List selectListByAppIdAndKeywordAll(String appId, String requestKeyword) { - return selectList(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAppId, appId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType()) - .eq(MpAutoReplyDO::getRequestMatch, MpAutoReplyMatchEnum.ALL.getMatch()) - .eq(MpAutoReplyDO::getRequestKeyword, requestKeyword)); - } - - default List selectListByAppIdAndKeywordLike(String appId, String requestKeyword) { - return selectList(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAppId, appId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType()) - .eq(MpAutoReplyDO::getRequestMatch, MpAutoReplyMatchEnum.LIKE.getMatch()) - .like(MpAutoReplyDO::getRequestKeyword, requestKeyword)); - } - - default List selectListByAppIdAndMessage(String appId, String requestMessageType) { - return selectList(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAppId, appId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.MESSAGE.getType()) - .eq(MpAutoReplyDO::getRequestMessageType, requestMessageType)); - } - - default List selectListByAppIdAndSubscribe(String appId) { - return selectList(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAppId, appId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.SUBSCRIBE.getType())); - } - - default MpAutoReplyDO selectByAccountIdAndSubscribe(Long accountId) { - return selectOne(MpAutoReplyDO::getAccountId, accountId, - MpAutoReplyDO::getType, MpAutoReplyTypeEnum.SUBSCRIBE.getType()); - } - - default MpAutoReplyDO selectByAccountIdAndMessage(Long accountId, String requestMessageType) { - return selectOne(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAccountId, accountId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.MESSAGE.getType()) - .eq(MpAutoReplyDO::getRequestMessageType, requestMessageType)); - } - - default MpAutoReplyDO selectByAccountIdAndKeyword(Long accountId, String requestKeyword) { - return selectOne(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAccountId, accountId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType()) - .eq(MpAutoReplyDO::getRequestKeyword, requestKeyword)); - } -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpMessageMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpMessageMapper.java deleted file mode 100644 index 72ba566277..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpMessageMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface MpMessageMapper extends BaseMapperX { - - default PageResult selectPage(MpMessagePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MpMessageDO::getAccountId, reqVO.getAccountId()) - .eqIfPresent(MpMessageDO::getType, reqVO.getType()) - .eqIfPresent(MpMessageDO::getOpenid, reqVO.getOpenid()) - .betweenIfPresent(MpMessageDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MpMessageDO::getId)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/tag/MpTagMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/tag/MpTagMapper.java deleted file mode 100644 index 760f53aa1c..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/tag/MpTagMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MpTagMapper extends BaseMapperX { - - default PageResult selectPage(MpTagPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MpTagDO::getAccountId, reqVO.getAccountId()) - .likeIfPresent(MpTagDO::getName, reqVO.getName()) - .orderByDesc(MpTagDO::getId)); - } - - default List selectListByAccountId(Long accountId) { - return selectList(MpTagDO::getAccountId, accountId); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/user/MpUserMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/user/MpUserMapper.java deleted file mode 100644 index bd13f925af..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/user/MpUserMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.user; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MpUserMapper extends BaseMapperX { - - default PageResult selectPage(MpUserPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(MpUserDO::getOpenid, reqVO.getOpenid()) - .likeIfPresent(MpUserDO::getNickname, reqVO.getNickname()) - .eqIfPresent(MpUserDO::getAccountId, reqVO.getAccountId()) - .orderByDesc(MpUserDO::getId)); - } - - default MpUserDO selectByAppIdAndOpenid(String appId, String openid) { - return selectOne(MpUserDO::getAppId, appId, - MpUserDO::getOpenid, openid); - } - - default List selectListByAppIdAndOpenid(String appId, List openids) { - return selectList(new LambdaQueryWrapperX() - .eq(MpUserDO::getAppId, appId) - .in(MpUserDO::getOpenid, openids)); - - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/config/MpConfiguration.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/config/MpConfiguration.java deleted file mode 100644 index c908660666..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/config/MpConfiguration.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.mp.config; - -import cn.iocoder.yudao.module.mp.framework.mp.core.DefaultMpServiceFactory; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.handler.menu.MenuHandler; -import cn.iocoder.yudao.module.mp.service.handler.message.MessageReceiveHandler; -import cn.iocoder.yudao.module.mp.service.handler.message.MessageAutoReplyHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.KfSessionHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.NullHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.ScanHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.StoreCheckNotifyHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.LocationHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.SubscribeHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.UnsubscribeHandler; -import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties; -import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.core.StringRedisTemplate; - -/** - * 微信公众号的配置类 - * - * @author 芋道源码 - */ -@Configuration -public class MpConfiguration { - - @Bean - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - public RedisTemplateWxRedisOps redisTemplateWxRedisOps(StringRedisTemplate stringRedisTemplate) { - return new RedisTemplateWxRedisOps(stringRedisTemplate); - } - - @Bean - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - public MpServiceFactory mpServiceFactory(RedisTemplateWxRedisOps redisTemplateWxRedisOps, - WxMpProperties wxMpProperties, - MessageReceiveHandler messageReceiveHandler, - KfSessionHandler kfSessionHandler, - StoreCheckNotifyHandler storeCheckNotifyHandler, - MenuHandler menuHandler, - NullHandler nullHandler, - SubscribeHandler subscribeHandler, - UnsubscribeHandler unsubscribeHandler, - LocationHandler locationHandler, - ScanHandler scanHandler, - MessageAutoReplyHandler messageAutoReplyHandler) { - return new DefaultMpServiceFactory(redisTemplateWxRedisOps, wxMpProperties, - messageReceiveHandler, kfSessionHandler, storeCheckNotifyHandler, menuHandler, - nullHandler, subscribeHandler, unsubscribeHandler, locationHandler, scanHandler, messageAutoReplyHandler); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/DefaultMpServiceFactory.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/DefaultMpServiceFactory.java deleted file mode 100644 index 414f73aa86..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/DefaultMpServiceFactory.java +++ /dev/null @@ -1,177 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.mp.core; - -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.service.handler.menu.MenuHandler; -import cn.iocoder.yudao.module.mp.service.handler.message.MessageReceiveHandler; -import cn.iocoder.yudao.module.mp.service.handler.message.MessageAutoReplyHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.KfSessionHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.NullHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.ScanHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.StoreCheckNotifyHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.LocationHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.SubscribeHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.UnsubscribeHandler; -import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties; -import com.google.common.collect.Maps; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; -import me.chanjar.weixin.mp.api.WxMpMessageRouter; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; -import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl; -import me.chanjar.weixin.mp.constant.WxMpEventConstants; - -import java.util.List; -import java.util.Map; - -/** - * 默认的 {@link MpServiceFactory} 实现类 - * - * @author 芋道源码 - */ -@Slf4j -@RequiredArgsConstructor -public class DefaultMpServiceFactory implements MpServiceFactory { - - /** - * 微信 appId 与 WxMpService 的映射 - */ - private volatile Map appId2MpServices; - /** - * 公众号账号 id 与 WxMpService 的映射 - */ - private volatile Map id2MpServices; - /** - * 微信 appId 与 WxMpMessageRouter 的映射 - */ - private volatile Map mpMessageRouters; - - private final RedisTemplateWxRedisOps redisTemplateWxRedisOps; - private final WxMpProperties mpProperties; - - // ========== 各种 Handler ========== - - private final MessageReceiveHandler messageReceiveHandler; - private final KfSessionHandler kfSessionHandler; - private final StoreCheckNotifyHandler storeCheckNotifyHandler; - private final MenuHandler menuHandler; - private final NullHandler nullHandler; - private final SubscribeHandler subscribeHandler; - private final UnsubscribeHandler unsubscribeHandler; - private final LocationHandler locationHandler; - private final ScanHandler scanHandler; - private final MessageAutoReplyHandler messageAutoReplyHandler; - - @Override - public void init(List list) { - Map appId2MpServices = Maps.newHashMap(); - Map id2MpServices = Maps.newHashMap(); - Map mpMessageRouters = Maps.newHashMap(); - // 处理 list - list.forEach(account -> { - // 构建 WxMpService 对象 - WxMpService mpService = buildMpService(account); - appId2MpServices.put(account.getAppId(), mpService); - id2MpServices.put(account.getId(), mpService); - // 构建 WxMpMessageRouter 对象 - WxMpMessageRouter mpMessageRouter = buildMpMessageRouter(mpService); - mpMessageRouters.put(account.getAppId(), mpMessageRouter); - }); - - // 设置到缓存 - this.appId2MpServices = appId2MpServices; - this.id2MpServices = id2MpServices; - this.mpMessageRouters = mpMessageRouters; - } - - @Override - public WxMpService getMpService(Long id) { - return id2MpServices.get(id); - } - - @Override - public WxMpService getMpService(String appId) { - return appId2MpServices.get(appId); - } - - @Override - public WxMpMessageRouter getMpMessageRouter(String appId) { - return mpMessageRouters.get(appId); - } - - private WxMpService buildMpService(MpAccountDO account) { - // 第一步,创建 WxMpRedisConfigImpl 对象 - WxMpRedisConfigImpl configStorage = new WxMpRedisConfigImpl( - redisTemplateWxRedisOps, mpProperties.getConfigStorage().getKeyPrefix()); - configStorage.setAppId(account.getAppId()); - configStorage.setSecret(account.getAppSecret()); - configStorage.setToken(account.getToken()); - configStorage.setAesKey(account.getAesKey()); - - // 第二步,创建 WxMpService 对象 - WxMpService service = new WxMpServiceImpl(); - service.setWxMpConfigStorage(configStorage); - return service; - } - - private WxMpMessageRouter buildMpMessageRouter(WxMpService mpService) { - WxMpMessageRouter router = new WxMpMessageRouter(mpService); - // 记录所有事件的日志(异步执行) - router.rule().handler(messageReceiveHandler).next(); - - // 接收客服会话管理事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxMpEventConstants.CustomerService.KF_CREATE_SESSION) - .handler(kfSessionHandler).end(); - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxMpEventConstants.CustomerService.KF_CLOSE_SESSION) - .handler(kfSessionHandler) - .end(); - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxMpEventConstants.CustomerService.KF_SWITCH_SESSION) - .handler(kfSessionHandler).end(); - - // 门店审核事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxMpEventConstants.POI_CHECK_NOTIFY) - .handler(storeCheckNotifyHandler).end(); - - // 自定义菜单事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.MenuButtonType.CLICK).handler(menuHandler).end(); - - // 点击菜单连接事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.MenuButtonType.VIEW).handler(nullHandler).end(); - - // 关注事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.EventType.SUBSCRIBE).handler(subscribeHandler) - .end(); - - // 取消关注事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.EventType.UNSUBSCRIBE) - .handler(unsubscribeHandler).end(); - - // 上报地理位置事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.EventType.LOCATION).handler(locationHandler) - .end(); - - // 接收地理位置消息 - router.rule().async(false).msgType(WxConsts.XmlMsgType.LOCATION) - .handler(locationHandler).end(); - - // 扫码事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.EventType.SCAN).handler(scanHandler).end(); - - // 默认 - router.rule().async(false).handler(messageAutoReplyHandler).end(); - return router; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/MpServiceFactory.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/MpServiceFactory.java deleted file mode 100644 index ce017ff64d..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/MpServiceFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.mp.core; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import me.chanjar.weixin.mp.api.WxMpMessageRouter; -import me.chanjar.weixin.mp.api.WxMpService; - -import java.util.List; - -/** - * {@link WxMpService} 工厂接口 - * - * @author 芋道源码 - */ -public interface MpServiceFactory { - - /** - * 基于微信公众号的账号,初始化对应的 WxMpService 与 WxMpMessageRouter 实例 - * - * @param list 公众号的账号列表 - */ - void init(List list); - - /** - * 获得 id 对应的 WxMpService 实例 - * - * @param id 微信公众号的编号 - * @return WxMpService 实例 - */ - WxMpService getMpService(Long id); - - default WxMpService getRequiredMpService(Long id) { - WxMpService wxMpService = getMpService(id); - Assert.notNull(wxMpService, "找到对应 id({}) 的 WxMpService,请核实!", id); - return wxMpService; - } - - /** - * 获得 appId 对应的 WxMpService 实例 - * - * @param appId 微信公众号 appId - * @return WxMpService 实例 - */ - WxMpService getMpService(String appId); - - default WxMpService getRequiredMpService(String appId) { - WxMpService wxMpService = getMpService(appId); - Assert.notNull(wxMpService, "找到对应 appId({}) 的 WxMpService,请核实!", appId); - return wxMpService; - } - - /** - * 获得 appId 对应的 WxMpMessageRouter 实例 - * - * @param appId 微信公众号 appId - * @return WxMpMessageRouter 实例 - */ - WxMpMessageRouter getMpMessageRouter(String appId); - - default WxMpMessageRouter getRequiredMpMessageRouter(String appId) { - WxMpMessageRouter wxMpMessageRouter = getMpMessageRouter(appId); - Assert.notNull(wxMpMessageRouter, "找到对应 appId({}) 的 WxMpMessageRouter,请核实!", appId); - return wxMpMessageRouter; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/context/MpContextHolder.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/context/MpContextHolder.java deleted file mode 100644 index e5c45c5318..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/context/MpContextHolder.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package cn.iocoder.yudao.module.mp.framework.mp.core.context; - -import cn.iocoder.yudao.module.mp.controller.admin.open.vo.MpOpenHandleMessageReqVO; -import com.alibaba.ttl.TransmittableThreadLocal; -import lombok.experimental.UtilityClass; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; - -/** - * 微信上下文 Context - * - * 目的:解决微信多公众号的问题,在 {@link WxMpMessageHandler} 实现类中,可以通过 {@link #getAppId()} 获取到当前的 appId - * - * @see cn.iocoder.yudao.module.mp.controller.admin.open.MpOpenController#handleMessage(String, String, MpOpenHandleMessageReqVO) - * - * @author 芋道源码 - */ -public class MpContextHolder { - - /** - * 微信公众号的 appId 上下文 - */ - private static final ThreadLocal APPID = new TransmittableThreadLocal<>(); - - public static void setAppId(String appId) { - APPID.set(appId); - } - - public static String getAppId() { - return APPID.get(); - } - - public static void clear() { - APPID.remove(); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/util/MpUtils.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/util/MpUtils.java deleted file mode 100644 index 1b52f83d7f..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/util/MpUtils.java +++ /dev/null @@ -1,167 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.mp.core.util; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; - -import jakarta.validation.Validator; - -/** - * 公众号工具类 - * - * @author 芋道源码 - */ -@Slf4j -public class MpUtils { - - /** - * 校验消息的格式是否符合要求 - * - * @param type 类型 - * @param message 消息 - */ - public static void validateMessage(Validator validator, String type, Object message) { - // 获得对应的校验 group - Class group; - switch (type) { - case WxConsts.XmlMsgType.TEXT: - group = TextMessageGroup.class; - break; - case WxConsts.XmlMsgType.IMAGE: - group = ImageMessageGroup.class; - break; - case WxConsts.XmlMsgType.VOICE: - group = VoiceMessageGroup.class; - break; - case WxConsts.XmlMsgType.VIDEO: - group = VideoMessageGroup.class; - break; - case WxConsts.XmlMsgType.NEWS: - group = NewsMessageGroup.class; - break; - case WxConsts.XmlMsgType.MUSIC: - group = MusicMessageGroup.class; - break; - default: - log.error("[validateMessage][未知的消息类型({})]", message); - throw new IllegalArgumentException("不支持的消息类型:" + type); - } - // 执行校验 - ValidationUtils.validate(validator, message, group); - } - - public static void validateButton(Validator validator, String type, String messageType, Object button) { - if (StrUtil.isBlank(type)) { - return; - } - // 获得对应的校验 group - Class group; - switch (type) { - case WxConsts.MenuButtonType.CLICK: - group = ClickButtonGroup.class; - validateMessage(validator, messageType, button); // 需要额外校验回复的消息格式 - break; - case WxConsts.MenuButtonType.VIEW: - group = ViewButtonGroup.class; - break; - case WxConsts.MenuButtonType.MINIPROGRAM: - group = MiniProgramButtonGroup.class; - break; - case WxConsts.MenuButtonType.SCANCODE_WAITMSG: - group = ScanCodeWaitMsgButtonGroup.class; - validateMessage(validator, messageType, button); // 需要额外校验回复的消息格式 - break; - case "article_" + WxConsts.MenuButtonType.VIEW_LIMITED: - group = ViewLimitedButtonGroup.class; - break; - case WxConsts.MenuButtonType.SCANCODE_PUSH: // 不用校验,直接 return 即可 - case WxConsts.MenuButtonType.PIC_SYSPHOTO: - case WxConsts.MenuButtonType.PIC_PHOTO_OR_ALBUM: - case WxConsts.MenuButtonType.PIC_WEIXIN: - case WxConsts.MenuButtonType.LOCATION_SELECT: - return; - default: - log.error("[validateButton][未知的按钮({})]", button); - throw new IllegalArgumentException("不支持的按钮类型:" + type); - } - // 执行校验 - ValidationUtils.validate(validator, button, group); - } - - /** - * 根据消息类型,获得对应的媒体文件类型 - * - * 注意,不会返回 WxConsts.MediaFileType.THUMB,因为该类型会有明确标注 - * - * @param messageType 消息类型 {@link WxConsts.XmlMsgType} - * @return 媒体文件类型 {@link WxConsts.MediaFileType} - */ - public static String getMediaFileType(String messageType) { - switch (messageType) { - case WxConsts.XmlMsgType.IMAGE: - return WxConsts.MediaFileType.IMAGE; - case WxConsts.XmlMsgType.VOICE: - return WxConsts.MediaFileType.VOICE; - case WxConsts.XmlMsgType.VIDEO: - return WxConsts.MediaFileType.VIDEO; - default: - return WxConsts.MediaFileType.FILE; - } - } - - /** - * Text 类型的消息,参数校验 Group - */ - public interface TextMessageGroup {} - - /** - * Image 类型的消息,参数校验 Group - */ - public interface ImageMessageGroup {} - - /** - * Voice 类型的消息,参数校验 Group - */ - public interface VoiceMessageGroup {} - - /** - * Video 类型的消息,参数校验 Group - */ - public interface VideoMessageGroup {} - - /** - * News 类型的消息,参数校验 Group - */ - public interface NewsMessageGroup {} - - /** - * Music 类型的消息,参数校验 Group - */ - public interface MusicMessageGroup {} - - /** - * Click 类型的按钮,参数校验 Group - */ - public interface ClickButtonGroup {} - - /** - * View 类型的按钮,参数校验 Group - */ - public interface ViewButtonGroup {} - - /** - * MiniProgram 类型的按钮,参数校验 Group - */ - public interface MiniProgramButtonGroup {} - - /** - * SCANCODE_WAITMSG 类型的按钮,参数校验 Group - */ - public interface ScanCodeWaitMsgButtonGroup {} - - /** - * VIEW_LIMITED 类型的按钮,参数校验 Group - */ - public interface ViewLimitedButtonGroup {} -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/package-info.java deleted file mode 100644 index 112ecdd26e..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 mp 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.mp.framework; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/web/config/MpWebConfiguration.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/web/config/MpWebConfiguration.java deleted file mode 100644 index 75a236289e..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/web/config/MpWebConfiguration.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.web.config; - -import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration; -import org.springdoc.core.models.GroupedOpenApi; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * mp 模块的 web 组件的 Configuration - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -public class MpWebConfiguration { - - /** - * mp 模块的 API 分组 - */ - @Bean - public GroupedOpenApi mpGroupedOpenApi() { - return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("mp"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/web/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/web/package-info.java deleted file mode 100644 index a103f1c380..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/web/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * mp 模块的 web 配置 - */ -package cn.iocoder.yudao.module.mp.framework.web; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/package-info.java deleted file mode 100644 index 5987180882..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * mp 模块,我们放微信微信公众号。 - * 例如说:提供微信公众号的账号、菜单、粉丝、标签、消息、自动回复、素材、模板通知、运营数据等功能 - * - * 1. Controller URL:以 /mp/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 mp_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.mp; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java deleted file mode 100644 index 1d7296d55a..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.account; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; - -import jakarta.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.ACCOUNT_NOT_EXISTS; - -/** - * 公众号账号 Service 接口 - * - * @author 芋道源码 - */ -public interface MpAccountService { - - /** - * 初始化缓存 - */ - void initLocalCache(); - - /** - * 创建公众号账号 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createAccount(@Valid MpAccountCreateReqVO createReqVO); - - /** - * 更新公众号账号 - * - * @param updateReqVO 更新信息 - */ - void updateAccount(@Valid MpAccountUpdateReqVO updateReqVO); - - /** - * 删除公众号账号 - * - * @param id 编号 - */ - void deleteAccount(Long id); - - /** - * 获得公众号账号 - * - * @param id 编号 - * @return 公众号账号 - */ - MpAccountDO getAccount(Long id); - - /** - * 获得公众号账号。若不存在,则抛出业务异常 - * - * @param id 编号 - * @return 公众号账号 - */ - default MpAccountDO getRequiredAccount(Long id) { - MpAccountDO account = getAccount(id); - if (account == null) { - throw exception(ACCOUNT_NOT_EXISTS); - } - return account; - } - - /** - * 从缓存中,获得公众号账号 - * - * @param appId 微信公众号 appId - * @return 公众号账号 - */ - MpAccountDO getAccountFromCache(String appId); - - /** - * 获得公众号账号分页 - * - * @param pageReqVO 分页查询 - * @return 公众号账号分页 - */ - PageResult getAccountPage(MpAccountPageReqVO pageReqVO); - - /** - * 获得公众号账号列表 - * - * @return 公众号账号列表 - */ - List getAccountList(); - - /** - * 生成公众号账号的二维码 - * - * @param id 编号 - */ - void generateAccountQrCode(Long id); - - /** - * 清空公众号账号的 API 配额 - * - * 参考文档:接口调用频次限制说明 - * - * @param id 编号 - */ - void clearAccountQuota(Long id); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java deleted file mode 100644 index 14e91b6612..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java +++ /dev/null @@ -1,229 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.account; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO; -import cn.iocoder.yudao.module.mp.convert.account.MpAccountConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.mysql.account.MpAccountMapper; -import cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import com.google.common.annotations.VisibleForTesting; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; -import org.springframework.context.annotation.Lazy; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.PostConstruct; -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMaxValue; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_USERNAME_EXISTS; - -/** - * 公众号账号 Service 实现类 - * - * @author fengdan - */ -@Slf4j -@Service -@Validated -public class MpAccountServiceImpl implements MpAccountService { - - /** - * 账号缓存 - * key:账号编号 {@link MpAccountDO#getAppId()} - * - * 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向 - */ - @Getter - private volatile Map accountCache; - - @Resource - private MpAccountMapper mpAccountMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Override - @PostConstruct - public void initLocalCache() { - // 注意:忽略自动多租户,因为要全局初始化缓存 - TenantUtils.executeIgnore(() -> { - // 第一步:查询数据 - List accounts = Collections.emptyList(); - try { - accounts = mpAccountMapper.selectList(); - } catch (Throwable ex) { - if (!ex.getMessage().contains("doesn't exist")) { - throw ex; - } - log.error("[微信公众号 yudao-module-mp - 表结构未导入][参考 https://doc.iocoder.cn/mp/build/ 开启]"); - } - log.info("[initLocalCacheIfUpdate][缓存公众号账号,数量为:{}]", accounts.size()); - - // 第二步:构建缓存。创建或更新支付 Client - mpServiceFactory.init(accounts); - accountCache = convertMap(accounts, MpAccountDO::getAppId); - }); - } - - /** - * 通过定时任务轮询,刷新缓存 - * - * 目的:多节点部署时,通过轮询”通知“所有节点,进行刷新 - */ - @Scheduled(initialDelay = 60, fixedRate = 60, timeUnit = TimeUnit.SECONDS) - public void refreshLocalCache() { - // 注意:忽略自动多租户,因为要全局初始化缓存 - TenantUtils.executeIgnore(() -> { - // 情况一:如果缓存里没有数据,则直接刷新缓存 - if (CollUtil.isEmpty(accountCache)) { - initLocalCache(); - return; - } - - // 情况二,如果缓存里数据,则通过 updateTime 判断是否有数据变更,有变更则刷新缓存 - LocalDateTime maxTime = getMaxValue(accountCache.values(), MpAccountDO::getUpdateTime); - if (mpAccountMapper.selectCountByUpdateTimeGt(maxTime) > 0) { - initLocalCache(); - } - }); - } - - @Override - public Long createAccount(MpAccountCreateReqVO createReqVO) { - // 校验 appId 唯一 - validateAppIdUnique(null, createReqVO.getAppId()); - - // 插入 - MpAccountDO account = MpAccountConvert.INSTANCE.convert(createReqVO); - mpAccountMapper.insert(account); - - // 刷新缓存 - initLocalCache(); - return account.getId(); - } - - @Override - public void updateAccount(MpAccountUpdateReqVO updateReqVO) { - // 校验存在 - validateAccountExists(updateReqVO.getId()); - // 校验 appId 唯一 - validateAppIdUnique(updateReqVO.getId(), updateReqVO.getAppId()); - - // 更新 - MpAccountDO updateObj = MpAccountConvert.INSTANCE.convert(updateReqVO); - mpAccountMapper.updateById(updateObj); - - // 刷新缓存 - initLocalCache(); - } - - @Override - public void deleteAccount(Long id) { - // 校验存在 - validateAccountExists(id); - // 删除 - mpAccountMapper.deleteById(id); - - // 刷新缓存 - initLocalCache(); - } - - private MpAccountDO validateAccountExists(Long id) { - MpAccountDO account = mpAccountMapper.selectById(id); - if (account == null) { - throw ServiceExceptionUtil.exception(ErrorCodeConstants.ACCOUNT_NOT_EXISTS); - } - return account; - } - - @VisibleForTesting - public void validateAppIdUnique(Long id, String appId) { - // 多个租户,appId 是不能重复,否则公众号回调会无法识别 - TenantUtils.executeIgnore(() -> { - MpAccountDO account = mpAccountMapper.selectByAppId(appId); - if (account == null) { - return; - } - // 存在 account 记录的情况下 - if (id == null // 新增时,说明重复 - || ObjUtil.notEqual(id, account.getId())) { // 更新时,如果 id 不一致,说明重复 - throw exception(USER_USERNAME_EXISTS); - } - }); - } - - @Override - public MpAccountDO getAccount(Long id) { - return mpAccountMapper.selectById(id); - } - - @Override - public MpAccountDO getAccountFromCache(String appId) { - return accountCache.get(appId); - } - - @Override - public PageResult getAccountPage(MpAccountPageReqVO pageReqVO) { - return mpAccountMapper.selectPage(pageReqVO); - } - - @Override - public List getAccountList() { - return mpAccountMapper.selectList(); - } - - @Override - public void generateAccountQrCode(Long id) { - // 校验存在 - MpAccountDO account = validateAccountExists(id); - - // 生成二维码 - WxMpService mpService = mpServiceFactory.getRequiredMpService(account.getAppId()); - String qrCodeUrl; - try { - WxMpQrCodeTicket qrCodeTicket = mpService.getQrcodeService().qrCodeCreateLastTicket("default"); - qrCodeUrl = mpService.getQrcodeService().qrCodePictureUrl(qrCodeTicket.getTicket()); - } catch (WxErrorException e) { - throw exception(ErrorCodeConstants.ACCOUNT_GENERATE_QR_CODE_FAIL, e.getError().getErrorMsg()); - } - - // 保存二维码 - mpAccountMapper.updateById(new MpAccountDO().setId(id).setQrCodeUrl(qrCodeUrl)); - } - - @Override - public void clearAccountQuota(Long id) { - // 校验存在 - MpAccountDO account = validateAccountExists(id); - - // 生成二维码 - WxMpService mpService = mpServiceFactory.getRequiredMpService(account.getAppId()); - try { - mpService.clearQuota(account.getAppId()); - } catch (WxErrorException e) { - throw exception(ErrorCodeConstants.ACCOUNT_CLEAR_QUOTA_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/menu/MenuHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/menu/MenuHandler.java deleted file mode 100644 index 560c2bda54..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/menu/MenuHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.menu; - -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.menu.MpMenuService; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMenuService; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.Map; - -import static me.chanjar.weixin.common.api.WxConsts.MenuButtonType; - -/** - * 自定义菜单的事件处理器 - * - * 逻辑:粉丝点击菜单时,触发对应的回复 - * - * @author 芋道源码 - */ -@Component -public class MenuHandler implements WxMpMessageHandler { - - @Resource - private MpMenuService mpMenuService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService weixinService, WxSessionManager sessionManager) { - return mpMenuService.reply(MpContextHolder.getAppId(), wxMessage.getEventKey(), wxMessage.getFromUser()); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java deleted file mode 100644 index 7e24a83878..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.message; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.Map; - -/** - * 自动回复消息的事件处理器 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class MessageAutoReplyHandler implements WxMpMessageHandler { - - @Resource - private MpAutoReplyService mpAutoReplyService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService weixinService, WxSessionManager sessionManager) { - // 只处理指定类型的消息 - if (!MpAutoReplyDO.REQUEST_MESSAGE_TYPE.contains(wxMessage.getMsgType())) { - return null; - } - - // 自动回复 - return mpAutoReplyService.replyForMessage(MpContextHolder.getAppId(), wxMessage); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageReceiveHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageReceiveHandler.java deleted file mode 100644 index 8a740a87e1..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageReceiveHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.message; - -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.message.MpMessageService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.Map; - -/** - * 保存微信消息的事件处理器 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class MessageReceiveHandler implements WxMpMessageHandler { - - @Resource - private MpMessageService mpMessageService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - log.info("[handle][接收到请求消息,内容:{}]", wxMessage); - mpMessageService.receiveMessage(MpContextHolder.getAppId(), wxMessage); - return null; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/KfSessionHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/KfSessionHandler.java deleted file mode 100644 index fca7fab9ac..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/KfSessionHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.other; - -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 接收客服会话管理的事件处理器 - * - * @author 芋道源码 - */ -@Component -public class KfSessionHandler implements WxMpMessageHandler { - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - throw new UnsupportedOperationException("未实现该处理,请自行重写"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/NullHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/NullHandler.java deleted file mode 100644 index 09b3efbf2e..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/NullHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.other; - -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 点击菜单连接的事件处理器 - */ -@Component -public class NullHandler implements WxMpMessageHandler { - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - throw new UnsupportedOperationException("未实现该处理,请自行重写"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/ScanHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/ScanHandler.java deleted file mode 100644 index 54a6bbc325..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/ScanHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.other; - -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 扫码的事件处理器 - */ -@Component -public class ScanHandler implements WxMpMessageHandler { - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map context, - WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException { - throw new UnsupportedOperationException("未实现该处理,请自行重写"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/StoreCheckNotifyHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/StoreCheckNotifyHandler.java deleted file mode 100644 index 475b8ee978..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/StoreCheckNotifyHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.other; - -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 门店审核事件的事件处理器 - */ -@Component -public class StoreCheckNotifyHandler implements WxMpMessageHandler { - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - throw new UnsupportedOperationException("未实现该处理,请自行重写"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/package-info.java deleted file mode 100644 index 7fd6622602..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 本包内的 handler 都是一些不重要的,所以放在 other 其它里 - */ -package cn.iocoder.yudao.module.mp.service.handler.other; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java deleted file mode 100644 index ebed43f4b3..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.user; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.Map; - -/** - * 上报地理位置的事件处理器 - * - * 触发操作:打开微信公众号 -> 点击 + 号 -> 选择「语音」 - * - * 逻辑:粉丝上传地理位置时,也可以触发自动回复 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class LocationHandler implements WxMpMessageHandler { - - @Resource - private MpAutoReplyService mpAutoReplyService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - // 防御性编程:必须是 LOCATION 消息 - if (ObjectUtil.notEqual(wxMessage.getMsgType(), WxConsts.XmlMsgType.LOCATION)) { - return null; - } - log.info("[handle][上报地理位置,纬度({})、经度({})、精度({})", wxMessage.getLatitude(), - wxMessage.getLongitude(), wxMessage.getPrecision()); - - // 自动回复 - return mpAutoReplyService.replyForMessage(MpContextHolder.getAppId(), wxMessage); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java deleted file mode 100644 index 14540836a7..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.user; - -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; -import cn.iocoder.yudao.module.mp.service.user.MpUserService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import me.chanjar.weixin.mp.bean.result.WxMpUser; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.Map; - -/** - * 关注的事件处理器 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class SubscribeHandler implements WxMpMessageHandler { - - @Resource - private MpUserService mpUserService; - @Resource - private MpAutoReplyService mpAutoReplyService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService weixinService, WxSessionManager sessionManager) throws WxErrorException { - // 第一步,从公众号平台,获取粉丝信息 - log.info("[handle][粉丝({}) 关注]", wxMessage.getFromUser()); - WxMpUser wxMpUser = null; - try { - wxMpUser = weixinService.getUserService().userInfo(wxMessage.getFromUser()); - } catch (WxErrorException e) { - log.error("[handle][粉丝({})] 获取粉丝信息失败!", wxMessage.getFromUser(), e); - } - - // 第二步,保存粉丝信息 - mpUserService.saveUser(MpContextHolder.getAppId(), wxMpUser); - - // 第三步,回复关注的欢迎语 - return mpAutoReplyService.replyForSubscribe(MpContextHolder.getAppId(), wxMessage); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/UnsubscribeHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/UnsubscribeHandler.java deleted file mode 100644 index e1afb1e41d..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/UnsubscribeHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.user; - -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.user.MpUserService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.util.Map; - -/** - * 取消关注的事件处理器 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class UnsubscribeHandler implements WxMpMessageHandler { - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpUserService mpUserService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, - Map context, WxMpService wxMpService, - WxSessionManager sessionManager) { - log.info("[handle][粉丝({}) 取消关注]", wxMessage.getFromUser()); - mpUserService.updateUserUnsubscribe(MpContextHolder.getAppId(), wxMessage.getFromUser()); - return null; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialService.java deleted file mode 100644 index a6a0041ed5..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.material; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadNewsImageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadPermanentReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadTemporaryReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import me.chanjar.weixin.common.api.WxConsts; - -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.Collection; -import java.util.List; - -/** - * 公众号素材 Service 接口 - * - * @author 芋道源码 - */ -public interface MpMaterialService { - - /** - * 获得素材的 URL - * - * 该 URL 来自我们自己的文件服务器存储的 URL,不是公众号存储的 URL - * - * @param accountId 公众号账号编号 - * @param mediaId 公众号素材 id - * @param type 文件类型 {@link WxConsts.MediaFileType} - * @return 素材的 URL - */ - String downloadMaterialUrl(Long accountId, String mediaId, String type); - - /** - * 上传临时素材 - * - * @param reqVO 请求 - * @return 素材 - * @throws IOException 文件操作发生异常 - */ - MpMaterialDO uploadTemporaryMaterial(@Valid MpMaterialUploadTemporaryReqVO reqVO) throws IOException; - - /** - * 上传永久素材 - * - * @param reqVO 请求 - * @return 素材 - * @throws IOException 文件操作发生异常 - */ - MpMaterialDO uploadPermanentMaterial(@Valid MpMaterialUploadPermanentReqVO reqVO) throws IOException; - - /** - * 上传图文内容中的图片 - * - * @param reqVO 上传请求 - * @return 图片地址 - */ - String uploadNewsImage(MpMaterialUploadNewsImageReqVO reqVO) throws IOException; - - /** - * 获得素材分页 - * - * @param pageReqVO 分页请求 - * @return 素材分页 - */ - PageResult getMaterialPage(MpMaterialPageReqVO pageReqVO); - - /** - * 获得素材列表 - * - * @param mediaIds 素材 mediaId 列表 - * @return 素材列表 - */ - List getMaterialListByMediaId(Collection mediaIds); - - /** - * 删除素材 - * - * @param id 编号 - */ - void deleteMaterial(Long id); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialServiceImpl.java deleted file mode 100644 index 11e4a3b5bd..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialServiceImpl.java +++ /dev/null @@ -1,224 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.material; - -import cn.hutool.core.io.FileTypeUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.infra.api.file.FileApi; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadNewsImageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadPermanentReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadTemporaryReqVO; -import cn.iocoder.yudao.module.mp.convert.material.MpMaterialConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import cn.iocoder.yudao.module.mp.dal.mysql.material.MpMaterialMapper; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 公众号素材 Service 接口 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class MpMaterialServiceImpl implements MpMaterialService { - - @Resource - private MpMaterialMapper mpMaterialMapper; - - @Resource - private FileApi fileApi; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpAccountService mpAccountService; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Override - public String downloadMaterialUrl(Long accountId, String mediaId, String type) { - // 第一步,直接从数据库查询。如果已经下载,直接返回 - MpMaterialDO material = mpMaterialMapper.selectByAccountIdAndMediaId(accountId, mediaId); - if (material != null) { - return material.getUrl(); - } - - // 第二步,尝试从临时素材中下载 - String url = downloadMedia(accountId, mediaId); - if (url == null) { - return null; - } - MpAccountDO account = mpAccountService.getRequiredAccount(accountId); - material = MpMaterialConvert.INSTANCE.convert(mediaId, type, url, account, null) - .setPermanent(false); - mpMaterialMapper.insert(material); - - // 不考虑下载永久素材,因为上传的时候已经保存 - return url; - } - - @Override - public MpMaterialDO uploadTemporaryMaterial(MpMaterialUploadTemporaryReqVO reqVO) throws IOException { - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - // 第一步,上传到公众号 - File file = null; - WxMediaUploadResult result; - String mediaId; - String url; - try { - // 写入到临时文件 - file = FileUtil.newFile(FileUtil.getTmpDirPath() + reqVO.getFile().getOriginalFilename()); - reqVO.getFile().transferTo(file); - // 上传到公众号 - result = mpService.getMaterialService().mediaUpload(reqVO.getType(), file); - // 上传到文件服务 - mediaId = ObjUtil.defaultIfNull(result.getMediaId(), result.getThumbMediaId()); - url = uploadFile(mediaId, file); - } catch (WxErrorException e) { - throw exception(MATERIAL_UPLOAD_FAIL, e.getError().getErrorMsg()); - } finally { - FileUtil.del(file); - } - - // 第二步,存储到数据库 - MpAccountDO account = mpAccountService.getRequiredAccount(reqVO.getAccountId()); - MpMaterialDO material = MpMaterialConvert.INSTANCE.convert(mediaId, reqVO.getType(), url, account, - reqVO.getFile().getName()).setPermanent(false); - mpMaterialMapper.insert(material); - return material; - } - - @Override - public MpMaterialDO uploadPermanentMaterial(MpMaterialUploadPermanentReqVO reqVO) throws IOException { - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - // 第一步,上传到公众号 - String name = StrUtil.blankToDefault(reqVO.getName(), reqVO.getFile().getName()); - File file = null; - WxMpMaterialUploadResult result; - String mediaId; - String url; - try { - // 写入到临时文件 - file = FileUtil.newFile(FileUtil.getTmpDirPath() + reqVO.getFile().getOriginalFilename()); - reqVO.getFile().transferTo(file); - // 上传到公众号 - result = mpService.getMaterialService().materialFileUpload(reqVO.getType(), - MpMaterialConvert.INSTANCE.convert(name, file, reqVO.getTitle(), reqVO.getIntroduction())); - // 上传到文件服务 - mediaId = ObjUtil.defaultIfNull(result.getMediaId(), result.getMediaId()); - url = uploadFile(mediaId, file); - } catch (WxErrorException e) { - throw exception(MATERIAL_UPLOAD_FAIL, e.getError().getErrorMsg()); - } finally { - FileUtil.del(file); - } - - // 第二步,存储到数据库 - MpAccountDO account = mpAccountService.getRequiredAccount(reqVO.getAccountId()); - MpMaterialDO material = MpMaterialConvert.INSTANCE.convert(mediaId, reqVO.getType(), url, account, - name, reqVO.getTitle(), reqVO.getIntroduction(), result.getUrl()).setPermanent(true); - mpMaterialMapper.insert(material); - return material; - } - - @Override - public String uploadNewsImage(MpMaterialUploadNewsImageReqVO reqVO) throws IOException { - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - File file = null; - try { - // 写入到临时文件 - file = FileUtil.newFile(FileUtil.getTmpDirPath() + reqVO.getFile().getOriginalFilename()); - reqVO.getFile().transferTo(file); - // 上传到公众号 - return mpService.getMaterialService().mediaImgUpload(file).getUrl(); - } catch (WxErrorException e) { - throw exception(MATERIAL_IMAGE_UPLOAD_FAIL, e.getError().getErrorMsg()); - } finally { - FileUtil.del(file); - } - } - - @Override - public PageResult getMaterialPage(MpMaterialPageReqVO pageReqVO) { - return mpMaterialMapper.selectPage(pageReqVO); - } - - @Override - public List getMaterialListByMediaId(Collection mediaIds) { - return mpMaterialMapper.selectListByMediaId(mediaIds); - } - - @Override - public void deleteMaterial(Long id) { - MpMaterialDO material = mpMaterialMapper.selectById(id); - if (material == null) { - throw exception(MATERIAL_NOT_EXISTS); - } - - // 第一步,从公众号删除 - if (material.getPermanent()) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(material.getAppId()); - try { - mpService.getMaterialService().materialDelete(material.getMediaId()); - } catch (WxErrorException e) { - throw exception(MATERIAL_DELETE_FAIL, e.getError().getErrorMsg()); - } - } - - // 第二步,从数据库中删除 - mpMaterialMapper.deleteById(id); - } - - /** - * 下载微信媒体文件的内容,并上传到文件服务 - * - * 为什么要下载?媒体文件在微信后台保存时间为 3 天,即 3 天后 media_id 失效。 - * - * @param accountId 公众号账号的编号 - * @param mediaId 媒体文件编号 - * @return 上传后的 URL - */ - public String downloadMedia(Long accountId, String mediaId) { - WxMpService mpService = mpServiceFactory.getMpService(accountId); - for (int i = 0; i < 3; i++) { - try { - // 第一步,从公众号下载媒体文件 - File file = mpService.getMaterialService().mediaDownload(mediaId); - // 第二步,上传到文件服务 - return uploadFile(mediaId, file); - } catch (WxErrorException e) { - log.error("[mediaDownload][media({}) 第 ({}) 次下载失败]", mediaId, i); - } - } - return null; - } - - private String uploadFile(String mediaId, File file) { - String path = mediaId + "." + FileTypeUtil.getType(file); - return fileApi.createFile(path, FileUtil.readBytes(file)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuService.java deleted file mode 100644 index 0b2fc451b3..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuService.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.menu; - -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuSaveReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * 公众号菜单 Service 接口 - * - * @author 芋道源码 - */ -public interface MpMenuService { - - /** - * 保存公众号菜单 - * - * @param createReqVO 创建信息 - */ - void saveMenu(@Valid MpMenuSaveReqVO createReqVO); - - /** - * 删除公众号菜单 - * - * @param accountId 公众号账号的编号 - */ - void deleteMenuByAccountId(Long accountId); - - /** - * 粉丝点击菜单按钮时,回复对应的消息 - * - * @param appId 公众号 AppId - * @param key 菜单按钮的标识 - * @param openid 粉丝的 openid - * @return 消息 - */ - WxMpXmlOutMessage reply(String appId, String key, String openid); - - /** - * 获得公众号菜单列表 - * - * @param accountId 公众号账号的编号 - * @return 公众号菜单列表 - */ - List getMenuListByAccountId(Long accountId); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuServiceImpl.java deleted file mode 100644 index 1afe47c8aa..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuServiceImpl.java +++ /dev/null @@ -1,171 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.menu; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuSaveReqVO; -import cn.iocoder.yudao.module.mp.convert.menu.MpMenuConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import cn.iocoder.yudao.module.mp.dal.mysql.menu.MpMenuMapper; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import cn.iocoder.yudao.module.mp.service.message.MpMessageService; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.bean.menu.WxMenu; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import jakarta.validation.Validator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MENU_DELETE_FAIL; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MENU_SAVE_FAIL; - -/** - * 公众号菜单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class MpMenuServiceImpl implements MpMenuService { - - @Resource - private MpMessageService mpMessageService; - @Resource - @Lazy // 延迟加载,避免循环引用报错 - private MpAccountService mpAccountService; - - @Resource - @Lazy // 延迟加载,避免循环引用报错 - private MpServiceFactory mpServiceFactory; - - @Resource - private Validator validator; - - @Resource - private MpMenuMapper mpMenuMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public void saveMenu(MpMenuSaveReqVO createReqVO) { - MpAccountDO account = mpAccountService.getRequiredAccount(createReqVO.getAccountId()); - WxMpService mpService = mpServiceFactory.getRequiredMpService(createReqVO.getAccountId()); - - // 参数校验 - createReqVO.getMenus().forEach(this::validateMenu); - - // 第一步,同步公众号 - WxMenu wxMenu = new WxMenu(); - wxMenu.setButtons(MpMenuConvert.INSTANCE.convert(createReqVO.getMenus())); - try { - mpService.getMenuService().menuCreate(wxMenu); - } catch (WxErrorException e) { - throw exception(MENU_SAVE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,存储到数据库 - mpMenuMapper.deleteByAccountId(createReqVO.getAccountId()); - createReqVO.getMenus().forEach(menu -> { - // 先保存顶级菜单 - MpMenuDO menuDO = createMenu(menu, null, account); - // 再保存子菜单 - if (CollUtil.isEmpty(menu.getChildren())) { - return; - } - menu.getChildren().forEach(childMenu -> createMenu(childMenu, menuDO, account)); - }); - } - - /** - * 校验菜单的格式是否正确 - * - * @param menu 菜单 - */ - private void validateMenu(MpMenuSaveReqVO.Menu menu) { - MpUtils.validateButton(validator, menu.getType(), menu.getReplyMessageType(), menu); - // 子菜单 - if (CollUtil.isEmpty(menu.getChildren())) { - return; - } - menu.getChildren().forEach(this::validateMenu); - } - - /** - * 创建菜单,并存储到数据库 - * - * @param wxMenu 菜单信息 - * @param parentMenu 父菜单 - * @param account 公众号账号 - * @return 创建后的菜单 - */ - private MpMenuDO createMenu(MpMenuSaveReqVO.Menu wxMenu, MpMenuDO parentMenu, MpAccountDO account) { - // 创建菜单 - MpMenuDO menu = CollUtil.isNotEmpty(wxMenu.getChildren()) - ? new MpMenuDO().setName(wxMenu.getName()) - : MpMenuConvert.INSTANCE.convert02(wxMenu); - // 设置菜单的公众号账号信息 - if (account != null) { - menu.setAccountId(account.getId()).setAppId(account.getAppId()); - } - // 设置父编号 - if (parentMenu != null) { - menu.setParentId(parentMenu.getId()); - } else { - menu.setParentId(MpMenuDO.ID_ROOT); - } - - // 插入到数据库 - mpMenuMapper.insert(menu); - return menu; - } - - @Override - public void deleteMenuByAccountId(Long accountId) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - // 第一步,同步公众号 - try { - mpService.getMenuService().menuDelete(); - } catch (WxErrorException e) { - throw exception(MENU_DELETE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,存储到数据库 - mpMenuMapper.deleteByAccountId(accountId); - } - - @Override - public WxMpXmlOutMessage reply(String appId, String key, String openid) { - // 第一步,获得菜单 - MpMenuDO menu = mpMenuMapper.selectByAppIdAndMenuKey(appId, key); - if (menu == null) { - log.error("[reply][appId({}) key({}) 找不到对应的菜单]", appId, key); - return null; - } - // 按钮必须要有消息类型,不然后续无法回复消息 - if (StrUtil.isEmpty(menu.getReplyMessageType())) { - log.error("[reply][menu({}) 不存在对应的消息类型]", menu); - return null; - } - - // 第二步,回复消息 - MpMessageSendOutReqBO sendReqBO = MpMenuConvert.INSTANCE.convert(openid, menu); - return mpMessageService.sendOutMessage(sendReqBO); - } - - @Override - public List getMenuListByAccountId(Long accountId) { - return mpMenuMapper.selectListByAccountId(accountId); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java deleted file mode 100644 index fc125d06d1..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyUpdateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; - -/** - * 公众号的自动回复 Service 接口 - * - * @author 芋道源码 - */ -public interface MpAutoReplyService { - - /** - * 获得公众号自动回复分页 - * - * @param pageVO 分页请求 - * @return 自动回复分页结果 - */ - PageResult getAutoReplyPage(MpMessagePageReqVO pageVO); - - /** - * 获得公众号自动回复 - * - * @param id 编号 - * @return 自动回复 - */ - MpAutoReplyDO getAutoReply(Long id); - - - /** - * 创建公众号自动回复 - * - * @param createReqVO 创建请求 - * @return 自动回复的编号 - */ - Long createAutoReply(MpAutoReplyCreateReqVO createReqVO); - - /** - * 更新公众号自动回复 - * - * @param updateReqVO 更新请求 - */ - void updateAutoReply(MpAutoReplyUpdateReqVO updateReqVO); - - /** - * 删除公众号自动回复 - * - * @param id 自动回复的编号 - */ - void deleteAutoReply(Long id); - - /** - * 当收到消息时,自动回复 - * - * @param appId 微信公众号 appId - * @param wxMessage 消息 - * @return 回复的消息 - */ - WxMpXmlOutMessage replyForMessage(String appId, WxMpXmlMessage wxMessage); - - /** - * 当粉丝关注时,自动回复 - * - * @param appId 微信公众号 appId - * @param wxMessage 消息 - * @return 回复的消息 - */ - WxMpXmlOutMessage replyForSubscribe(String appId, WxMpXmlMessage wxMessage); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java deleted file mode 100644 index 5341e817b9..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java +++ /dev/null @@ -1,202 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.exception.ErrorCode; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyUpdateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.convert.message.MpAutoReplyConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.dal.mysql.message.MpAutoReplyMapper; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import jakarta.validation.Validator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 公众号的自动回复 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class MpAutoReplyServiceImpl implements MpAutoReplyService { - - @Resource - private MpMessageService mpMessageService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private MpAccountService mpAccountService; - - @Resource - private Validator validator; - - @Resource - private MpAutoReplyMapper mpAutoReplyMapper; - - @Override - public PageResult getAutoReplyPage(MpMessagePageReqVO pageVO) { - return mpAutoReplyMapper.selectPage(pageVO); - } - - @Override - public MpAutoReplyDO getAutoReply(Long id) { - return mpAutoReplyMapper.selectById(id); - } - - @Override - public Long createAutoReply(MpAutoReplyCreateReqVO createReqVO) { - // 第一步,校验数据 - if (createReqVO.getResponseMessageType() != null) { - MpUtils.validateMessage(validator, createReqVO.getResponseMessageType(), createReqVO); - } - validateAutoReplyConflict(null, createReqVO.getAccountId(), createReqVO.getType(), - createReqVO.getRequestKeyword(), createReqVO.getRequestMessageType()); - - // 第二步,插入数据 - MpAccountDO account = mpAccountService.getRequiredAccount(createReqVO.getAccountId()); - MpAutoReplyDO autoReply = MpAutoReplyConvert.INSTANCE.convert(createReqVO) - .setAppId(account.getAppId()); - mpAutoReplyMapper.insert(autoReply); - return autoReply.getId(); - } - - @Override - public void updateAutoReply(MpAutoReplyUpdateReqVO updateReqVO) { - // 第一步,校验数据 - if (updateReqVO.getResponseMessageType() != null) { - MpUtils.validateMessage(validator, updateReqVO.getResponseMessageType(), updateReqVO); - } - MpAutoReplyDO autoReply = validateAutoReplyExists(updateReqVO.getId()); - validateAutoReplyConflict(updateReqVO.getId(), autoReply.getAccountId(), updateReqVO.getType(), - updateReqVO.getRequestKeyword(), updateReqVO.getRequestMessageType()); - - // 第二步,更新数据 - MpAutoReplyDO updateObj = MpAutoReplyConvert.INSTANCE.convert(updateReqVO) - .setAccountId(null).setAppId(null); // 避免前端传递,更新着两个字段 - mpAutoReplyMapper.updateById(updateObj); - } - - /** - * 校验自动回复是否冲突 - * - * 不同的 type,会有不同的逻辑: - * 1. type = SUBSCRIBE 时,不允许有其他的自动回复 - * 2. type = MESSAGE 时,校验 requestMessageType 已经存在自动回复 - * 3. type = KEYWORD 时,校验 keyword 已经存在自动回复 - * - * @param id 自动回复编号 - * @param accountId 公众号账号的编号 - * @param type 类型 - * @param requestKeyword 请求关键词 - * @param requestMessageType 请求消息类型 - */ - private void validateAutoReplyConflict(Long id, Long accountId, Integer type, - String requestKeyword, String requestMessageType) { - // 获得已经存在的自动回复 - MpAutoReplyDO autoReply = null; - ErrorCode errorCode = null; - if (MpAutoReplyTypeEnum.SUBSCRIBE.getType().equals(type)) { - autoReply = mpAutoReplyMapper.selectByAccountIdAndSubscribe(accountId); - errorCode = AUTO_REPLY_ADD_SUBSCRIBE_FAIL_EXISTS; - } else if (MpAutoReplyTypeEnum.MESSAGE.getType().equals(type)) { - autoReply = mpAutoReplyMapper.selectByAccountIdAndMessage(accountId, requestMessageType); - errorCode = AUTO_REPLY_ADD_MESSAGE_FAIL_EXISTS; - } else if (MpAutoReplyTypeEnum.KEYWORD.getType().equals(type)) { - autoReply = mpAutoReplyMapper.selectByAccountIdAndKeyword(accountId, requestKeyword); - errorCode = AUTO_REPLY_ADD_KEYWORD_FAIL_EXISTS; - } - if (autoReply == null) { - return; - } - - // 存在冲突,抛出业务异常 - if (id == null // 情况一,新增(id == null),存在记录,说明冲突 - || ObjUtil.notEqual(id, autoReply.getId())) { // 情况二,修改(id != null),id 不匹配,说明冲突 - throw exception(errorCode); - } - } - - @Override - public void deleteAutoReply(Long id) { - // 校验粉丝存在 - validateAutoReplyExists(id); - - // 删除自动回复 - mpAutoReplyMapper.deleteById(id); - } - - private MpAutoReplyDO validateAutoReplyExists(Long id) { - MpAutoReplyDO autoReply = mpAutoReplyMapper.selectById(id); - if (autoReply == null) { - throw exception(AUTO_REPLY_NOT_EXISTS); - } - return autoReply; - } - - @Override - public WxMpXmlOutMessage replyForMessage(String appId, WxMpXmlMessage wxMessage) { - // 第一步,匹配自动回复 - List replies = null; - // 1.1 关键字 - if (wxMessage.getMsgType().equals(WxConsts.XmlMsgType.TEXT)) { - // 完全匹配 - replies = mpAutoReplyMapper.selectListByAppIdAndKeywordAll(appId, wxMessage.getContent()); - if (CollUtil.isEmpty(replies)) { - // 模糊匹配 - replies = mpAutoReplyMapper.selectListByAppIdAndKeywordLike(appId, wxMessage.getContent()); - } - } - // 1.2 消息类型 - if (CollUtil.isEmpty(replies)) { - replies = mpAutoReplyMapper.selectListByAppIdAndMessage(appId, wxMessage.getMsgType()); - } - if (CollUtil.isEmpty(replies)) { - return null; - } - MpAutoReplyDO reply = CollUtil.getFirst(replies); - - // 第二步,基于自动回复,创建消息 - MpMessageSendOutReqBO sendReqBO = MpAutoReplyConvert.INSTANCE.convert(wxMessage.getFromUser(), reply); - return mpMessageService.sendOutMessage(sendReqBO); - } - - @Override - public WxMpXmlOutMessage replyForSubscribe(String appId, WxMpXmlMessage wxMessage) { - // 第一步,匹配自动回复 - List replies = mpAutoReplyMapper.selectListByAppIdAndSubscribe(appId); - MpAutoReplyDO reply = CollUtil.isNotEmpty(replies) ? CollUtil.getFirst(replies) - : buildDefaultSubscribeAutoReply(appId); // 如果不存在,提供一个默认末班 - - // 第二步,基于自动回复,创建消息 - MpMessageSendOutReqBO sendReqBO = MpAutoReplyConvert.INSTANCE.convert(wxMessage.getFromUser(), reply); - return mpMessageService.sendOutMessage(sendReqBO); - } - - private MpAutoReplyDO buildDefaultSubscribeAutoReply(String appId) { - MpAccountDO account = mpAccountService.getAccountFromCache(appId); - Assert.notNull(account, "公众号账号({}) 不存在", appId); - // 构建默认的【关注】自动回复 - return new MpAutoReplyDO().setAppId(appId).setAccountId(account.getId()) - .setType(MpAutoReplyTypeEnum.SUBSCRIBE.getType()) - .setResponseMessageType(WxConsts.XmlMsgType.TEXT).setResponseContent("感谢关注"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java deleted file mode 100644 index 5ee5818064..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageSendReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; - -import jakarta.validation.Valid; - -/** - * 公众号消息 Service 接口 - * - * @author 芋道源码 - */ -public interface MpMessageService { - - /** - * 获得公众号消息分页 - * - * @param pageReqVO 分页查询 - * @return 公众号消息分页 - */ - PageResult getMessagePage(MpMessagePageReqVO pageReqVO); - - /** - * 从公众号,接收到粉丝消息 - * - * @param appId 微信公众号 appId - * @param wxMessage 消息 - */ - void receiveMessage(String appId, WxMpXmlMessage wxMessage); - - /** - * 使用公众号,给粉丝回复消息 - * - * 例如说:自动回复、客服消息、菜单回复消息等场景 - * - * 注意,该方法只是返回 WxMpXmlOutMessage 对象,不会真的发送消息 - * - * @param sendReqBO 消息内容 - * @return 微信回复消息 XML - */ - WxMpXmlOutMessage sendOutMessage(@Valid MpMessageSendOutReqBO sendReqBO); - - /** - * 使用公众号,给粉丝发送【客服】消息 - * - * 注意,该方法会真实发送消息 - * - * @param sendReqVO 消息内容 - * @return 消息 - */ - MpMessageDO sendKefuMessage(MpMessageSendReqVO sendReqVO); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java deleted file mode 100644 index 748bd0c041..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java +++ /dev/null @@ -1,148 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageSendReqVO; -import cn.iocoder.yudao.module.mp.convert.message.MpMessageConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.dal.mysql.message.MpMessageMapper; -import cn.iocoder.yudao.module.mp.enums.message.MpMessageSendFromEnum; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import cn.iocoder.yudao.module.mp.service.material.MpMaterialService; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import cn.iocoder.yudao.module.mp.service.user.MpUserService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import jakarta.validation.Validator; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MESSAGE_SEND_FAIL; - -/** - * 粉丝消息 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class MpMessageServiceImpl implements MpMessageService { - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private MpAccountService mpAccountService; - @Resource - private MpUserService mpUserService; - @Resource - private MpMaterialService mpMaterialService; - - @Resource - private MpMessageMapper mpMessageMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Resource - private Validator validator; - - @Override - public PageResult getMessagePage(MpMessagePageReqVO pageReqVO) { - return mpMessageMapper.selectPage(pageReqVO); - } - - @Override - public void receiveMessage(String appId, WxMpXmlMessage wxMessage) { - // 获得关联信息 - MpAccountDO account = mpAccountService.getAccountFromCache(appId); - Assert.notNull(account, "公众号账号({}) 不存在", appId); - MpUserDO user = mpUserService.getUser(appId, wxMessage.getFromUser()); - Assert.notNull(user, "公众号粉丝({}/{}) 不存在", appId, wxMessage.getFromUser()); - - // 记录消息 - MpMessageDO message = MpMessageConvert.INSTANCE.convert(wxMessage, account, user) - .setSendFrom(MpMessageSendFromEnum.USER_TO_MP.getFrom()); - downloadMessageMedia(message); - mpMessageMapper.insert(message); - } - - @Override - public WxMpXmlOutMessage sendOutMessage(MpMessageSendOutReqBO sendReqBO) { - // 校验消息格式 - MpUtils.validateMessage(validator, sendReqBO.getType(), sendReqBO); - - // 获得关联信息 - MpAccountDO account = mpAccountService.getAccountFromCache(sendReqBO.getAppId()); - Assert.notNull(account, "公众号账号({}) 不存在", sendReqBO.getAppId()); - MpUserDO user = mpUserService.getUser(sendReqBO.getAppId(), sendReqBO.getOpenid()); - Assert.notNull(user, "公众号粉丝({}/{}) 不存在", sendReqBO.getAppId(), sendReqBO.getOpenid()); - - // 记录消息 - MpMessageDO message = MpMessageConvert.INSTANCE.convert(sendReqBO, account, user). - setSendFrom(MpMessageSendFromEnum.MP_TO_USER.getFrom()); - downloadMessageMedia(message); - mpMessageMapper.insert(message); - - // 转换返回 WxMpXmlOutMessage 对象 - return MpMessageConvert.INSTANCE.convert02(message, account); - } - - @Override - public MpMessageDO sendKefuMessage(MpMessageSendReqVO sendReqVO) { - // 校验消息格式 - MpUtils.validateMessage(validator, sendReqVO.getType(), sendReqVO); - - // 获得关联信息 - MpUserDO user = mpUserService.getRequiredUser(sendReqVO.getUserId()); - MpAccountDO account = mpAccountService.getRequiredAccount(user.getAccountId()); - - // 发送客服消息 - WxMpKefuMessage wxMessage = MpMessageConvert.INSTANCE.convert(sendReqVO, user); - WxMpService mpService = mpServiceFactory.getRequiredMpService(user.getAppId()); - try { - mpService.getKefuService().sendKefuMessageWithResponse(wxMessage); - } catch (WxErrorException e) { - throw exception(MESSAGE_SEND_FAIL, e.getError().getErrorMsg()); - } - - // 记录消息 - MpMessageDO message = MpMessageConvert.INSTANCE.convert(wxMessage, account, user) - .setSendFrom(MpMessageSendFromEnum.MP_TO_USER.getFrom()); - downloadMessageMedia(message); - mpMessageMapper.insert(message); - return message; - } - - /** - * 下载消息使用到的媒体文件,并上传到文件服务 - * - * @param message 消息 - */ - private void downloadMessageMedia(MpMessageDO message) { - if (StrUtil.isNotEmpty(message.getMediaId())) { - message.setMediaUrl(mpMaterialService.downloadMaterialUrl(message.getAccountId(), - message.getMediaId(), MpUtils.getMediaFileType(message.getType()))); - } - if (StrUtil.isNotEmpty(message.getThumbMediaId())) { - message.setThumbMediaUrl(mpMaterialService.downloadMaterialUrl(message.getAccountId(), - message.getThumbMediaId(), WxConsts.MediaFileType.THUMB)); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/bo/MpMessageSendOutReqBO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/bo/MpMessageSendOutReqBO.java deleted file mode 100644 index 2a53649cf1..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/bo/MpMessageSendOutReqBO.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message.bo; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils.*; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; -import org.hibernate.validator.constraints.URL; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.List; - -/** - * 公众号消息发送 Request BO - * - * 为什么要有该 BO 呢?在自动回复、客服消息、菜单回复消息等场景,都涉及到 MP 给粉丝发送消息,所以使用该 BO 统一承接 - * - * @author 芋道源码 - */ -@Data -public class MpMessageSendOutReqBO { - - /** - * 公众号 appId - */ - @NotEmpty(message = "公众号 appId 不能为空") - private String appId; - /** - * 公众号粉丝 openid - */ - @NotEmpty(message = "公众号粉丝 openid 不能为空") - private String openid; - - // ========== 消息内容 ========== - /** - * 消息类型 - * - * 枚举 {@link WxConsts.XmlMsgType} 中的 TEXT、IMAGE、VOICE、VIDEO、NEWS、MUSIC - */ - @NotEmpty(message = "消息类型不能为空") - public String type; - - /** - * 消息内容 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 TEXT - */ - @NotEmpty(message = "消息内容不能为空", groups = TextMessageGroup.class) - private String content; - - /** - * 媒体 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - @NotEmpty(message = "消息 mediaId 不能为空", groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String mediaId; - - /** - * 缩略图的媒体 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO、MUSIC - */ - @NotEmpty(message = "消息 thumbMediaId 不能为空", groups = {MusicMessageGroup.class}) - private String thumbMediaId; - - /** - * 标题 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - @NotEmpty(message = "消息标题不能为空", groups = VideoMessageGroup.class) - private String title; - /** - * 描述 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - @NotEmpty(message = "消息描述不能为空", groups = VideoMessageGroup.class) - private String description; - - /** - * 图文消息 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @Valid - @NotNull(message = "图文消息不能为空", groups = NewsMessageGroup.class) - private List articles; - - /** - * 音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - @NotEmpty(message = "音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String musicUrl; - - /** - * 高质量音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - @NotEmpty(message = "高质量音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String hqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java deleted file mode 100644 index 08e5c35bb9..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.statistics; - -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 公众号统计 Service 接口 - * - * @author 芋道源码 - */ -public interface MpStatisticsService { - - /** - * 获取粉丝增减数据 - * - * @param accountId 公众号账号编号 - * @param date 时间区间 - * @return 粉丝增减数据 - */ - List getUserSummary(Long accountId, LocalDateTime[] date); - - /** - * 获取粉丝累计数据 - * - * @param accountId 公众号账号编号 - * @param date 时间区间 - * @return 粉丝累计数据 - */ - List getUserCumulate(Long accountId, LocalDateTime[] date); - - /** - * 获取消息发送概况数据 - * - * @param accountId 公众号账号编号 - * @param date 时间区间 - * @return 消息发送概况数据 - */ - List getUpstreamMessage(Long accountId, LocalDateTime[] date); - - /** - * 获取接口分析数据 - * - * @param accountId 公众号账号编号 - * @param date 时间区间 - * @return 接口分析数据 - */ - List getInterfaceSummary(Long accountId, LocalDateTime[] date); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java deleted file mode 100644 index 5ee207321a..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.statistics; - -import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 公众号统计 Service 实现类 - * - * @author 芋道源码 - */ -@Service -public class MpStatisticsServiceImpl implements MpStatisticsService { - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Override - public List getUserSummary(Long accountId, LocalDateTime[] date) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - return mpService.getDataCubeService().getUserSummary( - DateUtil.date(date[0]), DateUtil.date(date[1])); - } catch (WxErrorException e) { - throw exception(STATISTICS_GET_USER_SUMMARY_FAIL, e.getError().getErrorMsg()); - } - } - - @Override - public List getUserCumulate(Long accountId, LocalDateTime[] date) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - return mpService.getDataCubeService().getUserCumulate( - DateUtil.date(date[0]), DateUtil.date(date[1])); - } catch (WxErrorException e) { - throw exception(STATISTICS_GET_USER_CUMULATE_FAIL, e.getError().getErrorMsg()); - } - } - - @Override - public List getUpstreamMessage(Long accountId, LocalDateTime[] date) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - return mpService.getDataCubeService().getUpstreamMsg( - DateUtil.date(date[0]), DateUtil.date(date[1])); - } catch (WxErrorException e) { - throw exception(STATISTICS_GET_UPSTREAM_MESSAGE_FAIL, e.getError().getErrorMsg()); - } - } - - @Override - public List getInterfaceSummary(Long accountId, LocalDateTime[] date) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - return mpService.getDataCubeService().getInterfaceSummary( - DateUtil.date(date[0]), DateUtil.date(date[1])); - } catch (WxErrorException e) { - throw exception(STATISTICS_GET_INTERFACE_SUMMARY_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagService.java deleted file mode 100644 index eb32486889..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagService.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * 公众号标签 Service 接口 - * - * @author fengdan - */ -public interface MpTagService { - - /** - * 创建公众号标签 - * - * @param createReqVO 创建标签信息 - * @return 标签编号 - */ - Long createTag(@Valid MpTagCreateReqVO createReqVO); - - /** - * 更新公众号标签 - * - * @param updateReqVO 更新标签信息 - */ - void updateTag(@Valid MpTagUpdateReqVO updateReqVO); - - /** - * 删除公众号标签 - * - * @param id 编号 - */ - void deleteTag(Long id); - - /** - * 获得公众号标签分页 - * - * @param pageReqVO 分页查询 - * @return 公众号标签分页 - */ - PageResult getTagPage(MpTagPageReqVO pageReqVO); - - /** - * 获得公众号标签详情 - * @param id id查询 - * @return 公众号标签详情 - */ - MpTagDO get(Long id); - - List getTagList(); - - /** - * 同步公众号标签 - * - * @param accountId 公众号账号的编号 - */ - void syncTag(Long accountId); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagServiceImpl.java deleted file mode 100644 index f48c1ab405..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagServiceImpl.java +++ /dev/null @@ -1,164 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.tag; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagUpdateReqVO; -import cn.iocoder.yudao.module.mp.convert.tag.MpTagConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import cn.iocoder.yudao.module.mp.dal.mysql.tag.MpTagMapper; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.tag.WxUserTag; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 公众号标签 Service 实现类 - * - * @author fengdan - */ -@Slf4j -@Service -@Validated -public class MpTagServiceImpl implements MpTagService { - - @Resource - private MpTagMapper mpTagMapper; - - @Resource - private MpAccountService mpAccountService; - - @Resource - @Lazy // 延迟加载,为了解决延迟加载 - private MpServiceFactory mpServiceFactory; - - @Override - public Long createTag(MpTagCreateReqVO createReqVO) { - // 获得公众号账号 - MpAccountDO account = mpAccountService.getRequiredAccount(createReqVO.getAccountId()); - - // 第一步,新增标签到公众号平台。标签名的唯一,交给公众号平台 - WxMpService mpService = mpServiceFactory.getRequiredMpService(createReqVO.getAccountId()); - WxUserTag wxTag; - try { - wxTag = mpService.getUserTagService().tagCreate(createReqVO.getName()); - } catch (WxErrorException e) { - throw exception(TAG_CREATE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,新增标签到数据库 - MpTagDO tag = MpTagConvert.INSTANCE.convert(wxTag, account); - mpTagMapper.insert(tag); - return tag.getId(); - } - - @Override - public void updateTag(MpTagUpdateReqVO updateReqVO) { - // 校验标签存在 - MpTagDO tag = validateTagExists(updateReqVO.getId()); - - // 第一步,更新标签到公众号平台。标签名的唯一,交给公众号平台 - WxMpService mpService = mpServiceFactory.getRequiredMpService(tag.getAccountId()); - try { - mpService.getUserTagService().tagUpdate(tag.getTagId(), updateReqVO.getName()); - } catch (WxErrorException e) { - throw exception(TAG_UPDATE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,更新标签到数据库 - mpTagMapper.updateById(new MpTagDO().setId(tag.getId()).setName(updateReqVO.getName())); - } - - @Override - public void deleteTag(Long id) { - // 校验标签存在 - MpTagDO tag = validateTagExists(id); - - // 第一步,删除标签到公众号平台。 - WxMpService mpService = mpServiceFactory.getRequiredMpService(tag.getAccountId()); - try { - mpService.getUserTagService().tagDelete(tag.getTagId()); - } catch (WxErrorException e) { - throw exception(TAG_DELETE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,删除标签到数据库 - mpTagMapper.deleteById(tag.getId()); - } - - private MpTagDO validateTagExists(Long id) { - MpTagDO tag = mpTagMapper.selectById(id); - if (tag == null) { - throw exception(TAG_NOT_EXISTS); - } - return tag; - } - - @Override - public PageResult getTagPage(MpTagPageReqVO pageReqVO) { - return mpTagMapper.selectPage(pageReqVO); - } - - @Override - public MpTagDO get(Long id) { - return mpTagMapper.selectById(id); - } - - @Override - public List getTagList() { - return mpTagMapper.selectList(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void syncTag(Long accountId) { - MpAccountDO account = mpAccountService.getRequiredAccount(accountId); - - // 第一步,从公众号平台获取最新的标签列表 - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - List wxTags; - try { - wxTags = mpService.getUserTagService().tagGet(); - } catch (WxErrorException e) { - throw exception(TAG_GET_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,合并更新回自己的数据库;由于标签只有 100 个,所以直接 for 循环操作 - Map tagMap = convertMap(mpTagMapper.selectListByAccountId(accountId), - MpTagDO::getTagId); - wxTags.forEach(wxTag -> { - MpTagDO tag = tagMap.remove(wxTag.getId()); - // 情况一,不存在,新增 - if (tag == null) { - tag = MpTagConvert.INSTANCE.convert(wxTag, account); - mpTagMapper.insert(tag); - return; - } - // 情况二,存在,则更新 - mpTagMapper.updateById(new MpTagDO().setId(tag.getId()) - .setName(wxTag.getName()).setCount(wxTag.getCount())); - }); - // 情况三,部分标签已经不存在了,删除 - if (CollUtil.isNotEmpty(tagMap)) { - mpTagMapper.deleteBatchIds(convertList(tagMap.values(), MpTagDO::getId)); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserService.java deleted file mode 100644 index bdefc0e601..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.user; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import me.chanjar.weixin.mp.bean.result.WxMpUser; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.USER_NOT_EXISTS; - -/** - * 公众号粉丝 Service 接口 - * - * @author 芋道源码 - */ -public interface MpUserService { - - /** - * 获得公众号粉丝 - * - * @param id 编号 - * @return 公众号粉丝 - */ - MpUserDO getUser(Long id); - - /** - * 使用 appId + openId,获得公众号粉丝 - * - * @param appId 公众号 appId - * @param openId 公众号 openId - * @return 公众号粉丝 - */ - MpUserDO getUser(String appId, String openId); - - /** - * 获得公众号粉丝 - * - * @param id 编号 - * @return 公众号粉丝 - */ - default MpUserDO getRequiredUser(Long id) { - MpUserDO user = getUser(id); - if (user == null) { - throw exception(USER_NOT_EXISTS); - } - return user; - } - - /** - * 获得公众号粉丝列表 - * - * @param ids 编号 - * @return 公众号粉丝列表 - */ - List getUserList(Collection ids); - - /** - * 获得公众号粉丝分页 - * - * @param pageReqVO 分页查询 - * @return 公众号粉丝分页 - */ - PageResult getUserPage(MpUserPageReqVO pageReqVO); - - /** - * 保存公众号粉丝 - * - * 新增或更新,根据是否存在数据库中 - * - * @param appId 公众号 appId - * @param wxMpUser 公众号粉丝的信息 - * @return 公众号粉丝 - */ - MpUserDO saveUser(String appId, WxMpUser wxMpUser); - - /** - * 同步一个公众号粉丝 - * - * @param accountId 公众号账号的编号 - */ - void syncUser(Long accountId); - - /** - * 更新公众号粉丝,取消关注 - * - * @param appId 公众号 appId - * @param openId 公众号粉丝的 openid - */ - void updateUserUnsubscribe(String appId, String openId); - - /** - * 更新公众号粉丝 - * - * @param updateReqVO 更新信息 - */ - void updateUser(MpUserUpdateReqVO updateReqVO); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserServiceImpl.java deleted file mode 100644 index 12dd0093d6..0000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserServiceImpl.java +++ /dev/null @@ -1,215 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.user; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO; -import cn.iocoder.yudao.module.mp.convert.user.MpUserConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.dal.mysql.user.MpUserMapper; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.result.WxMpUser; -import me.chanjar.weixin.mp.bean.result.WxMpUserList; -import org.springframework.context.annotation.Lazy; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.USER_NOT_EXISTS; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.USER_UPDATE_TAG_FAIL; - -/** - * 微信公众号粉丝 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class MpUserServiceImpl implements MpUserService { - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpAccountService mpAccountService; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Resource - private MpUserMapper mpUserMapper; - - @Override - public MpUserDO getUser(Long id) { - return mpUserMapper.selectById(id); - } - - @Override - public MpUserDO getUser(String appId, String openId) { - return mpUserMapper.selectByAppIdAndOpenid(appId, openId); - } - - @Override - public List getUserList(Collection ids) { - return mpUserMapper.selectBatchIds(ids); - } - - @Override - public PageResult getUserPage(MpUserPageReqVO pageReqVO) { - return mpUserMapper.selectPage(pageReqVO); - } - - @Override - public MpUserDO saveUser(String appId, WxMpUser wxMpUser) { - // 构建保存的 MpUserDO 对象 - MpAccountDO account = mpAccountService.getAccountFromCache(appId); - MpUserDO user = MpUserConvert.INSTANCE.convert(account, wxMpUser); - - // 根据情况,插入或更新 - MpUserDO dbUser = mpUserMapper.selectByAppIdAndOpenid(appId, wxMpUser.getOpenId()); - if (dbUser == null) { - mpUserMapper.insert(user); - } else { - user.setId(dbUser.getId()); - mpUserMapper.updateById(user); - } - return user; - } - - @Override - @Async - public void syncUser(Long accountId) { - MpAccountDO account = mpAccountService.getRequiredAccount(accountId); - // for 循环,避免递归出意外问题,导致死循环 - String nextOpenid = null; - for (int i = 0; i < Short.MAX_VALUE; i++) { - log.info("[syncUser][第({}) 次加载公众号粉丝列表,nextOpenid({})]", i, nextOpenid); - try { - nextOpenid = syncUser0(account, nextOpenid); - } catch (WxErrorException e) { - log.error("[syncUser][第({}) 次同步粉丝异常]", i, e); - break; - } - // 如果 nextOpenid 为空,表示已经同步完毕 - if (StrUtil.isEmpty(nextOpenid)) { - break; - } - } - } - - private String syncUser0(MpAccountDO account, String nextOpenid) throws WxErrorException { - // 第一步,从公众号流式加载粉丝 - WxMpService mpService = mpServiceFactory.getRequiredMpService(account.getId()); - WxMpUserList wxUserList = mpService.getUserService().userList(nextOpenid); - if (CollUtil.isEmpty(wxUserList.getOpenids())) { - return null; - } - - // 第二步,分批加载粉丝信息 - List> openidsList = CollUtil.split(wxUserList.getOpenids(), 100); - for (List openids : openidsList) { - log.info("[syncUser][批量加载粉丝信息,openids({})]", openids); - List wxUsers = mpService.getUserService().userInfoList(openids); - batchSaveUser(account, wxUsers); - } - - // 返回下一次的 nextOpenId - return wxUserList.getNextOpenid(); - } - - private void batchSaveUser(MpAccountDO account, List wxUsers) { - if (CollUtil.isEmpty(wxUsers)) { - return; - } - // 1. 获得数据库已保存的粉丝列表 - List dbUsers = mpUserMapper.selectListByAppIdAndOpenid(account.getAppId(), - CollectionUtils.convertList(wxUsers, WxMpUser::getOpenId)); - Map openId2Users = CollectionUtils.convertMap(dbUsers, MpUserDO::getOpenid); - - // 2.1 根据情况,插入或更新 - List users = MpUserConvert.INSTANCE.convertList(account, wxUsers); - List newUsers = new ArrayList<>(); - for (MpUserDO user : users) { - MpUserDO dbUser = openId2Users.get(user.getOpenid()); - if (dbUser == null) { // 新增:稍后批量插入 - newUsers.add(user); - } else { // 更新:直接执行更新 - user.setId(dbUser.getId()); - mpUserMapper.updateById(user); - } - } - // 2.2 批量插入 - if (CollUtil.isNotEmpty(newUsers)) { - mpUserMapper.insertBatch(newUsers); - } - } - - @Override - public void updateUserUnsubscribe(String appId, String openid) { - MpUserDO dbUser = mpUserMapper.selectByAppIdAndOpenid(appId, openid); - if (dbUser == null) { - log.error("[updateUserUnsubscribe][微信公众号粉丝 appId({}) openid({}) 不存在]", appId, openid); - return; - } - mpUserMapper.updateById(new MpUserDO().setId(dbUser.getId()).setSubscribeStatus(CommonStatusEnum.DISABLE.getStatus()) - .setUnsubscribeTime(LocalDateTime.now())); - } - - @Override - public void updateUser(MpUserUpdateReqVO updateReqVO) { - // 校验存在 - MpUserDO user = validateUserExists(updateReqVO.getId()); - - // 第一步,更新标签到公众号 - updateUserTag(user.getAppId(), user.getOpenid(), updateReqVO.getTagIds()); - - // 第二步,更新基本信息到数据库 - MpUserDO updateObj = MpUserConvert.INSTANCE.convert(updateReqVO).setId(user.getId()); - mpUserMapper.updateById(updateObj); - } - - private MpUserDO validateUserExists(Long id) { - MpUserDO user = mpUserMapper.selectById(id); - if (user == null) { - throw exception(USER_NOT_EXISTS); - } - return user; - } - - private void updateUserTag(String appId, String openid, List tagIds) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(appId); - try { - // 第一步,先取消原来的标签 - List oldTagIds = mpService.getUserTagService().userTagList(openid); - for (Long tagId : oldTagIds) { - mpService.getUserTagService().batchUntagging(tagId, new String[]{openid}); - } - // 第二步,再设置新的标签 - if (CollUtil.isEmpty(tagIds)) { - return; - } - for (Long tagId: tagIds) { - mpService.getUserTagService().batchTagging(tagId, new String[]{openid}); - } - } catch (WxErrorException e) { - throw exception(USER_UPDATE_TAG_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-pay/pom.xml b/yudao-module-pay/pom.xml deleted file mode 100644 index af42593002..0000000000 --- a/yudao-module-pay/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - cn.iocoder.boot - yudao - ${revision} - - 4.0.0 - yudao-module-pay - pom - - yudao-module-pay-api - yudao-module-pay-biz - - - ${project.artifactId} - - pay 模块,我们放支付业务,提供业务的支付能力。 - 例如说:商户、应用、支付、退款等等 - - - - diff --git a/yudao-module-pay/yudao-module-pay-api/pom.xml b/yudao-module-pay/yudao-module-pay-api/pom.xml deleted file mode 100644 index 0903abed54..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - yudao-module-pay - cn.iocoder.boot - ${revision} - - 4.0.0 - yudao-module-pay-api - jar - - ${project.artifactId} - - pay 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayOrderNotifyReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayOrderNotifyReqDTO.java deleted file mode 100644 index 8c01e8b3f2..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayOrderNotifyReqDTO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.notify.dto; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * 支付单的通知 Request DTO - * - * @author 芋道源码 - */ -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayOrderNotifyReqDTO { - - /** - * 商户订单编号 - */ - @NotEmpty(message = "商户订单号不能为空") - private String merchantOrderId; - - /** - * 支付订单编号 - */ - @NotNull(message = "支付订单编号不能为空") - private Long payOrderId; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayRefundNotifyReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayRefundNotifyReqDTO.java deleted file mode 100644 index 39de1b985b..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayRefundNotifyReqDTO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.notify.dto; - -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * 退款单的通知 Request DTO - * - * @author 芋道源码 - */ -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayRefundNotifyReqDTO { - - /** - * 商户退款单编号 - */ - @NotEmpty(message = "商户退款单编号不能为空") - private String merchantOrderId; - - /** - * 支付退款编号 - */ - @NotNull(message = "支付退款编号不能为空") - private Long payRefundId; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayTransferNotifyReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayTransferNotifyReqDTO.java deleted file mode 100644 index d96f06b123..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayTransferNotifyReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.notify.dto; - -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * 转账单的通知 Request DTO - * - * @author jason - */ -@Data -public class PayTransferNotifyReqDTO { - - /** - * 商户转账单号 - */ - @NotEmpty(message = "商户转账单号不能为空") - private String merchantTransferId; - - /** - * 转账订单编号 - */ - @NotNull(message = "转账订单编号不能为空") - private Long payTransferId; -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/package-info.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/package-info.java deleted file mode 100644 index 60c4ca8839..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,无特殊作用 - */ -package cn.iocoder.yudao.module.pay.api.notify; diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java deleted file mode 100644 index 965d79a19b..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.order; - -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; - -import jakarta.validation.Valid; - -/** - * 支付单 API 接口 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface PayOrderApi { - - /** - * 创建支付单 - * - * @param reqDTO 创建请求 - * @return 支付单编号 - */ - Long createOrder(@Valid PayOrderCreateReqDTO reqDTO); - - /** - * 获得支付单 - * - * @param id 支付单编号 - * @return 支付单 - */ - PayOrderRespDTO getOrder(Long id); - - /** - * 更新支付订单价格 - * - * @param id 支付单编号 - * @param payPrice 支付单价格 - */ - void updatePayOrderPrice(Long id, Integer payPrice); - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderCreateReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderCreateReqDTO.java deleted file mode 100644 index a960488281..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderCreateReqDTO.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.order.dto; - -import lombok.Data; -import org.hibernate.validator.constraints.Length; - -import jakarta.validation.constraints.DecimalMin; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - * 支付单创建 Request DTO - */ -@Data -public class PayOrderCreateReqDTO implements Serializable { - - public static final int SUBJECT_MAX_LENGTH = 32; - - /** - * 应用编号 - */ - @NotNull(message = "应用编号不能为空") - private Long appId; - /** - * 用户 IP - */ - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - // ========== 商户相关字段 ========== - - /** - * 商户订单编号 - */ - @NotEmpty(message = "商户订单编号不能为空") - private String merchantOrderId; - /** - * 商品标题 - */ - @NotEmpty(message = "商品标题不能为空") - @Length(max = SUBJECT_MAX_LENGTH, message = "商品标题不能超过 32") - private String subject; - /** - * 商品描述 - */ - @Length(max = 128, message = "商品描述信息长度不能超过128") - private String body; - - // ========== 订单相关字段 ========== - - /** - * 支付金额,单位:分 - */ - @NotNull(message = "支付金额不能为空") - @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") - private Integer price; - - /** - * 支付过期时间 - */ - @NotNull(message = "支付过期时间不能为空") - private LocalDateTime expireTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderRespDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderRespDTO.java deleted file mode 100644 index 583d6d54d7..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderRespDTO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.order.dto; - -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import lombok.Data; - -/** - * 支付单信息 Response DTO - * - * @author 芋道源码 - */ -@Data -public class PayOrderRespDTO { - - /** - * 订单编号,数据库自增 - */ - private Long id; - /** - * 渠道编码 - * - * 枚举 PayChannelEnum - */ - private String channelCode; - - // ========== 商户相关字段 ========== - /** - * 商户订单编号 - * 例如说,内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一 - */ - private String merchantOrderId; - - // ========== 订单相关字段 ========== - /** - * 支付金额,单位:分 - */ - private Integer price; - /** - * 支付状态 - * - * 枚举 {@link PayOrderStatusEnum} - */ - private Integer status; - - // ========== 渠道相关字段 ========== - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApi.java deleted file mode 100644 index fa768f87fa..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApi.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.refund; - -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundRespDTO; - -import jakarta.validation.Valid; - -/** - * 退款单 API 接口 - * - * @author 芋道源码 - */ -public interface PayRefundApi { - - /** - * 创建退款单 - * - * @param reqDTO 创建请求 - * @return 退款单编号 - */ - Long createRefund(@Valid PayRefundCreateReqDTO reqDTO); - - /** - * 获得退款单 - * - * @param id 退款单编号 - * @return 退款单 - */ - PayRefundRespDTO getRefund(Long id); - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundCreateReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundCreateReqDTO.java deleted file mode 100644 index 48a6df504a..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundCreateReqDTO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.refund.dto; - -import lombok.Data; -import org.hibernate.validator.constraints.Length; - -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * 退款单创建 Request DTO - * - * @author 芋道源码 - */ -@Data -public class PayRefundCreateReqDTO { - - /** - * 应用编号 - */ - @NotNull(message = "应用编号不能为空") - private Long appId; - /** - * 用户 IP - */ - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - // ========== 商户相关字段 ========== - /** - * 商户订单编号 - */ - @NotEmpty(message = "商户订单编号不能为空") - private String merchantOrderId; - - /** - * 商户退款编号 - */ - @NotEmpty(message = "商户退款编号不能为空") - private String merchantRefundId; - - /** - * 退款描述 - */ - @NotEmpty(message = "退款描述不能为空") - @Length(max = 128, message = "退款描述长度不能超过 128") - private String reason; - - // ========== 订单相关字段 ========== - - /** - * 退款金额,单位:分 - */ - @NotNull(message = "退款金额不能为空") - @Min(value = 1, message = "退款金额必须大于零") - private Integer price; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundRespDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundRespDTO.java deleted file mode 100644 index bcc2b7ffae..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundRespDTO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.refund.dto; - -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 退款单信息 Response DTO - * - * @author 芋道源码 - */ -@Data -public class PayRefundRespDTO { - - /** - * 退款单编号 - */ - private Long id; - - // ========== 退款相关字段 ========== - /** - * 退款状态 - * - * 枚举 {@link PayRefundStatusEnum} - */ - private Integer status; - /** - * 退款金额,单位:分 - */ - private Integer refundPrice; - - // ========== 商户相关字段 ========== - /** - * 商户订单编号 - */ - private String merchantOrderId; - /** - * 退款成功时间 - */ - private LocalDateTime successTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java deleted file mode 100644 index 7f000be74d..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.transfer; - -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; - -import jakarta.validation.Valid; - -/** - * 转账单 API 接口 - * - * @author jason - */ -public interface PayTransferApi { - - /** - * 创建转账单 - * - * @param reqDTO 创建请求 - * @return 转账单编号 - */ - Long createTransfer(@Valid PayTransferCreateReqDTO reqDTO); - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java deleted file mode 100644 index e86733050c..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.transfer.dto; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferTypeEnum; -import lombok.Data; - -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.Map; - -/** - * 转账单创建 Request DTO - * - * @author jason - */ -@Data -public class PayTransferCreateReqDTO { - - /** - * 应用编号 - */ - @NotNull(message = "应用编号不能为空") - private Long appId; - - @NotEmpty(message = "转账渠道不能为空") - private String channelCode; - - /** - * 转账渠道的额外参数 - */ - private Map channelExtras; - - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - /** - * 类型 - */ - @NotNull(message = "转账类型不能为空") - @InEnum(PayTransferTypeEnum.class) - private Integer type; - - - /** - * 商户转账单编号 - */ - @NotEmpty(message = "商户转账单编号能为空") - private String merchantTransferId; - - /** - * 转账金额,单位:分 - */ - @Min(value = 1, message = "转账金额必须大于零") - @NotNull(message = "转账金额不能为空") - private Integer price; - - /** - * 转账标题 - */ - @NotEmpty(message = "转账标题不能为空") - private String subject; - - /** - * 收款人姓名 - */ - @NotBlank(message = "收款人姓名不能为空", groups = {PayTransferTypeEnum.Alipay.class}) - private String userName; - - @NotBlank(message = "支付宝登录号不能为空", groups = {PayTransferTypeEnum.Alipay.class}) - private String alipayLogonId; - - // ========== 微信转账相关字段 ========== - @NotBlank(message = "微信 openId 不能为空", groups = {PayTransferTypeEnum.WxPay.class}) - private String openid; -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/DictTypeConstants.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/DictTypeConstants.java deleted file mode 100644 index 8f0d9b718d..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/DictTypeConstants.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums; - -/** - * Pay 字典类型的枚举类 - * - * @author 芋道源码 - */ -public interface DictTypeConstants { - - String CHANNEL_CODE = "pay_channel_code"; // 支付渠道编码 - - String ORDER_STATUS = "pay_order_status"; // 支付渠道 - - String REFUND_STATUS = "pay_order_status"; // 退款状态 - - String NOTIFY_STATUS = "pay_notify_status"; // 回调状态 - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java deleted file mode 100644 index 8b7a38ecf6..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Pay 错误码 Core 枚举类 - * - * pay 系统,使用 1-007-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== APP 模块 1-007-000-000 ========== - ErrorCode APP_NOT_FOUND = new ErrorCode(1_007_000_000, "App 不存在"); - ErrorCode APP_IS_DISABLE = new ErrorCode(1_007_000_002, "App 已经被禁用"); - ErrorCode APP_EXIST_ORDER_CANT_DELETE = new ErrorCode(1_007_000_003, "支付应用存在支付订单,无法删除"); - ErrorCode APP_EXIST_REFUND_CANT_DELETE = new ErrorCode(1_007_000_004, "支付应用存在退款订单,无法删除"); - - // ========== CHANNEL 模块 1-007-001-000 ========== - ErrorCode CHANNEL_NOT_FOUND = new ErrorCode(1_007_001_000, "支付渠道的配置不存在"); - ErrorCode CHANNEL_IS_DISABLE = new ErrorCode(1_007_001_001, "支付渠道已经禁用"); - ErrorCode CHANNEL_EXIST_SAME_CHANNEL_ERROR = new ErrorCode(1_007_001_004, "已存在相同的渠道"); - - // ========== ORDER 模块 1-007-002-000 ========== - ErrorCode PAY_ORDER_NOT_FOUND = new ErrorCode(1_007_002_000, "支付订单不存在"); - ErrorCode PAY_ORDER_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_002_001, "支付订单不处于待支付"); - ErrorCode PAY_ORDER_STATUS_IS_SUCCESS = new ErrorCode(1_007_002_002, "订单已支付,请刷新页面"); - ErrorCode PAY_ORDER_IS_EXPIRED = new ErrorCode(1_007_002_003, "支付订单已经过期"); - ErrorCode PAY_ORDER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_002_004, "发起支付报错,错误码:{},错误提示:{}"); - ErrorCode PAY_ORDER_REFUND_FAIL_STATUS_ERROR = new ErrorCode(1_007_002_005, "支付订单退款失败,原因:状态不是已支付或已退款"); - - // ========== ORDER 模块(拓展单) 1-007-003-000 ========== - ErrorCode PAY_ORDER_EXTENSION_NOT_FOUND = new ErrorCode(1_007_003_000, "支付交易拓展单不存在"); - ErrorCode PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_003_001, "支付交易拓展单不处于待支付"); - ErrorCode PAY_ORDER_EXTENSION_IS_PAID = new ErrorCode(1_007_003_002, "订单已支付,请等待支付结果"); - - // ========== 支付模块(退款) 1-007-006-000 ========== - ErrorCode REFUND_PRICE_EXCEED = new ErrorCode(1_007_006_000, "退款金额超过订单可退款金额"); - ErrorCode REFUND_HAS_REFUNDING = new ErrorCode(1_007_006_002, "已经有退款在处理中"); - ErrorCode REFUND_EXISTS = new ErrorCode(1_007_006_003, "已经存在退款单"); - ErrorCode REFUND_NOT_FOUND = new ErrorCode(1_007_006_004, "支付退款单不存在"); - ErrorCode REFUND_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_006_005, "支付退款单不处于待退款"); - - // ========== 钱包模块 1-007-007-000 ========== - ErrorCode WALLET_NOT_FOUND = new ErrorCode(1_007_007_000, "用户钱包不存在"); - ErrorCode WALLET_BALANCE_NOT_ENOUGH = new ErrorCode(1_007_007_001, "钱包余额不足"); - ErrorCode WALLET_TRANSACTION_NOT_FOUND = new ErrorCode(1_007_007_002, "未找到对应的钱包交易"); - ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1_007_007_003, "已经存在钱包退款"); - ErrorCode WALLET_FREEZE_PRICE_NOT_ENOUGH = new ErrorCode(1_007_007_004, "钱包冻结余额不足"); - - // ========== 钱包充值模块 1-007-008-000 ========== - ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1_007_008_000, "钱包充值记录不存在"); - ErrorCode WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_008_001, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态"); - ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR = new ErrorCode(1_007_008_002, "钱包充值更新支付状态失败,支付单编号不匹配"); - ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1_007_008_003, "钱包充值更新支付状态失败,支付单状态不是【支付成功】状态"); - ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH = new ErrorCode(1_007_008_004, "钱包充值更新支付状态失败,支付单金额不匹配"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_NOT_PAID = new ErrorCode(1_007_008_005, "钱包发起退款失败,钱包充值订单未支付"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUNDED = new ErrorCode(1_007_008_006, "钱包发起退款失败,钱包充值订单已退款"); - ErrorCode WALLET_RECHARGE_REFUND_BALANCE_NOT_ENOUGH = new ErrorCode(1_007_008_007, "钱包发起退款失败,钱包余额不足"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR = new ErrorCode(1_007_008_008, "钱包退款更新失败,钱包退款单编号不匹配"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND = new ErrorCode(1_007_008_009, "钱包退款更新失败,退款订单不存在"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH = new ErrorCode(1_007_008_010, "钱包退款更新失败,退款单金额不匹配"); - ErrorCode WALLET_RECHARGE_PACKAGE_NOT_FOUND = new ErrorCode(1_007_008_011, "钱包充值套餐不存在"); - ErrorCode WALLET_RECHARGE_PACKAGE_IS_DISABLE = new ErrorCode(1_007_008_012, "钱包充值套餐已禁用"); - ErrorCode WALLET_RECHARGE_PACKAGE_NAME_EXISTS = new ErrorCode(1_007_008_013, "钱包充值套餐名称已存在"); - - // ========== 转账模块 1-007-009-000 ========== - ErrorCode PAY_TRANSFER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_009_000, "发起转账报错,错误码:{},错误提示:{}"); - ErrorCode PAY_TRANSFER_NOT_FOUND = new ErrorCode(1_007_009_001, "转账单不存在"); - ErrorCode PAY_SAME_MERCHANT_TRANSFER_TYPE_NOT_MATCH = new ErrorCode(1_007_009_002, "两次相同转账请求的类型不匹配"); - ErrorCode PAY_SAME_MERCHANT_TRANSFER_PRICE_NOT_MATCH = new ErrorCode(1_007_009_003, "两次相同转账请求的金额不匹配"); - ErrorCode PAY_MERCHANT_TRANSFER_EXISTS = new ErrorCode(1_007_009_004, "该笔业务的转账已经发起,请查询转账订单相关状态"); - ErrorCode PAY_TRANSFER_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_009_005, "转账单不处于待转账"); - ErrorCode PAY_TRANSFER_STATUS_IS_NOT_PENDING = new ErrorCode(1_007_009_006, "转账单不处于待转账或转账中"); - - // ========== 示例订单 1-007-900-000 ========== - ErrorCode DEMO_ORDER_NOT_FOUND = new ErrorCode(1_007_900_000, "示例订单不存在"); - ErrorCode DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_900_001, "示例订单更新支付状态失败,订单不是【未支付】状态"); - ErrorCode DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR = new ErrorCode(1_007_900_002, "示例订单更新支付状态失败,支付单编号不匹配"); - ErrorCode DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1_007_900_003, "示例订单更新支付状态失败,支付单状态不是【支付成功】状态"); - ErrorCode DEMO_ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH = new ErrorCode(1_007_900_004, "示例订单更新支付状态失败,支付单金额不匹配"); - ErrorCode DEMO_ORDER_REFUND_FAIL_NOT_PAID = new ErrorCode(1_007_900_005, "发起退款失败,示例订单未支付"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUNDED = new ErrorCode(1_007_900_006, "发起退款失败,示例订单已退款"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_NOT_FOUND = new ErrorCode(1_007_900_007, "发起退款失败,退款订单不存在"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_NOT_SUCCESS = new ErrorCode(1_007_900_008, "发起退款失败,退款订单未退款成功"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_ORDER_ID_ERROR = new ErrorCode(1_007_900_009, "发起退款失败,退款单编号不匹配"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_PRICE_NOT_MATCH = new ErrorCode(1_007_900_010, "发起退款失败,退款单金额不匹配"); - - // ========== 示例转账订单 1-007-901-001 ========== - ErrorCode DEMO_TRANSFER_NOT_FOUND = new ErrorCode(1_007_901_001, "示例转账单不存在"); - ErrorCode DEMO_TRANSFER_FAIL_TRANSFER_ID_ERROR = new ErrorCode(1_007_901_002, "转账失败,转账单编号不匹配"); - ErrorCode DEMO_TRANSFER_FAIL_PRICE_NOT_MATCH = new ErrorCode(1_007_901_003, "转账失败,转账单金额不匹配"); -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyStatusEnum.java deleted file mode 100644 index b735598d53..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyStatusEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.notify; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 支付通知状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayNotifyStatusEnum { - - WAITING(0, "等待通知"), - SUCCESS(10, "通知成功"), - FAILURE(20, "通知失败"), // 多次尝试,彻底失败 - REQUEST_SUCCESS(21, "请求成功,但是结果失败"), - REQUEST_FAILURE(22, "请求失败"), - - ; - - /** - * 状态 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyTypeEnum.java deleted file mode 100644 index 873e015c6a..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyTypeEnum.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.notify; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 支付通知类型 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayNotifyTypeEnum { - - ORDER(1, "支付单"), - REFUND(2, "退款单"), - TRANSFER(3, "转账单") - ; - - /** - * 类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java deleted file mode 100644 index 86a9e1704b..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.order; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 支付订单的状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayOrderStatusEnum implements IntArrayValuable { - - WAITING(0, "未支付"), - SUCCESS(10, "支付成功"), - REFUND(20, "已退款"), - CLOSED(30, "支付关闭"), // 注意:全部退款后,还是 REFUND 状态 - ; - - private final Integer status; - private final String name; - - @Override - public int[] array() { - return new int[0]; - } - - /** - * 判断是否支付成功 - * - * @param status 状态 - * @return 是否支付成功 - */ - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - /** - * 判断是否支付成功或者已退款 - * - * @param status 状态 - * @return 是否支付成功或者已退款 - */ - public static boolean isSuccessOrRefund(Integer status) { - return ObjectUtils.equalsAny(status, - SUCCESS.getStatus(), REFUND.getStatus()); - } - - /** - * 判断是否支付关闭 - * - * @param status 状态 - * @return 是否支付关闭 - */ - public static boolean isClosed(Integer status) { - return Objects.equals(status, CLOSED.getStatus()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/refund/PayRefundStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/refund/PayRefundStatusEnum.java deleted file mode 100644 index 4ae14cc67d..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/refund/PayRefundStatusEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.refund; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 渠道的退款状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayRefundStatusEnum { - - WAITING(0, "未退款"), - SUCCESS(10, "退款成功"), - FAILURE(20, "退款失败"); - - private final Integer status; - private final String name; - - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - public static boolean isFailure(Integer status) { - return Objects.equals(status, FAILURE.getStatus()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferStatusEnum.java deleted file mode 100644 index 6f2f27c753..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferStatusEnum.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.transfer; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * @author jason - */ -@Getter -@AllArgsConstructor -public enum PayTransferStatusEnum { - - WAITING(0, "等待转账"), - /** - * TODO 转账到银行卡. 会有T+0 T+1 到账的请情况。 还未实现 - */ - IN_PROGRESS(10, "转账进行中"), - - SUCCESS(20, "转账成功"), - /** - * 转账关闭 (失败,或者其它情况) // TODO 改成 转账失败状态 - */ - CLOSED(30, "转账关闭"); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - public static boolean isClosed(Integer status) { - return Objects.equals(status, CLOSED.getStatus()); - } - - public static boolean isWaiting(Integer status) { - return Objects.equals(status, WAITING.getStatus()); - } - public static boolean isInProgress(Integer status) { - return Objects.equals(status, IN_PROGRESS.getStatus()); - } - - /** - * 是否处于待转账或者转账中的状态 - * @param status 状态 - */ - public static boolean isPendingStatus(Integer status) { - return Objects.equals(status, WAITING.getStatus()) || Objects.equals(status, IN_PROGRESS.getStatus()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java deleted file mode 100644 index c881515897..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.transfer; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 转账类型枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum PayTransferTypeEnum implements IntArrayValuable { - - ALIPAY_BALANCE(1, "支付宝余额"), - WX_BALANCE(2, "微信余额"), - BANK_CARD(3, "银行卡"), - WALLET_BALANCE(4, "钱包余额"); - - public interface WxPay { - } - - public interface Alipay { - } - - private final Integer type; - private final String name; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PayTransferTypeEnum::getType).toArray(); - - @Override - public int[] array() { - return ARRAYS; - } - - public static PayTransferTypeEnum typeOf(Integer type) { - return ArrayUtil.firstMatch(item -> item.getType().equals(type), values()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java deleted file mode 100644 index 20e0a8b09f..0000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.wallet; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 钱包交易业务分类 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum PayWalletBizTypeEnum implements IntArrayValuable { - - RECHARGE(1, "充值"), - RECHARGE_REFUND(2, "充值退款"), - PAYMENT(3, "支付"), - PAYMENT_REFUND(4, "支付退款"); - - // TODO 后续增加 - - /** - * 业务分类 - */ - private final Integer type; - /** - * 说明 - */ - private final String description; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PayWalletBizTypeEnum::getType).toArray(); - - @Override - public int[] array() { - return ARRAYS; - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/pom.xml b/yudao-module-pay/yudao-module-pay-biz/pom.xml deleted file mode 100644 index f7c3e6053c..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/pom.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - yudao-module-pay - cn.iocoder.boot - ${revision} - - 4.0.0 - yudao-module-pay-biz - jar - - ${project.artifactId} - - pay 模块,我们放支付业务,提供业务的支付能力。 - 例如说:商户、应用、支付、退款等等 - - - - - cn.iocoder.boot - yudao-module-pay-api - ${revision} - - - cn.iocoder.boot - yudao-module-member-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-pay - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.boot - yudao-spring-boot-starter-redis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-job - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - - - - - cn.iocoder.boot - yudao-spring-boot-starter-excel - - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApiImpl.java deleted file mode 100644 index 3584f470b3..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApiImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.order; - -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import org.springframework.stereotype.Service; - -import jakarta.annotation.Resource; - -/** - * 支付单 API 实现类 - * - * @author 芋道源码 - */ -@Service -public class PayOrderApiImpl implements PayOrderApi { - - @Resource - private PayOrderService payOrderService; - - @Override - public Long createOrder(PayOrderCreateReqDTO reqDTO) { - return payOrderService.createOrder(reqDTO); - } - - @Override - public PayOrderRespDTO getOrder(Long id) { - PayOrderDO order = payOrderService.getOrder(id); - return PayOrderConvert.INSTANCE.convert2(order); - } - - @Override - public void updatePayOrderPrice(Long id, Integer payPrice) { - payOrderService.updatePayOrderPrice(id, payPrice); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApiImpl.java deleted file mode 100644 index 595f97d034..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApiImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.refund; - -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.convert.refund.PayRefundConvert; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -/** - * 退款单 API 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class PayRefundApiImpl implements PayRefundApi { - - @Resource - private PayRefundService payRefundService; - - @Override - public Long createRefund(PayRefundCreateReqDTO reqDTO) { - return payRefundService.createPayRefund(reqDTO); - } - - @Override - public PayRefundRespDTO getRefund(Long id) { - return PayRefundConvert.INSTANCE.convert02(payRefundService.getRefund(id)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java deleted file mode 100644 index 5e6a3dcdb7..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.transfer; - -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -/** - * 转账单 API 实现类 - * - * @author jason - */ -@Service -@Validated -public class PayTransferApiImpl implements PayTransferApi { - - @Resource - private PayTransferService payTransferService; - - @Override - public Long createTransfer(PayTransferCreateReqDTO reqDTO) { - return payTransferService.createTransfer(reqDTO); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/PayAppController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/PayAppController.java deleted file mode 100644 index c7dfcfdbf0..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/PayAppController.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.*; -import cn.iocoder.yudao.module.pay.convert.app.PayAppConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Slf4j -@Tag(name = "管理后台 - 支付应用信息") -@RestController -@RequestMapping("/pay/app") -@Validated -public class PayAppController { - - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - - @PostMapping("/create") - @Operation(summary = "创建支付应用信息") - @PreAuthorize("@ss.hasPermission('pay:app:create')") - public CommonResult createApp(@Valid @RequestBody PayAppCreateReqVO createReqVO) { - return success(appService.createApp(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新支付应用信息") - @PreAuthorize("@ss.hasPermission('pay:app:update')") - public CommonResult updateApp(@Valid @RequestBody PayAppUpdateReqVO updateReqVO) { - appService.updateApp(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新支付应用状态") - @PreAuthorize("@ss.hasPermission('pay:app:update')") - public CommonResult updateAppStatus(@Valid @RequestBody PayAppUpdateStatusReqVO updateReqVO) { - appService.updateAppStatus(updateReqVO.getId(), updateReqVO.getStatus()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除支付应用信息") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('pay:app:delete')") - public CommonResult deleteApp(@RequestParam("id") Long id) { - appService.deleteApp(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得支付应用信息") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:app:query')") - public CommonResult getApp(@RequestParam("id") Long id) { - PayAppDO app = appService.getApp(id); - return success(PayAppConvert.INSTANCE.convert(app)); - } - - @GetMapping("/page") - @Operation(summary = "获得支付应用信息分页") - @PreAuthorize("@ss.hasPermission('pay:app:query')") - public CommonResult> getAppPage(@Valid PayAppPageReqVO pageVO) { - // 得到应用分页列表 - PageResult pageResult = appService.getAppPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 得到所有的应用编号,查出所有的渠道 - Collection appIds = convertList(pageResult.getList(), PayAppDO::getId); - List channels = channelService.getChannelListByAppIds(appIds); - - // 拼接后返回 - return success(PayAppConvert.INSTANCE.convertPage(pageResult, channels)); - } - - @GetMapping("/list") - @Operation(summary = "获得应用列表") - @PreAuthorize("@ss.hasPermission('pay:merchant:query')") - public CommonResult> getAppList() { - List appListDO = appService.getAppList(); - return success(PayAppConvert.INSTANCE.convertList(appListDO)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java deleted file mode 100644 index a95242a9f8..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import org.hibernate.validator.constraints.URL; - -import jakarta.validation.constraints.*; - -/** -* 支付应用信息 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayAppBaseVO { - - @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "小豆") - @NotNull(message = "应用名不能为空") - private String name; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "开启状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "备注", example = "我是一个测试应用") - private String remark; - - @Schema(description = "支付结果的回调地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "http://127.0.0.1:48080/pay-callback") - @NotNull(message = "支付结果的回调地址不能为空") - @URL(message = "支付结果的回调地址必须为 URL 格式") - private String orderNotifyUrl; - - @Schema(description = "退款结果的回调地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "http://127.0.0.1:48080/refund-callback") - @NotNull(message = "退款结果的回调地址不能为空") - @URL(message = "退款结果的回调地址必须为 URL 格式") - private String refundNotifyUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java deleted file mode 100644 index 03cab7d3e0..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -@Schema(description = "管理后台 - 支付应用信息创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppCreateReqVO extends PayAppBaseVO { - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java deleted file mode 100644 index 76b62003cb..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.Set; - -@Schema(description = "管理后台 - 支付应用信息分页查询 Response VO,相比于支付信息,还会多出应用渠道的开关信息") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppPageItemRespVO extends PayAppBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "已配置的支付渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "[alipay_pc, alipay_wap]") - private Set channelCodes; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java deleted file mode 100644 index 94ade7ce62..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付应用信息分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppPageReqVO extends PageParam { - - @Schema(description = "应用名", example = "小豆") - private String name; - - @Schema(description = "开启状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.java deleted file mode 100644 index 9471a2f016..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付应用信息 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppRespVO extends PayAppBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java deleted file mode 100644 index 68c5599143..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import jakarta.validation.constraints.*; - -@Schema(description = "管理后台 - 支付应用信息更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppUpdateReqVO extends PayAppBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long id; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateStatusReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateStatusReqVO.java deleted file mode 100644 index 585a18fc71..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateStatusReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 应用更新状态 Request VO") -@Data -public class PayAppUpdateStatusReqVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long id; - - @Schema(description = "状态,见 SysCommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java deleted file mode 100644 index b7b0aeded3..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.channel.PayChannelConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 支付渠道") -@RestController -@RequestMapping("/pay/channel") -@Validated -public class PayChannelController { - - @Resource - private PayChannelService channelService; - - @PostMapping("/create") - @Operation(summary = "创建支付渠道 ") - @PreAuthorize("@ss.hasPermission('pay:channel:create')") - public CommonResult createChannel(@Valid @RequestBody PayChannelCreateReqVO createReqVO) { - return success(channelService.createChannel(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新支付渠道 ") - @PreAuthorize("@ss.hasPermission('pay:channel:update')") - public CommonResult updateChannel(@Valid @RequestBody PayChannelUpdateReqVO updateReqVO) { - channelService.updateChannel(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除支付渠道 ") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('pay:channel:delete')") - public CommonResult deleteChannel(@RequestParam("id") Long id) { - channelService.deleteChannel(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得支付渠道") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:channel:query')") - public CommonResult getChannel(@RequestParam(value = "id", required = false) Long id, - @RequestParam(value = "appId", required = false) Long appId, - @RequestParam(value = "code", required = false) String code) { - PayChannelDO channel = null; - if (id != null) { - channel = channelService.getChannel(id); - } else if (appId != null && code != null) { - channel = channelService.getChannelByAppIdAndCode(appId, code); - } - return success(PayChannelConvert.INSTANCE.convert(channel)); - } - - @GetMapping("/get-enable-code-list") - @Operation(summary = "获得指定应用的开启的支付渠道编码列表") - @Parameter(name = "appId", description = "应用编号", required = true, example = "1") - public CommonResult> getEnableChannelCodeList(@RequestParam("appId") Long appId) { - List channels = channelService.getEnableChannelList(appId); - return success(convertSet(channels, PayChannelDO::getCode)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelBaseVO.java deleted file mode 100644 index df99a3c73d..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelBaseVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import jakarta.validation.constraints.*; - -/** -* 支付渠道 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayChannelBaseVO { - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "开启状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "备注", example = "我是小备注") - private String remark; - - @Schema(description = "渠道费率,单位:百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "渠道费率,单位:百分比不能为空") - private Double feeRate; - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long appId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelCreateReqVO.java deleted file mode 100644 index ccb0497ada..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 支付渠道 创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayChannelCreateReqVO extends PayChannelBaseVO { - - @Schema(description = "渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "alipay_pc") - @NotNull(message = "渠道编码不能为空") - private String code; - - @Schema(description = "渠道配置的 json 字符串") - @NotBlank(message = "渠道配置不能为空") - private String config; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelRespVO.java deleted file mode 100644 index dafd29ec94..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付渠道 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayChannelRespVO extends PayChannelBaseVO { - - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private LocalDateTime createTime; - - @Schema(description = "渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "alipay_pc") - private String code; - - @Schema(description = "配置", requiredMode = Schema.RequiredMode.REQUIRED) - private String config; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelUpdateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelUpdateReqVO.java deleted file mode 100644 index 999852847f..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import jakarta.validation.constraints.*; - -@Schema(description = "管理后台 - 支付渠道 更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayChannelUpdateReqVO extends PayChannelBaseVO { - - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "商户编号不能为空") - private Long id; - - @Schema(description = "渠道配置的json字符串") - @NotBlank(message = "渠道配置不能为空") - private String config; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java deleted file mode 100644 index 615be4969e..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.order.PayDemoOrderCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.order.PayDemoOrderRespVO; -import cn.iocoder.yudao.module.pay.convert.demo.PayDemoOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; -import cn.iocoder.yudao.module.pay.service.demo.PayDemoOrderService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.annotation.security.PermitAll; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 示例订单") -@RestController -@RequestMapping("/pay/demo-order") -@Validated -public class PayDemoOrderController { - - @Resource - private PayDemoOrderService payDemoOrderService; - - @PostMapping("/create") - @Operation(summary = "创建示例订单") - public CommonResult createDemoOrder(@Valid @RequestBody PayDemoOrderCreateReqVO createReqVO) { - return success(payDemoOrderService.createDemoOrder(getLoginUserId(), createReqVO)); - } - - @GetMapping("/page") - @Operation(summary = "获得示例订单分页") - public CommonResult> getDemoOrderPage(@Valid PageParam pageVO) { - PageResult pageResult = payDemoOrderService.getDemoOrderPage(pageVO); - return success(PayDemoOrderConvert.INSTANCE.convertPage(pageResult)); - } - - @PostMapping("/update-paid") - @Operation(summary = "更新示例订单为已支付") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录,安全由 PayDemoOrderService 内部校验实现 - @OperateLog(enable = false) // 禁用操作日志,因为没有操作人 - public CommonResult updateDemoOrderPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) { - payDemoOrderService.updateDemoOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayOrderId()); - return success(true); - } - - @PutMapping("/refund") - @Operation(summary = "发起示例订单的退款") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult refundDemoOrder(@RequestParam("id") Long id) { - payDemoOrderService.refundDemoOrder(id, getClientIP()); - return success(true); - } - - @PostMapping("/update-refunded") - @Operation(summary = "更新示例订单为已退款") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录,安全由 PayDemoOrderService 内部校验实现 - @OperateLog(enable = false) // 禁用操作日志,因为没有操作人 - public CommonResult updateDemoOrderRefunded(@RequestBody PayRefundNotifyReqDTO notifyReqDTO) { - payDemoOrderService.updateDemoOrderRefunded(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayRefundId()); - return success(true); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoTransferController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoTransferController.java deleted file mode 100644 index f35f9190fb..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoTransferController.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayTransferNotifyReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferRespVO; -import cn.iocoder.yudao.module.pay.convert.demo.PayDemoTransferConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoTransferDO; -import cn.iocoder.yudao.module.pay.service.demo.PayDemoTransferService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.annotation.security.PermitAll; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 示例转账单") -@RestController -@RequestMapping("/pay/demo-transfer") -@Validated -public class PayDemoTransferController { - @Resource - private PayDemoTransferService demoTransferService; - - @PostMapping("/create") - @Operation(summary = "创建示例转账订单") - public CommonResult createDemoTransfer(@Valid @RequestBody PayDemoTransferCreateReqVO createReqVO) { - return success(demoTransferService.createDemoTransfer(createReqVO)); - } - - @GetMapping("/page") - @Operation(summary = "获得示例转账订单分页") - public CommonResult> getDemoTransferPage(@Valid PageParam pageVO) { - PageResult pageResult = demoTransferService.getDemoTransferPage(pageVO); - return success(PayDemoTransferConvert.INSTANCE.convertPage(pageResult)); - } - - @PostMapping("/update-status") - @Operation(summary = "更新示例转账订单的转账状态") // 由 pay-module 转账服务,进行回调 - @PermitAll // 无需登录,安全由 PayDemoTransferService 内部校验实现 - @OperateLog(enable = false) // 禁用操作日志,因为没有操作人 - public CommonResult updateDemoTransferStatus(@RequestBody PayTransferNotifyReqDTO notifyReqDTO) { - demoTransferService.updateDemoTransferStatus(Long.valueOf(notifyReqDTO.getMerchantTransferId()), - notifyReqDTO.getPayTransferId()); - return success(true); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/order/PayDemoOrderCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/order/PayDemoOrderCreateReqVO.java deleted file mode 100644 index 27ca07bc59..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/order/PayDemoOrderCreateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo.vo.order; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 示例订单创建 Request VO") -@Data -public class PayDemoOrderCreateReqVO { - - @Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17682") - @NotNull(message = "商品编号不能为空") - private Long spuId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/order/PayDemoOrderRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/order/PayDemoOrderRespVO.java deleted file mode 100644 index cb305631d0..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/order/PayDemoOrderRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo.vo.order; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -/** -* 示例订单 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayDemoOrderRespVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23199") - private Long userId; - - @Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17682") - private Long spuId; - - @Schema(description = "商家备注", example = "李四") - private String spuName; - - @Schema(description = "价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "30381") - private Integer price; - - @Schema(description = "是否已支付", requiredMode = Schema.RequiredMode.REQUIRED) - private Boolean payStatus; - - @Schema(description = "支付订单编号", example = "16863") - private Long payOrderId; - - @Schema(description = "订单支付时间") - private LocalDateTime payTime; - - @Schema(description = "支付渠道", example = "alipay_qr") - private String payChannelCode; - - @Schema(description = "支付退款编号", example = "23366") - private Long payRefundId; - - @Schema(description = "退款金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "14039") - private Integer refundPrice; - - @Schema(description = "退款时间") - private LocalDateTime refundTime; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java deleted file mode 100644 index 73288372b5..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer; - -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.Validator; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; - -import static cn.iocoder.yudao.module.pay.enums.transfer.PayTransferTypeEnum.*; - -/** - * @author jason - */ -@Schema(description = "管理后台 - 示例转账单创建 Request VO") -@Data -public class PayDemoTransferCreateReqVO { - - @Schema(description = "转账类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "转账类型不能为空") - @InEnum(PayTransferTypeEnum.class) - private Integer type; - - @Schema(description = "转账金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "转账金额不能为空") - @Min(value = 1, message = "转账金额必须大于零") - private Integer price; - - @Schema(description = "收款人姓名", example = "test1") - @NotBlank(message = "收款人姓名不能为空", groups = {Alipay.class}) - private String userName; - - // ========== 支付宝转账相关字段 ========== - @Schema(description = "支付宝登录号,支持邮箱和手机号格式", example = "test1@@sandbox.com") - @NotBlank(message = "支付宝登录号不能为空", groups = {Alipay.class}) - private String alipayLogonId; - - // ========== 微信转账相关字段 ========== - @Schema(description = "微信 openId", example = "oLefc4g5Gxx") - @NotBlank(message = "微信 openId 不能为空", groups = {WxPay.class}) - private String openid; - - - // ========== 转账到银行卡和钱包相关字段 待补充 ========== - - public void validate(Validator validator) { - PayTransferTypeEnum transferType = PayTransferTypeEnum.typeOf(type); - switch (transferType) { - case ALIPAY_BALANCE: { - ValidationUtils.validate(validator, this, Alipay.class); - break; - } - case WX_BALANCE: { - ValidationUtils.validate(validator, this, WxPay.class); - break; - } - default: { - throw new UnsupportedOperationException("待实现"); - } - } - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferRespVO.java deleted file mode 100644 index 3fdab57c3e..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferRespVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 示例业务转账订单 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class PayDemoTransferRespVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long appId; - - @Schema(description = "转账金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "22338") - private Integer price; - - @Schema(description = "转账类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - @Schema(description = "收款人姓名", example = "test") - private String userName; - - @Schema(description = "支付宝登录号", example = "32167") - private String alipayLogonId; - - @Schema(description = "微信 openId", example = "31139") - private String openid; - - @Schema(description = "转账状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer transferStatus; - - @Schema(description = "转账订单编号", example = "23695") - private Long payTransferId; - - @Schema(description = "转账支付成功渠道") - private String payChannelCode; - - @Schema(description = "转账支付时间") - private LocalDateTime transferTime; -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java deleted file mode 100644 index 65c8c43c56..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.notify; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskDetailRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskRespVO; -import cn.iocoder.yudao.module.pay.convert.notify.PayNotifyTaskConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.annotation.security.PermitAll; -import jakarta.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.CHANNEL_NOT_FOUND; - -@Tag(name = "管理后台 - 回调通知") -@RestController -@RequestMapping("/pay/notify") -@Validated -@Slf4j -public class PayNotifyController { - - @Resource - private PayOrderService orderService; - @Resource - private PayRefundService refundService; - @Resource - private PayNotifyService notifyService; - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - - @PostMapping(value = "/order/{channelId}") - @Operation(summary = "支付渠道的统一【支付】回调") - @PermitAll - @OperateLog(enable = false) // 回调地址,无需记录操作日志 - public String notifyOrder(@PathVariable("channelId") Long channelId, - @RequestParam(required = false) Map params, - @RequestBody(required = false) String body) { - log.info("[notifyOrder][channelId({}) 回调数据({}/{})]", channelId, params, body); - // 1. 校验支付渠道是否存在 - PayClient payClient = channelService.getPayClient(channelId); - if (payClient == null) { - log.error("[notifyCallback][渠道编号({}) 找不到对应的支付客户端]", channelId); - throw exception(CHANNEL_NOT_FOUND); - } - - // 2. 解析通知数据 - PayOrderRespDTO notify = payClient.parseOrderNotify(params, body); - orderService.notifyOrder(channelId, notify); - return "success"; - } - - @PostMapping(value = "/refund/{channelId}") - @Operation(summary = "支付渠道的统一【退款】回调") - @PermitAll - @OperateLog(enable = false) // 回调地址,无需记录操作日志 - public String notifyRefund(@PathVariable("channelId") Long channelId, - @RequestParam(required = false) Map params, - @RequestBody(required = false) String body) { - log.info("[notifyRefund][channelId({}) 回调数据({}/{})]", channelId, params, body); - // 1. 校验支付渠道是否存在 - PayClient payClient = channelService.getPayClient(channelId); - if (payClient == null) { - log.error("[notifyCallback][渠道编号({}) 找不到对应的支付客户端]", channelId); - throw exception(CHANNEL_NOT_FOUND); - } - - // 2. 解析通知数据 - PayRefundRespDTO notify = payClient.parseRefundNotify(params, body); - refundService.notifyRefund(channelId, notify); - return "success"; - } - - @GetMapping("/get-detail") - @Operation(summary = "获得回调通知的明细") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:notify:query')") - public CommonResult getNotifyTaskDetail(@RequestParam("id") Long id) { - PayNotifyTaskDO task = notifyService.getNotifyTask(id); - if (task == null) { - return success(null); - } - // 拼接返回 - PayAppDO app = appService.getApp(task.getAppId()); - List logs = notifyService.getNotifyLogList(id); - return success(PayNotifyTaskConvert.INSTANCE.convert(task, app, logs)); - } - - @GetMapping("/page") - @Operation(summary = "获得回调通知分页") - @PreAuthorize("@ss.hasPermission('pay:notify:query')") - public CommonResult> getNotifyTaskPage(@Valid PayNotifyTaskPageReqVO pageVO) { - PageResult pageResult = notifyService.getNotifyTaskPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - // 拼接返回 - Map appMap = appService.getAppMap(convertList(pageResult.getList(), PayNotifyTaskDO::getAppId)); - return success(PayNotifyTaskConvert.INSTANCE.convertPage(pageResult, appMap)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskBaseVO.java deleted file mode 100644 index 1e623751ba..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskBaseVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.notify.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 回调通知 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class PayNotifyTaskBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10636") - private Long appId; - - @Schema(description = "通知类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Byte type; - - @Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6722") - private Long dataId; - - @Schema(description = "通知状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Byte status; - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26697") - private String merchantOrderId; - - @Schema(description = "下一次通知时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime nextNotifyTime; - - @Schema(description = "最后一次执行时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime lastExecuteTime; - - @Schema(description = "当前通知次数", requiredMode = Schema.RequiredMode.REQUIRED) - private Byte notifyTimes; - - @Schema(description = "最大可通知次数", requiredMode = Schema.RequiredMode.REQUIRED) - private Byte maxNotifyTimes; - - @Schema(description = "异步通知地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") - private String notifyUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskDetailRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskDetailRespVO.java deleted file mode 100644 index 7c75613e21..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskDetailRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ - -package cn.iocoder.yudao.module.pay.controller.admin.notify.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 回调通知的明细 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayNotifyTaskDetailRespVO extends PayNotifyTaskBaseVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3380") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime updateTime; - - @Schema(description = "应用名称", example = "wx_pay") - private String appName; - - @Schema(description = "回调日志列表") - private List logs; - - @Schema(description = "管理后台 - 回调日志") - @Data - public static class Log { - - @Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8848") - private Long id; - - @Schema(description = "通知状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Byte status; - - @Schema(description = "当前通知次数", requiredMode = Schema.RequiredMode.REQUIRED) - private Byte notifyTimes; - - @Schema(description = "HTTP 响应结果", requiredMode = Schema.RequiredMode.REQUIRED) - private String response; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskPageReqVO.java deleted file mode 100644 index 003d2fb336..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskPageReqVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.notify.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 回调通知分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayNotifyTaskPageReqVO extends PageParam { - - @Schema(description = "应用编号", example = "10636") - private Long appId; - - @Schema(description = "通知类型", example = "2") - private Integer type; - - @Schema(description = "数据编号", example = "6722") - private Long dataId; - - @Schema(description = "通知状态", example = "1") - private Integer status; - - @Schema(description = "商户订单编号", example = "26697") - private String merchantOrderId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskRespVO.java deleted file mode 100644 index d7f7fe6fb1..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.notify.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 回调通知 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayNotifyTaskRespVO extends PayNotifyTaskBaseVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3380") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "应用名称", example = "wx_pay") - private String appName; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java deleted file mode 100755 index 4c9dd84a83..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order; - -import cn.hutool.core.collection.CollectionUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.*; -import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import com.google.common.collect.Maps; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType; - -@Tag(name = "管理后台 - 支付订单") -@RestController -@RequestMapping("/pay/order") -@Validated -public class PayOrderController { - - @Resource - private PayOrderService orderService; - @Resource - private PayAppService appService; - - @GetMapping("/get") - @Operation(summary = "获得支付订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:order:query')") - public CommonResult getOrder(@RequestParam("id") Long id) { - return success(PayOrderConvert.INSTANCE.convert(orderService.getOrder(id))); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得支付订单详情") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:order:query')") - public CommonResult getOrderDetail(@RequestParam("id") Long id) { - PayOrderDO order = orderService.getOrder(id); - if (order == null) { - return success(null); - } - - // 拼接返回 - PayAppDO app = appService.getApp(order.getAppId()); - PayOrderExtensionDO orderExtension = orderService.getOrderExtension(order.getExtensionId()); - return success(PayOrderConvert.INSTANCE.convert(order, orderExtension, app)); - } - - @PostMapping("/submit") - @Operation(summary = "提交支付订单") - public CommonResult submitPayOrder(@RequestBody PayOrderSubmitReqVO reqVO) { - // 1. 钱包支付事,需要额外传 user_id 和 user_type - if (Objects.equals(reqVO.getChannelCode(), PayChannelEnum.WALLET.getCode())) { - Map channelExtras = reqVO.getChannelExtras() == null ? - Maps.newHashMapWithExpectedSize(2) : reqVO.getChannelExtras(); - channelExtras.put(WalletPayClient.USER_ID_KEY, String.valueOf(getLoginUserId())); - channelExtras.put(WalletPayClient.USER_TYPE_KEY, String.valueOf(getLoginUserType())); - reqVO.setChannelExtras(channelExtras); - } - - // 2. 提交支付 - PayOrderSubmitRespVO respVO = orderService.submitOrder(reqVO, getClientIP()); - return success(respVO); - } - - @GetMapping("/page") - @Operation(summary = "获得支付订单分页") - @PreAuthorize("@ss.hasPermission('pay:order:query')") - public CommonResult> getOrderPage(@Valid PayOrderPageReqVO pageVO) { - PageResult pageResult = orderService.getOrderPage(pageVO); - if (CollectionUtil.isEmpty(pageResult.getList())) { - return success(new PageResult<>(pageResult.getTotal())); - } - - // 拼接返回 - Map appMap = appService.getAppMap(convertList(pageResult.getList(), PayOrderDO::getAppId)); - return success(PayOrderConvert.INSTANCE.convertPage(pageResult, appMap)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出支付订单 Excel") - @PreAuthorize("@ss.hasPermission('pay:order:export')") - @OperateLog(type = EXPORT) - public void exportOrderExcel(@Valid PayOrderExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = orderService.getOrderList(exportReqVO); - if (CollectionUtil.isEmpty(list)) { - ExcelUtils.write(response, "支付订单.xls", "数据", - PayOrderExcelVO.class, new ArrayList<>()); - return; - } - - // 拼接返回 - Map appMap = appService.getAppMap(convertList(list, PayOrderDO::getAppId)); - List excelList = PayOrderConvert.INSTANCE.convertList(list, appMap); - // 导出 Excel - ExcelUtils.write(response, "支付订单.xls", "数据", PayOrderExcelVO.class, excelList); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java deleted file mode 100755 index 8cb5b80fec..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import jakarta.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 支付订单 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author aquan - */ -@Data -public class PayOrderBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long appId; - - @Schema(description = "渠道编号", example = "2048") - private Long channelId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - @NotNull(message = "商户订单编号不能为空") - private String merchantOrderId; - - @Schema(description = "商品标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆") - @NotNull(message = "商品标题不能为空") - private String subject; - - @Schema(description = "商品描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是土豆") - @NotNull(message = "商品描述不能为空") - private String body; - - @Schema(description = "异步通知地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "http://127.0.0.1:48080/pay/notify") - @NotNull(message = "异步通知地址不能为空") - private String notifyUrl; - - @Schema(description = "支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "支付金额,单位:分不能为空") - private Long price; - - @Schema(description = "渠道手续费,单位:百分比", example = "10") - private Double channelFeeRate; - - @Schema(description = "渠道手续金额,单位:分", example = "100") - private Integer channelFeePrice; - - @Schema(description = "支付状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "支付状态不能为空") - private Integer status; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - @NotNull(message = "用户 IP不能为空") - private String userIp; - - @Schema(description = "订单失效时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "订单失效时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime expireTime; - - @Schema(description = "订单支付成功时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime successTime; - - @Schema(description = "支付成功的订单拓展单编号", example = "50") - private Long extensionId; - - @Schema(description = "支付订单号", example = "2048888") - private String no; - - @Schema(description = "退款总金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "退款总金额,单位:分不能为空") - private Long refundPrice; - - @Schema(description = "渠道用户编号", example = "2048") - private String channelUserId; - - @Schema(description = "渠道订单号", example = "4096") - private String channelOrderNo; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java deleted file mode 100644 index a4fe4632f2..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付订单详细信息 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayOrderDetailsRespVO extends PayOrderBaseVO { - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String appName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime updateTime; - - /** - * 支付订单扩展 - */ - private PayOrderExtension extension; - - @Data - @Schema(description = "支付订单扩展") - public static class PayOrderExtension { - - @Schema(description = "支付订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String no; - - @Schema(description = "支付异步通知的内容") - private String channelNotifyData; - - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java deleted file mode 100755 index 5dc17a0f0c..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert; -import cn.iocoder.yudao.module.pay.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 支付订单 Excel VO - * - * @author aquan - */ -@Data -public class PayOrderExcelVO { - - @ExcelProperty("编号") - private Long id; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @ExcelProperty(value = "支付金额", converter = MoneyConvert.class) - private Integer price; - - @ExcelProperty(value = "退款金额", converter = MoneyConvert.class) - private Integer refundPrice; - - @ExcelProperty(value = "手续金额", converter = MoneyConvert.class) - private Integer channelFeePrice; - - @ExcelProperty("商户单号") - private String merchantOrderId; - - @ExcelProperty(value = "支付单号") - private String no; - - @ExcelProperty("渠道单号") - private String channelOrderNo; - - @ExcelProperty(value = "支付状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.ORDER_STATUS) - private Integer status; - - @ExcelProperty(value = "渠道编号名称", converter = DictConvert.class) - @DictFormat(DictTypeConstants.CHANNEL_CODE) - private String channelCode; - - @ExcelProperty("订单支付成功时间") - private LocalDateTime successTime; - - @ExcelProperty("订单失效时间") - private LocalDateTime expireTime; - - @ExcelProperty(value = "应用名称") - private String appName; - - @ExcelProperty("商品标题") - private String subject; - - @ExcelProperty("商品描述") - private String body; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java deleted file mode 100755 index 9e4d20b918..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付订单 Excel 导出 Request VO,参数和 PayOrderPageReqVO 是一致的") -@Data -public class PayOrderExportReqVO { - - @Schema(description = "应用编号", example = "1024") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户订单编号", example = "4096") - private String merchantOrderId; - - @Schema(description = "渠道编号", example = "1888") - private String channelOrderNo; - - @Schema(description = "支付单号", example = "2014888") - private String no; - - @Schema(description = "支付状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java deleted file mode 100755 index 05411c9136..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayOrderPageItemRespVO extends PayOrderBaseVO { - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "应用名称", example = "wx_pay") - private String appName; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java deleted file mode 100755 index f7ff801cb3..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayOrderPageReqVO extends PageParam { - - @Schema(description = "应用编号", example = "1024") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户订单编号", example = "4096") - private String merchantOrderId; - - @Schema(description = "渠道编号", example = "1888") - private String channelOrderNo; - - @Schema(description = "支付单号", example = "2014888") - private String no; - - @Schema(description = "支付状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderRespVO.java deleted file mode 100644 index d48a4db088..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付订单 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayOrderRespVO extends PayOrderBaseVO { - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitReqVO.java deleted file mode 100644 index 3fc7fc90fd..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.URL; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.Map; - -@Schema(description = "管理后台 - 支付订单提交 Request VO") -@Data -public class PayOrderSubmitReqVO { - - @Schema(description = "支付单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "支付单编号不能为空") - private Long id; - - @Schema(description = "支付渠道", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_pub") - @NotEmpty(message = "支付渠道不能为空") - private String channelCode; - - @Schema(description = "支付渠道的额外参数,例如说,微信公众号需要传递 openid 参数") - private Map channelExtras; - - @Schema(description = "展示模式", example = "url") // 参见 {@link PayDisplayModeEnum} 枚举。如果不传递,则每个支付渠道使用默认的方式 - private String displayMode; - - @Schema(description = "回跳地址") - @URL(message = "回跳地址的格式必须是 URL") - private String returnUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitRespVO.java deleted file mode 100644 index 8dcd9df2f7..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 支付订单提交 Response VO") -@Data -public class PayOrderSubmitRespVO { - - @Schema(description = "支付状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") // 参见 PayOrderStatusEnum 枚举 - private Integer status; - - @Schema(description = "展示模式", requiredMode = Schema.RequiredMode.REQUIRED, example = "url") // 参见 PayDisplayModeEnum 枚举 - private String displayMode; - @Schema(description = "展示内容", requiredMode = Schema.RequiredMode.REQUIRED) - private String displayContent; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java deleted file mode 100755 index 2723d8a642..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund; - -import cn.hutool.core.collection.CollectionUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.*; -import cn.iocoder.yudao.module.pay.convert.refund.PayRefundConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; - -@Tag(name = "管理后台 - 退款订单") -@RestController -@RequestMapping("/pay/refund") -@Validated -public class PayRefundController { - - @Resource - private PayRefundService refundService; - @Resource - private PayAppService appService; - - @GetMapping("/get") - @Operation(summary = "获得退款订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:refund:query')") - public CommonResult getRefund(@RequestParam("id") Long id) { - PayRefundDO refund = refundService.getRefund(id); - if (refund == null) { - return success(new PayRefundDetailsRespVO()); - } - - // 拼接数据 - PayAppDO app = appService.getApp(refund.getAppId()); - return success(PayRefundConvert.INSTANCE.convert(refund, app)); - } - - @GetMapping("/page") - @Operation(summary = "获得退款订单分页") - @PreAuthorize("@ss.hasPermission('pay:refund:query')") - public CommonResult> getRefundPage(@Valid PayRefundPageReqVO pageVO) { - PageResult pageResult = refundService.getRefundPage(pageVO); - if (CollectionUtil.isEmpty(pageResult.getList())) { - return success(new PageResult<>(pageResult.getTotal())); - } - - // 处理应用ID数据 - Map appMap = appService.getAppMap(convertList(pageResult.getList(), PayRefundDO::getAppId)); - return success(PayRefundConvert.INSTANCE.convertPage(pageResult, appMap)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出退款订单 Excel") - @PreAuthorize("@ss.hasPermission('pay:refund:export')") - @OperateLog(type = EXPORT) - public void exportRefundExcel(@Valid PayRefundExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = refundService.getRefundList(exportReqVO); - if (CollectionUtil.isEmpty(list)) { - ExcelUtils.write(response, "退款订单.xls", "数据", - PayRefundExcelVO.class, new ArrayList<>()); - return; - } - - // 拼接返回 - Map appMap = appService.getAppMap(convertList(list, PayRefundDO::getAppId)); - List excelList = PayRefundConvert.INSTANCE.convertList(list, appMap); - // 导出 Excel - ExcelUtils.write(response, "退款订单.xls", "数据", PayRefundExcelVO.class, excelList); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java deleted file mode 100755 index 25cadf478f..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** -* 退款订单 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayRefundBaseVO { - - @Schema(description = "外部退款号", requiredMode = Schema.RequiredMode.REQUIRED, example = "110") - private String no; - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long appId; - - @Schema(description = "渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long channelId; - - @Schema(description = "渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_app") - private String channelCode; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderId; - - // ========== 商户相关字段 ========== - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "225") - private String merchantOrderId; - - @Schema(description = "商户退款订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") - private String merchantRefundId; - - @Schema(description = "异步通知地址", requiredMode = Schema.RequiredMode.REQUIRED) - private String notifyUrl; - - // ========== 退款相关字段 ========== - - @Schema(description = "退款状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long payPrice; - - @Schema(description = "退款金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Long refundPrice; - - @Schema(description = "退款原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "我要退了") - private String reason; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - private String userIp; - - // ========== 渠道相关字段 ========== - - @Schema(description = "渠道订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "233") - private String channelOrderNo; - - @Schema(description = "渠道退款单号", example = "2022") - private String channelRefundNo; - - @Schema(description = "退款成功时间") - private LocalDateTime successTime; - - @Schema(description = "调用渠道的错误码") - private String channelErrorCode; - - @Schema(description = "调用渠道的错误提示") - private String channelErrorMsg; - - @Schema(description = "支付渠道的额外参数") - private String channelNotifyData; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java deleted file mode 100755 index 8f50a3a13c..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 退款订单详情 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayRefundDetailsRespVO extends PayRefundBaseVO { - - @Schema(description = "支付退款编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是芋艿") - private String appName; - - @Schema(description = "支付订单", requiredMode = Schema.RequiredMode.REQUIRED) - private Order order; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间") - private LocalDateTime updateTime; - - @Schema(description = "管理后台 - 支付订单") - @Data - public static class Order { - - @Schema(description = "商品标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆") - private String subject; - - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java deleted file mode 100755 index 758b6b6b09..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert; -import cn.iocoder.yudao.module.pay.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 退款订单 Excel VO - * - * @author aquan - */ -@Data -public class PayRefundExcelVO { - - @ExcelProperty("支付退款编号") - private Long id; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @ExcelProperty(value = "支付金额", converter = MoneyConvert.class) - private Integer payPrice; - - @ExcelProperty(value = "退款金额", converter = MoneyConvert.class) - private Integer refundPrice; - - @ExcelProperty("商户退款单号") - private String merchantRefundId; - @ExcelProperty("退款单号") - private String no; - @ExcelProperty("渠道退款单号") - private String channelRefundNo; - - @ExcelProperty("商户支付单号") - private String merchantOrderId; - @ExcelProperty("渠道支付单号") - private String channelOrderNo; - - @ExcelProperty(value = "退款状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.REFUND_STATUS) - private Integer status; - - @ExcelProperty(value = "退款渠道", converter = DictConvert.class) - @DictFormat(DictTypeConstants.CHANNEL_CODE) - private String channelCode; - - @ExcelProperty("成功时间") - private LocalDateTime successTime; - - @ExcelProperty(value = "支付应用") - private String appName; - - @ExcelProperty("退款原因") - private String reason; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java deleted file mode 100755 index 645816ee23..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 退款订单 Excel 导出 Request VO,参数和 PayRefundPageReqVO 是一致的") -@Data -public class PayRefundExportReqVO { - - @Schema(description = "应用编号", example = "1024") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户支付单号", example = "10") - private String merchantOrderId; - - @Schema(description = "商户退款单号", example = "20") - private String merchantRefundId; - - @Schema(description = "渠道支付单号", example = "30") - private String channelOrderNo; - - @Schema(description = "渠道退款单号", example = "40") - private String channelRefundNo; - - @Schema(description = "退款状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java deleted file mode 100755 index 27c1285ccc..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 退款订单分页查询 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayRefundPageItemRespVO extends PayRefundBaseVO { - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是芋艿") - private String appName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java deleted file mode 100755 index 7ff1530f05..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 退款订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayRefundPageReqVO extends PageParam { - - @Schema(description = "应用编号", example = "1024") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户支付单号", example = "10") - private String merchantOrderId; - - @Schema(description = "商户退款单号", example = "20") - private String merchantRefundId; - - @Schema(description = "渠道支付单号", example = "30") - private String channelOrderNo; - - @Schema(description = "渠道退款单号", example = "40") - private String channelRefundNo; - - @Schema(description = "退款状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java deleted file mode 100644 index 72593c9630..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.transfer; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.*; -import cn.iocoder.yudao.module.pay.convert.transfer.PayTransferConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; -import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; - -@Tag(name = "管理后台 - 转账单") -@RestController -@RequestMapping("/pay/transfer") -@Validated -public class PayTransferController { - - @Resource - private PayTransferService payTransferService; - - @PostMapping("/create") - @Operation(summary = "创建转账单,发起转账") - @PreAuthorize("@ss.hasPermission('pay:transfer:create')") - public CommonResult createPayTransfer(@Valid @RequestBody PayTransferCreateReqVO reqVO) { - PayTransferDO payTransfer = payTransferService.createTransfer(reqVO, getClientIP()); - return success(new PayTransferCreateRespVO().setId(payTransfer.getId()).setStatus(payTransfer.getStatus())); - } - - @GetMapping("/get") - @Operation(summary = "获得转账订单") - @PreAuthorize("@ss.hasPermission('pay:transfer:query')") - public CommonResult getTransfer(@RequestParam("id") Long id) { - return success(PayTransferConvert.INSTANCE.convert(payTransferService.getTransfer(id))); - } - - @GetMapping("/page") - @Operation(summary = "获得转账订单分页") - @PreAuthorize("@ss.hasPermission('pay:transfer:query')") - public CommonResult> getTransferPage(@Valid PayTransferPageReqVO pageVO) { - PageResult pageResult = payTransferService.getTransferPage(pageVO); - return success(PayTransferConvert.INSTANCE.convertPage(pageResult)); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferCreateReqVO.java deleted file mode 100644 index bda44cff65..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferCreateReqVO.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.transfer.vo; - -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.Validator; -import jakarta.validation.constraints.*; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.NOT_IMPLEMENTED; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.transfer.PayTransferTypeEnum.*; - -@Schema(description = "管理后台 - 发起转账 Request VO") -@Data -public class PayTransferCreateReqVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "应用编号不能为空") - private Long appId; - - @Schema(description = "商户转账单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商户转账单编号不能为空") - private String merchantTransferId; - - @Schema(description = "转账类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "转账类型不能为空") - @InEnum(PayTransferTypeEnum.class) - private Integer type; - - @Schema(description = "转账渠道", requiredMode = Schema.RequiredMode.REQUIRED, example = "alipay_pc") - @NotEmpty(message = "转账渠道不能为空") - private String channelCode; - - @Min(value = 1, message = "转账金额必须大于零") - @NotNull(message = "转账金额不能为空") - private Integer price; - - @Schema(description = "转账标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "示例转账") - @NotEmpty(message = "转账标题不能为空") - private String subject; - - @Schema(description = "收款人姓名", example = "test1") - @NotBlank(message = "收款人姓名不能为空", groups = {Alipay.class}) - private String userName; - - @Schema(description = "支付宝登录号", example = "test1@sandbox.com") - @NotBlank(message = "支付宝登录号不能为空", groups = {Alipay.class}) - private String alipayLogonId; - - @Schema(description = "微信 openId", example = "oLefc4g5Gxx") - @NotBlank(message = "微信 openId 不能为空", groups = {WxPay.class}) - private String openid; - - @Schema(description = "转账渠道的额外参数") - private Map channelExtras; - - public void validate(Validator validator) { - PayTransferTypeEnum transferType = typeOf(type); - switch (transferType) { - case ALIPAY_BALANCE: { - ValidationUtils.validate(validator, this, Alipay.class); - break; - } - case WX_BALANCE: { - ValidationUtils.validate(validator, this, WxPay.class); - break; - } - default: { - throw new UnsupportedOperationException("待实现"); - } - } - } - - @AssertTrue(message = "转账类型和转账渠道不匹配") - public boolean isValidChannelCode() { - PayTransferTypeEnum transferType = typeOf(type); - switch (transferType) { - case ALIPAY_BALANCE: { - return PayChannelEnum.isAlipay(channelCode); - } - case WX_BALANCE: - case BANK_CARD: - case WALLET_BALANCE: { - throw exception(NOT_IMPLEMENTED); - } - } - return Boolean.FALSE; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferCreateRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferCreateRespVO.java deleted file mode 100644 index 9cb44bf60a..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferCreateRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.transfer.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 发起转账 Response VO") -@Data -public class PayTransferCreateRespVO { - - @Schema(description = "转账单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "转账状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 参见 PayTransferStatusEnum 枚举 - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferPageItemRespVO.java deleted file mode 100644 index 9440142097..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferPageItemRespVO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.transfer.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * @author jason - */ -@Schema(description = "管理后台 - 转账单分页项 Response VO") -@Data -public class PayTransferPageItemRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2931") - private Long id; - - @Schema(description = "转账单号", requiredMode = Schema.RequiredMode.REQUIRED) - private String no; - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12831") - private Long appId; - - @Schema(description = "转账渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24833") - private Long channelId; - - @Schema(description = "转账渠道编码", requiredMode = Schema.RequiredMode.REQUIRED) - private String channelCode; - - @Schema(description = "商户转账单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17481") - private String merchantTransferId; - - @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer type; - - @Schema(description = "转账状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer status; - - @Schema(description = "转账成功时间") - private LocalDateTime successTime; - - @Schema(description = "转账金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "964") - private Integer price; - - @Schema(description = "转账标题", requiredMode = Schema.RequiredMode.REQUIRED) - private String subject; - - @Schema(description = "收款人姓名", example = "王五") - private String userName; - - @Schema(description = "支付宝登录号", example = "29245") - private String alipayLogonId; - - @Schema(description = "微信 openId", example = "26589") - private String openid; - - @Schema(description = "渠道转账单号") - private String channelTransferNo; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferPageReqVO.java deleted file mode 100644 index 88cda1b599..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.transfer.vo; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 转账单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayTransferPageReqVO extends PageParam { - - @Schema(description = "转账单号") - private String no; - - @Schema(description = "应用编号", example = "12831") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户转账单编号", example = "17481") - private String merchantTransferId; - - @Schema(description = "类型", example = "2") - private Integer type; - - @Schema(description = "转账状态", example = "2") - private Integer status; - - @Schema(description = "收款人姓名", example = "王五") - private String userName; - - @Schema(description = "渠道转账单号") - private String channelTransferNo; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferRespVO.java deleted file mode 100644 index 6b65dfd6bd..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferRespVO.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.transfer.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; -import java.util.Map; - -@Schema(description = "管理后台 - 转账单 Response VO") -@Data -public class PayTransferRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2931") - private Long id; - - @Schema(description = "转账单号", requiredMode = Schema.RequiredMode.REQUIRED) - private String no; - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12831") - private Long appId; - - @Schema(description = "转账渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24833") - private Long channelId; - - @Schema(description = "转账渠道编码", requiredMode = Schema.RequiredMode.REQUIRED) - private String channelCode; - - @Schema(description = "商户转账单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17481") - private String merchantTransferId; - - @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer type; - - @Schema(description = "转账状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer status; - - @Schema(description = "转账成功时间") - private LocalDateTime successTime; - - @Schema(description = "转账金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "964") - private Integer price; - - @Schema(description = "转账标题", requiredMode = Schema.RequiredMode.REQUIRED) - private String subject; - - @Schema(description = "收款人姓名", example = "王五") - private String userName; - - @Schema(description = "支付宝登录号", example = "29245") - private String alipayLogonId; - - @Schema(description = "微信 openId", example = "26589") - private String openid; - - @Schema(description = "异步通知商户地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") - private String notifyUrl; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED) - private String userIp; - - @Schema(description = "渠道的额外参数") - private Map channelExtras; - - @Schema(description = "渠道转账单号") - private String channelTransferNo; - - @Schema(description = "调用渠道的错误码") - private String channelErrorCode; - - @Schema(description = "调用渠道的错误提示") - private String channelErrorMsg; - - @Schema(description = "渠道的同步/异步通知的内容") - private String channelNotifyData; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java deleted file mode 100644 index b4b8575538..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet; - -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUserReqVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.enums.UserTypeEnum.MEMBER; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; - -@Tag(name = "管理后台 - 用户钱包") -@RestController -@RequestMapping("/pay/wallet") -@Validated -@Slf4j -public class PayWalletController { - - @Resource - private PayWalletService payWalletService; - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/get") - @PreAuthorize("@ss.hasPermission('pay:wallet:query')") - @Operation(summary = "获得用户钱包明细") - public CommonResult getWallet(PayWalletUserReqVO reqVO) { - PayWalletDO wallet = payWalletService.getOrCreateWallet(reqVO.getUserId(), MEMBER.getValue()); - // TODO jason:如果为空,返回给前端只要 null 就可以了 - MemberUserRespDTO memberUser = memberUserApi.getUser(reqVO.getUserId()); - String nickname = memberUser == null ? "" : memberUser.getNickname(); - String avatar = memberUser == null ? "" : memberUser.getAvatar(); - return success(PayWalletConvert.INSTANCE.convert02(nickname, avatar, wallet)); - } - - @GetMapping("/page") - @Operation(summary = "获得会员钱包分页") - @PreAuthorize("@ss.hasPermission('pay:wallet:query')") - public CommonResult> getWalletPage(@Valid PayWalletPageReqVO pageVO) { - if (StrUtil.isNotEmpty(pageVO.getNickname())) { - List users = memberUserApi.getUserListByNickname(pageVO.getNickname()); - pageVO.setUserIds(convertSet(users, MemberUserRespDTO::getId)); - } - // TODO @jason:管理员也可以先查询下。。 - // 暂时支持查询 userType 会员类型。管理员类型还不知道使用场景 - PageResult pageResult = payWalletService.getWalletPage(MEMBER.getValue(),pageVO); - if (CollectionUtil.isEmpty(pageResult.getList())) { - return success(new PageResult<>(pageResult.getTotal())); - } - List users = memberUserApi.getUserList(convertList(pageResult.getList(), PayWalletDO::getUserId)); - Map userMap = convertMap(users, MemberUserRespDTO::getId); - return success(PayWalletConvert.INSTANCE.convertPage(pageResult, userMap)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargeController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargeController.java deleted file mode 100644 index 63133d2c83..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargeController.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.annotation.security.PermitAll; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; - -@Tag(name = "管理后台 - 钱包充值") -@RestController -@RequestMapping("/pay/wallet-recharge") -@Validated -@Slf4j -public class PayWalletRechargeController { - - @Resource - private PayWalletRechargeService walletRechargeService; - - @PostMapping("/update-paid") - @Operation(summary = "更新钱包充值为已充值") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录, 内部校验实现 - @OperateLog(enable = false) // 禁用操作日志,因为没有操作人 - public CommonResult updateWalletRechargerPaid(@Valid @RequestBody PayOrderNotifyReqDTO notifyReqDTO) { - walletRechargeService.updateWalletRechargerPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayOrderId()); - return success(true); - } - - // TODO @jason:发起退款,要 post 操作哈; - @GetMapping("/refund") - @Operation(summary = "发起钱包充值退款") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult refundWalletRecharge(@RequestParam("id") Long id) { - walletRechargeService.refundWalletRecharge(id, getClientIP()); - return success(true); - } - - @PostMapping("/update-refunded") - @Operation(summary = "更新钱包充值为已退款") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录, 内部校验实现 - @OperateLog(enable = false) // 禁用操作日志,因为没有操作人 - public CommonResult updateWalletRechargeRefunded(@RequestBody PayRefundNotifyReqDTO notifyReqDTO) { - walletRechargeService.updateWalletRechargeRefunded( - Long.valueOf(notifyReqDTO.getMerchantOrderId()), notifyReqDTO.getPayRefundId()); - return success(true); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargePackageController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargePackageController.java deleted file mode 100644 index d7aa25e2f8..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargePackageController.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.wallet.WalletRechargePackageConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargePackageService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - - -@Tag(name = "管理后台 - 钱包充值套餐") -@RestController -@RequestMapping("/pay/wallet-recharge-package") -@Validated -public class PayWalletRechargePackageController { - - @Resource - private PayWalletRechargePackageService walletRechargePackageService; - - @PostMapping("/create") - @Operation(summary = "创建钱包充值套餐") - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:create')") - public CommonResult createWalletRechargePackage(@Valid @RequestBody WalletRechargePackageCreateReqVO createReqVO) { - return success(walletRechargePackageService.createWalletRechargePackage(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新钱包充值套餐") - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:update')") - public CommonResult updateWalletRechargePackage(@Valid @RequestBody WalletRechargePackageUpdateReqVO updateReqVO) { - walletRechargePackageService.updateWalletRechargePackage(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除钱包充值套餐") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:delete')") - public CommonResult deleteWalletRechargePackage(@RequestParam("id") Long id) { - walletRechargePackageService.deleteWalletRechargePackage(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得钱包充值套餐") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:query')") - public CommonResult getWalletRechargePackage(@RequestParam("id") Long id) { - PayWalletRechargePackageDO walletRechargePackage = walletRechargePackageService.getWalletRechargePackage(id); - return success(WalletRechargePackageConvert.INSTANCE.convert(walletRechargePackage)); - } - - @GetMapping("/page") - @Operation(summary = "获得钱包充值套餐分页") - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:query')") - public CommonResult> getWalletRechargePackagePage(@Valid WalletRechargePackagePageReqVO pageVO) { - PageResult pageResult = walletRechargePackageService.getWalletRechargePackagePage(pageVO); - return success(WalletRechargePackageConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java deleted file mode 100644 index 4b9aee6da2..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionRespVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 钱包余额明细") -@RestController -@RequestMapping("/pay/wallet-transaction") -@Validated -@Slf4j -public class PayWalletTransactionController { - - @Resource - private PayWalletTransactionService payWalletTransactionService; - - @GetMapping("/page") - @Operation(summary = "获得钱包流水分页") - @PreAuthorize("@ss.hasPermission('pay:wallet:query')") - public CommonResult> getWalletTransactionPage( - @Valid PayWalletTransactionPageReqVO pageReqVO) { - PageResult result = payWalletTransactionService.getWalletTransactionPage(pageReqVO); - return success(PayWalletTransactionConvert.INSTANCE.convertPage2(result)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageBaseVO.java deleted file mode 100644 index ea6f0c4652..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageBaseVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 充值套餐 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class WalletRechargePackageBaseVO { - - @Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "套餐名不能为空") - private String name; - - @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "16454") - @NotNull(message = "支付金额不能为空") - private Integer payPrice; - - @Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20887") - @NotNull(message = "赠送金额不能为空") - private Integer bonusPrice; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "状态不能为空") - private Byte status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageCreateReqVO.java deleted file mode 100644 index 4232a9983d..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 充值套餐创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WalletRechargePackageCreateReqVO extends WalletRechargePackageBaseVO { - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java deleted file mode 100644 index 346e85902a..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 充值套餐分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WalletRechargePackagePageReqVO extends PageParam { - - @Schema(description = "套餐名", example = "李四") - private String name; - - @Schema(description = "状态", example = "2") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageRespVO.java deleted file mode 100644 index 84abaf78a3..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 充值套餐 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WalletRechargePackageRespVO extends WalletRechargePackageBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9032") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageUpdateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageUpdateReqVO.java deleted file mode 100644 index 77b230fb7e..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 充值套餐更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WalletRechargePackageUpdateReqVO extends WalletRechargePackageBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9032") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionPageReqVO.java deleted file mode 100644 index 678649ce04..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionPageReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 钱包流水分页 Request VO") -@Data -public class PayWalletTransactionPageReqVO extends PageParam { - - @Schema(description = "钱包编号", example = "1") - private Long walletId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionRespVO.java deleted file mode 100644 index 6203b78d51..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionRespVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 APP - 钱包流水分页 Response VO") -@Data -public class PayWalletTransactionRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "钱包编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Long walletId; - - @Schema(description = "业务分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer bizType; - - @Schema(description = "交易金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long price; - - @Schema(description = "流水标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆土豆") - private String title; - - @Schema(description = "交易后的余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long balance; - - @Schema(description = "交易时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // TODO @jason:merchantOrderId 字段,需要在 PayWalletTransaction 存储下;然后,前端也返回下这个字段,界面也展示下商户名 - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletBaseVO.java deleted file mode 100644 index 2e319dee0f..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletBaseVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -/** - * 用户钱包 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class PayWalletBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20020") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "用户类型不能为空") - private Integer userType; - - @Schema(description = "余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "余额,单位分不能为空") - private Integer balance; - - @Schema(description = "累计支出,单位分", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "累计支出,单位分不能为空") - private Integer totalExpense; - - @Schema(description = "累计充值,单位分", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "累计充值,单位分不能为空") - private Integer totalRecharge; - - @Schema(description = "冻结金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "20737") - @NotNull(message = "冻结金额,单位分不能为空") - private Integer freezePrice; - -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java deleted file mode 100644 index d74bd44b19..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.Collection; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员钱包分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayWalletPageReqVO extends PageParam { - - @Schema(description = "用户昵称", example = "李四") - private String nickname; - - @Schema(description = "用户编号", example = "[1,2]") - private Collection userIds; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java deleted file mode 100644 index a9eedbdfd0..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户钱包 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayWalletRespVO extends PayWalletBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29528") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王**") - private String nickname; - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java deleted file mode 100644 index e6d4986e96..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 用户钱包明细 Request VO") -@Data -public class PayWalletUserReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "用户编号不能为空") - private Long userId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/channel/AppPayChannelController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/channel/AppPayChannelController.java deleted file mode 100644 index 9340515e19..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/channel/AppPayChannelController.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.channel; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "用户 App - 支付渠道") -@RestController -@RequestMapping("/pay/channel") -@Validated -public class AppPayChannelController { - - @Resource - private PayChannelService channelService; - - @GetMapping("/get-enable-code-list") - @Operation(summary = "获得指定应用的开启的支付渠道编码列表") - @Parameter(name = "appId", description = "应用编号", required = true, example = "1") - public CommonResult> getEnableChannelCodeList(@RequestParam("appId") Long appId) { - List channels = channelService.getEnableChannelList(appId); - return success(convertSet(channels, PayChannelDO::getCode)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http deleted file mode 100644 index 14ce54ef92..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http +++ /dev/null @@ -1,63 +0,0 @@ -### /pay/create 提交支付订单【alipay_pc】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 174, - "channelCode": "alipay_pc" -} - -### /pay/create 提交支付订单【wx_bar】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 202, - "channelCode": "wx_bar", - "channelExtras": { - "authCode": "134042110834344848" - } -} - -### /pay/create 提交支付订单【wx_pub】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 202, - "channelCode": "wx_pub", - "channelExtras": { - "openid": "ockUAwIZ-0OeMZl9ogcZ4ILrGba0" - } -} - -### /pay/create 提交支付订单【wx_lite】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 202, - "channelCode": "wx_lite", - "channelExtras": { - "openid": "oLefc4g5GjKWHJjLjMSXB3wX0fD0" - } -} - -### /pay/create 提交支付订单【wx_native】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 202, - "channelCode": "wx_native" -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.java deleted file mode 100644 index da3cf72948..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import com.google.common.collect.Maps; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; - -import java.util.Map; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType; - -@Tag(name = "用户 APP - 支付订单") -@RestController -@RequestMapping("/pay/order") -@Validated -@Slf4j -public class AppPayOrderController { - - @Resource - private PayOrderService payOrderService; - - // TODO 芋艿:临时 demo,技术打样。 - @GetMapping("/get") - @Operation(summary = "获得支付订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getOrder(@RequestParam("id") Long id) { - return success(PayOrderConvert.INSTANCE.convert(payOrderService.getOrder(id))); - } - - @PostMapping("/submit") - @Operation(summary = "提交支付订单") - public CommonResult submitPayOrder(@RequestBody AppPayOrderSubmitReqVO reqVO) { - // 1. 钱包支付事,需要额外传 user_id 和 user_type - if (Objects.equals(reqVO.getChannelCode(), PayChannelEnum.WALLET.getCode())) { - Map channelExtras = reqVO.getChannelExtras() == null ? - Maps.newHashMapWithExpectedSize(2) : reqVO.getChannelExtras(); - channelExtras.put(WalletPayClient.USER_ID_KEY, String.valueOf(getLoginUserId())); - channelExtras.put(WalletPayClient.USER_TYPE_KEY, String.valueOf(getLoginUserType())); - reqVO.setChannelExtras(channelExtras); - } - - // 2. 提交支付 - PayOrderSubmitRespVO respVO = payOrderService.submitOrder(reqVO, getClientIP()); - return success(PayOrderConvert.INSTANCE.convert3(respVO)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitReqVO.java deleted file mode 100644 index 0b92d25d93..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitReqVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.order.vo; - -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import java.util.Map; - -@Schema(description = "用户 APP - 支付订单提交 Request VO") -@Data -public class AppPayOrderSubmitReqVO extends PayOrderSubmitReqVO { -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitRespVO.java deleted file mode 100644 index 106535efd8..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitRespVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.order.vo; - -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Schema(description = "用户 APP - 支付订单提交 Response VO") -@Data -public class AppPayOrderSubmitRespVO extends PayOrderSubmitRespVO { - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/refund/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/refund/package-info.java deleted file mode 100644 index ee2004e1a6..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/refund/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占个位置,没啥用 - */ -package cn.iocoder.yudao.module.pay.controller.app.refund; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletController.java deleted file mode 100644 index 24e4fb4415..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletController.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet.AppPayWalletRespVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -/** - * @author jason - */ -@Tag(name = "用户 APP - 钱包") -@RestController -@RequestMapping("/pay/wallet") -@Validated -@Slf4j -public class AppPayWalletController { - - @Resource - private PayWalletService payWalletService; - - @GetMapping("/get") - @Operation(summary = "获取钱包") - @PreAuthenticated - public CommonResult getPayWallet() { - PayWalletDO wallet = payWalletService.getOrCreateWallet(getLoginUserId(), UserTypeEnum.MEMBER.getValue()); - return success(PayWalletConvert.INSTANCE.convert(wallet)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java deleted file mode 100644 index 21e5ef34c5..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -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.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType; - -@Tag(name = "用户 APP - 钱包充值") -@RestController -@RequestMapping("/pay/wallet-recharge") -@Validated -@Slf4j -public class AppPayWalletRechargeController { - - @Resource - private PayWalletRechargeService walletRechargeService; - - @PostMapping("/create") - @Operation(summary = "创建钱包充值记录(发起充值)") - public CommonResult createWalletRecharge( - @Valid @RequestBody AppPayWalletRechargeCreateReqVO reqVO) { - PayWalletRechargeDO walletRecharge = walletRechargeService.createWalletRecharge( - getLoginUserId(), getLoginUserType(), getClientIP(), reqVO); - return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargePackageController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargePackageController.java deleted file mode 100644 index 9b2aac1884..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargePackageController.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletPackageRespVO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.ArrayList; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 钱包充值套餐") -@RestController -@RequestMapping("/pay/wallet-recharge-package") -@Validated -@Slf4j -public class AppPayWalletRechargePackageController { - - @GetMapping("/list") - @Operation(summary = "获得钱包充值套餐列表") - public CommonResult> getWalletRechargePackageList() { - // 只查询开启;需要按照 payPrice 排序; - List list = new ArrayList<>(); - list.add(new AppPayWalletPackageRespVO().setId(1L).setName("土豆").setPayPrice(10).setBonusPrice(2)); - list.add(new AppPayWalletPackageRespVO().setId(2L).setName("番茄").setPayPrice(20).setBonusPrice(5)); - return success(list); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletTransactionController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletTransactionController.java deleted file mode 100644 index 89b04dbf84..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletTransactionController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 钱包余额明细") -@RestController -@RequestMapping("/pay/wallet-transaction") -@Validated -@Slf4j -public class AppPayWalletTransactionController { - - @Resource - private PayWalletTransactionService payWalletTransactionService; - - @GetMapping("/page") - @Operation(summary = "获得钱包流水分页") - public CommonResult> getWalletTransactionPage( - @Valid AppPayWalletTransactionPageReqVO pageReqVO) { - if (true) { - PageResult result = new PageResult<>(10L); - result.getList().add(new AppPayWalletTransactionRespVO().setPrice(1L) - .setTitle("测试").setCreateTime(LocalDateTime.now())); - result.getList().add(new AppPayWalletTransactionRespVO().setPrice(-1L) - .setTitle("测试2").setCreateTime(LocalDateTime.now())); - return success(result); - } - PageResult result = payWalletTransactionService.getWalletTransactionPage(getLoginUserId(), - UserTypeEnum.MEMBER.getValue(), pageReqVO); - return success(PayWalletTransactionConvert.INSTANCE.convertPage(result)); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletPackageRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletPackageRespVO.java deleted file mode 100644 index c12db98894..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletPackageRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 用户充值套餐 Response VO") -@Data -public class AppPayWalletPackageRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - @Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "小套餐") - private String name; - - @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer payPrice; - @Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer bonusPrice; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java deleted file mode 100644 index 986a5c247c..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.AssertTrue; -import jakarta.validation.constraints.Min; -import java.util.Objects; - -@Schema(description = "用户 APP - 创建钱包充值 Request VO") -@Data -public class AppPayWalletRechargeCreateReqVO { - - @Schema(description = "支付金额", example = "1000") - @Min(value = 1, message = "支付金额必须大于零") - private Integer payPrice; - - @Schema(description = "充值套餐编号", example = "1024") - private Long packageId; - - @AssertTrue(message = "充值金额和充钱套餐不能同时为空") - public boolean isValidPayPriceAndPackageId() { - return Objects.nonNull(payPrice) || Objects.nonNull(packageId); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateRespVO.java deleted file mode 100644 index 2c4a96f625..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 创建钱包充值 Resp VO") -@Data -public class AppPayWalletRechargeCreateRespVO { - - @Schema(description = "钱包充值编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long payOrderId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionPageReqVO.java deleted file mode 100644 index 942ab5b6df..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionPageReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 钱包流水分页 Request VO") -@Data -public class AppPayWalletTransactionPageReqVO extends PageParam { - - /** - * 类型 - 收入 - */ - public static final Integer TYPE_INCOME = 1; - /** - * 类型 - 支出 - */ - public static final Integer TYPE_EXPENSE = 2; - - @Schema(description = "类型", example = "1") - private Integer type; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionRespVO.java deleted file mode 100644 index 5c20188ebd..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 APP - 钱包流水分页 Response VO") -@Data -public class AppPayWalletTransactionRespVO { - - @Schema(description = "业务分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer bizType; - - @Schema(description = "交易金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long price; - - @Schema(description = "流水标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆土豆") - private String title; - - @Schema(description = "交易时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/wallet/AppPayWalletRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/wallet/AppPayWalletRespVO.java deleted file mode 100644 index f0c78e405a..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/wallet/AppPayWalletRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 用户钱包 Response VO") -@Data -public class AppPayWalletRespVO { - - @Schema(description = "钱包余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer balance; - - @Schema(description = "累计支出, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer totalExpense; - - @Schema(description = "累计充值, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - private Integer totalRecharge; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/package-info.java deleted file mode 100644 index 652122752d..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.pay.controller; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java deleted file mode 100644 index 4853d07f70..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.app; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageItemRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; - -/** - * 支付应用信息 Convert - * - * @author 芋艿 - */ -@Mapper -public interface PayAppConvert { - - PayAppConvert INSTANCE = Mappers.getMapper(PayAppConvert.class); - - PayAppPageItemRespVO pageConvert (PayAppDO bean); - - PayAppDO convert(PayAppCreateReqVO bean); - - PayAppDO convert(PayAppUpdateReqVO bean); - - PayAppRespVO convert(PayAppDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult pageResult, List channels) { - PageResult voPageResult = convertPage(pageResult); - // 处理 channel 关系 - Map> appIdChannelMap = CollectionUtils.convertMultiMap2(channels, PayChannelDO::getAppId, PayChannelDO::getCode); - voPageResult.getList().forEach(app -> app.setChannelCodes(appIdChannelMap.get(app.getId()))); - return voPageResult; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java deleted file mode 100644 index 5baf598fd4..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.channel; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayChannelConvert { - - PayChannelConvert INSTANCE = Mappers.getMapper(PayChannelConvert.class); - - @Mapping(target = "config",ignore = true) - PayChannelDO convert(PayChannelCreateReqVO bean); - - @Mapping(target = "config",ignore = true) - PayChannelDO convert(PayChannelUpdateReqVO bean); - - @Mapping(target = "config",expression = "java(cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString(bean.getConfig()))") - PayChannelRespVO convert(PayChannelDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoOrderConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoOrderConvert.java deleted file mode 100644 index 8fca997919..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoOrderConvert.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.demo; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.order.PayDemoOrderCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.order.PayDemoOrderRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 示例订单 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface PayDemoOrderConvert { - - PayDemoOrderConvert INSTANCE = Mappers.getMapper(PayDemoOrderConvert.class); - - PayDemoOrderDO convert(PayDemoOrderCreateReqVO bean); - - PayDemoOrderRespVO convert(PayDemoOrderDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoTransferConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoTransferConvert.java deleted file mode 100644 index 0df9c9d5c2..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoTransferConvert.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.demo; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoTransferDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * @author jason - */ -@Mapper -public interface PayDemoTransferConvert { - - PayDemoTransferConvert INSTANCE = Mappers.getMapper(PayDemoTransferConvert.class); - - PayDemoTransferDO convert(PayDemoTransferCreateReqVO bean); - - PageResult convertPage(PageResult pageResult); -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/notify/PayNotifyTaskConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/notify/PayNotifyTaskConvert.java deleted file mode 100644 index d0b8e36ff8..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/notify/PayNotifyTaskConvert.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.notify; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskDetailRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 支付通知 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface PayNotifyTaskConvert { - - PayNotifyTaskConvert INSTANCE = Mappers.getMapper(PayNotifyTaskConvert.class); - - PayNotifyTaskRespVO convert(PayNotifyTaskDO bean); - - default PageResult convertPage(PageResult page, Map appMap){ - PageResult result = convertPage(page); - result.getList().forEach(order -> MapUtils.findAndThen(appMap, order.getAppId(), app -> order.setAppName(app.getName()))); - return result; - } - PageResult convertPage(PageResult page); - - default PayNotifyTaskDetailRespVO convert(PayNotifyTaskDO task, PayAppDO app, List logs) { - PayNotifyTaskDetailRespVO respVO = convert(task, logs); - if (app != null) { - respVO.setAppName(app.getName()); - } - return respVO; - } - PayNotifyTaskDetailRespVO convert(PayNotifyTaskDO task, List logs); -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java deleted file mode 100755 index 6820060415..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.*; -import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 支付订单 Convert - * - * @author aquan - */ -@Mapper -public interface PayOrderConvert { - - PayOrderConvert INSTANCE = Mappers.getMapper(PayOrderConvert.class); - - PayOrderRespVO convert(PayOrderDO bean); - - PayOrderRespDTO convert2(PayOrderDO order); - - default PayOrderDetailsRespVO convert(PayOrderDO order, PayOrderExtensionDO orderExtension, PayAppDO app) { - PayOrderDetailsRespVO respVO = convertDetail(order); - respVO.setExtension(convert(orderExtension)); - if (app != null) { - respVO.setAppName(app.getName()); - } - return respVO; - } - PayOrderDetailsRespVO convertDetail(PayOrderDO bean); - PayOrderDetailsRespVO.PayOrderExtension convert(PayOrderExtensionDO bean); - - default PageResult convertPage(PageResult page, Map appMap) { - PageResult result = convertPage(page); - result.getList().forEach(order -> MapUtils.findAndThen(appMap, order.getAppId(), app -> order.setAppName(app.getName()))); - return result; - } - PageResult convertPage(PageResult page); - - default List convertList(List list, Map appMap) { - return CollectionUtils.convertList(list, order -> { - PayOrderExcelVO excelVO = convertExcel(order); - MapUtils.findAndThen(appMap, order.getAppId(), app -> excelVO.setAppName(app.getName())); - return excelVO; - }); - } - PayOrderExcelVO convertExcel(PayOrderDO bean); - - PayOrderDO convert(PayOrderCreateReqDTO bean); - - @Mapping(target = "id", ignore = true) - PayOrderExtensionDO convert(PayOrderSubmitReqVO bean, String userIp); - - PayOrderUnifiedReqDTO convert2(PayOrderSubmitReqVO reqVO, String userIp); - - @Mapping(source = "order.status", target = "status") - PayOrderSubmitRespVO convert(PayOrderDO order, cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO respDTO); - - AppPayOrderSubmitRespVO convert3(PayOrderSubmitRespVO bean); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/package-info.java deleted file mode 100644 index df43d5ac3e..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.pay.convert; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/refund/PayRefundConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/refund/PayRefundConvert.java deleted file mode 100755 index 9f087f7029..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/refund/PayRefundConvert.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.refund; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundDetailsRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExcelVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageItemRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -@Mapper -public interface PayRefundConvert { - - PayRefundConvert INSTANCE = Mappers.getMapper(PayRefundConvert.class); - - - default PayRefundDetailsRespVO convert(PayRefundDO refund, PayAppDO app) { - PayRefundDetailsRespVO respVO = convert(refund); - if (app != null) { - respVO.setAppName(app.getName()); - } - return respVO; - } - PayRefundDetailsRespVO convert(PayRefundDO bean); - PayRefundDetailsRespVO.Order convert(PayOrderDO bean); - - default PageResult convertPage(PageResult page, Map appMap) { - PageResult result = convertPage(page); - result.getList().forEach(order -> MapUtils.findAndThen(appMap, order.getAppId(), app -> order.setAppName(app.getName()))); - return result; - } - PageResult convertPage(PageResult page); - - PayRefundDO convert(PayRefundCreateReqDTO bean); - - PayRefundRespDTO convert02(PayRefundDO bean); - - default List convertList(List list, Map appMap) { - return CollectionUtils.convertList(list, order -> { - PayRefundExcelVO excelVO = convertExcel(order); - MapUtils.findAndThen(appMap, order.getAppId(), app -> excelVO.setAppName(app.getName())); - return excelVO; - }); - } - PayRefundExcelVO convertExcel(PayRefundDO bean); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java deleted file mode 100644 index 4e79548d0d..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.transfer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageItemRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayTransferConvert { - - PayTransferConvert INSTANCE = Mappers.getMapper(PayTransferConvert.class); - - PayTransferDO convert(PayTransferCreateReqDTO dto); - - PayTransferUnifiedReqDTO convert2(PayTransferDO dto); - - PayTransferCreateReqDTO convert(PayTransferCreateReqVO vo); - - PayTransferCreateReqDTO convert(PayDemoTransferCreateReqVO vo); - - PayTransferRespVO convert(PayTransferDO bean); - - PageResult convertPage(PageResult pageResult); -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java deleted file mode 100644 index 5a003a22eb..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet.AppPayWalletRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.Map; - -@Mapper -public interface PayWalletConvert { - - PayWalletConvert INSTANCE = Mappers.getMapper(PayWalletConvert.class); - - AppPayWalletRespVO convert(PayWalletDO bean); - - PayWalletRespVO convert02(String nickname,String avatar, PayWalletDO bean); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, Map userMap) { - PageResult pageResult = convertPage(page); - pageResult.getList().forEach(wallet -> MapUtils.findAndThen(userMap, wallet.getUserId(), - user -> wallet.setNickname(user.getNickname()).setAvatar(user.getAvatar()))); - return pageResult; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletRechargeConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletRechargeConvert.java deleted file mode 100644 index eda8bcf952..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletRechargeConvert.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.wallet; - -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayWalletRechargeConvert { - - PayWalletRechargeConvert INSTANCE = Mappers.getMapper(PayWalletRechargeConvert.class); - - @Mapping(target = "totalPrice", expression = "java( payPrice + bonusPrice)") - PayWalletRechargeDO convert(Long walletId, Integer payPrice, Integer bonusPrice, Long packageId); - - AppPayWalletRechargeCreateRespVO convert(PayWalletRechargeDO bean); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletTransactionConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletTransactionConvert.java deleted file mode 100644 index f956f8d56e..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletTransactionConvert.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionRespVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayWalletTransactionConvert { - - PayWalletTransactionConvert INSTANCE = Mappers.getMapper(PayWalletTransactionConvert.class); - - PageResult convertPage(PageResult page); - - PageResult convertPage2(PageResult page); - - PayWalletTransactionDO convert(WalletTransactionCreateReqBO bean); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/WalletRechargePackageConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/WalletRechargePackageConvert.java deleted file mode 100644 index 8d3fdbc147..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/WalletRechargePackageConvert.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.wallet; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface WalletRechargePackageConvert { - - WalletRechargePackageConvert INSTANCE = Mappers.getMapper(WalletRechargePackageConvert.class); - - PayWalletRechargePackageDO convert(WalletRechargePackageCreateReqVO bean); - - PayWalletRechargePackageDO convert(WalletRechargePackageUpdateReqVO bean); - - WalletRechargePackageRespVO convert(PayWalletRechargePackageDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git "a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" "b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" deleted file mode 100644 index 8153487b72..0000000000 --- "a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java deleted file mode 100644 index 8f3490fc74..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.app; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 支付应用 DO - * 一个商户下,可能会有多个支付应用。例如说,京东有京东商城、京东到家等等 - * 不过一般来说,一个商户,只有一个应用哈~ - * - * 即 PayMerchantDO : PayAppDO = 1 : n - * - * @author 芋道源码 - */ -@TableName("pay_app") -@KeySequence("pay_app_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayAppDO extends BaseDO { - - /** - * 应用编号,数据库自增 - */ - @TableId - private Long id; - /** - * 应用名 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 支付结果的回调地址 - */ - private String orderNotifyUrl; - /** - * 退款结果的回调地址 - */ - private String refundNotifyUrl; - - /** - * 转账结果的回调地址 - */ - private String transferNotifyUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/channel/PayChannelDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/channel/PayChannelDO.java deleted file mode 100644 index 72387eb1ce..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/channel/PayChannelDO.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.channel; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -/** - * 支付渠道 DO - * 一个应用下,会有多种支付渠道,例如说微信支付、支付宝支付等等 - * - * 即 PayAppDO : PayChannelDO = 1 : n - * - * @author 芋道源码 - */ -@TableName(value = "pay_channel", autoResultMap = true) -@KeySequence("pay_channel_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayChannelDO extends TenantBaseDO { - - /** - * 渠道编号,数据库自增 - */ - private Long id; - /** - * 渠道编码 - * - * 枚举 {@link PayChannelEnum} - */ - private String code; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 渠道费率,单位:百分比 - */ - private Double feeRate; - /** - * 备注 - */ - private String remark; - - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 支付渠道配置 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private PayClientConfig config; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoOrderDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoOrderDO.java deleted file mode 100644 index a22f7c1b87..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoOrderDO.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.demo; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 示例订单 - * - * 演示业务系统的订单,如何接入 pay 系统的支付与退款 - * - * @author 芋道源码 - */ -@TableName("pay_demo_order") -@KeySequence("pay_demo_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayDemoOrderDO extends BaseDO { - - /** - * 订单编号,自增 - */ - @TableId - private Long id; - /** - * 用户编号 - */ - private Long userId; - /** - * 商品编号 - */ - private Long spuId; - /** - * 商品名称 - */ - private String spuName; - /** - * 价格,单位:分 - */ - private Integer price; - - // ========== 支付相关字段 ========== - - /** - * 是否支付 - */ - private Boolean payStatus; - /** - * 支付订单编号 - * - * 对接 pay-module-biz 支付服务的支付订单编号,即 PayOrderDO 的 id 编号 - */ - private Long payOrderId; - /** - * 付款时间 - */ - private LocalDateTime payTime; - /** - * 支付渠道 - * - * 对应 PayChannelEnum 枚举 - */ - private String payChannelCode; - - // ========== 退款相关字段 ========== - /** - * 支付退款单号 - */ - private Long payRefundId; - /** - * 退款金额,单位:分 - */ - private Integer refundPrice; - /** - * 退款完成时间 - */ - private LocalDateTime refundTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoTransferDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoTransferDO.java deleted file mode 100644 index 621cafc3ab..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoTransferDO.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.demo; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 示例转账订单 - * - * 演示业务系统的转账业务 - */ -@TableName(value ="pay_demo_transfer", autoResultMap = true) -@KeySequence("pay_demo_transfer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayDemoTransferDO extends BaseDO { - - /** - * 订单编号 - */ - @TableId - private Long id; - - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - - /** - * 转账类型 - *

- * 枚举 {@link PayTransferTypeEnum} - */ - private Integer type; - - /** - * 转账金额,单位:分 - */ - private Integer price; - - /** - * 收款人姓名 - */ - private String userName; - - /** - * 支付宝登录号 - */ - private String alipayLogonId; - - /** - * 微信 openId - */ - private String openid; - - /** - * 转账状态 - */ - private Integer transferStatus; - - /** - * 转账单编号 - */ - private Long payTransferId; - - /** - * 转账支付成功渠道 - */ - private String payChannelCode; - - /** - * 转账支付时间 - */ - private LocalDateTime transferTime; - -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyLogDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyLogDO.java deleted file mode 100644 index a482605d52..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyLogDO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.notify; - -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商户支付、退款等的通知 Log - * 每次通知时,都会在该表中,记录一次 Log,方便排查问题 - * - * @author 芋道源码 - */ -@TableName("pay_notify_log") -@KeySequence("pay_notify_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayNotifyLogDO extends BaseDO { - - /** - * 日志编号,自增 - */ - private Long id; - /** - * 通知任务编号 - * - * 关联 {@link PayNotifyTaskDO#getId()} - */ - private Long taskId; - /** - * 第几次被通知 - * - * 对应到 {@link PayNotifyTaskDO#getNotifyTimes()} - */ - private Integer notifyTimes; - /** - * HTTP 响应结果 - */ - private String response; - /** - * 支付通知状态 - * - * 外键 {@link PayNotifyStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java deleted file mode 100644 index 7bfabad3ff..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.notify; - -import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.time.LocalDateTime; - -/** - * 支付通知 - * 在支付系统收到支付渠道的支付、退款的结果后,需要不断的通知到业务系统,直到成功。 - * - * @author 芋道源码 - */ -@TableName("pay_notify_task") -@KeySequence("pay_notify_task_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class PayNotifyTaskDO extends TenantBaseDO { - - /** - * 通知频率,单位为秒。 - * - * 算上首次的通知,实际是一共 1 + 8 = 9 次。 - */ - public static final Integer[] NOTIFY_FREQUENCY = new Integer[]{ - 15, 15, 30, 180, - 1800, 1800, 1800, 3600 - }; - - /** - * 编号,自增 - */ - @TableId - private Long id; - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 通知类型 - * - * 外键 {@link PayNotifyTypeEnum} - */ - private Integer type; - /** - * 数据编号,根据不同 type 进行关联: - * - * 1. {@link PayNotifyTypeEnum#ORDER} 时,关联 {@link PayOrderDO#getId()} - * 2. {@link PayNotifyTypeEnum#REFUND} 时,关联 {@link PayRefundDO#getId()} - */ - private Long dataId; - /** - * 商户订单编号 - */ - private String merchantOrderId; - /** - * 商户转账单编号 - */ - private String merchantTransferId; - /** - * 通知状态 - * - * 外键 {@link PayNotifyStatusEnum} - */ - private Integer status; - /** - * 下一次通知时间 - */ - private LocalDateTime nextNotifyTime; - /** - * 最后一次执行时间 - */ - private LocalDateTime lastExecuteTime; - /** - * 当前通知次数 - */ - private Integer notifyTimes; - /** - * 最大可通知次数 - */ - private Integer maxNotifyTimes; - /** - * 通知地址 - */ - private String notifyUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java deleted file mode 100644 index a51b875fd1..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.order; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 支付订单 DO - * - * @author 芋道源码 - */ -@TableName("pay_order") -@KeySequence("pay_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayOrderDO extends BaseDO { - - /** - * 订单编号,数据库自增 - */ - private Long id; - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 渠道编号 - * - * 关联 {@link PayChannelDO#getId()} - */ - private Long channelId; - /** - * 渠道编码 - * - * 枚举 {@link PayChannelEnum} - */ - private String channelCode; - - // ========== 商户相关字段 ========== - - /** - * 商户订单编号 - * - * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一 - */ - private String merchantOrderId; - /** - * 商品标题 - */ - private String subject; - /** - * 商品描述信息 - */ - private String body; - /** - * 异步通知地址 - */ - private String notifyUrl; - - // ========== 订单相关字段 ========== - - /** - * 支付金额,单位:分 - */ - private Integer price; - /** - * 渠道手续费,单位:百分比 - * - * 冗余 {@link PayChannelDO#getFeeRate()} - */ - private Double channelFeeRate; - /** - * 渠道手续金额,单位:分 - */ - private Integer channelFeePrice; - /** - * 支付状态 - * - * 枚举 {@link PayOrderStatusEnum} - */ - private Integer status; - /** - * 用户 IP - */ - private String userIp; - /** - * 订单失效时间 - */ - private LocalDateTime expireTime; - /** - * 订单支付成功时间 - */ - private LocalDateTime successTime; - /** - * 支付成功的订单拓展单编号 - * - * 关联 {@link PayOrderExtensionDO#getId()} - */ - private Long extensionId; - /** - * 支付成功的外部订单号 - * - * 关联 {@link PayOrderExtensionDO#getNo()} - */ - private String no; - - // ========== 退款相关字段 ========== - /** - * 退款总金额,单位:分 - */ - private Integer refundPrice; - - // ========== 渠道相关字段 ========== - /** - * 渠道用户编号 - * - * 例如说,微信 openid、支付宝账号 - */ - private String channelUserId; - /** - * 渠道订单号 - */ - private String channelOrderNo; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java deleted file mode 100644 index 9466243e11..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.order; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.Map; - -/** - * 支付订单拓展 DO - * - * 每次调用支付渠道,都会生成一条对应记录 - * - * @author 芋道源码 - */ -@TableName(value = "pay_order_extension",autoResultMap = true) -@KeySequence("pay_order_extension_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayOrderExtensionDO extends BaseDO { - - /** - * 订单拓展编号,数据库自增 - */ - private Long id; - /** - * 外部订单号,根据规则生成 - * - * 调用支付渠道时,使用该字段作为对接的订单号: - * 1. 微信支付:对应 JSAPI 支付 的 out_trade_no 字段 - * 2. 支付宝支付:对应 电脑网站支付 的 out_trade_no 字段 - * - * 例如说,P202110132239124200055 - */ - private String no; - /** - * 订单号 - * - * 关联 {@link PayOrderDO#getId()} - */ - private Long orderId; - /** - * 渠道编号 - * - * 关联 {@link PayChannelDO#getId()} - */ - private Long channelId; - /** - * 渠道编码 - */ - private String channelCode; - /** - * 用户 IP - */ - private String userIp; - /** - * 支付状态 - * - * 枚举 {@link PayOrderStatusEnum} - */ - private Integer status; - /** - * 支付渠道的额外参数 - * - * 参见 参数说明 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private Map channelExtras; - - /** - * 调用渠道的错误码 - */ - private String channelErrorCode; - /** - * 调用渠道报错时,错误信息 - */ - private String channelErrorMsg; - - /** - * 支付渠道的同步/异步通知的内容 - * - * 对应 {@link PayOrderRespDTO#getRawData()} - */ - private String channelNotifyData; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java deleted file mode 100644 index 5d9c612a33..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java +++ /dev/null @@ -1,160 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.refund; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 支付退款单 DO - * 一个支付订单,可以拥有多个支付退款单 - * - * 即 PayOrderDO : PayRefundDO = 1 : n - * - * @author 芋道源码 - */ -@TableName("pay_refund") -@KeySequence("pay_refund_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayRefundDO extends BaseDO { - - /** - * 退款单编号,数据库自增 - */ - @TableId - private Long id; - /** - * 外部退款号,根据规则生成 - * - * 调用支付渠道时,使用该字段作为对接的退款号: - * 1. 微信退款:对应 申请退款 的 out_refund_no 字段 - * 2. 支付宝退款:对应 的 out_request_no 字段 - */ - private String no; - - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 渠道编号 - * - * 关联 {@link PayChannelDO#getId()} - */ - private Long channelId; - /** - * 商户编码 - * - * 枚举 {@link PayChannelEnum} - */ - private String channelCode; - /** - * 订单编号 - * - * 关联 {@link PayOrderDO#getId()} - */ - private Long orderId; - /** - * 支付订单编号 - * - * 冗余 {@link PayOrderDO#getNo()} - */ - private String orderNo; - - // ========== 商户相关字段 ========== - /** - * 商户订单编号 - * - * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一 - */ - private String merchantOrderId; - /** - * 商户退款订单号 - * - * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一 - */ - private String merchantRefundId; - /** - * 异步通知地址 - */ - private String notifyUrl; - - // ========== 退款相关字段 ========== - /** - * 退款状态 - * - * 枚举 {@link PayRefundStatusEnum} - */ - private Integer status; - - /** - * 支付金额,单位:分 - */ - private Integer payPrice; - /** - * 退款金额,单位:分 - */ - private Integer refundPrice; - - /** - * 退款原因 - */ - private String reason; - - /** - * 用户 IP - */ - private String userIp; - - // ========== 渠道相关字段 ========== - /** - * 渠道订单号 - * - * 冗余 {@link PayOrderDO#getChannelOrderNo()} - */ - private String channelOrderNo; - /** - * 渠道退款单号 - * - * 1. 微信退款:对应 申请退款 的 refund_id 字段 - * 2. 支付宝退款:没有字段 - */ - private String channelRefundNo; - /** - * 退款成功时间 - */ - private LocalDateTime successTime; - - /** - * 调用渠道的错误码 - */ - private String channelErrorCode; - /** - * 调用渠道的错误提示 - */ - private String channelErrorMsg; - - /** - * 支付渠道的同步/异步通知的内容 - * - * 对应 {@link PayRefundRespDTO#getRawData()} - */ - private String channelNotifyData; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java deleted file mode 100644 index 0bae028f4b..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java +++ /dev/null @@ -1,157 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.transfer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Map; - -/** - * 转账单 DO - * - * @author jason - */ -@TableName(value ="pay_transfer", autoResultMap = true) -@KeySequence("pay_transfer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayTransferDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 转账单号 - * - */ - private String no; - - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - - /** - * 转账渠道编号 - * - * 关联 {@link PayChannelDO#getId()} - */ - private Long channelId; - - /** - * 转账渠道编码 - * - * 枚举 {@link PayChannelEnum} - */ - private String channelCode; - - // ========== 商户相关字段 ========== - /** - * 商户转账单编号 - * - * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一 - */ - private String merchantTransferId; - - // ========== 转账相关字段 ========== - - /** - * 类型 - * - * 枚举 {@link PayTransferTypeEnum} - */ - private Integer type; - - /** - * 转账标题 - */ - private String subject; - - /** - * 转账金额,单位:分 - */ - private Integer price; - - /** - * 收款人姓名 - */ - private String userName; - - /** - * 转账状态 - * - * 枚举 {@link PayTransferStatusRespEnum} - */ - private Integer status; - - /** - * 订单转账成功时间 - */ - private LocalDateTime successTime; - - // ========== 支付宝转账相关字段 ========== - /** - * 支付宝登录号 - */ - private String alipayLogonId; - - - // ========== 微信转账相关字段 ========== - /** - * 微信 openId - */ - private String openid; - - // ========== 其它字段 ========== - - /** - * 异步通知地址 - */ - private String notifyUrl; - - /** - * 用户 IP - */ - private String userIp; - - /** - * 渠道的额外参数 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private Map channelExtras; - - /** - * 渠道转账单号 - */ - private String channelTransferNo; - - /** - * 调用渠道的错误码 - */ - private String channelErrorCode; - /** - * 调用渠道的错误提示 - */ - private String channelErrorMsg; - - /** - * 渠道的同步/异步通知的内容 - * - */ - private String channelNotifyData; - -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletDO.java deleted file mode 100644 index a3c54c969e..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletDO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 会员钱包 DO - * - * @author jason - */ -@TableName(value ="pay_wallet") -@KeySequence("pay_wallet_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayWalletDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 用户 id - * - * 关联 MemberUserDO 的 id 编号 - * 关联 AdminUserDO 的 id 编号 - */ - private Long userId; - /** - * 用户类型, 预留 多商户转帐可能需要用到 - * - * 关联 {@link UserTypeEnum} - */ - private Integer userType; - - /** - * 余额,单位分 - */ - private Integer balance; - - /** - * 冻结金额,单位分 - */ - private Integer freezePrice; - - /** - * 累计支出,单位分 - */ - private Integer totalExpense; - /** - * 累计充值,单位分 - */ - private Integer totalRecharge; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargeDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargeDO.java deleted file mode 100644 index a842c95e6c..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargeDO.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 会员钱包充值 - */ -@TableName(value ="pay_wallet_recharge") -@KeySequence("pay_wallet_recharge_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayWalletRechargeDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 钱包编号 - * - * 关联 {@link PayWalletDO#getId()} - */ - private Long walletId; - - /** - * 用户实际到账余额 - * - * 例如充 100 送 20,则该值是 120 - */ - private Integer totalPrice; - /** - * 实际支付金额 - */ - private Integer payPrice; - /** - * 钱包赠送金额 - */ - private Integer bonusPrice; - - /** - * 充值套餐编号 - * - * 关联 {@link PayWalletRechargeDO#getPackageId()} 字段 - */ - private Long packageId; - - /** - * 是否已支付 - * - * true - 已支付 - * false - 未支付 - */ - private Boolean payStatus; - - /** - * 支付订单编号 - * - * 关联 {@link PayOrderDO#getId()} - */ - private Long payOrderId; - - /** - * 支付成功的支付渠道 - * - * 冗余 {@link PayOrderDO#getChannelCode()} - */ - private String payChannelCode; - /** - * 订单支付时间 - */ - private LocalDateTime payTime; - - /** - * 支付退款单编号 - * - * 关联 {@link PayRefundDO#getId()} - */ - private Long payRefundId; - - /** - * 退款金额,包含赠送金额 - */ - private Integer refundTotalPrice; - /** - * 退款支付金额 - */ - private Integer refundPayPrice; - - /** - * 退款钱包赠送金额 - */ - private Integer refundBonusPrice; - - /** - * 退款时间 - */ - private LocalDateTime refundTime; - - /** - * 退款状态 - * - * 枚举 {@link PayRefundStatusEnum} - */ - private Integer refundStatus; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargePackageDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargePackageDO.java deleted file mode 100644 index 72fc43d962..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargePackageDO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 会员钱包充值套餐 DO - * - * 通过充值套餐时,可以赠送一定金额; - * - * @author 芋道源码 - */ -@TableName(value ="pay_wallet_recharge_package") -@KeySequence("pay_wallet_recharge_package_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayWalletRechargePackageDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 套餐名 - */ - private String name; - - /** - * 支付金额 - */ - private Integer payPrice; - /** - * 赠送金额 - */ - private Integer bonusPrice; - - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletTransactionDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletTransactionDO.java deleted file mode 100644 index 654e511576..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletTransactionDO.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 会员钱包流水 DO - * - * @author jason - */ -@TableName(value ="pay_wallet_transaction") -@KeySequence("pay_wallet_transaction_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayWalletTransactionDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 流水号 - */ - private String no; - - /** - * 钱包编号 - * - * 关联 {@link PayWalletDO#getId()} - */ - private Long walletId; - - /** - * 关联业务分类 - * - * 枚举 {@link PayWalletBizTypeEnum#getType()} - */ - private Integer bizType; - - /** - * 关联业务编号 - */ - private String bizId; - - /** - * 流水说明 - */ - private String title; - - /** - * 交易金额,单位分 - * - * 正值表示余额增加,负值表示余额减少 - */ - private Integer price; - - /** - * 交易后余额,单位分 - */ - private Integer balance; -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java deleted file mode 100644 index c31dba551c..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.app; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayAppMapper extends BaseMapperX { - - default PageResult selectPage(PayAppPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(PayAppDO::getName, reqVO.getName()) - .eqIfPresent(PayAppDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayAppDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayAppDO::getId)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java deleted file mode 100644 index e6984984e6..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.channel; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -@Mapper -public interface PayChannelMapper extends BaseMapperX { - - default PayChannelDO selectByAppIdAndCode(Long appId, String code) { - return selectOne(PayChannelDO::getAppId, appId, PayChannelDO::getCode, code); - } - - default List selectListByAppIds(Collection appIds){ - return selectList(PayChannelDO::getAppId, appIds); - } - - default List selectListByAppId(Long appId, Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(PayChannelDO::getAppId, appId) - .eq(PayChannelDO::getStatus, status)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoOrderMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoOrderMapper.java deleted file mode 100644 index 0a92c6b76b..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoOrderMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.demo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 示例订单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface PayDemoOrderMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .orderByDesc(PayDemoOrderDO::getId)); - } - - default int updateByIdAndPayed(Long id, boolean wherePayed, PayDemoOrderDO updateObj) { - return update(updateObj, new LambdaQueryWrapperX() - .eq(PayDemoOrderDO::getId, id).eq(PayDemoOrderDO::getPayStatus, wherePayed)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoTransferMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoTransferMapper.java deleted file mode 100644 index 77c7ba0478..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoTransferMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.demo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoTransferDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayDemoTransferMapper extends BaseMapperX { - - default PageResult selectPage(PageParam pageParam){ - return selectPage(pageParam, new LambdaQueryWrapperX() - .orderByDesc(PayDemoTransferDO::getId)); - } -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyLogMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyLogMapper.java deleted file mode 100644 index 8b586dff2e..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyLogMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.notify; - -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface PayNotifyLogMapper extends BaseMapperX { - - default List selectListByTaskId(Long taskId) { - return selectList(PayNotifyLogDO::getTaskId, taskId); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyTaskMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyTaskMapper.java deleted file mode 100644 index cc7701271c..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyTaskMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.notify; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; - -@Mapper -public interface PayNotifyTaskMapper extends BaseMapperX { - - /** - * 获得需要通知的 PayNotifyTaskDO 记录。需要满足如下条件: - * - * 1. status 非成功 - * 2. nextNotifyTime 小于当前时间 - * - * @return PayTransactionNotifyTaskDO 数组 - */ - default List selectListByNotify() { - return selectList(new LambdaQueryWrapper() - .in(PayNotifyTaskDO::getStatus, PayNotifyStatusEnum.WAITING.getStatus(), - PayNotifyStatusEnum.REQUEST_SUCCESS.getStatus(), PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()) - .le(PayNotifyTaskDO::getNextNotifyTime, LocalDateTime.now())); - } - - default PageResult selectPage(PayNotifyTaskPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(PayNotifyTaskDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayNotifyTaskDO::getType, reqVO.getType()) - .eqIfPresent(PayNotifyTaskDO::getDataId, reqVO.getDataId()) - .eqIfPresent(PayNotifyTaskDO::getStatus, reqVO.getStatus()) - .eqIfPresent(PayNotifyTaskDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .betweenIfPresent(PayNotifyTaskDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayNotifyTaskDO::getId)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderExtensionMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderExtensionMapper.java deleted file mode 100755 index 8513c4b319..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderExtensionMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.order; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; - -@Mapper -public interface PayOrderExtensionMapper extends BaseMapperX { - - default PayOrderExtensionDO selectByNo(String no) { - return selectOne(PayOrderExtensionDO::getNo, no); - } - - default int updateByIdAndStatus(Long id, Integer status, PayOrderExtensionDO update) { - return update(update, new LambdaQueryWrapper() - .eq(PayOrderExtensionDO::getId, id).eq(PayOrderExtensionDO::getStatus, status)); - } - - default List selectListByOrderId(Long orderId) { - return selectList(PayOrderExtensionDO::getOrderId, orderId); - } - - default List selectListByStatusAndCreateTimeGe(Integer status, LocalDateTime minCreateTime) { - return selectList(new LambdaQueryWrapper() - .eq(PayOrderExtensionDO::getStatus, status) - .ge(PayOrderExtensionDO::getCreateTime, minCreateTime)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java deleted file mode 100755 index 95510d5f7e..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; - -@Mapper -public interface PayOrderMapper extends BaseMapperX { - - default PageResult selectPage(PayOrderPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(PayOrderDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayOrderDO::getChannelCode, reqVO.getChannelCode()) - .likeIfPresent(PayOrderDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .likeIfPresent(PayOrderDO::getChannelOrderNo, reqVO.getChannelOrderNo()) - .likeIfPresent(PayOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(PayOrderDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayOrderDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayOrderDO::getId)); - } - - default List selectList(PayOrderExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(PayOrderDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayOrderDO::getChannelCode, reqVO.getChannelCode()) - .likeIfPresent(PayOrderDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .likeIfPresent(PayOrderDO::getChannelOrderNo, reqVO.getChannelOrderNo()) - .likeIfPresent(PayOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(PayOrderDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayOrderDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayOrderDO::getId)); - } - - default Long selectCountByAppId(Long appId) { - return selectCount(PayOrderDO::getAppId, appId); - } - - default PayOrderDO selectByAppIdAndMerchantOrderId(Long appId, String merchantOrderId) { - return selectOne(PayOrderDO::getAppId, appId, - PayOrderDO::getMerchantOrderId, merchantOrderId); - } - - default int updateByIdAndStatus(Long id, Integer status, PayOrderDO update) { - return update(update, new LambdaQueryWrapper() - .eq(PayOrderDO::getId, id).eq(PayOrderDO::getStatus, status)); - } - - default List selectListByStatusAndExpireTimeLt(Integer status, LocalDateTime expireTime) { - return selectList(new LambdaQueryWrapper() - .eq(PayOrderDO::getStatus, status) - .lt(PayOrderDO::getExpireTime, expireTime)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java deleted file mode 100755 index 0b620eaedc..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.refund; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface PayRefundMapper extends BaseMapperX { - - default Long selectCountByAppId(Long appId) { - return selectCount(PayRefundDO::getAppId, appId); - } - - default PayRefundDO selectByAppIdAndMerchantRefundId(Long appId, String merchantRefundId) { - return selectOne(new LambdaQueryWrapperX() - .eq(PayRefundDO::getAppId, appId) - .eq(PayRefundDO::getMerchantRefundId, merchantRefundId)); - } - - default Long selectCountByAppIdAndOrderId(Long appId, Long orderId, Integer status) { - return selectCount(new LambdaQueryWrapperX() - .eq(PayRefundDO::getAppId, appId) - .eq(PayRefundDO::getOrderId, orderId) - .eq(PayRefundDO::getStatus, status)); - } - - default PayRefundDO selectByAppIdAndNo(Long appId, String no) { - return selectOne(new LambdaQueryWrapperX() - .eq(PayRefundDO::getAppId, appId) - .eq(PayRefundDO::getNo, no)); - } - - default PayRefundDO selectByNo(String no) { - return selectOne(PayRefundDO::getNo, no); - } - - default int updateByIdAndStatus(Long id, Integer status, PayRefundDO update) { - return update(update, new LambdaQueryWrapper() - .eq(PayRefundDO::getId, id).eq(PayRefundDO::getStatus, status)); - } - - default PageResult selectPage(PayRefundPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(PayRefundDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayRefundDO::getChannelCode, reqVO.getChannelCode()) - .likeIfPresent(PayRefundDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .likeIfPresent(PayRefundDO::getMerchantRefundId, reqVO.getMerchantRefundId()) - .likeIfPresent(PayRefundDO::getChannelOrderNo, reqVO.getChannelOrderNo()) - .likeIfPresent(PayRefundDO::getChannelRefundNo, reqVO.getChannelRefundNo()) - .eqIfPresent(PayRefundDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayRefundDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayRefundDO::getId)); - } - - default List selectList(PayRefundExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(PayRefundDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayRefundDO::getChannelCode, reqVO.getChannelCode()) - .likeIfPresent(PayRefundDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .likeIfPresent(PayRefundDO::getMerchantRefundId, reqVO.getMerchantRefundId()) - .likeIfPresent(PayRefundDO::getChannelOrderNo, reqVO.getChannelOrderNo()) - .likeIfPresent(PayRefundDO::getChannelRefundNo, reqVO.getChannelRefundNo()) - .eqIfPresent(PayRefundDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayRefundDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayRefundDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(PayRefundDO::getStatus, status); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java deleted file mode 100644 index af4f6debf7..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.transfer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface PayTransferMapper extends BaseMapperX { - - default int updateByIdAndStatus(Long id, List status, PayTransferDO updateObj) { - return update(updateObj, new LambdaQueryWrapper() - .eq(PayTransferDO::getId, id).in(PayTransferDO::getStatus, status)); - } - - default PayTransferDO selectByAppIdAndMerchantTransferId(Long appId, String merchantTransferId){ - return selectOne(PayTransferDO::getAppId, appId, - PayTransferDO::getMerchantTransferId, merchantTransferId); - } - - default PayTransferDO selectByNo(String no){ - return selectOne(PayTransferDO::getNo, no); - } - - default PageResult selectPage(PayTransferPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(PayTransferDO::getNo, reqVO.getNo()) - .eqIfPresent(PayTransferDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayTransferDO::getChannelCode, reqVO.getChannelCode()) - .eqIfPresent(PayTransferDO::getMerchantTransferId, reqVO.getMerchantTransferId()) - .eqIfPresent(PayTransferDO::getType, reqVO.getType()) - .eqIfPresent(PayTransferDO::getStatus, reqVO.getStatus()) - .likeIfPresent(PayTransferDO::getUserName, reqVO.getUserName()) - .eqIfPresent(PayTransferDO::getChannelTransferNo, reqVO.getChannelTransferNo()) - .betweenIfPresent(PayTransferDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayTransferDO::getId)); - } - - default List selectListByStatus(Integer status){ - return selectList(PayTransferDO::getStatus, status); - } -} - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java deleted file mode 100644 index ce672255a6..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.wallet; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayWalletMapper extends BaseMapperX { - - default PayWalletDO selectByUserIdAndType(Long userId, Integer userType) { - return selectOne(PayWalletDO::getUserId, userId, - PayWalletDO::getUserType, userType); - } - - default PageResult selectPage(Integer userType, PayWalletPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .inIfPresent(PayWalletDO::getUserId, reqVO.getUserIds()) - .eqIfPresent(PayWalletDO::getUserType, userType) - .betweenIfPresent(PayWalletDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayWalletDO::getId)); - } - - /** - * 当消费退款时候, 更新钱包 - * - * @param id 钱包 id - * @param price 消费金额 - */ - default int updateWhenConsumptionRefund(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance + " + price - + ", total_expense = total_expense - " + price) - .eq(PayWalletDO::getId, id); - return update(null, lambdaUpdateWrapper); - } - - /** - * 当消费时候, 更新钱包 - * - * @param price 消费金额 - * @param id 钱包 id - */ - default int updateWhenConsumption(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance - " + price - + ", total_expense = total_expense + " + price) - .eq(PayWalletDO::getId, id) - .ge(PayWalletDO::getBalance, price); // cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - /** - * 当充值的时候,更新钱包 - * - * @param id 钱包 id - * @param price 钱包金额 - */ - default int updateWhenRecharge(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance + " + price - + ", total_recharge = total_recharge + " + price) - .eq(PayWalletDO::getId, id); - return update(null, lambdaUpdateWrapper); - } - - /** - * 冻结钱包部分余额 - * - * @param id 钱包 id - * @param price 冻结金额 - */ - default int freezePrice(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance - " + price - + ", freeze_price = freeze_price + " + price) - .eq(PayWalletDO::getId, id) - .ge(PayWalletDO::getBalance, price); // cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - /** - * 解冻钱包余额 - * - * @param id 钱包 id - * @param price 解冻金额 - */ - default int unFreezePrice(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance + " + price - + ", freeze_price = freeze_price - " + price) - .eq(PayWalletDO::getId, id) - .ge(PayWalletDO::getFreezePrice, price); // cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - /** - * 当充值退款时, 更新钱包 - * - * @param id 钱包 id - * @param price 退款金额 - */ - default int updateWhenRechargeRefund(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" freeze_price = freeze_price - " + price - + ", total_recharge = total_recharge - " + price) - .eq(PayWalletDO::getId, id) - .ge(PayWalletDO::getFreezePrice, price) - .ge(PayWalletDO::getTotalRecharge, price);// cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - -} - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java deleted file mode 100644 index 4cb77f0207..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.wallet; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayWalletRechargeMapper extends BaseMapperX { - - default int updateByIdAndPaid(Long id, boolean wherePayStatus, PayWalletRechargeDO updateObj) { - return update(updateObj, new LambdaQueryWrapperX() - .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getPayStatus, wherePayStatus)); - } - - default int updateByIdAndRefunded(Long id, Integer whereRefundStatus, PayWalletRechargeDO updateObj) { - return update(updateObj, new LambdaQueryWrapperX() - .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getRefundStatus, whereRefundStatus)); - } - -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java deleted file mode 100644 index b68b4c8932..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.wallet; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayWalletRechargePackageMapper extends BaseMapperX { - - default PageResult selectPage(WalletRechargePackagePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(PayWalletRechargePackageDO::getName, reqVO.getName()) - .eqIfPresent(PayWalletRechargePackageDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayWalletRechargePackageDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayWalletRechargePackageDO::getPayPrice)); - } - - // TODO @jason:这里要有空格哈;String name) { - default PayWalletRechargePackageDO selectByName(String name){ - return selectOne(PayWalletRechargePackageDO::getName, name); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java deleted file mode 100644 index 41d7dbeb46..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.wallet; - - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Objects; - -@Mapper -public interface PayWalletTransactionMapper extends BaseMapperX { - - default PageResult selectPage(Long walletId, Integer type, - PageParam pageParam) { - LambdaQueryWrapperX query = new LambdaQueryWrapperX() - .eqIfPresent(PayWalletTransactionDO::getWalletId, walletId); - if (Objects.equals(type, AppPayWalletTransactionPageReqVO.TYPE_INCOME)) { - query.gt(PayWalletTransactionDO::getPrice, 0); - } else if (Objects.equals(type, AppPayWalletTransactionPageReqVO.TYPE_EXPENSE)) { - query.lt(PayWalletTransactionDO::getPrice, 0); - } - query.orderByDesc(PayWalletTransactionDO::getId); - return selectPage(pageParam, query); - } - - default PayWalletTransactionDO selectByNo(String no) { - return selectOne(PayWalletTransactionDO::getNo, no); - } - - default PayWalletTransactionDO selectByBiz(String bizId, Integer bizType) { - return selectOne(PayWalletTransactionDO::getBizId, bizId, - PayWalletTransactionDO::getBizType, bizType); - } - -} - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/RedisKeyConstants.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/RedisKeyConstants.java deleted file mode 100644 index 30081c6e8e..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/RedisKeyConstants.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.redis; - -/** - * 支付 Redis Key 枚举类 - * - * @author 芋道源码 - */ -public interface RedisKeyConstants { - - /** - * 通知任务的分布式锁 - * - * KEY 格式:pay_notify:lock:%d // 参数来自 DefaultLockKeyBuilder 类 - * VALUE 数据格式:HASH // RLock.class:Redisson 的 Lock 锁,使用 Hash 数据结构 - * 过期时间:不固定 - */ - String PAY_NOTIFY_LOCK = "pay_notify:lock:%d"; - - /** - * 支付序号的缓存 - * - * KEY 格式:pay_no:{prefix} - * VALUE 数据格式:编号自增 - */ - String PAY_NO = "pay_no:"; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/no/PayNoRedisDAO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/no/PayNoRedisDAO.java deleted file mode 100644 index 1482ddf63f..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/no/PayNoRedisDAO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.redis.no; - -import cn.hutool.core.date.DatePattern;import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.pay.dal.redis.RedisKeyConstants; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Repository; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; - -/** - * 支付序号的 Redis DAO - * - * @author 芋道源码 - */ -@Repository -public class PayNoRedisDAO { - - @Resource - private StringRedisTemplate stringRedisTemplate; - - /** - * 生成序号 - * - * @param prefix 前缀 - * @return 序号 - */ - public String generate(String prefix) { - // 递增序号 - String noPrefix = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN); - String key = RedisKeyConstants.PAY_NO + noPrefix; - Long no = stringRedisTemplate.opsForValue().increment(key); - // 设置过期时间 - stringRedisTemplate.expire(key, Duration.ofMinutes(1L)); - return noPrefix + no; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java deleted file mode 100644 index b5916f62d3..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.redis.notify; - -import org.redisson.api.RLock; -import org.redisson.api.RedissonClient; -import org.springframework.stereotype.Repository; - -import jakarta.annotation.Resource; -import java.util.concurrent.TimeUnit; - -import static cn.iocoder.yudao.module.pay.dal.redis.RedisKeyConstants.PAY_NOTIFY_LOCK; - -/** - * 支付通知的锁 Redis DAO - * - * @author 芋道源码 - */ -@Repository -public class PayNotifyLockRedisDAO { - - @Resource - private RedissonClient redissonClient; - - public void lock(Long id, Long timeoutMillis, Runnable runnable) { - String lockKey = formatKey(id); - RLock lock = redissonClient.getLock(lockKey); - try { - lock.lock(timeoutMillis, TimeUnit.MILLISECONDS); - // 执行逻辑 - runnable.run(); - } finally { - lock.unlock(); - } - } - - private static String formatKey(Long id) { - return String.format(PAY_NOTIFY_LOCK, id); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/config/PayJobConfiguration.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/config/PayJobConfiguration.java deleted file mode 100644 index cd6bd0bb73..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/config/PayJobConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.job.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -import java.util.concurrent.ThreadPoolExecutor; - -@Configuration(proxyBeanMethods = false) -public class PayJobConfiguration { - - public static final String NOTIFY_THREAD_POOL_TASK_EXECUTOR = "NOTIFY_THREAD_POOL_TASK_EXECUTOR"; - - @Bean(NOTIFY_THREAD_POOL_TASK_EXECUTOR) - public ThreadPoolTaskExecutor notifyThreadPoolTaskExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(8); // 设置核心线程数 - executor.setMaxPoolSize(16); // 设置最大线程数 - executor.setKeepAliveSeconds(60); // 设置空闲时间 - executor.setQueueCapacity(100); // 设置队列大小 - executor.setThreadNamePrefix("notify-task-"); // 配置线程池的前缀 - executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); - // 进行加载 - executor.initialize(); - return executor; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/core/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/core/package-info.java deleted file mode 100644 index 5a5a689f87..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.pay.framework.job.core; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/package-info.java deleted file mode 100644 index a1286828ea..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 pay 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.pay.framework; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayConfiguration.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayConfiguration.java deleted file mode 100644 index 376cd0acbb..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayConfiguration.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.pay.config; - -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties(PayProperties.class) -public class PayConfiguration { -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java deleted file mode 100644 index 02254ca0b8..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.pay.config; - -import lombok.Data; -import org.hibernate.validator.constraints.URL; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -import jakarta.validation.constraints.NotEmpty; - -@ConfigurationProperties(prefix = "yudao.pay") -@Validated -@Data -public class PayProperties { - - private static final String ORDER_NO_PREFIX = "P"; - private static final String REFUND_NO_PREFIX = "R"; - - /** - * 支付回调地址 - * - * 实际上,对应的 PayNotifyController 的 notifyOrder 方法的 URL - * - * 回调顺序:支付渠道(支付宝支付、微信支付) => yudao-module-pay 的 orderNotifyUrl 地址 => 业务的 PayAppDO.orderNotifyUrl 地址 - */ - @NotEmpty(message = "支付回调地址不能为空") - @URL(message = "支付回调地址的格式必须是 URL") - private String orderNotifyUrl; - - /** - * 退款回调地址 - * - * 实际上,对应的 PayNotifyController 的 notifyRefund 方法的 URL - * - * 回调顺序:支付渠道(支付宝支付、微信支付) => yudao-module-pay 的 refundNotifyUrl 地址 => 业务的 PayAppDO.notifyRefundUrl 地址 - */ - @NotEmpty(message = "支付回调地址不能为空") - @URL(message = "支付回调地址的格式必须是 URL") - private String refundNotifyUrl; - - /** - * 支付订单 no 的前缀 - */ - @NotEmpty(message = "支付订单 no 的前缀不能为空") - private String orderNoPrefix = ORDER_NO_PREFIX; - - /** - * 退款订单 no 的前缀 - */ - @NotEmpty(message = "退款订单 no 的前缀不能为空") - private String refundNoPrefix = REFUND_NO_PREFIX; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java deleted file mode 100644 index c7be35f1ab..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java +++ /dev/null @@ -1,190 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.pay.core; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.map.MapUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; -import lombok.extern.slf4j.Slf4j; - -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_ORDER_EXTENSION_NOT_FOUND; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.REFUND_NOT_FOUND; - -/** - * 钱包支付的 PayClient 实现类 - * - * @author jason - */ -@Slf4j -public class WalletPayClient extends AbstractPayClient { - - public static final String USER_ID_KEY = "user_id"; - public static final String USER_TYPE_KEY = "user_type"; - - private PayWalletService wallService; - private PayWalletTransactionService walletTransactionService; - private PayOrderService orderService; - private PayRefundService refundService; - - public WalletPayClient(Long channelId, NonePayClientConfig config) { - super(channelId, PayChannelEnum.WALLET.getCode(), config); - } - - @Override - protected void doInit() { - if (wallService == null) { - wallService = SpringUtil.getBean(PayWalletService.class); - } - if (walletTransactionService == null) { - walletTransactionService = SpringUtil.getBean(PayWalletTransactionService.class); - } - } - - @Override - protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - try { - Long userId = MapUtil.getLong(reqDTO.getChannelExtras(), USER_ID_KEY); - Integer userType = MapUtil.getInt(reqDTO.getChannelExtras(), USER_TYPE_KEY); - Assert.notNull(userId, "用户 id 不能为空"); - Assert.notNull(userType, "用户类型不能为空"); - PayWalletTransactionDO transaction = wallService.orderPay(userId, userType, reqDTO.getOutTradeNo(), - reqDTO.getPrice()); - return PayOrderRespDTO.successOf(transaction.getNo(), transaction.getCreator(), - transaction.getCreateTime(), - reqDTO.getOutTradeNo(), transaction); - } catch (Throwable ex) { - log.error("[doUnifiedOrder] 失败", ex); - Integer errorCode = INTERNAL_SERVER_ERROR.getCode(); - String errorMsg = INTERNAL_SERVER_ERROR.getMsg(); - if (ex instanceof ServiceException) { - ServiceException serviceException = (ServiceException) ex; - errorCode = serviceException.getCode(); - errorMsg = serviceException.getMessage(); - } - return PayOrderRespDTO.closedOf(String.valueOf(errorCode), errorMsg, - reqDTO.getOutTradeNo(), ""); - } - } - - @Override - protected PayOrderRespDTO doParseOrderNotify(Map params, String body) { - throw new UnsupportedOperationException("钱包支付无支付回调"); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) { - if (orderService == null) { - orderService = SpringUtil.getBean(PayOrderService.class); - } - PayOrderExtensionDO orderExtension = orderService.getOrderExtensionByNo(outTradeNo); - // 支付交易拓展单不存在, 返回关闭状态 - if (orderExtension == null) { - return PayOrderRespDTO.closedOf(String.valueOf(PAY_ORDER_EXTENSION_NOT_FOUND.getCode()), - PAY_ORDER_EXTENSION_NOT_FOUND.getMsg(), outTradeNo, ""); - } - // 关闭状态 - if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) { - return PayOrderRespDTO.closedOf(orderExtension.getChannelErrorCode(), - orderExtension.getChannelErrorMsg(), outTradeNo, ""); - } - // 成功状态 - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { - PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransaction( - String.valueOf(orderExtension.getOrderId()), PayWalletBizTypeEnum.PAYMENT); - Assert.notNull(walletTransaction, "支付单 {} 钱包流水不能为空", outTradeNo); - return PayOrderRespDTO.successOf(walletTransaction.getNo(), walletTransaction.getCreator(), - walletTransaction.getCreateTime(), outTradeNo, walletTransaction); - } - // 其它状态为无效状态 - log.error("[doGetOrder] 支付单 {} 的状态不正确", outTradeNo); - throw new IllegalStateException(String.format("支付单[%s] 状态不正确", outTradeNo)); - } - - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - try { - PayWalletTransactionDO payWalletTransaction = wallService.orderRefund(reqDTO.getOutRefundNo(), - reqDTO.getRefundPrice(), reqDTO.getReason()); - return PayRefundRespDTO.successOf(payWalletTransaction.getNo(), payWalletTransaction.getCreateTime(), - reqDTO.getOutRefundNo(), payWalletTransaction); - } catch (Throwable ex) { - log.error("[doUnifiedRefund] 失败", ex); - Integer errorCode = INTERNAL_SERVER_ERROR.getCode(); - String errorMsg = INTERNAL_SERVER_ERROR.getMsg(); - if (ex instanceof ServiceException) { - ServiceException serviceException = (ServiceException) ex; - errorCode = serviceException.getCode(); - errorMsg = serviceException.getMessage(); - } - return PayRefundRespDTO.failureOf(String.valueOf(errorCode), errorMsg, - reqDTO.getOutRefundNo(), ""); - } - } - - @Override - protected PayRefundRespDTO doParseRefundNotify(Map params, String body) { - throw new UnsupportedOperationException("钱包支付无退款回调"); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) { - if (refundService == null) { - refundService = SpringUtil.getBean(PayRefundService.class); - } - PayRefundDO payRefund = refundService.getRefundByNo(outRefundNo); - // 支付退款单不存在, 返回退款失败状态 - if (payRefund == null) { - return PayRefundRespDTO.failureOf(String.valueOf(REFUND_NOT_FOUND), REFUND_NOT_FOUND.getMsg(), - outRefundNo, ""); - } - // 退款失败 - if (PayRefundStatusRespEnum.isFailure(payRefund.getStatus())) { - return PayRefundRespDTO.failureOf(payRefund.getChannelErrorCode(), payRefund.getChannelErrorMsg(), - outRefundNo, ""); - } - // 退款成功 - if (PayRefundStatusRespEnum.isSuccess(payRefund.getStatus())) { - PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransaction( - String.valueOf(payRefund.getId()), PayWalletBizTypeEnum.PAYMENT_REFUND); - Assert.notNull(walletTransaction, "支付退款单 {} 钱包流水不能为空", outRefundNo); - return PayRefundRespDTO.successOf(walletTransaction.getNo(), walletTransaction.getCreateTime(), - outRefundNo, walletTransaction); - } - // 其它状态为无效状态 - log.error("[doGetRefund] 支付退款单 {} 的状态不正确", outRefundNo); - throw new IllegalStateException(String.format("支付退款单[%s] 状态不正确", outRefundNo)); - } - - @Override - public PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { - throw new UnsupportedOperationException("待实现"); - } - - @Override - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) { - throw new UnsupportedOperationException("待实现"); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/web/config/PayWebConfiguration.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/web/config/PayWebConfiguration.java deleted file mode 100644 index 4a9dbb4d17..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/web/config/PayWebConfiguration.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.web.config; - -import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration; -import org.springdoc.core.models.GroupedOpenApi; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * pay 模块的 web 组件的 Configuration - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -public class PayWebConfiguration { - - /** - * pay 模块的 API 分组 - */ - @Bean - public GroupedOpenApi payGroupedOpenApi() { - return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("pay"); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/web/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/web/package-info.java deleted file mode 100644 index 03bfad9787..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/web/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * pay 模块的 web 配置 - */ -package cn.iocoder.yudao.module.pay.framework.web; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/notify/PayNotifyJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/notify/PayNotifyJob.java deleted file mode 100644 index e95bb0a8ea..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/notify/PayNotifyJob.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.notify; - -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -/** - * 支付通知 Job - * 通过不断扫描待通知的 PayNotifyTaskDO 记录,回调业务线的回调接口 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class PayNotifyJob implements JobHandler { - - @Resource - private PayNotifyService payNotifyService; - - @Override - @TenantJob - public String execute(String param) throws Exception { - int notifyCount = payNotifyService.executeNotify(); - return String.format("执行支付通知 %s 个", notifyCount); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderExpireJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderExpireJob.java deleted file mode 100644 index 8f957377f9..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderExpireJob.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.order; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -/** - * 支付订单的过期 Job - * - * 支付超过过期时间时,支付渠道是不会通知进行过期,所以需要定时进行过期关闭。 - * - * @author 芋道源码 - */ -@Component -public class PayOrderExpireJob implements JobHandler { - - @Resource - private PayOrderService orderService; - - @Override - @TenantJob - public String execute(String param) { - int count = orderService.expireOrder(); - return StrUtil.format("支付过期 {} 个", count); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderSyncJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderSyncJob.java deleted file mode 100644 index c3b4baa350..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderSyncJob.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.order; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; - -/** - * 支付订单的同步 Job - * - * 由于支付订单的状态,是由支付渠道异步通知进行同步,考虑到异步通知可能会失败(小概率),所以需要定时进行同步。 - * - * @author 芋道源码 - */ -@Component -public class PayOrderSyncJob implements JobHandler { - - /** - * 同步创建时间在 N 分钟之前的订单 - * - * 为什么同步 10 分钟之前的订单? - * 因为一个订单发起支付,到支付成功,大多数在 10 分钟内,需要保证轮询到。 - * 如果设置为 30、60 或者更大时间范围,会导致轮询的订单太多,影响性能。当然,你也可以根据自己的业务情况来处理。 - */ - private static final Duration CREATE_TIME_DURATION_BEFORE = Duration.ofMinutes(10); - - @Resource - private PayOrderService orderService; - - @Override - @TenantJob - public String execute(String param) { - LocalDateTime minCreateTime = LocalDateTime.now().minus(CREATE_TIME_DURATION_BEFORE); - int count = orderService.syncOrder(minCreateTime); - return StrUtil.format("同步支付订单 {} 个", count); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/refund/PayRefundSyncJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/refund/PayRefundSyncJob.java deleted file mode 100644 index 0d5c850373..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/refund/PayRefundSyncJob.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.refund; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -/** - * 退款订单的同步 Job - * - * 由于退款订单的状态,是由支付渠道异步通知进行同步,考虑到异步通知可能会失败(小概率),所以需要定时进行同步。 - * - * @author 芋道源码 - */ -@Component -public class PayRefundSyncJob implements JobHandler { - - @Resource - private PayRefundService refundService; - - @Override - @TenantJob - public String execute(String param) { - int count = refundService.syncRefund(); - return StrUtil.format("同步退款订单 {} 个", count); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/transfer/PayTransferSyncJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/transfer/PayTransferSyncJob.java deleted file mode 100644 index d8f132194d..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/transfer/PayTransferSyncJob.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.transfer; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; - -/** - * 转账订单的同步 Job - * - * 由于转账订单的转账结果,有些渠道是异步通知进行同步的,考虑到异步通知可能会失败(小概率),所以需要定时进行同步。 - * - * @author jason - */ -@Component -public class PayTransferSyncJob implements JobHandler { - - @Resource - private PayTransferService transferService; - - @Override - @TenantJob - public String execute(String param) { - int count = transferService.syncTransfer(); - return StrUtil.format("同步转账订单 {} 个", count); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/package-info.java deleted file mode 100644 index 40ab66da08..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * pay 模块,我们放支付业务,提供业务的支付能力。 - * 例如说:商户、应用、支付、退款等等 - * - * 1. Controller URL:以 /pay/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 pay_ 开头,方便在数据库中区分 - * - * 注意,由于 Pay 模块和 Trade 模块,容易重名,所以类名都加载 Pay 的前缀~ - */ -package cn.iocoder.yudao.module.pay; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java deleted file mode 100644 index c7a54bdafe..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.app; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 支付应用 Service 接口 - * - * @author 芋艿 - */ -public interface PayAppService { - - /** - * 创建支付应用 - * - * @param createReqVO 创建 - * @return 编号 - */ - Long createApp(@Valid PayAppCreateReqVO createReqVO); - - /** - * 更新支付应用 - * - * @param updateReqVO 更新 - */ - void updateApp(@Valid PayAppUpdateReqVO updateReqVO); - - /** - * 修改应用状态 - * - * @param id 应用编号 - * @param status 状态 - */ - void updateAppStatus(Long id, Integer status); - - /** - * 删除支付应用 - * - * @param id 编号 - */ - void deleteApp(Long id); - - /** - * 获得支付应用 - * - * @param id 编号 - * @return 支付应用 - */ - PayAppDO getApp(Long id); - - /** - * 获得支付应用列表 - * - * @param ids 编号 - * @return 支付应用列表 - */ - List getAppList(Collection ids); - - /** - * 获得支付应用列表 - * - * @return 支付应用列表 - */ - List getAppList(); - - /** - * 获得支付应用分页 - * - * @param pageReqVO 分页查询 - * @return 支付应用分页 - */ - PageResult getAppPage(PayAppPageReqVO pageReqVO); - - /** - * 获得指定编号的商户 Map - * - * @param ids 应用编号集合 - * @return 商户 Map - */ - default Map getAppMap(Collection ids) { - List list = getAppList(ids); - return CollectionUtils.convertMap(list, PayAppDO::getId); - } - - /** - * 支付应用的合法性 - * - * 如果不合法,抛出 {@link ServiceException} 业务异常 - * - * @param id 应用编号 - * @return 应用 - */ - PayAppDO validPayApp(Long id); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java deleted file mode 100644 index 786b70c9fe..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.app; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.app.PayAppConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.mysql.app.PayAppMapper; -import cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 支付应用 Service 实现类 - * - * @author aquan - */ -@Service -@Validated -public class PayAppServiceImpl implements PayAppService { - - @Resource - private PayAppMapper appMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖报错 - private PayOrderService orderService; - @Resource - @Lazy // 延迟加载,避免循环依赖报错 - private PayRefundService refundService; - - @Override - public Long createApp(PayAppCreateReqVO createReqVO) { - // 插入 - PayAppDO app = PayAppConvert.INSTANCE.convert(createReqVO); - appMapper.insert(app); - // 返回 - return app.getId(); - } - - @Override - public void updateApp(PayAppUpdateReqVO updateReqVO) { - // 校验存在 - validateAppExists(updateReqVO.getId()); - // 更新 - PayAppDO updateObj = PayAppConvert.INSTANCE.convert(updateReqVO); - appMapper.updateById(updateObj); - } - - @Override - public void updateAppStatus(Long id, Integer status) { - // 校验商户存在 - validateAppExists(id); - // 更新状态 - appMapper.updateById(new PayAppDO().setId(id).setStatus(status)); - } - - @Override - public void deleteApp(Long id) { - // 校验存在 - validateAppExists(id); - // 校验关联数据是否存在 - if (orderService.getOrderCountByAppId(id) > 0) { - throw exception(APP_EXIST_ORDER_CANT_DELETE); - } - if (refundService.getRefundCountByAppId(id) > 0) { - throw exception(APP_EXIST_REFUND_CANT_DELETE); - } - - // 删除 - appMapper.deleteById(id); - } - - private void validateAppExists(Long id) { - if (appMapper.selectById(id) == null) { - throw exception(APP_NOT_FOUND); - } - } - - @Override - public PayAppDO getApp(Long id) { - return appMapper.selectById(id); - } - - @Override - public List getAppList(Collection ids) { - return appMapper.selectBatchIds(ids); - } - - @Override - public List getAppList() { - return appMapper.selectList(); - } - - @Override - public PageResult getAppPage(PayAppPageReqVO pageReqVO) { - return appMapper.selectPage(pageReqVO); - } - - @Override - public PayAppDO validPayApp(Long id) { - PayAppDO app = appMapper.selectById(id); - // 校验是否存在 - if (app == null) { - throw exception(ErrorCodeConstants.APP_NOT_FOUND); - } - // 校验是否禁用 - if (CommonStatusEnum.DISABLE.getStatus().equals(app.getStatus())) { - throw exception(ErrorCodeConstants.APP_IS_DISABLE); - } - return app; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java deleted file mode 100644 index dcd075db90..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.channel; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 支付渠道 Service 接口 - * - * @author aquan - */ -public interface PayChannelService { - - /** - * 创建支付渠道 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createChannel(@Valid PayChannelCreateReqVO createReqVO); - - /** - * 更新支付渠道 - * - * @param updateReqVO 更新信息 - */ - void updateChannel(@Valid PayChannelUpdateReqVO updateReqVO); - - /** - * 删除支付渠道 - * - * @param id 编号 - */ - void deleteChannel(Long id); - - /** - * 获得支付渠道 - * - * @param id 编号 - * @return 支付渠道 - */ - PayChannelDO getChannel(Long id); - - /** - * 根据支付应用 ID 集合,获得支付渠道列表 - * - * @param appIds 应用编号集合 - * @return 支付渠道列表 - */ - List getChannelListByAppIds(Collection appIds); - - /** - * 根据条件获取渠道 - * - * @param appId 应用编号 - * @param code 渠道编码 - * @return 数量 - */ - PayChannelDO getChannelByAppIdAndCode(Long appId, String code); - - /** - * 支付渠道的合法性 - * - * 如果不合法,抛出 {@link ServiceException} 业务异常 - * - * @param id 渠道编号 - * @return 渠道信息 - */ - PayChannelDO validPayChannel(Long id); - - /** - * 支付渠道的合法性 - * - * 如果不合法,抛出 {@link ServiceException} 业务异常 - * - * @param appId 应用编号 - * @param code 支付渠道 - * @return 渠道信息 - */ - PayChannelDO validPayChannel(Long appId, String code); - - /** - * 获得指定应用的开启的渠道列表 - * - * @param appId 应用编号 - * @return 渠道列表 - */ - List getEnableChannelList(Long appId); - - /** - * 获得指定编号的支付客户端 - * - * @param id 编号 - * @return 支付客户端 - */ - PayClient getPayClient(Long id); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java deleted file mode 100644 index 522b2b0ae5..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java +++ /dev/null @@ -1,208 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.channel; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.channel.PayChannelConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.mysql.channel.PayChannelMapper; -import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.PostConstruct; -import jakarta.annotation.Resource; -import jakarta.validation.Validator; -import java.time.Duration; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 支付渠道 Service 实现类 - * - * @author aquan - */ -@Service -@Slf4j -@Validated -public class PayChannelServiceImpl implements PayChannelService { - - /** - * {@link PayClient} 缓存,通过它异步清空 smsClientFactory - */ - @Getter - private final LoadingCache clientCache = buildAsyncReloadingCache(Duration.ofSeconds(10L), - new CacheLoader() { - - @Override - public PayClient load(Long id) { - // 查询,然后尝试清空 - PayChannelDO channel = payChannelMapper.selectById(id); - if (channel != null) { - payClientFactory.createOrUpdatePayClient(channel.getId(), channel.getCode(), channel.getConfig()); - } - return payClientFactory.getPayClient(id); - } - - }); - - @Resource - private PayClientFactory payClientFactory; - - @Resource - private PayChannelMapper payChannelMapper; - - @Resource - private Validator validator; - - /** - * 初始化,为了注册钱包 - */ - @PostConstruct - public void init() { - payClientFactory.registerPayClientClass(PayChannelEnum.WALLET, WalletPayClient.class); - } - - @Override - public Long createChannel(PayChannelCreateReqVO reqVO) { - // 断言是否有重复的 - PayChannelDO dbChannel = getChannelByAppIdAndCode(reqVO.getAppId(), reqVO.getCode()); - if (dbChannel != null) { - throw exception(CHANNEL_EXIST_SAME_CHANNEL_ERROR); - } - - // 新增渠道 - PayChannelDO channel = PayChannelConvert.INSTANCE.convert(reqVO) - .setConfig(parseConfig(reqVO.getCode(), reqVO.getConfig())); - payChannelMapper.insert(channel); - return channel.getId(); - } - - @Override - public void updateChannel(PayChannelUpdateReqVO updateReqVO) { - // 校验存在 - PayChannelDO dbChannel = validateChannelExists(updateReqVO.getId()); - - // 更新 - PayChannelDO channel = PayChannelConvert.INSTANCE.convert(updateReqVO) - .setConfig(parseConfig(dbChannel.getCode(), updateReqVO.getConfig())); - payChannelMapper.updateById(channel); - - // 清空缓存 - clearCache(channel.getId()); - } - - /** - * 解析并校验配置 - * - * @param code 渠道编码 - * @param configStr 配置 - * @return 支付配置 - */ - private PayClientConfig parseConfig(String code, String configStr) { - // 解析配置 - Class payClass = PayChannelEnum.getByCode(code).getConfigClass(); - if (ObjectUtil.isNull(payClass)) { - throw exception(CHANNEL_NOT_FOUND); - } - PayClientConfig config = JsonUtils.parseObject2(configStr, payClass); - Assert.notNull(config); - - // 验证参数 - config.validate(validator); - return config; - } - - @Override - public void deleteChannel(Long id) { - // 校验存在 - validateChannelExists(id); - - // 删除 - payChannelMapper.deleteById(id); - - // 清空缓存 - clearCache(id); - } - - /** - * 删除缓存 - * - * @param id 渠道编号 - */ - private void clearCache(Long id) { - clientCache.invalidate(id); - } - - private PayChannelDO validateChannelExists(Long id) { - PayChannelDO channel = payChannelMapper.selectById(id); - if (channel == null) { - throw exception(CHANNEL_NOT_FOUND); - } - return channel; - } - - @Override - public PayChannelDO getChannel(Long id) { - return payChannelMapper.selectById(id); - } - - @Override - public List getChannelListByAppIds(Collection appIds) { - return payChannelMapper.selectListByAppIds(appIds); - } - - @Override - public PayChannelDO getChannelByAppIdAndCode(Long appId, String code) { - return payChannelMapper.selectByAppIdAndCode(appId, code); - } - - @Override - public PayChannelDO validPayChannel(Long id) { - PayChannelDO channel = payChannelMapper.selectById(id); - validPayChannel(channel); - return channel; - } - - @Override - public PayChannelDO validPayChannel(Long appId, String code) { - PayChannelDO channel = payChannelMapper.selectByAppIdAndCode(appId, code); - validPayChannel(channel); - return channel; - } - - private void validPayChannel(PayChannelDO channel) { - if (channel == null) { - throw exception(CHANNEL_NOT_FOUND); - } - if (CommonStatusEnum.DISABLE.getStatus().equals(channel.getStatus())) { - throw exception(CHANNEL_IS_DISABLE); - } - } - - @Override - public List getEnableChannelList(Long appId) { - return payChannelMapper.selectListByAppId(appId, CommonStatusEnum.ENABLE.getStatus()); - } - - @Override - public PayClient getPayClient(Long id) { - return clientCache.getUnchecked(id); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderService.java deleted file mode 100644 index 512007e7dd..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderService.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.demo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.order.PayDemoOrderCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; - -import jakarta.validation.Valid; - -/** - * 示例订单 Service 接口 - * - * @author 芋道源码 - */ -public interface PayDemoOrderService { - - /** - * 创建示例订单 - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDemoOrder(Long userId, @Valid PayDemoOrderCreateReqVO createReqVO); - - /** - * 获得示例订单 - * - * @param id 编号 - * @return 示例订单 - */ - PayDemoOrderDO getDemoOrder(Long id); - - /** - * 获得示例订单分页 - * - * @param pageReqVO 分页查询 - * @return 示例订单分页 - */ - PageResult getDemoOrderPage(PageParam pageReqVO); - - /** - * 更新示例订单为已支付 - * - * @param id 编号 - * @param payOrderId 支付订单号 - */ - void updateDemoOrderPaid(Long id, Long payOrderId); - - /** - * 发起示例订单的退款 - * - * @param id 编号 - * @param userIp 用户编号 - */ - void refundDemoOrder(Long id, String userIp); - - /** - * 更新示例订单为已退款 - * - * @param id 编号 - * @param payRefundId 退款订单号 - */ - void updateDemoOrderRefunded(Long id, Long payRefundId); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderServiceImpl.java deleted file mode 100644 index b86342841d..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderServiceImpl.java +++ /dev/null @@ -1,265 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.demo; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.order.PayDemoOrderCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; -import cn.iocoder.yudao.module.pay.dal.mysql.demo.PayDemoOrderMapper; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import static cn.hutool.core.util.ObjectUtil.notEqual; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 示例订单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class PayDemoOrderServiceImpl implements PayDemoOrderService { - - /** - * 接入的实力应用编号 - * - * 从 [支付管理 -> 应用信息] 里添加 - */ - private static final Long PAY_APP_ID = 7L; - - /** - * 商品信息 Map - * - * key:商品编号 - * value:[商品名、商品价格] - */ - private final Map spuNames = new HashMap<>(); - - @Resource - private PayOrderApi payOrderApi; - @Resource - private PayRefundApi payRefundApi; - - @Resource - private PayDemoOrderMapper payDemoOrderMapper; - - public PayDemoOrderServiceImpl() { - spuNames.put(1L, new Object[]{"华为手机", 1}); - spuNames.put(2L, new Object[]{"小米电视", 10}); - spuNames.put(3L, new Object[]{"苹果手表", 100}); - spuNames.put(4L, new Object[]{"华硕笔记本", 1000}); - spuNames.put(5L, new Object[]{"蔚来汽车", 200000}); - } - - @Override - public Long createDemoOrder(Long userId, PayDemoOrderCreateReqVO createReqVO) { - // 1.1 获得商品 - Object[] spu = spuNames.get(createReqVO.getSpuId()); - Assert.notNull(spu, "商品({}) 不存在", createReqVO.getSpuId()); - String spuName = (String) spu[0]; - Integer price = (Integer) spu[1]; - // 1.2 插入 demo 订单 - PayDemoOrderDO demoOrder = new PayDemoOrderDO().setUserId(userId) - .setSpuId(createReqVO.getSpuId()).setSpuName(spuName) - .setPrice(price).setPayStatus(false).setRefundPrice(0); - payDemoOrderMapper.insert(demoOrder); - - // 2.1 创建支付单 - Long payOrderId = payOrderApi.createOrder(new PayOrderCreateReqDTO() - .setAppId(PAY_APP_ID).setUserIp(getClientIP()) // 支付应用 - .setMerchantOrderId(demoOrder.getId().toString()) // 业务的订单编号 - .setSubject(spuName).setBody("").setPrice(price) // 价格信息 - .setExpireTime(addTime(Duration.ofHours(2L)))); // 支付的过期时间 - // 2.2 更新支付单到 demo 订单 - payDemoOrderMapper.updateById(new PayDemoOrderDO().setId(demoOrder.getId()) - .setPayOrderId(payOrderId)); - // 返回 - return demoOrder.getId(); - } - - @Override - public PayDemoOrderDO getDemoOrder(Long id) { - return payDemoOrderMapper.selectById(id); - } - - @Override - public PageResult getDemoOrderPage(PageParam pageReqVO) { - return payDemoOrderMapper.selectPage(pageReqVO); - } - - @Override - public void updateDemoOrderPaid(Long id, Long payOrderId) { - // 校验并获得支付订单(可支付) - PayOrderRespDTO payOrder = validateDemoOrderCanPaid(id, payOrderId); - - // 更新 PayDemoOrderDO 状态为已支付 - int updateCount = payDemoOrderMapper.updateByIdAndPayed(id, false, - new PayDemoOrderDO().setPayStatus(true).setPayTime(LocalDateTime.now()) - .setPayChannelCode(payOrder.getChannelCode())); - if (updateCount == 0) { - throw exception(DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - } - - /** - * 校验交易订单满足被支付的条件 - * - * 1. 交易订单未支付 - * 2. 支付单已支付 - * - * @param id 交易订单编号 - * @param payOrderId 支付订单编号 - * @return 交易订单 - */ - private PayOrderRespDTO validateDemoOrderCanPaid(Long id, Long payOrderId) { - // 1.1 校验订单是否存在 - PayDemoOrderDO order = payDemoOrderMapper.selectById(id); - if (order == null) { - throw exception(DEMO_ORDER_NOT_FOUND); - } - // 1.2 校验订单未支付 - if (order.getPayStatus()) { - log.error("[validateDemoOrderCanPaid][order({}) 不处于待支付状态,请进行处理!order 数据是:{}]", - id, toJsonString(order)); - throw exception(DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - // 1.3 校验支付订单匹配 - if (notEqual(order.getPayOrderId(), payOrderId)) { // 支付单号 - log.error("[validateDemoOrderCanPaid][order({}) 支付单不匹配({}),请进行处理!order 数据是:{}]", - id, payOrderId, toJsonString(order)); - throw exception(DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - - // 2.1 校验支付单是否存在 - PayOrderRespDTO payOrder = payOrderApi.getOrder(payOrderId); - if (payOrder == null) { - log.error("[validateDemoOrderCanPaid][order({}) payOrder({}) 不存在,请进行处理!]", id, payOrderId); - throw exception(PAY_ORDER_NOT_FOUND); - } - // 2.2 校验支付单已支付 - if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) { - log.error("[validateDemoOrderCanPaid][order({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]", - id, payOrderId, toJsonString(payOrder)); - throw exception(DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS); - } - // 2.3 校验支付金额一致 - if (notEqual(payOrder.getPrice(), order.getPrice())) { - log.error("[validateDemoOrderCanPaid][order({}) payOrder({}) 支付金额不匹配,请进行处理!order 数据是:{},payOrder 数据是:{}]", - id, payOrderId, toJsonString(order), toJsonString(payOrder)); - throw exception(DEMO_ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH); - } - // 2.4 校验支付订单匹配(二次) - if (notEqual(payOrder.getMerchantOrderId(), id.toString())) { - log.error("[validateDemoOrderCanPaid][order({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]", - id, payOrderId, toJsonString(payOrder)); - throw exception(DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - return payOrder; - } - - @Override - public void refundDemoOrder(Long id, String userIp) { - // 1. 校验订单是否可以退款 - PayDemoOrderDO order = validateDemoOrderCanRefund(id); - - // 2.1 生成退款单号 - // 一般来说,用户发起退款的时候,都会单独插入一个售后维权表,然后使用该表的 id 作为 refundId - // 这里我们是个简单的 demo,所以没有售后维权表,直接使用订单 id + "-refund" 来演示 - String refundId = order.getId() + "-refund"; - // 2.2 创建退款单 - Long payRefundId = payRefundApi.createRefund(new PayRefundCreateReqDTO() - .setAppId(PAY_APP_ID).setUserIp(getClientIP()) // 支付应用 - .setMerchantOrderId(String.valueOf(order.getId())) // 支付单号 - .setMerchantRefundId(refundId) - .setReason("想退钱").setPrice(order.getPrice()));// 价格信息 - // 2.3 更新退款单到 demo 订单 - payDemoOrderMapper.updateById(new PayDemoOrderDO().setId(id) - .setPayRefundId(payRefundId).setRefundPrice(order.getPrice())); - } - - private PayDemoOrderDO validateDemoOrderCanRefund(Long id) { - // 校验订单是否存在 - PayDemoOrderDO order = payDemoOrderMapper.selectById(id); - if (order == null) { - throw exception(DEMO_ORDER_NOT_FOUND); - } - // 校验订单是否支付 - if (!order.getPayStatus()) { - throw exception(DEMO_ORDER_REFUND_FAIL_NOT_PAID); - } - // 校验订单是否已退款 - if (order.getPayRefundId() != null) { - throw exception(DEMO_ORDER_REFUND_FAIL_REFUNDED); - } - return order; - } - - @Override - public void updateDemoOrderRefunded(Long id, Long payRefundId) { - // 1. 校验并获得退款订单(可退款) - PayRefundRespDTO payRefund = validateDemoOrderCanRefunded(id, payRefundId); - // 2.2 更新退款单到 demo 订单 - payDemoOrderMapper.updateById(new PayDemoOrderDO().setId(id) - .setRefundTime(payRefund.getSuccessTime())); - } - - private PayRefundRespDTO validateDemoOrderCanRefunded(Long id, Long payRefundId) { - // 1.1 校验示例订单 - PayDemoOrderDO order = payDemoOrderMapper.selectById(id); - if (order == null) { - throw exception(DEMO_ORDER_NOT_FOUND); - } - // 1.2 校验退款订单匹配 - if (Objects.equals(order.getPayOrderId(), payRefundId)) { - log.error("[validateDemoOrderCanRefunded][order({}) 退款单不匹配({}),请进行处理!order 数据是:{}]", - id, payRefundId, toJsonString(order)); - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_ORDER_ID_ERROR); - } - - // 2.1 校验退款订单 - PayRefundRespDTO payRefund = payRefundApi.getRefund(payRefundId); - if (payRefund == null) { - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_NOT_FOUND); - } - // 2.2 - if (!PayRefundStatusEnum.isSuccess(payRefund.getStatus())) { - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_NOT_SUCCESS); - } - // 2.3 校验退款金额一致 - if (notEqual(payRefund.getRefundPrice(), order.getPrice())) { - log.error("[validateDemoOrderCanRefunded][order({}) payRefund({}) 退款金额不匹配,请进行处理!order 数据是:{},payRefund 数据是:{}]", - id, payRefundId, toJsonString(order), toJsonString(payRefund)); - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_PRICE_NOT_MATCH); - } - // 2.4 校验退款订单匹配(二次) - if (notEqual(payRefund.getMerchantOrderId(), id.toString())) { - log.error("[validateDemoOrderCanRefunded][order({}) 退款单不匹配({}),请进行处理!payRefund 数据是:{}]", - id, payRefundId, toJsonString(payRefund)); - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_ORDER_ID_ERROR); - } - return payRefund; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferService.java deleted file mode 100644 index 9563c2a691..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferService.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.demo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoTransferDO; - -import jakarta.validation.Valid; - -/** - * 示例转账业务 Service 接口 - * - * @author jason - */ -public interface PayDemoTransferService { - - /** - * 创建转账业务示例订单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDemoTransfer(@Valid PayDemoTransferCreateReqVO createReqVO); - - /** - * 获得转账业务示例订单分页 - * - * @param pageVO 分页查询参数 - */ - PageResult getDemoTransferPage(PageParam pageVO); - - /** - * 更新转账业务示例订单的转账状态 - * - * @param id 编号 - * @param payTransferId 转账单编号 - */ - void updateDemoTransferStatus(Long id, Long payTransferId); -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java deleted file mode 100644 index 19c00fd598..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.demo; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.convert.demo.PayDemoTransferConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoTransferDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; -import cn.iocoder.yudao.module.pay.dal.mysql.demo.PayDemoTransferMapper; -import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum; -import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import jakarta.validation.Validator; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum.WAITING; - -/** - * 示例转账业务 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class PayDemoTransferServiceImpl implements PayDemoTransferService { - - /** - * 接入的实力应用编号 - - * 从 [支付管理 -> 应用信息] 里添加 - */ - private static final Long TRANSFER_APP_ID = 8L; - @Resource - private PayDemoTransferMapper demoTransferMapper; - @Resource - private PayTransferService payTransferService; - @Resource - private Validator validator; - - @Override - public Long createDemoTransfer(@Valid PayDemoTransferCreateReqVO vo) { - // 1 校验参数 - vo.validate(validator); - // 2 保存示例转账业务表 - PayDemoTransferDO demoTransfer = PayDemoTransferConvert.INSTANCE.convert(vo) - .setAppId(TRANSFER_APP_ID).setTransferStatus(WAITING.getStatus()); - demoTransferMapper.insert(demoTransfer); - return demoTransfer.getId(); - } - - @Override - public PageResult getDemoTransferPage(PageParam pageVO) { - return demoTransferMapper.selectPage(pageVO); - } - - @Override - public void updateDemoTransferStatus(Long id, Long payTransferId) { - PayTransferDO payTransfer = validateDemoTransferStatusCanUpdate(id, payTransferId); - // 更新示例订单状态 - if (payTransfer != null) { - demoTransferMapper.updateById(new PayDemoTransferDO().setId(id) - .setPayTransferId(payTransferId) - .setPayChannelCode(payTransfer.getChannelCode()) - .setTransferStatus(payTransfer.getStatus()) - .setTransferTime(payTransfer.getSuccessTime())); - } - } - - private PayTransferDO validateDemoTransferStatusCanUpdate(Long id, Long payTransferId) { - PayDemoTransferDO demoTransfer = demoTransferMapper.selectById(id); - if (demoTransfer == null) { - throw exception(DEMO_TRANSFER_NOT_FOUND); - } - if (PayTransferStatusEnum.isSuccess(demoTransfer.getTransferStatus()) - || PayTransferStatusEnum.isClosed(demoTransfer.getTransferStatus())) { - // 无需更新返回 null - return null; - } - PayTransferDO transfer = payTransferService.getTransfer(payTransferId); - if (transfer == null) { - throw exception(PAY_TRANSFER_NOT_FOUND); - } - if (!Objects.equals(demoTransfer.getPrice(), transfer.getPrice())) { - throw exception(DEMO_TRANSFER_FAIL_PRICE_NOT_MATCH); - } - if (ObjectUtil.notEqual(transfer.getMerchantTransferId(), id.toString())) { - throw exception(DEMO_TRANSFER_FAIL_TRANSFER_ID_ERROR); - } - // TODO 校验账号 - return transfer; - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyService.java deleted file mode 100644 index ed9399772d..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyService.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.notify; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; - -import java.util.List; - -/** - * 回调通知 Service 接口 - * - * @author 芋道源码 - */ -public interface PayNotifyService { - - /** - * 创建回调通知任务 - * - * @param type 类型 - * @param dataId 数据编号 - */ - void createPayNotifyTask(Integer type, Long dataId); - - /** - * 执行回调通知 - * - * 注意,该方法提供给定时任务调用。目前是 yudao-server 进行调用 - * @return 通知数量 - */ - int executeNotify() throws InterruptedException; - - /** - * 获得回调通知 - * - * @param id 编号 - * @return 回调通知 - */ - PayNotifyTaskDO getNotifyTask(Long id); - - /** - * 获得回调通知分页 - * - * @param pageReqVO 分页查询 - * @return 回调通知分页 - */ - PageResult getNotifyTaskPage(PayNotifyTaskPageReqVO pageReqVO); - - /** - * 获得回调日志列表 - * - * @param taskId 任务编号 - * @return 日志列表 - */ - List getNotifyLogList(Long taskId); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java deleted file mode 100644 index ba4c7ee9b4..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java +++ /dev/null @@ -1,308 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.notify; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.exceptions.ExceptionUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.hutool.http.HttpResponse; -import cn.hutool.http.HttpUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayTransferNotifyReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; -import cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyLogMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyTaskMapper; -import cn.iocoder.yudao.module.pay.dal.redis.notify.PayNotifyLockRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.module.pay.framework.job.config.PayJobConfiguration.NOTIFY_THREAD_POOL_TASK_EXECUTOR; - -/** - * 支付通知 Core Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Valid -@Slf4j -public class PayNotifyServiceImpl implements PayNotifyService { - - /** - * 通知超时时间,单位:秒 - */ - public static final int NOTIFY_TIMEOUT = 120; - /** - * {@link #NOTIFY_TIMEOUT} 的毫秒 - */ - public static final long NOTIFY_TIMEOUT_MILLIS = 120 * DateUtils.SECOND_MILLIS; - - @Resource - @Lazy // 循环依赖,避免报错 - private PayOrderService orderService; - @Resource - @Lazy // 循环依赖,避免报错 - private PayRefundService refundService; - @Resource - @Lazy // 循环依赖,避免报错 - private PayTransferService transferService; - - @Resource - private PayNotifyTaskMapper notifyTaskMapper; - @Resource - private PayNotifyLogMapper notifyLogMapper; - - @Resource(name = NOTIFY_THREAD_POOL_TASK_EXECUTOR) - private ThreadPoolTaskExecutor threadPoolTaskExecutor; - - @Resource - private PayNotifyLockRedisDAO notifyLockCoreRedisDAO; - - @Override - @Transactional(rollbackFor = Exception.class) - public void createPayNotifyTask(Integer type, Long dataId) { - PayNotifyTaskDO task = new PayNotifyTaskDO().setType(type).setDataId(dataId); - task.setStatus(PayNotifyStatusEnum.WAITING.getStatus()).setNextNotifyTime(LocalDateTime.now()) - .setNotifyTimes(0).setMaxNotifyTimes(PayNotifyTaskDO.NOTIFY_FREQUENCY.length + 1); - // 补充 appId + notifyUrl 字段 - if (Objects.equals(task.getType(), PayNotifyTypeEnum.ORDER.getType())) { - PayOrderDO order = orderService.getOrder(task.getDataId()); // 不进行非空判断,有问题直接异常 - task.setAppId(order.getAppId()). - setMerchantOrderId(order.getMerchantOrderId()).setNotifyUrl(order.getNotifyUrl()); - } else if (Objects.equals(task.getType(), PayNotifyTypeEnum.REFUND.getType())) { - PayRefundDO refundDO = refundService.getRefund(task.getDataId()); - task.setAppId(refundDO.getAppId()) - .setMerchantOrderId(refundDO.getMerchantOrderId()).setNotifyUrl(refundDO.getNotifyUrl()); - } else if (Objects.equals(task.getType(), PayNotifyTypeEnum.TRANSFER.getType())) { - PayTransferDO transfer = transferService.getTransfer(task.getDataId()); - task.setAppId(transfer.getAppId()).setMerchantTransferId(transfer.getMerchantTransferId()) - .setNotifyUrl(transfer.getNotifyUrl()); - } - - // 执行插入 - notifyTaskMapper.insert(task); - - // 必须在事务提交后,在发起任务,否则 PayNotifyTaskDO 还没入库,就提前回调接入的业务 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - @Override - public void afterCommit() { - executeNotify(task); - } - }); - } - - @Override - public int executeNotify() throws InterruptedException { - // 获得需要通知的任务 - List tasks = notifyTaskMapper.selectListByNotify(); - if (CollUtil.isEmpty(tasks)) { - return 0; - } - - // 遍历,逐个通知 - CountDownLatch latch = new CountDownLatch(tasks.size()); - tasks.forEach(task -> threadPoolTaskExecutor.execute(() -> { - try { - executeNotify(task); - } finally { - latch.countDown(); - } - })); - // 等待完成 - awaitExecuteNotify(latch); - // 返回执行完成的任务数(成功 + 失败) - return tasks.size(); - } - - /** - * 等待全部支付通知的完成 - * 每 1 秒会打印一次剩余任务数量 - * - * @param latch Latch - * @throws InterruptedException 如果被打断 - */ - private void awaitExecuteNotify(CountDownLatch latch) throws InterruptedException { - long size = latch.getCount(); - for (int i = 0; i < NOTIFY_TIMEOUT; i++) { - if (latch.await(1L, TimeUnit.SECONDS)) { - return; - } - log.info("[awaitExecuteNotify][任务处理中, 总任务数({}) 剩余任务数({})]", size, latch.getCount()); - } - log.error("[awaitExecuteNotify][任务未处理完,总任务数({}) 剩余任务数({})]", size, latch.getCount()); - } - - /** - * 同步执行单个支付通知 - * - * @param task 通知任务 - */ - public void executeNotify(PayNotifyTaskDO task) { - // 分布式锁,避免并发问题 - notifyLockCoreRedisDAO.lock(task.getId(), NOTIFY_TIMEOUT_MILLIS, () -> { - // 校验,当前任务是否已经被通知过 - // 虽然已经通过分布式加锁,但是可能同时满足通知的条件,然后都去获得锁。此时,第一个执行完后,第二个还是能拿到锁,然后会再执行一次。 - // 因此,此处我们通过第 notifyTimes 通知次数是否匹配来判断 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - if (ObjectUtil.notEqual(task.getNotifyTimes(), dbTask.getNotifyTimes())) { - log.warn("[executeNotifySync][task({}) 任务被忽略,原因是它的通知不是第 ({}) 次,可能是因为并发执行了]", - JsonUtils.toJsonString(task), dbTask.getNotifyTimes()); - return; - } - - // 执行通知 - getSelf().executeNotify0(dbTask); - }); - } - - @Transactional(rollbackFor = Exception.class) - public void executeNotify0(PayNotifyTaskDO task) { - // 发起回调 - CommonResult invokeResult = null; - Throwable invokeException = null; - try { - invokeResult = executeNotifyInvoke(task); - } catch (Throwable e) { - invokeException = e; - } - - // 处理结果 - Integer newStatus = processNotifyResult(task, invokeResult, invokeException); - - // 记录 PayNotifyLog 日志 - String response = invokeException != null ? ExceptionUtil.getRootCauseMessage(invokeException) : - JsonUtils.toJsonString(invokeResult); - notifyLogMapper.insert(PayNotifyLogDO.builder().taskId(task.getId()) - .notifyTimes(task.getNotifyTimes() + 1).status(newStatus).response(response).build()); - } - - /** - * 执行单个支付任务的 HTTP 调用 - * - * @param task 通知任务 - * @return HTTP 响应 - */ - private CommonResult executeNotifyInvoke(PayNotifyTaskDO task) { - // 拼接 body 参数 - Object request; - if (Objects.equals(task.getType(), PayNotifyTypeEnum.ORDER.getType())) { - request = PayOrderNotifyReqDTO.builder().merchantOrderId(task.getMerchantOrderId()) - .payOrderId(task.getDataId()).build(); - } else if (Objects.equals(task.getType(), PayNotifyTypeEnum.REFUND.getType())) { - request = PayRefundNotifyReqDTO.builder().merchantOrderId(task.getMerchantOrderId()) - .payRefundId(task.getDataId()).build(); - } else if (Objects.equals(task.getType(), PayNotifyTypeEnum.TRANSFER.getType())) { - request = new PayTransferNotifyReqDTO().setMerchantTransferId(task.getMerchantTransferId()) - .setPayTransferId(task.getDataId()); - } else { - throw new RuntimeException("未知的通知任务类型:" + JsonUtils.toJsonString(task)); - } - // 拼接 header 参数 - Map headers = new HashMap<>(); - TenantUtils.addTenantHeader(headers, task.getTenantId()); - - // 发起请求 - try (HttpResponse response = HttpUtil.createPost(task.getNotifyUrl()) - .body(JsonUtils.toJsonString(request)).addHeaders(headers) - .timeout((int) NOTIFY_TIMEOUT_MILLIS).execute()) { - // 解析结果 - return JsonUtils.parseObject(response.body(), CommonResult.class); - } - } - - /** - * 处理并更新通知结果 - * - * @param task 通知任务 - * @param invokeResult 通知结果 - * @param invokeException 通知异常 - * @return 最终任务的状态 - */ - @VisibleForTesting - Integer processNotifyResult(PayNotifyTaskDO task, CommonResult invokeResult, Throwable invokeException) { - // 设置通用的更新 PayNotifyTaskDO 的字段 - PayNotifyTaskDO updateTask = new PayNotifyTaskDO() - .setId(task.getId()) - .setLastExecuteTime(LocalDateTime.now()) - .setNotifyTimes(task.getNotifyTimes() + 1); - - // 情况一:调用成功 - if (invokeResult != null && invokeResult.isSuccess()) { - updateTask.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()); - notifyTaskMapper.updateById(updateTask); - return updateTask.getStatus(); - } - - // 情况二:调用失败、调用异常 - // 2.1 超过最大回调次数 - if (updateTask.getNotifyTimes() >= PayNotifyTaskDO.NOTIFY_FREQUENCY.length) { - updateTask.setStatus(PayNotifyStatusEnum.FAILURE.getStatus()); - notifyTaskMapper.updateById(updateTask); - return updateTask.getStatus(); - } - // 2.2 未超过最大回调次数 - updateTask.setNextNotifyTime(addTime(Duration.ofSeconds(PayNotifyTaskDO.NOTIFY_FREQUENCY[updateTask.getNotifyTimes()]))); - updateTask.setStatus(invokeException != null ? PayNotifyStatusEnum.REQUEST_FAILURE.getStatus() - : PayNotifyStatusEnum.REQUEST_SUCCESS.getStatus()); - notifyTaskMapper.updateById(updateTask); - return updateTask.getStatus(); - } - - @Override - public PayNotifyTaskDO getNotifyTask(Long id) { - return notifyTaskMapper.selectById(id); - } - - @Override - public PageResult getNotifyTaskPage(PayNotifyTaskPageReqVO pageReqVO) { - return notifyTaskMapper.selectPage(pageReqVO); - } - - @Override - public List getNotifyLogList(Long taskId) { - return notifyLogMapper.selectListByTaskId(taskId); - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private PayNotifyServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderService.java deleted file mode 100755 index 9532de2d27..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderService.java +++ /dev/null @@ -1,140 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import java.time.LocalDateTime; -import java.util.List; - -/** - * 支付订单 Service 接口 - * - * @author aquan - */ -public interface PayOrderService { - - /** - * 获得支付订单 - * - * @param id 编号 - * @return 支付订单 - */ - PayOrderDO getOrder(Long id); - - /** - * 获得支付订单 - * - * @param appId 应用编号 - * @param merchantOrderId 商户订单编号 - * @return 支付订单 - */ - PayOrderDO getOrder(Long appId, String merchantOrderId); - - /** - * 获得指定应用的订单数量 - * - * @param appId 应用编号 - * @return 订单数量 - */ - Long getOrderCountByAppId(Long appId); - - /** - * 获得支付订单分页 - * - * @param pageReqVO 分页查询 - * @return 支付订单分页 - */ - PageResult getOrderPage(PayOrderPageReqVO pageReqVO); - - /** - * 获得支付订单列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 支付订单列表 - */ - List getOrderList(PayOrderExportReqVO exportReqVO); - - /** - * 创建支付单 - * - * @param reqDTO 创建请求 - * @return 支付单编号 - */ - Long createOrder(@Valid PayOrderCreateReqDTO reqDTO); - - /** - * 提交支付 - * 此时,会发起支付渠道的调用 - * - * @param reqVO 提交请求 - * @param userIp 提交 IP - * @return 提交结果 - */ - PayOrderSubmitRespVO submitOrder(@Valid PayOrderSubmitReqVO reqVO, - @NotEmpty(message = "提交 IP 不能为空") String userIp); - - /** - * 通知支付单成功 - * - * @param channelId 渠道编号 - * @param notify 通知 - */ - void notifyOrder(Long channelId, PayOrderRespDTO notify); - - /** - * 更新支付订单的退款金额 - * - * @param id 编号 - * @param incrRefundPrice 增加的退款金额 - */ - void updateOrderRefundPrice(Long id, Integer incrRefundPrice); - - /** - * 更新支付订单价格 - * - * @param id 支付单编号 - * @param payPrice 支付单价格 - */ - void updatePayOrderPrice(Long id, Integer payPrice); - - /** - * 获得支付订单 - * - * @param id 编号 - * @return 支付订单 - */ - PayOrderExtensionDO getOrderExtension(Long id); - - /** - * 获得支付订单 - * - * @param no 支付订单 no - * @return 支付订单 - */ - PayOrderExtensionDO getOrderExtensionByNo(String no); - - /** - * 同步订单的支付状态 - * - * @param minCreateTime 最小创建时间 - * @return 同步到已支付的订单数量 - */ - int syncOrder(LocalDateTime minCreateTime); - - /** - * 将已过期的订单,状态修改为已关闭 - * - * @return 过期的订单数量 - */ - int expireOrder(); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java deleted file mode 100755 index 4a2550c77d..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java +++ /dev/null @@ -1,570 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderExtensionMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 支付订单 Service 实现类 - * - * @author aquan - */ -@Service -@Validated -@Slf4j -public class PayOrderServiceImpl implements PayOrderService { - - @Resource - private PayProperties payProperties; - - @Resource - private PayOrderMapper orderMapper; - @Resource - private PayOrderExtensionMapper orderExtensionMapper; - @Resource - private PayNoRedisDAO noRedisDAO; - - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - @Resource - private PayNotifyService notifyService; - - @Override - public PayOrderDO getOrder(Long id) { - return orderMapper.selectById(id); - } - - @Override - public PayOrderDO getOrder(Long appId, String merchantOrderId) { - return orderMapper.selectByAppIdAndMerchantOrderId(appId, merchantOrderId); - } - - @Override - public Long getOrderCountByAppId(Long appId) { - return orderMapper.selectCountByAppId(appId); - } - - @Override - public PageResult getOrderPage(PayOrderPageReqVO pageReqVO) { - return orderMapper.selectPage(pageReqVO); - } - - @Override - public List getOrderList(PayOrderExportReqVO exportReqVO) { - return orderMapper.selectList(exportReqVO); - } - - @Override - public Long createOrder(PayOrderCreateReqDTO reqDTO) { - // 校验 App - PayAppDO app = appService.validPayApp(reqDTO.getAppId()); - - // 查询对应的支付交易单是否已经存在。如果是,则直接返回 - PayOrderDO order = orderMapper.selectByAppIdAndMerchantOrderId( - reqDTO.getAppId(), reqDTO.getMerchantOrderId()); - if (order != null) { - log.warn("[createOrder][appId({}) merchantOrderId({}) 已经存在对应的支付单({})]", order.getAppId(), - order.getMerchantOrderId(), toJsonString(order)); // 理论来说,不会出现这个情况 - return order.getId(); - } - - // 创建支付交易单 - order = PayOrderConvert.INSTANCE.convert(reqDTO).setAppId(app.getId()) - // 商户相关字段 - .setNotifyUrl(app.getOrderNotifyUrl()) - // 订单相关字段 - .setStatus(PayOrderStatusEnum.WAITING.getStatus()) - // 退款相关字段 - .setRefundPrice(0); - orderMapper.insert(order); - return order.getId(); - } - - @Override // 注意,这里不能添加事务注解,避免调用支付渠道失败时,将 PayOrderExtensionDO 回滚了 - public PayOrderSubmitRespVO submitOrder(PayOrderSubmitReqVO reqVO, String userIp) { - // 1.1 获得 PayOrderDO ,并校验其是否存在 - PayOrderDO order = validateOrderCanSubmit(reqVO.getId()); - // 1.32 校验支付渠道是否有效 - PayChannelDO channel = validateChannelCanSubmit(order.getAppId(), reqVO.getChannelCode()); - PayClient client = channelService.getPayClient(channel.getId()); - - // 2. 插入 PayOrderExtensionDO - String no = noRedisDAO.generate(payProperties.getOrderNoPrefix()); - PayOrderExtensionDO orderExtension = PayOrderConvert.INSTANCE.convert(reqVO, userIp) - .setOrderId(order.getId()).setNo(no) - .setChannelId(channel.getId()).setChannelCode(channel.getCode()) - .setStatus(PayOrderStatusEnum.WAITING.getStatus()); - orderExtensionMapper.insert(orderExtension); - - // 3. 调用三方接口 - PayOrderUnifiedReqDTO unifiedOrderReqDTO = PayOrderConvert.INSTANCE.convert2(reqVO, userIp) - // 商户相关的字段 - .setOutTradeNo(orderExtension.getNo()) // 注意,此处使用的是 PayOrderExtensionDO.no 属性! - .setSubject(order.getSubject()).setBody(order.getBody()) - .setNotifyUrl(genChannelOrderNotifyUrl(channel)) - .setReturnUrl(reqVO.getReturnUrl()) - // 订单相关字段 - .setPrice(order.getPrice()).setExpireTime(order.getExpireTime()); - PayOrderRespDTO unifiedOrderResp = client.unifiedOrder(unifiedOrderReqDTO); - - // 4. 如果调用直接支付成功,则直接更新支付单状态为成功。例如说:付款码支付,免密支付时,就直接验证支付成功 - if (unifiedOrderResp != null) { - getSelf().notifyOrder(channel, unifiedOrderResp); - // 如有渠道错误码,则抛出业务异常,提示用户 - if (StrUtil.isNotEmpty(unifiedOrderResp.getChannelErrorCode())) { - throw exception(PAY_ORDER_SUBMIT_CHANNEL_ERROR, unifiedOrderResp.getChannelErrorCode(), - unifiedOrderResp.getChannelErrorMsg()); - } - // 此处需要读取最新的状态 - order = orderMapper.selectById(order.getId()); - } - return PayOrderConvert.INSTANCE.convert(order, unifiedOrderResp); - } - - private PayOrderDO validateOrderCanSubmit(Long id) { - PayOrderDO order = orderMapper.selectById(id); - if (order == null) { // 是否存在 - throw exception(PAY_ORDER_NOT_FOUND); - } - if (PayOrderStatusEnum.isSuccess(order.getStatus())) { // 校验状态,发现已支付 - throw exception(PAY_ORDER_STATUS_IS_SUCCESS); - } - if (!PayOrderStatusEnum.WAITING.getStatus().equals(order.getStatus())) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING); - } - if (LocalDateTimeUtils.beforeNow(order.getExpireTime())) { // 校验是否过期 - throw exception(PAY_ORDER_IS_EXPIRED); - } - - // 【重要】校验是否支付拓展单已支付,只是没有回调、或者数据不正常 - validateOrderActuallyPaid(id); - return order; - } - - /** - * 校验支付订单实际已支付 - * - * @param id 支付编号 - */ - @VisibleForTesting - void validateOrderActuallyPaid(Long id) { - List orderExtensions = orderExtensionMapper.selectListByOrderId(id); - orderExtensions.forEach(orderExtension -> { - // 情况一:校验数据库中的 orderExtension 是不是已支付 - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { - log.warn("[validateOrderCanSubmit][order({}) 的 extension({}) 已支付,可能是数据不一致]", - id, orderExtension.getId()); - throw exception(PAY_ORDER_EXTENSION_IS_PAID); - } - // 情况二:调用三方接口,查询支付单状态,是不是已支付 - PayClient payClient = channelService.getPayClient(orderExtension.getChannelId()); - if (payClient == null) { - log.error("[validateOrderCanSubmit][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId()); - return; - } - PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo()); - if (respDTO != null && PayOrderStatusRespEnum.isSuccess(respDTO.getStatus())) { - log.warn("[validateOrderCanSubmit][order({}) 的 PayOrderRespDTO({}) 已支付,可能是回调延迟]", - id, toJsonString(respDTO)); - throw exception(PAY_ORDER_EXTENSION_IS_PAID); - } - }); - } - - private PayChannelDO validateChannelCanSubmit(Long appId, String channelCode) { - // 校验 App - appService.validPayApp(appId); - // 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(appId, channelCode); - PayClient client = channelService.getPayClient(channel.getId()); - if (client == null) { - log.error("[validatePayChannelCanSubmit][渠道编号({}) 找不到对应的支付客户端]", channel.getId()); - throw exception(CHANNEL_NOT_FOUND); - } - return channel; - } - - /** - * 根据支付渠道的编码,生成支付渠道的回调地址 - * - * @param channel 支付渠道 - * @return 支付渠道的回调地址 配置地址 + "/" + channel id - */ - private String genChannelOrderNotifyUrl(PayChannelDO channel) { - return payProperties.getOrderNotifyUrl() + "/" + channel.getId(); - } - - @Override - public void notifyOrder(Long channelId, PayOrderRespDTO notify) { - // 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(channelId); - // 更新支付订单为已支付 - TenantUtils.execute(channel.getTenantId(), () -> getSelf().notifyOrder(channel, notify)); - } - - /** - * 通知并更新订单的支付结果 - * - * @param channel 支付渠道 - * @param notify 通知 - */ - @Transactional(rollbackFor = Exception.class) - // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyPayOrder(channel, notify) 调用,否则事务不生效 - public void notifyOrder(PayChannelDO channel, PayOrderRespDTO notify) { - // 情况一:支付成功的回调 - if (PayOrderStatusRespEnum.isSuccess(notify.getStatus())) { - notifyOrderSuccess(channel, notify); - return; - } - // 情况二:支付失败的回调 - if (PayOrderStatusRespEnum.isClosed(notify.getStatus())) { - notifyOrderClosed(channel, notify); - } - // 情况三:WAITING:无需处理 - // 情况四:REFUND:通过退款回调处理 - } - - private void notifyOrderSuccess(PayChannelDO channel, PayOrderRespDTO notify) { - // 1. 更新 PayOrderExtensionDO 支付成功 - PayOrderExtensionDO orderExtension = updateOrderSuccess(notify); - // 2. 更新 PayOrderDO 支付成功 - Boolean paid = updateOrderSuccess(channel, orderExtension, notify); - if (paid) { // 如果之前已经成功回调,则直接返回,不用重复记录支付通知记录;例如说:支付平台重复回调 - return; - } - - // 3. 插入支付通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.ORDER.getType(), - orderExtension.getOrderId()); - } - - /** - * 更新 PayOrderExtensionDO 支付成功 - * - * @param notify 通知 - * @return PayOrderExtensionDO 对象 - */ - private PayOrderExtensionDO updateOrderSuccess(PayOrderRespDTO notify) { - // 1. 查询 PayOrderExtensionDO - PayOrderExtensionDO orderExtension = orderExtensionMapper.selectByNo(notify.getOutTradeNo()); - if (orderExtension == null) { - throw exception(PAY_ORDER_EXTENSION_NOT_FOUND); - } - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { // 如果已经是成功,直接返回,不用重复更新 - log.info("[updateOrderExtensionSuccess][orderExtension({}) 已经是已支付,无需更新]", orderExtension.getId()); - return orderExtension; - } - if (ObjectUtil.notEqual(orderExtension.getStatus(), PayOrderStatusEnum.WAITING.getStatus())) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - - // 2. 更新 PayOrderExtensionDO - int updateCounts = orderExtensionMapper.updateByIdAndStatus(orderExtension.getId(), orderExtension.getStatus(), - PayOrderExtensionDO.builder().status(PayOrderStatusEnum.SUCCESS.getStatus()).channelNotifyData(toJsonString(notify)).build()); - if (updateCounts == 0) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - log.info("[updateOrderExtensionSuccess][orderExtension({}) 更新为已支付]", orderExtension.getId()); - return orderExtension; - } - - /** - * 更新 PayOrderDO 支付成功 - * - * @param channel 支付渠道 - * @param orderExtension 支付拓展单 - * @param notify 通知回调 - * @return 是否之前已经成功回调 - */ - private Boolean updateOrderSuccess(PayChannelDO channel, PayOrderExtensionDO orderExtension, - PayOrderRespDTO notify) { - // 1. 判断 PayOrderDO 是否处于待支付 - PayOrderDO order = orderMapper.selectById(orderExtension.getOrderId()); - if (order == null) { - throw exception(PAY_ORDER_NOT_FOUND); - } - if (PayOrderStatusEnum.isSuccess(order.getStatus()) // 如果已经是成功,直接返回,不用重复更新 - && Objects.equals(order.getExtensionId(), orderExtension.getId())) { - log.info("[updateOrderExtensionSuccess][order({}) 已经是已支付,无需更新]", order.getId()); - return true; - } - if (!PayOrderStatusEnum.WAITING.getStatus().equals(order.getStatus())) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING); - } - - // 2. 更新 PayOrderDO - int updateCounts = orderMapper.updateByIdAndStatus(order.getId(), PayOrderStatusEnum.WAITING.getStatus(), - PayOrderDO.builder().status(PayOrderStatusEnum.SUCCESS.getStatus()) - .channelId(channel.getId()).channelCode(channel.getCode()) - .successTime(notify.getSuccessTime()).extensionId(orderExtension.getId()).no(orderExtension.getNo()) - .channelOrderNo(notify.getChannelOrderNo()).channelUserId(notify.getChannelUserId()) - .channelFeeRate(channel.getFeeRate()) - .channelFeePrice(MoneyUtils.calculateRatePrice(order.getPrice(), channel.getFeeRate())) - .build()); - if (updateCounts == 0) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING); - } - log.info("[updateOrderExtensionSuccess][order({}) 更新为已支付]", order.getId()); - return false; - } - - private void notifyOrderClosed(PayChannelDO channel, PayOrderRespDTO notify) { - updateOrderExtensionClosed(channel, notify); - } - - private void updateOrderExtensionClosed(PayChannelDO channel, PayOrderRespDTO notify) { - // 1. 查询 PayOrderExtensionDO - PayOrderExtensionDO orderExtension = orderExtensionMapper.selectByNo(notify.getOutTradeNo()); - if (orderExtension == null) { - throw exception(PAY_ORDER_EXTENSION_NOT_FOUND); - } - if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) { // 如果已经是关闭,直接返回,不用重复更新 - log.info("[updateOrderExtensionClosed][orderExtension({}) 已经是支付关闭,无需更新]", orderExtension.getId()); - return; - } - // 一般出现先是支付成功,然后支付关闭,都是全部退款导致关闭的场景。这个情况,我们不更新支付拓展单,只通过退款流程,更新支付单 - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { - log.info("[updateOrderExtensionClosed][orderExtension({}) 是已支付,无需更新为支付关闭]", orderExtension.getId()); - return; - } - if (ObjectUtil.notEqual(orderExtension.getStatus(), PayOrderStatusEnum.WAITING.getStatus())) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - - // 2. 更新 PayOrderExtensionDO - int updateCounts = orderExtensionMapper.updateByIdAndStatus(orderExtension.getId(), orderExtension.getStatus(), - PayOrderExtensionDO.builder().status(PayOrderStatusEnum.CLOSED.getStatus()).channelNotifyData(toJsonString(notify)) - .channelErrorCode(notify.getChannelErrorCode()).channelErrorMsg(notify.getChannelErrorMsg()).build()); - if (updateCounts == 0) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - log.info("[updateOrderExtensionClosed][orderExtension({}) 更新为支付关闭]", orderExtension.getId()); - } - - @Override - public void updateOrderRefundPrice(Long id, Integer incrRefundPrice) { - PayOrderDO order = orderMapper.selectById(id); - if (order == null) { - throw exception(PAY_ORDER_NOT_FOUND); - } - if (!PayOrderStatusEnum.isSuccessOrRefund(order.getStatus())) { - throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - if (order.getRefundPrice() + incrRefundPrice > order.getPrice()) { - throw exception(REFUND_PRICE_EXCEED); - } - - // 更新订单 - PayOrderDO updateObj = new PayOrderDO() - .setRefundPrice(order.getRefundPrice() + incrRefundPrice) - .setStatus(PayOrderStatusEnum.REFUND.getStatus()); - int updateCount = orderMapper.updateByIdAndStatus(id, order.getStatus(), updateObj); - if (updateCount == 0) { - throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - } - - @Override - public void updatePayOrderPrice(Long id, Integer payPrice) { - PayOrderDO order = orderMapper.selectById(id); - if (order == null) { - throw exception(PAY_ORDER_NOT_FOUND); - } - if (ObjectUtil.notEqual(PayOrderStatusEnum.WAITING.getStatus(), order.getStatus())) { - throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING); - } - if (ObjectUtil.equal(order.getPrice(), payPrice)) { - return; - } - - // TODO 芋艿:应该 new 出来更新 - order.setPrice(payPrice); - orderMapper.updateById(order); - } - - @Override - public PayOrderExtensionDO getOrderExtension(Long id) { - return orderExtensionMapper.selectById(id); - } - - @Override - public PayOrderExtensionDO getOrderExtensionByNo(String no) { - return orderExtensionMapper.selectByNo(no); - } - - @Override - public int syncOrder(LocalDateTime minCreateTime) { - // 1. 查询指定创建时间内的待支付订单 - List orderExtensions = orderExtensionMapper.selectListByStatusAndCreateTimeGe( - PayOrderStatusEnum.WAITING.getStatus(), minCreateTime); - if (CollUtil.isEmpty(orderExtensions)) { - return 0; - } - // 2. 遍历执行 - int count = 0; - for (PayOrderExtensionDO orderExtension : orderExtensions) { - count += syncOrder(orderExtension) ? 1 : 0; - } - return count; - } - - /** - * 同步单个支付拓展单 - * - * @param orderExtension 支付拓展单 - * @return 是否已支付 - */ - private boolean syncOrder(PayOrderExtensionDO orderExtension) { - try { - // 1.1 查询支付订单信息 - PayClient payClient = channelService.getPayClient(orderExtension.getChannelId()); - if (payClient == null) { - log.error("[syncOrder][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId()); - return false; - } - PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo()); - // 1.2 回调支付结果 - notifyOrder(orderExtension.getChannelId(), respDTO); - - // 2. 如果是已支付,则返回 true - return PayOrderStatusRespEnum.isSuccess(respDTO.getStatus()); - } catch (Throwable e) { - log.error("[syncOrder][orderExtension({}) 同步支付状态异常]", orderExtension.getId(), e); - return false; - } - } - - @Override - public int expireOrder() { - // 1. 查询过期的待支付订单 - List orders = orderMapper.selectListByStatusAndExpireTimeLt( - PayOrderStatusEnum.WAITING.getStatus(), LocalDateTime.now()); - if (CollUtil.isEmpty(orders)) { - return 0; - } - - // 2. 遍历执行 - int count = 0; - for (PayOrderDO order : orders) { - count += expireOrder(order) ? 1 : 0; - } - return count; - } - - /** - * 同步单个支付单 - * - * @param order 支付单 - * @return 是否已过期 - */ - private boolean expireOrder(PayOrderDO order) { - try { - // 1. 需要先处理关联的支付拓展单,避免错误的过期已支付 or 已退款的订单 - List orderExtensions = orderExtensionMapper.selectListByOrderId(order.getId()); - for (PayOrderExtensionDO orderExtension : orderExtensions) { - if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) { - continue; - } - // 情况一:校验数据库中的 orderExtension 是不是已支付 - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { - log.error("[expireOrder][order({}) 的 extension({}) 已支付,可能是数据不一致]", - order.getId(), orderExtension.getId()); - return false; - } - // 情况二:调用三方接口,查询支付单状态,是不是已支付/已退款 - PayClient payClient = channelService.getPayClient(orderExtension.getChannelId()); - if (payClient == null) { - log.error("[expireOrder][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId()); - return false; - } - PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo()); - if (PayOrderStatusRespEnum.isRefund(respDTO.getStatus())) { - // 补充说明:按道理,应该是 WAITING => SUCCESS => REFUND 状态,如果直接 WAITING => REFUND 状态,说明中间丢了过程 - // 此时,需要人工介入,手工补齐数据,保持 WAITING => SUCCESS => REFUND 的过程 - log.error("[expireOrder][extension({}) 的 PayOrderRespDTO({}) 已退款,可能是回调延迟]", - orderExtension.getId(), toJsonString(respDTO)); - return false; - } - if (PayOrderStatusRespEnum.isSuccess(respDTO.getStatus())) { - notifyOrder(orderExtension.getChannelId(), respDTO); - return false; - } - // 兜底逻辑:将支付拓展单更新为已关闭 - PayOrderExtensionDO updateObj = new PayOrderExtensionDO().setStatus(PayOrderStatusEnum.CLOSED.getStatus()) - .setChannelNotifyData(toJsonString(respDTO)); - if (orderExtensionMapper.updateByIdAndStatus(orderExtension.getId(), PayOrderStatusEnum.WAITING.getStatus(), - updateObj) == 0) { - log.error("[expireOrder][extension({}) 更新为支付关闭失败]", orderExtension.getId()); - return false; - } - log.info("[expireOrder][extension({}) 更新为支付关闭成功]", orderExtension.getId()); - } - - // 2. 都没有上述情况,可以安心更新为已关闭 - PayOrderDO updateObj = new PayOrderDO().setStatus(PayOrderStatusEnum.CLOSED.getStatus()); - if (orderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateObj) == 0) { - log.error("[expireOrder][order({}) 更新为支付关闭失败]", order.getId()); - return false; - } - log.info("[expireOrder][order({}) 更新为支付关闭失败]", order.getId()); - return true; - } catch (Throwable e) { - log.error("[expireOrder][order({}) 过期订单异常]", order.getId(), e); - return false; - } - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private PayOrderServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundService.java deleted file mode 100755 index 258cea9640..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.refund; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; - -import java.util.List; - -/** - * 退款订单 Service 接口 - * - * @author aquan - */ -public interface PayRefundService { - - /** - * 获得退款订单 - * - * @param id 编号 - * @return 退款订单 - */ - PayRefundDO getRefund(Long id); - - /** - * 获得退款订单 - * - * @param no 外部退款单号 - * @return 退款订单 - */ - PayRefundDO getRefundByNo(String no); - - /** - * 获得指定应用的退款数量 - * - * @param appId 应用编号 - * @return 退款数量 - */ - Long getRefundCountByAppId(Long appId); - - /** - * 获得退款订单分页 - * - * @param pageReqVO 分页查询 - * @return 退款订单分页 - */ - PageResult getRefundPage(PayRefundPageReqVO pageReqVO); - - /** - * 获得退款订单列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 退款订单列表 - */ - List getRefundList(PayRefundExportReqVO exportReqVO); - - /** - * 创建退款申请 - * - * @param reqDTO 退款申请信息 - * @return 退款单号 - */ - Long createPayRefund(PayRefundCreateReqDTO reqDTO); - - /** - * 渠道的退款通知 - * - * @param channelId 渠道编号 - * @param notify 通知 - */ - void notifyRefund(Long channelId, PayRefundRespDTO notify); - - /** - * 同步渠道退款的退款状态 - * - * @return 同步到状态的退款数量,包括退款成功、退款失败 - */ - int syncRefund(); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java deleted file mode 100755 index 360d00abf7..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java +++ /dev/null @@ -1,331 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.refund; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.convert.refund.PayRefundConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.mysql.refund.PayRefundMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 退款订单 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -@Validated -public class PayRefundServiceImpl implements PayRefundService { - - @Resource - private PayProperties payProperties; - - @Resource - private PayRefundMapper refundMapper; - @Resource - private PayNoRedisDAO noRedisDAO; - - @Resource - private PayOrderService orderService; - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - @Resource - private PayNotifyService notifyService; - - @Override - public PayRefundDO getRefund(Long id) { - return refundMapper.selectById(id); - } - - @Override - public PayRefundDO getRefundByNo(String no) { - return refundMapper.selectByNo(no); - } - - @Override - public Long getRefundCountByAppId(Long appId) { - return refundMapper.selectCountByAppId(appId); - } - - @Override - public PageResult getRefundPage(PayRefundPageReqVO pageReqVO) { - return refundMapper.selectPage(pageReqVO); - } - - @Override - public List getRefundList(PayRefundExportReqVO exportReqVO) { - return refundMapper.selectList(exportReqVO); - } - - @Override - public Long createPayRefund(PayRefundCreateReqDTO reqDTO) { - // 1.1 校验 App - PayAppDO app = appService.validPayApp(reqDTO.getAppId()); - // 1.2 校验支付订单 - PayOrderDO order = validatePayOrderCanRefund(reqDTO); - // 1.3 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(order.getChannelId()); - PayClient client = channelService.getPayClient(channel.getId()); - if (client == null) { - log.error("[refund][渠道编号({}) 找不到对应的支付客户端]", channel.getId()); - throw exception(CHANNEL_NOT_FOUND); - } - // 1.4 校验退款订单是否已经存在 - PayRefundDO refund = refundMapper.selectByAppIdAndMerchantRefundId( - app.getId(), reqDTO.getMerchantRefundId()); - if (refund != null) { - throw exception(REFUND_EXISTS); - } - - // 2.1 插入退款单 - String no = noRedisDAO.generate(payProperties.getRefundNoPrefix()); - refund = PayRefundConvert.INSTANCE.convert(reqDTO) - .setNo(no).setOrderId(order.getId()).setOrderNo(order.getNo()) - .setChannelId(order.getChannelId()).setChannelCode(order.getChannelCode()) - // 商户相关的字段 - .setNotifyUrl(app.getRefundNotifyUrl()) - // 渠道相关字段 - .setChannelOrderNo(order.getChannelOrderNo()) - // 退款相关字段 - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setPayPrice(order.getPrice()).setRefundPrice(reqDTO.getPrice()); - refundMapper.insert(refund); - try { - // 2.2 向渠道发起退款申请 - PayRefundUnifiedReqDTO unifiedReqDTO = new PayRefundUnifiedReqDTO() - .setPayPrice(order.getPrice()) - .setRefundPrice(reqDTO.getPrice()) - .setOutTradeNo(order.getNo()) - .setOutRefundNo(refund.getNo()) - .setNotifyUrl(genChannelRefundNotifyUrl(channel)) - .setReason(reqDTO.getReason()); - PayRefundRespDTO refundRespDTO = client.unifiedRefund(unifiedReqDTO); - // 2.3 处理退款返回 - getSelf().notifyRefund(channel, refundRespDTO); - } catch (Throwable e) { - // 注意:这里仅打印异常,不进行抛出。 - // 原因是:虽然调用支付渠道进行退款发生异常(网络请求超时),实际退款成功。这个结果,后续通过退款回调、或者退款轮询补偿可以拿到。 - // 最终,在异常的情况下,支付中心会异步回调业务的退款回调接口,提供退款结果 - log.error("[createPayRefund][退款 id({}) requestDTO({}) 发生异常]", - refund.getId(), reqDTO, e); - } - - // 返回退款编号 - return refund.getId(); - } - - /** - * 校验支付订单是否可以退款 - * - * @param reqDTO 退款申请信息 - * @return 支付订单 - */ - private PayOrderDO validatePayOrderCanRefund(PayRefundCreateReqDTO reqDTO) { - PayOrderDO order = orderService.getOrder(reqDTO.getAppId(), reqDTO.getMerchantOrderId()); - if (order == null) { - throw exception(PAY_ORDER_NOT_FOUND); - } - // 校验状态,必须是已支付、或者已退款 - if (!PayOrderStatusEnum.isSuccessOrRefund(order.getStatus())) { - throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - - // 校验金额,退款金额不能大于原定的金额 - if (reqDTO.getPrice() + order.getRefundPrice() > order.getPrice()){ - throw exception(REFUND_PRICE_EXCEED); - } - // 是否有退款中的订单 - if (refundMapper.selectCountByAppIdAndOrderId(reqDTO.getAppId(), order.getId(), - PayRefundStatusEnum.WAITING.getStatus()) > 0) { - throw exception(REFUND_HAS_REFUNDING); - } - return order; - } - - /** - * 根据支付渠道的编码,生成支付渠道的回调地址 - * - * @param channel 支付渠道 - * @return 支付渠道的回调地址 配置地址 + "/" + channel id - */ - private String genChannelRefundNotifyUrl(PayChannelDO channel) { - return payProperties.getRefundNotifyUrl() + "/" + channel.getId(); - } - - @Override - public void notifyRefund(Long channelId, PayRefundRespDTO notify) { - // 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(channelId); - // 更新退款订单 - TenantUtils.execute(channel.getTenantId(), () -> getSelf().notifyRefund(channel, notify)); - } - - /** - * 通知并更新订单的退款结果 - * - * @param channel 支付渠道 - * @param notify 通知 - */ - @Transactional(rollbackFor = Exception.class) // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyRefund(channel, notify) 调用,否则事务不生效 - public void notifyRefund(PayChannelDO channel, PayRefundRespDTO notify) { - // 情况一:退款成功 - if (PayRefundStatusRespEnum.isSuccess(notify.getStatus())) { - notifyRefundSuccess(channel, notify); - return; - } - // 情况二:退款失败 - if (PayRefundStatusRespEnum.isFailure(notify.getStatus())) { - notifyRefundFailure(channel, notify); - } - } - - private void notifyRefundSuccess(PayChannelDO channel, PayRefundRespDTO notify) { - // 1.1 查询 PayRefundDO - PayRefundDO refund = refundMapper.selectByAppIdAndNo( - channel.getAppId(), notify.getOutRefundNo()); - if (refund == null) { - throw exception(REFUND_NOT_FOUND); - } - if (PayRefundStatusEnum.isSuccess(refund.getStatus())) { // 如果已经是成功,直接返回,不用重复更新 - log.info("[notifyRefundSuccess][退款订单({}) 已经是退款成功,无需更新]", refund.getId()); - return; - } - if (!PayRefundStatusEnum.WAITING.getStatus().equals(refund.getStatus())) { - throw exception(REFUND_STATUS_IS_NOT_WAITING); - } - // 1.2 更新 PayRefundDO - PayRefundDO updateRefundObj = new PayRefundDO() - .setSuccessTime(notify.getSuccessTime()) - .setChannelRefundNo(notify.getChannelRefundNo()) - .setStatus(PayRefundStatusEnum.SUCCESS.getStatus()) - .setChannelNotifyData(toJsonString(notify)); - int updateCounts = refundMapper.updateByIdAndStatus(refund.getId(), refund.getStatus(), updateRefundObj); - if (updateCounts == 0) { // 校验状态,必须是等待状态 - throw exception(REFUND_STATUS_IS_NOT_WAITING); - } - log.info("[notifyRefundSuccess][退款订单({}) 更新为退款成功]", refund.getId()); - - // 2. 更新订单 - orderService.updateOrderRefundPrice(refund.getOrderId(), refund.getRefundPrice()); - - // 3. 插入退款通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.REFUND.getType(), - refund.getId()); - } - - private void notifyRefundFailure(PayChannelDO channel, PayRefundRespDTO notify) { - // 1.1 查询 PayRefundDO - PayRefundDO refund = refundMapper.selectByAppIdAndNo( - channel.getAppId(), notify.getOutRefundNo()); - if (refund == null) { - throw exception(REFUND_NOT_FOUND); - } - if (PayRefundStatusEnum.isFailure(refund.getStatus())) { // 如果已经是成功,直接返回,不用重复更新 - log.info("[notifyRefundSuccess][退款订单({}) 已经是退款关闭,无需更新]", refund.getId()); - return; - } - if (!PayRefundStatusEnum.WAITING.getStatus().equals(refund.getStatus())) { - throw exception(REFUND_STATUS_IS_NOT_WAITING); - } - // 1.2 更新 PayRefundDO - PayRefundDO updateRefundObj = new PayRefundDO() - .setChannelRefundNo(notify.getChannelRefundNo()) - .setStatus(PayRefundStatusEnum.FAILURE.getStatus()) - .setChannelNotifyData(toJsonString(notify)) - .setChannelErrorCode(notify.getChannelErrorCode()).setChannelErrorMsg(notify.getChannelErrorMsg()); - int updateCounts = refundMapper.updateByIdAndStatus(refund.getId(), refund.getStatus(), updateRefundObj); - if (updateCounts == 0) { // 校验状态,必须是等待状态 - throw exception(REFUND_STATUS_IS_NOT_WAITING); - } - log.info("[notifyRefundFailure][退款订单({}) 更新为退款失败]", refund.getId()); - - // 2. 插入退款通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.REFUND.getType(), - refund.getId()); - } - - @Override - public int syncRefund() { - // 1. 查询指定创建时间内的待退款订单 - List refunds = refundMapper.selectListByStatus(PayRefundStatusEnum.WAITING.getStatus()); - if (CollUtil.isEmpty(refunds)) { - return 0; - } - // 2. 遍历执行 - int count = 0; - for (PayRefundDO refund : refunds) { - count += syncRefund(refund) ? 1 : 0; - } - return count; - } - - /** - * 同步单个退款订单 - * - * @param refund 退款订单 - * @return 是否同步到 - */ - private boolean syncRefund(PayRefundDO refund) { - try { - // 1.1 查询退款订单信息 - PayClient payClient = channelService.getPayClient(refund.getChannelId()); - if (payClient == null) { - log.error("[syncRefund][渠道编号({}) 找不到对应的支付客户端]", refund.getChannelId()); - return false; - } - PayRefundRespDTO respDTO = payClient.getRefund(refund.getOrderNo(), refund.getNo()); - // 1.2 回调退款结果 - notifyRefund(refund.getChannelId(), respDTO); - - // 2. 如果同步到,则返回 true - return PayRefundStatusEnum.isSuccess(respDTO.getStatus()) - || PayRefundStatusEnum.isFailure(respDTO.getStatus()); - } catch (Throwable e) { - log.error("[syncRefund][refund({}) 同步退款状态异常]", refund.getId(), e); - return false; - } - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private PayRefundServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java deleted file mode 100644 index d3bc982e44..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.transfer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; - -import jakarta.validation.Valid; - -/** - * 转账 Service 接口 - * - * @author jason - */ -public interface PayTransferService { - - /** - * 创建转账单,并发起转账 - * - * 此时,会发起转账渠道的调用 - * - * @param reqVO 请求 - * @param userIp 用户 ip - * @return 渠道的返回结果 - */ - PayTransferDO createTransfer(@Valid PayTransferCreateReqVO reqVO, String userIp); - - /** - * 创建转账单,并发起转账 - * - * @param reqDTO 创建请求 - * @return 转账单编号 - */ - Long createTransfer(@Valid PayTransferCreateReqDTO reqDTO); - - /** - * 获取转账单 - * @param id 转账单编号 - */ - PayTransferDO getTransfer(Long id); - - /** - * 获得转账单分页 - * - * @param pageReqVO 分页查询 - * @return 转账单分页 - */ - PageResult getTransferPage(PayTransferPageReqVO pageReqVO); - - /** - * 同步渠道转账单状态 - * - * @return 同步到状态的转账数量,包括转账成功、转账失败、转账中的 - */ - int syncTransfer(); -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java deleted file mode 100644 index cf8fc3f5e7..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java +++ /dev/null @@ -1,301 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.transfer; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; -import cn.iocoder.yudao.module.pay.dal.mysql.transfer.PayTransferMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import jakarta.annotation.Resource; -import jakarta.validation.Validator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.convert.transfer.PayTransferConvert.INSTANCE; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum.*; - -// TODO @jason:等彻底实现完,单测写写; - -/** - * 转账 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -public class PayTransferServiceImpl implements PayTransferService { - - private static final String TRANSFER_NO_PREFIX = "T"; - - @Resource - private PayTransferMapper transferMapper; - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - @Resource - private PayNotifyService notifyService; - @Resource - private PayNoRedisDAO noRedisDAO; - @Resource - private Validator validator; - - @Override - public PayTransferDO createTransfer(PayTransferCreateReqVO reqVO, String userIp) { - // 1. 校验参数 - reqVO.validate(validator); - - // 2. 创建转账单,发起转账 - PayTransferCreateReqDTO req = INSTANCE.convert(reqVO).setUserIp(userIp); - Long transferId = createTransfer(req); - - // 3. 返回转账单 - return getTransfer(transferId); - } - - @Override - public Long createTransfer(PayTransferCreateReqDTO reqDTO) { - // 1.1 校验 App - PayAppDO payApp = appService.validPayApp(reqDTO.getAppId()); - // 1.2 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(reqDTO.getAppId(), reqDTO.getChannelCode()); - PayClient client = channelService.getPayClient(channel.getId()); - if (client == null) { - log.error("[createTransfer][渠道编号({}) 找不到对应的支付客户端]", channel.getId()); - throw exception(CHANNEL_NOT_FOUND); - } - // 1.3 校验转账单已经发起过转账。 - PayTransferDO transfer = validateTransferCanCreate(reqDTO); - - if (transfer == null) { - // 2.不存在创建转账单. 否则允许使用相同的 no 再次发起转账 - String no = noRedisDAO.generate(TRANSFER_NO_PREFIX); - transfer = INSTANCE.convert(reqDTO) - .setChannelId(channel.getId()) - .setNo(no).setStatus(WAITING.getStatus()) - .setNotifyUrl(payApp.getTransferNotifyUrl()); - transferMapper.insert(transfer); - } - try { - // 3. 调用三方渠道发起转账 - PayTransferUnifiedReqDTO transferUnifiedReq = INSTANCE.convert2(transfer) - .setOutTransferNo(transfer.getNo()); - PayTransferRespDTO unifiedTransferResp = client.unifiedTransfer(transferUnifiedReq); - // 4. 通知转账结果 - getSelf().notifyTransfer(channel, unifiedTransferResp); - } catch (Throwable e) { - // 注意这里仅打印异常,不进行抛出。 - // 原因是:虽然调用支付渠道进行转账发生异常(网络请求超时),实际转账成功。这个结果,后续转账轮询可以拿到。 - // 或者使用相同 no 再次发起转账请求 - log.error("[createTransfer][转账 id({}) requestDTO({}) 发生异常]", transfer.getId(), reqDTO, e); - } - - return transfer.getId(); - } - - private PayTransferDO validateTransferCanCreate(PayTransferCreateReqDTO dto) { - PayTransferDO transfer = transferMapper.selectByAppIdAndMerchantTransferId(dto.getAppId(), dto.getMerchantTransferId()); - if (transfer != null) { - // 已经存在,并且状态不为等待状态。说明已经调用渠道转账并返回结果. - if (!PayTransferStatusEnum.isWaiting(transfer.getStatus())) { - throw exception(PAY_MERCHANT_TRANSFER_EXISTS); - } - if (ObjectUtil.notEqual(dto.getPrice(), transfer.getPrice())) { - throw exception(PAY_SAME_MERCHANT_TRANSFER_PRICE_NOT_MATCH); - } - if (ObjectUtil.notEqual(dto.getType(), transfer.getType())) { - throw exception(PAY_SAME_MERCHANT_TRANSFER_TYPE_NOT_MATCH); - } - } - // 如果状态为等待状态。不知道渠道转账是否发起成功。 允许使用相同的 no 再次发起转账,渠道会保证幂等 - return transfer; - } - - @Transactional(rollbackFor = Exception.class) - // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyTransfer(channel, notify) 调用,否则事务不生效 - public void notifyTransfer(PayChannelDO channel, PayTransferRespDTO notify) { - // 转账成功的回调 - if (PayTransferStatusRespEnum.isSuccess(notify.getStatus())) { - notifyTransferSuccess(channel, notify); - } - // 转账关闭的回调 - if (PayTransferStatusRespEnum.isClosed(notify.getStatus())) { - notifyTransferClosed(channel, notify); - } - // 转账处理中的回调 - if (PayTransferStatusRespEnum.isInProgress(notify.getStatus())) { - notifyTransferInProgress(channel, notify); - } - // WAITING 状态无需处理 - } - - private void notifyTransferInProgress(PayChannelDO channel, PayTransferRespDTO notify) { - // 1.校验 - PayTransferDO transfer = transferMapper.selectByNo(notify.getOutTransferNo()); - if (transfer == null) { - throw exception(PAY_TRANSFER_NOT_FOUND); - } - if (isInProgress(transfer.getStatus())) { // 如果已经是转账中,直接返回,不用重复更新 - return; - } - if (!isWaiting(transfer.getStatus())) { - throw exception(PAY_TRANSFER_STATUS_IS_NOT_WAITING); - } - // 2.更新 - int updateCounts = transferMapper.updateByIdAndStatus(transfer.getId(), - CollUtil.newArrayList(WAITING.getStatus()), - new PayTransferDO().setStatus(IN_PROGRESS.getStatus())); - if (updateCounts == 0) { - throw exception(PAY_TRANSFER_STATUS_IS_NOT_WAITING); - } - log.info("[notifyTransferInProgress][transfer({}) 更新为转账进行中状态]", transfer.getId()); - - // 3. 插入转账通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.TRANSFER.getType(), - transfer.getId()); - } - - - private void notifyTransferSuccess(PayChannelDO channel, PayTransferRespDTO notify) { - // 1.校验 - PayTransferDO transfer = transferMapper.selectByNo(notify.getOutTransferNo()); - if (transfer == null) { - throw exception(PAY_TRANSFER_NOT_FOUND); - } - if (isSuccess(transfer.getStatus())) { // 如果已成功,直接返回,不用重复更新 - return; - } - if (!isPendingStatus(transfer.getStatus())) { - throw exception(PAY_TRANSFER_STATUS_IS_NOT_PENDING); - } - // 2.更新 - int updateCounts = transferMapper.updateByIdAndStatus(transfer.getId(), - CollUtil.newArrayList(WAITING.getStatus(), IN_PROGRESS.getStatus()), - new PayTransferDO().setStatus(SUCCESS.getStatus()).setSuccessTime(notify.getSuccessTime()) - .setChannelTransferNo(notify.getChannelTransferNo()) - .setChannelId(channel.getId()).setChannelCode(channel.getCode()) - .setChannelNotifyData(JsonUtils.toJsonString(notify))); - if (updateCounts == 0) { - throw exception(PAY_TRANSFER_STATUS_IS_NOT_PENDING); - } - log.info("[updateTransferSuccess][transfer({}) 更新为已转账]", transfer.getId()); - - // 3. 插入转账通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.TRANSFER.getType(), - transfer.getId()); - } - - private void notifyTransferClosed(PayChannelDO channel, PayTransferRespDTO notify) { - // 1.校验 - PayTransferDO transfer = transferMapper.selectByNo(notify.getOutTransferNo()); - if (transfer == null) { - throw exception(PAY_TRANSFER_NOT_FOUND); - } - if (isClosed(transfer.getStatus())) { // 如果已是关闭状态,直接返回,不用重复更新 - log.info("[updateTransferClosed][transfer({}) 已经是关闭状态,无需更新]", transfer.getId()); - return; - } - if (!isPendingStatus(transfer.getStatus())) { - throw exception(PAY_TRANSFER_STATUS_IS_NOT_PENDING); - } - - // 2.更新 - int updateCount = transferMapper.updateByIdAndStatus(transfer.getId(), - CollUtil.newArrayList(WAITING.getStatus(), IN_PROGRESS.getStatus()), - new PayTransferDO().setStatus(CLOSED.getStatus()).setChannelId(channel.getId()) - .setChannelCode(channel.getCode()).setChannelTransferNo(notify.getChannelTransferNo()) - .setChannelErrorCode(notify.getChannelErrorCode()).setChannelErrorMsg(notify.getChannelErrorMsg()) - .setChannelNotifyData(JsonUtils.toJsonString(notify))); - if (updateCount == 0) { - throw exception(PAY_TRANSFER_STATUS_IS_NOT_PENDING); - } - log.info("[updateTransferClosed][transfer({}) 更新为关闭状态]", transfer.getId()); - - // 3. 插入转账通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.TRANSFER.getType(), - transfer.getId()); - - } - - @Override - public PayTransferDO getTransfer(Long id) { - return transferMapper.selectById(id); - } - - @Override - public PageResult getTransferPage(PayTransferPageReqVO pageReqVO) { - return transferMapper.selectPage(pageReqVO); - } - - @Override - public int syncTransfer() { - List list = transferMapper.selectListByStatus(WAITING.getStatus()); - if (CollUtil.isEmpty(list)) { - return 0; - } - int count = 0; - for (PayTransferDO transfer : list) { - count += syncTransfer(transfer) ? 1 : 0; - } - return count; - } - - private boolean syncTransfer(PayTransferDO transfer) { - try { - // 1. 查询转账订单信息 - PayClient payClient = channelService.getPayClient(transfer.getChannelId()); - if (payClient == null) { - log.error("[syncTransfer][渠道编号({}) 找不到对应的支付客户端]", transfer.getChannelId()); - return false; - } - PayTransferRespDTO resp = payClient.getTransfer(transfer.getNo(), - PayTransferTypeEnum.typeOf(transfer.getType())); - - // 2. 回调转账结果 - notifyTransfer(transfer.getChannelId(), resp); - return true; - } catch (Throwable ex) { - log.error("[syncTransfer][transfer({}) 同步转账单状态异常]", transfer.getId(), ex); - return false; - } - } - - private void notifyTransfer(Long channelId, PayTransferRespDTO notify) { - // 校验渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(channelId); - // 通知转账结果给对应的业务 - TenantUtils.execute(channel.getTenantId(), () -> getSelf().notifyTransfer(channel, notify)); - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private PayTransferServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageService.java deleted file mode 100644 index c4754b84da..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageService.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; - -import jakarta.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 钱包充值套餐 Service 接口 - * - * @author jason - */ -public interface PayWalletRechargePackageService { - - /** - * 获取钱包充值套餐 - * @param packageId 充值套餐编号 - */ - PayWalletRechargePackageDO getWalletRechargePackage(Long packageId); - - /** - * 校验钱包充值套餐的有效性, 无效的话抛出 ServiceException 异常 - * - * @param packageId 充值套餐编号 - */ - PayWalletRechargePackageDO validWalletRechargePackage(Long packageId); - - /** - * 创建充值套餐 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createWalletRechargePackage(@Valid WalletRechargePackageCreateReqVO createReqVO); - - /** - * 更新充值套餐 - * - * @param updateReqVO 更新信息 - */ - void updateWalletRechargePackage(@Valid WalletRechargePackageUpdateReqVO updateReqVO); - - /** - * 删除充值套餐 - * - * @param id 编号 - */ - void deleteWalletRechargePackage(Long id); - - /** - * 获得充值套餐分页 - * - * @param pageReqVO 分页查询 - * @return 充值套餐分页 - */ - PageResult getWalletRechargePackagePage(WalletRechargePackagePageReqVO pageReqVO); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java deleted file mode 100644 index 5ddebc5577..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.wallet.WalletRechargePackageConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletRechargePackageMapper; -import org.springframework.stereotype.Service; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 钱包充值套餐 Service 实现类 - * - * @author jason - */ -@Service -public class PayWalletRechargePackageServiceImpl implements PayWalletRechargePackageService { - - @Resource - private PayWalletRechargePackageMapper walletRechargePackageMapper; - - @Override - public PayWalletRechargePackageDO getWalletRechargePackage(Long packageId) { - return walletRechargePackageMapper.selectById(packageId); - } - - @Override - public PayWalletRechargePackageDO validWalletRechargePackage(Long packageId) { - PayWalletRechargePackageDO rechargePackageDO = walletRechargePackageMapper.selectById(packageId); - if (rechargePackageDO == null) { - throw exception(WALLET_RECHARGE_PACKAGE_NOT_FOUND); - } - if (CommonStatusEnum.DISABLE.getStatus().equals(rechargePackageDO.getStatus())) { - throw exception(WALLET_RECHARGE_PACKAGE_IS_DISABLE); - } - return rechargePackageDO; - } - - @Override - public Long createWalletRechargePackage(WalletRechargePackageCreateReqVO createReqVO) { - // 校验套餐名是否唯一 - validateRechargePackageNameUnique(null, createReqVO.getName()); - - // 插入 - PayWalletRechargePackageDO walletRechargePackage = WalletRechargePackageConvert.INSTANCE.convert(createReqVO); - walletRechargePackageMapper.insert(walletRechargePackage); - // 返回 - return walletRechargePackage.getId(); - } - - @Override - public void updateWalletRechargePackage(WalletRechargePackageUpdateReqVO updateReqVO) { - // 校验存在 - validateWalletRechargePackageExists(updateReqVO.getId()); - // 校验套餐名是否唯一 - validateRechargePackageNameUnique(updateReqVO.getId(), updateReqVO.getName()); - - // 更新 - PayWalletRechargePackageDO updateObj = WalletRechargePackageConvert.INSTANCE.convert(updateReqVO); - walletRechargePackageMapper.updateById(updateObj); - } - - private void validateRechargePackageNameUnique(Long id, String name) { - if (StrUtil.isBlank(name)) { - return; - } - PayWalletRechargePackageDO rechargePackage = walletRechargePackageMapper.selectByName(name); - if (rechargePackage == null) { - return ; - } - if (id == null) { - throw exception(WALLET_RECHARGE_PACKAGE_NAME_EXISTS); - } - if (!id.equals(rechargePackage.getId())) { - throw exception(WALLET_RECHARGE_PACKAGE_NAME_EXISTS); - } - } - - @Override - public void deleteWalletRechargePackage(Long id) { - // 校验存在 - validateWalletRechargePackageExists(id); - // 删除 - walletRechargePackageMapper.deleteById(id); - } - - private void validateWalletRechargePackageExists(Long id) { - if (walletRechargePackageMapper.selectById(id) == null) { - throw exception(WALLET_RECHARGE_PACKAGE_NOT_FOUND); - } - } - - @Override - public PageResult getWalletRechargePackagePage(WalletRechargePackagePageReqVO pageReqVO) { - return walletRechargePackageMapper.selectPage(pageReqVO); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java deleted file mode 100644 index 752ce89af4..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; - -/** - * 钱包充值 Service 接口 - * - * @author jason - */ -public interface PayWalletRechargeService { - - /** - * 创建钱包充值记录(发起充值) - * - * @param userId 用户 id - * @param userType 用户类型 - * @param createReqVO 钱包充值请求 VO - * @param userIp 用户Ip - * @return 钱包充值记录 - */ - PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp, - AppPayWalletRechargeCreateReqVO createReqVO); - - /** - * 更新钱包充值成功 - * - * @param id 钱包充值记录 id - * @param payOrderId 支付订单 id - */ - void updateWalletRechargerPaid(Long id, Long payOrderId); - - /** - * 发起钱包充值退款 - * - * @param id 钱包充值编号 - * @param userIp 用户 ip 地址 - */ - void refundWalletRecharge(Long id, String userIp); - - /** - * 更新钱包充值记录为已退款 - * - * @param id 钱包充值 id - * @param payRefundId 退款单id - */ - void updateWalletRechargeRefunded(Long id, Long payRefundId); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java deleted file mode 100644 index 68ca42a8bf..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java +++ /dev/null @@ -1,277 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletRechargeMapper; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.Objects; - -import static cn.hutool.core.util.ObjectUtil.notEqual; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert.INSTANCE; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*; - -/** - * 钱包充值 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { - - /** - * TODO 芋艿:放到 payconfig - */ - private static final Long WALLET_PAY_APP_ID = 8L; - - private static final String WALLET_RECHARGE_ORDER_SUBJECT = "钱包余额充值"; - - @Resource - private PayWalletRechargeMapper walletRechargeMapper; - @Resource - private PayWalletService payWalletService; - @Resource - private PayOrderService payOrderService; - @Resource - private PayRefundService payRefundService; - @Resource - private PayWalletRechargePackageService payWalletRechargePackageService; - - @Override - @Transactional(rollbackFor = Exception.class) - public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp, - AppPayWalletRechargeCreateReqVO reqVO) { - - // 1.1 计算充值金额 - int payPrice; - int bonusPrice = 0; - if (Objects.nonNull(reqVO.getPackageId())) { - PayWalletRechargePackageDO rechargePackage = payWalletRechargePackageService.validWalletRechargePackage(reqVO.getPackageId()); - payPrice = rechargePackage.getPayPrice(); - bonusPrice = rechargePackage.getBonusPrice(); - } else { - payPrice = reqVO.getPayPrice(); - } - // 1.2 插入充值记录 - PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType); - PayWalletRechargeDO recharge = INSTANCE.convert(wallet.getId(), payPrice, bonusPrice, reqVO.getPackageId()); - walletRechargeMapper.insert(recharge); - - // 2.1 创建支付单 - Long payOrderId = payOrderService.createOrder(new PayOrderCreateReqDTO() - .setAppId(WALLET_PAY_APP_ID).setUserIp(userIp) - .setMerchantOrderId(recharge.getId().toString()) // 业务的订单编号 - .setSubject(WALLET_RECHARGE_ORDER_SUBJECT).setBody("") - .setPrice(recharge.getPayPrice()) - .setExpireTime(addTime(Duration.ofHours(2L)))); // TODO @芋艿:支付超时时间 - // 2.2 更新钱包充值记录中支付订单 - walletRechargeMapper.updateById(new PayWalletRechargeDO().setId(recharge.getId()).setPayOrderId(payOrderId)); - recharge.setPayOrderId(payOrderId); - return recharge; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateWalletRechargerPaid(Long id, Long payOrderId) { - // 1.1 获取钱包充值记录 - PayWalletRechargeDO walletRecharge = walletRechargeMapper.selectById(id); - if (walletRecharge == null) { - log.error("[updateWalletRechargerPaid][钱包充值记录不存在,钱包充值记录 id({})]", id); - throw exception(WALLET_RECHARGE_NOT_FOUND); - } - // 1.2 校验钱包充值是否可以支付 - PayOrderDO payOrderDO = validateWalletRechargerCanPaid(walletRecharge, payOrderId); - - // 2. 更新钱包充值的支付状态 - int updateCount = walletRechargeMapper.updateByIdAndPaid(id, false, - new PayWalletRechargeDO().setId(id).setPayStatus(true).setPayTime(LocalDateTime.now()) - .setPayChannelCode(payOrderDO.getChannelCode())); - if (updateCount == 0) { - throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID); - } - - // 3. 更新钱包余额 - // TODO @jason:这样的话,未来提现会不会把充值的,也提现走哈。类似先充 100,送 110;然后提现 110; - // TODO 需要钱包中加个可提现余额 - payWalletService.addWalletBalance(walletRecharge.getWalletId(), String.valueOf(id), - PayWalletBizTypeEnum.RECHARGE, walletRecharge.getTotalPrice()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void refundWalletRecharge(Long id, String userIp) { - // 1.1 获取钱包充值记录 - PayWalletRechargeDO walletRecharge = walletRechargeMapper.selectById(id); - if (walletRecharge == null) { - log.error("[refundWalletRecharge][钱包充值记录不存在,钱包充值记录 id({})]", id); - throw exception(WALLET_RECHARGE_NOT_FOUND); - } - // 1.2 校验钱包充值是否可以发起退款 - PayWalletDO wallet = validateWalletRechargeCanRefund(walletRecharge); - - // 2. 冻结退款的余额,暂时只处理赠送的余额也全部退回 - payWalletService.freezePrice(wallet.getId(), walletRecharge.getTotalPrice()); - - // 3. 创建退款单 - String walletRechargeId = String.valueOf(id); - String refundId = walletRechargeId + "-refund"; - Long payRefundId = payRefundService.createPayRefund(new PayRefundCreateReqDTO() - .setAppId(WALLET_PAY_APP_ID).setUserIp(userIp) - .setMerchantOrderId(walletRechargeId) - .setMerchantRefundId(refundId) - .setReason("想退钱").setPrice(walletRecharge.getPayPrice())); - - // 4. 更新充值记录退款单号 - // TODO @jaosn:一般新建这种 update 对象,建议是,第一个 set id 属性,容易知道以它为更新 - walletRechargeMapper.updateById(new PayWalletRechargeDO().setPayRefundId(payRefundId) - .setRefundStatus(WAITING.getStatus()).setId(walletRecharge.getId())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateWalletRechargeRefunded(Long id, Long payRefundId) { - // 1.1 获取钱包充值记录 - PayWalletRechargeDO walletRecharge = walletRechargeMapper.selectById(id); - if (walletRecharge == null) { - log.error("[updateWalletRechargerPaid][钱包充值记录不存在,钱包充值记录 id({})]", id); - throw exception(WALLET_RECHARGE_NOT_FOUND); - } - // 1.2 校验钱包充值是否可以更新已退款 - PayRefundDO payRefund = validateWalletRechargeCanRefunded(walletRecharge, payRefundId); - - PayWalletRechargeDO updateObj = new PayWalletRechargeDO().setId(id); - // 退款成功 - if (PayRefundStatusEnum.isSuccess(payRefund.getStatus())) { - // 2.1 更新钱包余额 - payWalletService.reduceWalletBalance(walletRecharge.getWalletId(), id, - PayWalletBizTypeEnum.RECHARGE_REFUND, walletRecharge.getTotalPrice()); - - updateObj.setRefundStatus(SUCCESS.getStatus()).setRefundTime(payRefund.getSuccessTime()) - .setRefundTotalPrice(walletRecharge.getTotalPrice()).setRefundPayPrice(walletRecharge.getPayPrice()) - .setRefundBonusPrice(walletRecharge.getBonusPrice()); - } - // 退款失败 - if (PayRefundStatusRespEnum.isFailure(payRefund.getStatus())) { - // 2.2 解冻余额 - payWalletService.unfreezePrice(walletRecharge.getWalletId(), walletRecharge.getTotalPrice()); - - updateObj.setRefundStatus(FAILURE.getStatus()); - } - // 3. 更新钱包充值的退款字段 - walletRechargeMapper.updateByIdAndRefunded(id, WAITING.getStatus(), updateObj); - } - - private PayRefundDO validateWalletRechargeCanRefunded(PayWalletRechargeDO walletRecharge, Long payRefundId) { - // 1. 校验退款订单匹配 - if (notEqual(walletRecharge.getPayRefundId(), payRefundId)) { - log.error("[validateWalletRechargeCanRefunded][钱包充值({}) 退款单不匹配({}),请进行处理!钱包充值的数据是:{}]", - walletRecharge.getId(), payRefundId, toJsonString(walletRecharge)); - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR); - } - - // 2.1 校验退款订单 - PayRefundDO payRefund = payRefundService.getRefund(payRefundId); - if (payRefund == null) { - log.error("[validateWalletRechargeCanRefunded][payRefund({})不存在]", payRefundId); - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND); - } - // 2.2 校验退款金额一致 - if (notEqual(payRefund.getRefundPrice(), walletRecharge.getPayPrice())) { - log.error("[validateWalletRechargeCanRefunded][钱包({}) payRefund({}) 退款金额不匹配,请进行处理!钱包数据是:{},payRefund 数据是:{}]", - walletRecharge.getId(), payRefundId, toJsonString(walletRecharge), toJsonString(payRefund)); - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH); - } - // 2.3 校验退款订单商户订单是否匹配 - if (notEqual(payRefund.getMerchantOrderId(), walletRecharge.getId().toString())) { - log.error("[validateWalletRechargeCanRefunded][钱包({}) 退款单不匹配({}),请进行处理!payRefund 数据是:{}]", - walletRecharge.getId(), payRefundId, toJsonString(payRefund)); - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR); - } - return payRefund; - } - - private PayWalletDO validateWalletRechargeCanRefund(PayWalletRechargeDO walletRecharge) { - // 校验充值订单是否支付 - if (!walletRecharge.getPayStatus()) { - throw exception(WALLET_RECHARGE_REFUND_FAIL_NOT_PAID); - } - // 校验充值订单是否已退款 - if (walletRecharge.getPayRefundId() != null) { - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUNDED); - } - // 校验钱包余额是否足够 - PayWalletDO wallet = payWalletService.getWallet(walletRecharge.getWalletId()); - Assert.notNull(wallet, "用户钱包({}) 不存在", wallet.getId()); - if (wallet.getBalance() < walletRecharge.getTotalPrice()) { - throw exception(WALLET_RECHARGE_REFUND_BALANCE_NOT_ENOUGH); - } - // TODO @芋艿:需要考虑下,赠送的金额,会不会导致提现超过; - return wallet; - } - - private PayOrderDO validateWalletRechargerCanPaid(PayWalletRechargeDO walletRecharge, Long payOrderId) { - // 1.1 校验充值记录的支付状态 - if (walletRecharge.getPayStatus()) { - log.error("[validateWalletRechargerCanPaid][钱包({}) 不处于未支付状态! 钱包数据是:{}]", - walletRecharge.getId(), toJsonString(walletRecharge)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID); - } - // 1.2 校验支付订单匹配 - if (notEqual(walletRecharge.getPayOrderId(), payOrderId)) { // 支付单号 - log.error("[validateWalletRechargerCanPaid][钱包({}) 支付单不匹配({}),请进行处理! 钱包数据是:{}]", - walletRecharge.getId(), payOrderId, toJsonString(walletRecharge)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR); - } - - // 2.1 校验支付单是否存在 - PayOrderDO payOrder = payOrderService.getOrder(payOrderId); - if (payOrder == null) { - log.error("[validateWalletRechargerCanPaid][钱包({}) payOrder({}) 不存在,请进行处理!]", - walletRecharge.getId(), payOrderId); - throw exception(PAY_ORDER_NOT_FOUND); - } - // 2.2 校验支付单已支付 - if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) { - log.error("[validateWalletRechargerCanPaid][钱包({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]", - walletRecharge.getId(), payOrderId, toJsonString(payOrder)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS); - } - // 2.3 校验支付金额一致 - if (notEqual(payOrder.getPrice(), walletRecharge.getPayPrice())) { - log.error("[validateDemoOrderCanPaid][钱包({}) payOrder({}) 支付金额不匹配,请进行处理!钱包 数据是:{},payOrder 数据是:{}]", - walletRecharge.getId(), payOrderId, toJsonString(walletRecharge), toJsonString(payOrder)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH); - } - // 2.4 校验支付订单的商户订单匹配 - if (notEqual(payOrder.getMerchantOrderId(), walletRecharge.getId().toString())) { - log.error("[validateDemoOrderCanPaid][钱包({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]", - walletRecharge.getId(), payOrderId, toJsonString(payOrder)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR); - } - return payOrder; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java deleted file mode 100644 index d9abe958d8..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; - -/** - * 钱包 Service 接口 - * - * @author jason - */ -public interface PayWalletService { - - /** - * 获取钱包信息 - *

- * 如果不存在,则创建钱包。由于用户注册时候不会创建钱包 - * - * @param userId 用户编号 - * @param userType 用户类型 - */ - PayWalletDO getOrCreateWallet(Long userId, Integer userType); - - /** - * 获取钱包信息 - * - * @param walletId 钱包 id - */ - PayWalletDO getWallet(Long walletId); - - - /** - * 获得会员钱包分页 - * - * @param pageReqVO 分页查询 - * @return 会员钱包分页 - */ - PageResult getWalletPage(Integer userType, PayWalletPageReqVO pageReqVO); - - /** - * 钱包订单支付 - * - * @param userId 用户 id - * @param userType 用户类型 - * @param outTradeNo 外部订单号 - * @param price 金额 - */ - PayWalletTransactionDO orderPay(Long userId, Integer userType, String outTradeNo, Integer price); - - /** - * 钱包订单支付退款 - * - * @param outRefundNo 外部退款号 - * @param refundPrice 退款金额 - * @param reason 退款原因 - */ - PayWalletTransactionDO orderRefund(String outRefundNo, Integer refundPrice, String reason); - - /** - * 扣减钱包余额 - * - * @param walletId 钱包 id - * @param bizId 业务关联 id - * @param bizType 业务关联分类 - * @param price 扣减金额 - * @return 钱包流水 - */ - PayWalletTransactionDO reduceWalletBalance(Long walletId, Long bizId, - PayWalletBizTypeEnum bizType, Integer price); - - /** - * 增加钱包余额 - * - * @param walletId 钱包 id - * @param bizId 业务关联 id - * @param bizType 业务关联分类 - * @param price 增加金额 - * @return 钱包流水 - */ - PayWalletTransactionDO addWalletBalance(Long walletId, String bizId, - PayWalletBizTypeEnum bizType, Integer price); - - /** - * 冻结钱包部分余额 - * - * @param id 钱包编号 - * @param price 冻结金额 - */ - void freezePrice(Long id, Integer price); - - /** - * 解冻钱包余额 - * - * @param id 钱包编号 - * @param price 解冻金额 - */ - void unfreezePrice(Long id, Integer price); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java deleted file mode 100644 index 036d73d04b..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java +++ /dev/null @@ -1,206 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletMapper; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT; -import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT_REFUND; - -/** - * 钱包 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -public class PayWalletServiceImpl implements PayWalletService { - - @Resource - private PayWalletMapper walletMapper; - @Resource - private PayWalletTransactionService walletTransactionService; - @Resource - @Lazy - private PayOrderService orderService; - @Resource - @Lazy - private PayRefundService refundService; - - @Override - public PayWalletDO getOrCreateWallet(Long userId, Integer userType) { - PayWalletDO wallet = walletMapper.selectByUserIdAndType(userId, userType); - if (wallet == null) { - wallet = new PayWalletDO().setUserId(userId).setUserType(userType) - .setBalance(0).setTotalExpense(0).setTotalRecharge(0); - wallet.setCreateTime(LocalDateTime.now()); - walletMapper.insert(wallet); - } - return wallet; - } - - @Override - public PayWalletDO getWallet(Long walletId) { - return walletMapper.selectById(walletId); - } - - @Override - public PageResult getWalletPage(Integer userType,PayWalletPageReqVO pageReqVO) { - return walletMapper.selectPage(userType, pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public PayWalletTransactionDO orderPay(Long userId, Integer userType, String outTradeNo, Integer price) { - // 1. 判断支付交易拓展单是否存 - PayOrderExtensionDO orderExtension = orderService.getOrderExtensionByNo(outTradeNo); - if (orderExtension == null) { - throw exception(PAY_ORDER_EXTENSION_NOT_FOUND); - } - PayWalletDO wallet = getOrCreateWallet(userId, userType); - // 2. 扣减余额 - return reduceWalletBalance(wallet.getId(), orderExtension.getOrderId(), PAYMENT, price); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public PayWalletTransactionDO orderRefund(String outRefundNo, Integer refundPrice, String reason) { - // 1.1 判断退款单是否存在 - PayRefundDO payRefund = refundService.getRefundByNo(outRefundNo); - if (payRefund == null) { - throw exception(REFUND_NOT_FOUND); - } - // 1.2 校验是否可以退款 - Long walletId = validateWalletCanRefund(payRefund.getId(), payRefund.getChannelOrderNo()); - PayWalletDO wallet = walletMapper.selectById(walletId); - Assert.notNull(wallet, "钱包 {} 不存在", walletId); - - // 2. 增加余额 - return addWalletBalance(walletId, String.valueOf(payRefund.getId()), PAYMENT_REFUND, refundPrice); - } - - /** - * 校验是否能退款 - * - * @param refundId 支付退款单 id - * @param walletPayNo 钱包支付 no - */ - private Long validateWalletCanRefund(Long refundId, String walletPayNo) { - // 1. 校验钱包支付交易存在 - PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransactionByNo(walletPayNo); - if (walletTransaction == null) { - throw exception(WALLET_TRANSACTION_NOT_FOUND); - } - // 2. 校验退款是否存在 - PayWalletTransactionDO refundTransaction = walletTransactionService.getWalletTransaction( - String.valueOf(refundId), PAYMENT_REFUND); - if (refundTransaction != null) { - throw exception(WALLET_REFUND_EXIST); - } - return walletTransaction.getWalletId(); - } - - @Override - public PayWalletTransactionDO reduceWalletBalance(Long walletId, Long bizId, - PayWalletBizTypeEnum bizType, Integer price) { - // 1. 获取钱包 - PayWalletDO payWallet = getWallet(walletId); - if (payWallet == null) { - log.error("[reduceWalletBalance],用户钱包({})不存在.", walletId); - throw exception(WALLET_NOT_FOUND); - } - - // 2.1 扣除余额 - int updateCounts; - switch (bizType) { - case PAYMENT: { - updateCounts = walletMapper.updateWhenConsumption(payWallet.getId(), price); - break; - } - case RECHARGE_REFUND: { - updateCounts = walletMapper.updateWhenRechargeRefund(payWallet.getId(), price); - break; - } - default: { - // TODO 其它类型待实现 - throw new UnsupportedOperationException("待实现"); - } - } - if (updateCounts == 0) { - throw exception(WALLET_BALANCE_NOT_ENOUGH); - } - // 2.2 生成钱包流水 - Integer afterBalance = payWallet.getBalance() - price; - WalletTransactionCreateReqBO bo = new WalletTransactionCreateReqBO().setWalletId(payWallet.getId()) - .setPrice(-price).setBalance(afterBalance).setBizId(String.valueOf(bizId)) - .setBizType(bizType.getType()).setTitle(bizType.getDescription()); - return walletTransactionService.createWalletTransaction(bo); - } - - @Override - public PayWalletTransactionDO addWalletBalance(Long walletId, String bizId, - PayWalletBizTypeEnum bizType, Integer price) { - // 1.1 获取钱包 - PayWalletDO payWallet = getWallet(walletId); - if (payWallet == null) { - log.error("[addWalletBalance],用户钱包({})不存在.", walletId); - throw exception(WALLET_NOT_FOUND); - } - // 1.2 更新钱包金额 - switch (bizType) { - case PAYMENT_REFUND: { // 退款更新 - walletMapper.updateWhenConsumptionRefund(payWallet.getId(), price); - break; - } - case RECHARGE: { // 充值更新 - walletMapper.updateWhenRecharge(payWallet.getId(), price); - break; - } - default: { - // TODO 其它类型待实现 - throw new UnsupportedOperationException("待实现"); - } - } - - // 2. 生成钱包流水 - WalletTransactionCreateReqBO transactionCreateReqBO = new WalletTransactionCreateReqBO() - .setWalletId(payWallet.getId()).setPrice(price).setBalance(payWallet.getBalance() + price) - .setBizId(bizId).setBizType(bizType.getType()).setTitle(bizType.getDescription()); - return walletTransactionService.createWalletTransaction(transactionCreateReqBO); - } - - @Override - public void freezePrice(Long id, Integer price) { - int updateCounts = walletMapper.freezePrice(id, price); - if (updateCounts == 0) { - throw exception(WALLET_BALANCE_NOT_ENOUGH); - } - } - - @Override - public void unfreezePrice(Long id, Integer price) { - int updateCounts = walletMapper.unFreezePrice(id, price); - if (updateCounts == 0) { - throw exception(WALLET_FREEZE_PRICE_NOT_ENOUGH); - } - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java deleted file mode 100644 index 551a18261c..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; - -import jakarta.validation.Valid; - -/** - * 钱包余额流水 Service 接口 - * - * @author jason - */ -public interface PayWalletTransactionService { - - /** - * 查询钱包余额流水分页 - * - * @param userId 用户编号 - * @param userType 用户类型 - * @param pageVO 分页查询参数 - */ - PageResult getWalletTransactionPage(Long userId, Integer userType, - AppPayWalletTransactionPageReqVO pageVO); - - /** - * 查询钱包余额流水分页 - * - * @param pageVO 分页查询参数 - */ - PageResult getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO); - - /** - * 新增钱包余额流水 - * - * @param bo 创建钱包流水 bo - * @return 新建的钱包 do - */ - PayWalletTransactionDO createWalletTransaction(@Valid WalletTransactionCreateReqBO bo); - - /** - * 根据 no,获取钱包余流水 - * - * @param no 流水号 - */ - PayWalletTransactionDO getWalletTransactionByNo(String no); - - /** - * 获取钱包流水 - * - * @param bizId 业务编号 - * @param type 业务类型 - * @return 钱包流水 - */ - PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java deleted file mode 100644 index 34e1c7956e..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletTransactionMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -/** - * 钱包流水 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -@Validated -public class PayWalletTransactionServiceImpl implements PayWalletTransactionService { - - /** - * 钱包流水的 no 前缀 - */ - private static final String WALLET_NO_PREFIX = "W"; - - @Resource - private PayWalletService payWalletService; - @Resource - private PayWalletTransactionMapper payWalletTransactionMapper; - @Resource - private PayNoRedisDAO noRedisDAO; - - @Override - public PageResult getWalletTransactionPage(Long userId, Integer userType, - AppPayWalletTransactionPageReqVO pageVO) { - PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType); - return payWalletTransactionMapper.selectPage(wallet.getId(), pageVO.getType(), pageVO); - } - - @Override - public PageResult getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO) { - return payWalletTransactionMapper.selectPage(pageVO.getWalletId(), null, pageVO); - } - - @Override - public PayWalletTransactionDO createWalletTransaction(WalletTransactionCreateReqBO bo) { - PayWalletTransactionDO transaction = PayWalletTransactionConvert.INSTANCE.convert(bo) - .setNo(noRedisDAO.generate(WALLET_NO_PREFIX)); - payWalletTransactionMapper.insert(transaction); - return transaction; - } - - @Override - public PayWalletTransactionDO getWalletTransactionByNo(String no) { - return payWalletTransactionMapper.selectByNo(no); - } - - @Override - public PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type) { - return payWalletTransactionMapper.selectByBiz(bizId, type.getType()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java deleted file mode 100644 index cde57f1128..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet.bo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -/** - * 创建钱包流水 BO - * - * @author jason - */ -@Data -public class WalletTransactionCreateReqBO { - - /** - * 钱包编号 - * - */ - @NotNull(message = "钱包编号不能为空") - private Long walletId; - - /** - * 交易金额,单位分 - * - * 正值表示余额增加,负值表示余额减少 - */ - @NotNull(message = "交易金额不能为空") - private Integer price; - - /** - * 交易后余额,单位分 - */ - @NotNull(message = "交易后余额不能为空") - private Integer balance; - - /** - * 关联业务分类 - * - * 枚举 {@link PayWalletBizTypeEnum#getType()} - */ - @NotNull(message = "关联业务分类不能为空") - @InEnum(PayWalletBizTypeEnum.class) - private Integer bizType; - - /** - * 关联业务编号 - */ - @NotEmpty(message = "关联业务编号不能为空") - private String bizId; - - /** - * 流水说明 - */ - @NotEmpty(message = "流水说明不能为空") - private String title; -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java deleted file mode 100644 index 73b4f6f828..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.merchant; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WXPayClientConfig; -import org.junit.jupiter.api.Test; - -public class PayChannelDOTest { - - @Test - public void testSerialization() { - PayChannelDO payChannelDO = new PayChannelDO(); - // 创建配置 - WXPayClientConfig config = new WXPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WXPayClientConfig.API_VERSION_V2); - config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); - payChannelDO.setConfig(config); - - // 序列化 - String text = JsonUtils.toJsonString(payChannelDO); - System.out.println(text); - - // 反序列化 - payChannelDO = JsonUtils.parseObject(text, PayChannelDO.class); - System.out.println(payChannelDO.getConfig().getClass()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java deleted file mode 100644 index bed3d1471e..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.merchant; - -import cn.hutool.core.io.IoUtil; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WXPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import cn.iocoder.yudao.module.pay.test.BaseDbIntegrationTest; -import org.junit.jupiter.api.Test; - -import jakarta.annotation.Resource; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.List; - -@Resource -public class PayChannelMapperIntegrationTest extends BaseDbIntegrationTest { - - @Resource - private PayChannelMapper payChannelMapper; - - /** - * 插入 {@link PayChannelEnum#WX_PUB} 初始配置 - */ - @Test - public void testInsertWxPub() throws FileNotFoundException { - PayChannelDO payChannelDO = new PayChannelDO(); - payChannelDO.setCode(PayChannelEnum.WX_PUB.getCode()); - payChannelDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - payChannelDO.setFeeRate(1D); - payChannelDO.setAppId(6L); - // 配置 - WXPayClientConfig config = new WXPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WXPayClientConfig.API_VERSION_V2); - config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); - config.setPrivateKeyContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_key.pem"))); - config.setPrivateCertContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"))); - config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase"); - payChannelDO.setConfig(config); - // 执行插入 - payChannelMapper.insert(payChannelDO); - } - - // TODO @ouyang:Zfb 改成 AlipayQr - /** - * 插入 {@link PayChannelEnum#ALIPAY_QR} 初始配置 - */ - @Test - public void testInsertZfb() { - PayChannelDO payChannelDO = new PayChannelDO(); - payChannelDO.setCode(PayChannelEnum.ALIPAY_QR.getCode()); - payChannelDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - payChannelDO.setFeeRate(1D); - payChannelDO.setAppId(6L); - // 配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(AlipayPayClientConfig.SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - payChannelDO.setConfig(config); - // 执行插入 - payChannelMapper.insert(payChannelDO); - } - - /** - * 查询所有支付配置,看看是否都是 ok 的 - */ - @Test - public void testSelectList() { - List payChannels = payChannelMapper.selectList(); - System.out.println(payChannels.size()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java deleted file mode 100644 index 60d8f9ba69..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.order; - -import cn.iocoder.yudao.module.pay.service.channel.PayAppServiceImpl; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelServiceImpl; -import cn.iocoder.yudao.module.pay.service.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.service.order.dto.PayOrderSubmitReqDTO; -import cn.iocoder.yudao.module.pay.test.BaseDbIntegrationTest; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.pay.config.YudaoPayAutoConfiguration; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.Duration; - -@Import({PayOrderServiceImpl.class, PayAppServiceImpl.class, - PayChannelServiceImpl.class, YudaoPayAutoConfiguration.class}) -public class PayOrderServiceIntegrationTest extends BaseDbIntegrationTest { - - @Resource - private PayOrderService payOrderService; - - @Test - public void testCreatePayOrder() { - // 构造请求 - PayOrderCreateReqDTO reqDTO = new PayOrderCreateReqDTO(); - reqDTO.setAppId(6L); - reqDTO.setUserIp("127.0.0.1"); - reqDTO.setMerchantOrderId(String.valueOf(System.currentTimeMillis())); - reqDTO.setSubject("标题"); - reqDTO.setBody("内容"); - reqDTO.setPrice(100); - reqDTO.setExpireTime(DateUtils.addTime(Duration.ofDays(1))); - // 发起请求 - payOrderService.createPayOrder(reqDTO); - } - - @Test - public void testSubmitPayOrder() { - // 构造请求 - PayOrderSubmitReqDTO reqDTO = new PayOrderSubmitReqDTO(); - reqDTO.setId(10L); - reqDTO.setAppId(6L); - reqDTO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqDTO.setUserIp("127.0.0.1"); - // 发起请求 - payOrderService.submitPayOrder(reqDTO); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java deleted file mode 100644 index 2cad91ebaa..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.pay.service; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbAndRedisIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbAndRedisIntegrationTest.java deleted file mode 100644 index 2ee19ebf91..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbAndRedisIntegrationTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.pay.test; - -import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; -import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration; -import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; -import org.redisson.spring.starter.RedissonAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbAndRedisIntegrationTest.Application.class) -@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 -public class BaseDbAndRedisIntegrationTest { - - @Import({ - // DB 配置类 - DynamicDataSourceAutoConfiguration.class, // Dynamic Datasource 配置类 - YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 - DataSourceAutoConfiguration.class, // Spring DB 自动配置类 - DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 - // MyBatis 配置类 - YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 - MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 - - // Redis 配置类 - RedisAutoConfiguration.class, // Spring Redis 自动配置类 - YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 - RedissonAutoConfiguration.class, // Redisson 自动高配置类 - }) - public static class Application { - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbIntegrationTest.java deleted file mode 100644 index 380efa3f40..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbIntegrationTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.test; - -import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; -import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration; -import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbIntegrationTest.Application.class) -@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 -public class BaseDbIntegrationTest { - - @Import({ - // DB 配置类 - DynamicDataSourceAutoConfiguration.class, // Dynamic Datasource 配置类 - YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 - DataSourceAutoConfiguration.class, // Spring DB 自动配置类 - DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 - // MyBatis 配置类 - YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 - MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 - }) - public static class Application { - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseRedisIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseRedisIntegrationTest.java deleted file mode 100644 index d01353d725..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseRedisIntegrationTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.pay.test; - -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import org.redisson.spring.starter.RedissonAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseRedisIntegrationTest.Application.class) -@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 -public class BaseRedisIntegrationTest { - - @Import({ - // Redis 配置类 - RedisAutoConfiguration.class, // Spring Redis 自动配置类 - YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 - RedissonAutoConfiguration.class, // Redisson 自动高配置类 - }) - public static class Application { - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml deleted file mode 100644 index 0e55d5639a..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml +++ /dev/null @@ -1,94 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - name: ruoyi-vue-pro - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT - driver-class-name: com.mysql.jdbc.Driver - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 - name: ruoyi-vue-pro - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT - driver-class-name: com.mysql.jdbc.Driver - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印日志 - global-config: - db-config: - id-type: AUTO # 自增 ID - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - mapper-locations: classpath*:mapper/*.xml - type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 -resilience4j: - ratelimiter: - instances: - backendA: - limit-for-period: 1 # 每个周期内,允许的请求数。默认为 50 - limit-refresh-period: 60s # 每个周期的时长,单位:微秒。默认为 500 - timeout-duration: 1s # 被限流时,阻塞等待的时长,单位:微秒。默认为 5s - register-health-indicator: true # 是否注册到健康监测 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module - pay: - pay-notify-url: http://niubi.natapp1.cc/api/pay/order/notify - refund-notify-url: http://niubi.natapp1.cc/api/pay/refund/notify diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceTest.java deleted file mode 100644 index 326d58617e..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceTest.java +++ /dev/null @@ -1,260 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.app; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.mysql.app.PayAppMapper; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static java.util.Collections.singleton; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link PayAppServiceImpl} 的单元测试 - * - * @author aquan - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import(PayAppServiceImpl.class) -public class PayAppServiceTest extends BaseDbUnitTest { - - @Resource - private PayAppServiceImpl appService; - - @Resource - private PayAppMapper appMapper; - - @MockBean - private PayOrderService orderService; - @MockBean - private PayRefundService refundService; - - @Test - public void testCreateApp_success() { - // 准备参数 - PayAppCreateReqVO reqVO = randomPojo(PayAppCreateReqVO.class, o -> - o.setStatus((RandomUtil.randomEle(CommonStatusEnum.values()).getStatus())) - .setOrderNotifyUrl(randomURL()) - .setRefundNotifyUrl(randomURL())); - - // 调用 - Long appId = appService.createApp(reqVO); - // 断言 - assertNotNull(appId); - PayAppDO app = appMapper.selectById(appId); - assertPojoEquals(reqVO, app); - } - - @Test - public void testUpdateApp_success() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - PayAppUpdateReqVO reqVO = randomPojo(PayAppUpdateReqVO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setOrderNotifyUrl(randomURL()).setRefundNotifyUrl(randomURL()); - o.setId(dbApp.getId()); // 设置更新的 ID - }); - - // 调用 - appService.updateApp(reqVO); - // 校验是否更新正确 - PayAppDO app = appMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, app); - } - - @Test - public void testUpdateApp_notExists() { - // 准备参数 - PayAppUpdateReqVO reqVO = randomPojo(PayAppUpdateReqVO.class, o -> - o.setStatus((RandomUtil.randomEle(CommonStatusEnum.values()).getStatus()))); - // 调用, 并断言异常 - assertServiceException(() -> appService.updateApp(reqVO), APP_NOT_FOUND); - } - - @Test - public void testUpdateAppStatus() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, o -> - o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - - // 准备参数 - Long id = dbApp.getId(); - Integer status = CommonStatusEnum.ENABLE.getStatus(); - // 调用 - appService.updateAppStatus(id, status); - // 断言 - PayAppDO app = appMapper.selectById(id); // 获取最新的 - assertEquals(status, app.getStatus()); - } - - @Test - public void testDeleteApp_success() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - - // 调用 - appService.deleteApp(id); - // 校验数据不存在了 - assertNull(appMapper.selectById(id)); - } - - @Test - public void testDeleteApp_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> appService.deleteApp(id), APP_NOT_FOUND); - } - - @Test - public void testDeleteApp_existOrder() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - // mock 订单有订单 - when(orderService.getOrderCountByAppId(eq(id))).thenReturn(10L); - - // 调用, 并断言异常 - assertServiceException(() -> appService.deleteApp(id), APP_EXIST_ORDER_CANT_DELETE); - } - - @Test - public void testDeleteApp_existRefund() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - // mock 订单有订单 - when(refundService.getRefundCountByAppId(eq(id))).thenReturn(10L); - - // 调用, 并断言异常 - assertServiceException(() -> appService.deleteApp(id), APP_EXIST_REFUND_CANT_DELETE); - } - - @Test - public void testApp() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - - // 调用 - PayAppDO app = appService.getApp(id); - // 校验数据一致 - assertPojoEquals(app, dbApp); - } - - @Test - public void testAppMap() { - // mock 数据 - PayAppDO dbApp01 = randomPojo(PayAppDO.class); - appMapper.insert(dbApp01);// @Sql: 先插入出一条存在的数据 - PayAppDO dbApp02 = randomPojo(PayAppDO.class); - appMapper.insert(dbApp02);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp01.getId(); - - // 调用 - Map appMap = appService.getAppMap(singleton(id)); - // 校验数据一致 - assertEquals(1, appMap.size()); - assertPojoEquals(dbApp01, appMap.get(id)); - } - - @Test - public void testGetAppPage() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, o -> { // 等会查询到 - o.setName("灿灿姐的杂货铺"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2021,11,20)); - }); - - appMapper.insert(dbApp); - // 测试 name 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setName("敏敏姐的杂货铺"))); - // 测试 status 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setCreateTime(buildTime(2021,12,21)))); - // 准备参数 - PayAppPageReqVO reqVO = new PayAppPageReqVO(); - reqVO.setName("灿灿姐的杂货铺"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2021, 11, 19, 2021, 11, 21)); - - // 调用 - PageResult pageResult = appService.getAppPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbApp, pageResult.getList().get(0)); - } - - @Test - public void testValidPayApp_success() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, - o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - - // 调用 - PayAppDO app = appService.validPayApp(id); - // 校验数据一致 - assertPojoEquals(app, dbApp); - } - - @Test - public void testValidPayApp_notFound() { - assertServiceException(() -> appService.validPayApp(randomLongId()), APP_NOT_FOUND); - } - - @Test - public void testValidPayApp_disable() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, - o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - - // 调用,并断言异常 - assertServiceException(() -> appService.validPayApp(id), APP_IS_DISABLE); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java deleted file mode 100644 index e8840d42e7..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java +++ /dev/null @@ -1,343 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.channel; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.mysql.channel.PayChannelMapper; -import com.alibaba.fastjson.JSON; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import jakarta.validation.Validator; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -@Import({PayChannelServiceImpl.class}) -public class PayChannelServiceTest extends BaseDbUnitTest { - - @Resource - private PayChannelServiceImpl channelService; - - @Resource - private PayChannelMapper channelMapper; - - @MockBean - private PayClientFactory payClientFactory; - @MockBean - private Validator validator; - - @Test - public void testCreateChannel_success() { - // 准备参数 - WxPayClientConfig config = randomWxPayClientConfig(); - PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> { - o.setStatus(randomCommonStatus()); - o.setCode(PayChannelEnum.WX_PUB.getCode()); - o.setConfig(JsonUtils.toJsonString(config)); - }); - - // 调用 - Long channelId = channelService.createChannel(reqVO); - // 校验记录的属性是否正确 - PayChannelDO channel = channelMapper.selectById(channelId); - assertPojoEquals(reqVO, channel, "config"); - assertPojoEquals(config, channel.getConfig()); - // 校验缓存 - assertNull(channelService.getClientCache().getIfPresent(channelId)); - } - - @Test - public void testCreateChannel_exists() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, - o -> o.setConfig(randomWxPayClientConfig())); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> { - o.setAppId(dbChannel.getAppId()); - o.setCode(dbChannel.getCode()); - }); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.createChannel(reqVO), CHANNEL_EXIST_SAME_CHANNEL_ERROR); - } - - @Test - public void testUpdateChannel_success() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - AlipayPayClientConfig config = randomAlipayPayClientConfig(); - PayChannelUpdateReqVO reqVO = randomPojo(PayChannelUpdateReqVO.class, o -> { - o.setId(dbChannel.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - o.setConfig(JsonUtils.toJsonString(config)); - }); - - // 调用 - channelService.updateChannel(reqVO); - // 校验是否更新正确 - PayChannelDO channel = channelMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, channel, "config"); - assertPojoEquals(config, channel.getConfig()); - // 校验缓存 - assertNull(channelService.getClientCache().getIfPresent(channel.getId())); - } - - @Test - public void testUpdateChannel_notExists() { - // 准备参数 - AlipayPayClientConfig payClientPublicKeyConfig = randomAlipayPayClientConfig(); - PayChannelUpdateReqVO reqVO = randomPojo(PayChannelUpdateReqVO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setConfig(JSON.toJSONString(payClientPublicKeyConfig)); - }); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.updateChannel(reqVO), CHANNEL_NOT_FOUND); - } - - @Test - public void testDeleteChannel_success() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbChannel.getId(); - - // 调用 - channelService.deleteChannel(id); - // 校验数据不存在了 - assertNull(channelMapper.selectById(id)); - // 校验缓存 - assertNull(channelService.getClientCache().getIfPresent(id)); - } - - @Test - public void testDeleteChannel_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.deleteChannel(id), CHANNEL_NOT_FOUND); - } - - @Test - public void testGetChannel() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbChannel.getId(); - - // 调用 - PayChannelDO channel = channelService.getChannel(id); - // 校验是否更新正确 - assertPojoEquals(dbChannel, channel); - } - - @Test - public void testGetChannelListByAppIds() { - // mock 数据 - PayChannelDO dbChannel01 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel01);// @Sql: 先插入出一条存在的数据 - PayChannelDO dbChannel02 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.WX_PUB.getCode()); - o.setConfig(randomWxPayClientConfig()); - }); - channelMapper.insert(dbChannel02);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long appId = dbChannel01.getAppId(); - - // 调用 - List channels = channelService.getChannelListByAppIds(Collections.singleton(appId)); - // 校验是否更新正确 - assertEquals(1, channels.size()); - assertPojoEquals(dbChannel01, channels.get(0)); - } - - @Test - public void testGetChannelByAppIdAndCode() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long appId = dbChannel.getAppId(); - String code = dbChannel.getCode();; - - // 调用 - PayChannelDO channel = channelService.getChannelByAppIdAndCode(appId, code); - // 断言 - assertPojoEquals(channel, dbChannel); - } - - @Test - public void testValidPayChannel_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.validPayChannel(id), CHANNEL_NOT_FOUND); - } - - @Test - public void testValidPayChannel_isDisable() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbChannel.getId(); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.validPayChannel(id), CHANNEL_IS_DISABLE); - } - - @Test - public void testValidPayChannel_success() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbChannel.getId(); - - // 调用 - PayChannelDO channel = channelService.validPayChannel(id); - // 断言异常 - assertPojoEquals(channel, dbChannel); - } - - @Test - public void testValidPayChannel_appIdAndCode() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long appId = dbChannel.getAppId(); - String code = dbChannel.getCode(); - - // 调用 - PayChannelDO channel = channelService.validPayChannel(appId, code); - // 断言异常 - assertPojoEquals(channel, dbChannel); - } - - @Test - public void testGetEnableChannelList() { - // 准备参数 - Long appId = randomLongId(); - // mock 数据 01(enable 不匹配) - PayChannelDO dbChannel01 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - }); - channelMapper.insert(dbChannel01);// @Sql: 先插入出一条存在的数据 - // mock 数据 02(appId 不匹配) - PayChannelDO dbChannel02 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - channelMapper.insert(dbChannel02);// @Sql: 先插入出一条存在的数据 - // mock 数据 03 - PayChannelDO dbChannel03 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setAppId(appId); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - channelMapper.insert(dbChannel03);// @Sql: 先插入出一条存在的数据 - - // 调用 - List channel = channelService.getEnableChannelList(appId); - // 断言异常 - assertPojoEquals(channel, dbChannel03); - } - - @Test - public void testGetPayClient() { - // mock 数据 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(channel); - // mock 参数 - Long id = channel.getId(); - // mock 方法 - PayClient mockClient = mock(PayClient.class); - when(payClientFactory.getPayClient(eq(id))).thenReturn(mockClient); - - // 调用 - PayClient client = channelService.getPayClient(id); - // 断言 - assertSame(client, mockClient); - verify(payClientFactory).createOrUpdatePayClient(eq(id), eq(channel.getCode()), - eq(channel.getConfig())); - } - - public WxPayClientConfig randomWxPayClientConfig() { - return new WxPayClientConfig() - .setAppId(randomString()) - .setMchId(randomString()) - .setApiVersion(WxPayClientConfig.API_VERSION_V2) - .setMchKey(randomString()); - } - - public AlipayPayClientConfig randomAlipayPayClientConfig() { - return new AlipayPayClientConfig() - .setServerUrl(randomURL()) - .setAppId(randomString()) - .setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT) - .setMode(AlipayPayClientConfig.MODE_PUBLIC_KEY) - .setPrivateKey(randomString()) - .setAlipayPublicKey(randomString()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceTest.java deleted file mode 100644 index cfd01ae626..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceTest.java +++ /dev/null @@ -1,353 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.notify; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyLogMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyTaskMapper; -import cn.iocoder.yudao.module.pay.dal.redis.notify.PayNotifyLockRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.framework.job.config.PayJobConfiguration; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundServiceImpl; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.redisson.api.RLock; -import org.redisson.api.RedissonClient; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -/** - * {@link PayRefundServiceImpl} 的单元测试类 - * - * @author 芋艿 - */ -@Disabled // TODO 芋艿:后续 fix 补充的单测 -@Import({PayJobConfiguration.class, PayNotifyServiceImpl.class, PayNotifyLockRedisDAO.class}) -public class PayNotifyServiceTest extends BaseDbUnitTest { - - @Resource - private PayNotifyServiceImpl notifyService; - - @MockBean - private PayOrderService orderService; - @MockBean - private PayRefundService refundService; - - @Resource - private PayNotifyTaskMapper notifyTaskMapper; - @Resource - private PayNotifyLogMapper notifyLogMapper; - - @MockBean - private RedissonClient redissonClient; - - @Test - public void testCreatePayNotifyTask_order() { - PayNotifyServiceImpl payNotifyService = mock(PayNotifyServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayNotifyServiceImpl.class))) - .thenReturn(payNotifyService); - - // 准备参数 - Integer type = PayNotifyTypeEnum.ORDER.getType(); - Long dataId = 1L; - // mock 方法(order) - PayOrderDO order = randomPojo(PayOrderDO.class); - when(orderService.getOrder(eq(1L))).thenReturn(order); - // mock 方法(lock) - mockLock(null); // null 的原因,是咱没办法拿到 taskId 新增 - - // 调用 - notifyService.createPayNotifyTask(type, dataId); - // 断言,task - PayNotifyTaskDO dbTask = notifyTaskMapper.selectOne(null); - assertNotNull(dbTask.getNextNotifyTime()); - assertThat(dbTask) - .extracting("type", "dataId", "status", "notifyTimes", "maxNotifyTimes", - "appId", "merchantOrderId", "notifyUrl") - .containsExactly(type, dataId, PayNotifyStatusEnum.WAITING.getStatus(), 0, 9, - order.getAppId(), order.getMerchantOrderId(), order.getNotifyUrl()); - // 断言,调用 - verify(payNotifyService).executeNotify0(eq(dbTask)); - } - } - - @Test - public void testCreatePayNotifyTask_refund() { - PayNotifyServiceImpl payNotifyService = mock(PayNotifyServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayNotifyServiceImpl.class))) - .thenReturn(payNotifyService); - - // 准备参数 - Integer type = PayNotifyTypeEnum.REFUND.getType(); - Long dataId = 1L; - // mock 方法(refund) - PayRefundDO refund = randomPojo(PayRefundDO.class); - when(refundService.getRefund(eq(1L))).thenReturn(refund); - // mock 方法(lock) - mockLock(null); // null 的原因,是咱没办法拿到 taskId 新增 - - // 调用 - notifyService.createPayNotifyTask(type, dataId); - // 断言,task - PayNotifyTaskDO dbTask = notifyTaskMapper.selectOne(null); - assertNotNull(dbTask.getNextNotifyTime()); - assertThat(dbTask) - .extracting("type", "dataId", "status", "notifyTimes", "maxNotifyTimes", - "appId", "merchantOrderId", "notifyUrl") - .containsExactly(type, dataId, PayNotifyStatusEnum.WAITING.getStatus(), 0, 9, - refund.getAppId(), refund.getMerchantOrderId(), refund.getNotifyUrl()); - // 断言,调用 - verify(payNotifyService).executeNotify0(eq(dbTask)); - } - } - - @Test - public void testExecuteNotify() throws InterruptedException { - // mock 数据(notify) - PayNotifyTaskDO dbTask01 = randomPojo(PayNotifyTaskDO.class, - o -> o.setStatus(PayNotifyStatusEnum.WAITING.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask01); - PayNotifyTaskDO dbTask02 = randomPojo(PayNotifyTaskDO.class, - o -> o.setStatus(PayNotifyStatusEnum.REQUEST_SUCCESS.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask02); - PayNotifyTaskDO dbTask03 = randomPojo(PayNotifyTaskDO.class, - o -> o.setStatus(PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask03); - PayNotifyTaskDO dbTask04 = randomPojo(PayNotifyTaskDO.class, // 不满足状态 - o -> o.setStatus(PayNotifyStatusEnum.FAILURE.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask04); - PayNotifyTaskDO dbTask05 = randomPojo(PayNotifyTaskDO.class, // 不满足状态 - o -> o.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask05); - PayNotifyTaskDO dbTask06 = randomPojo(PayNotifyTaskDO.class, // 不满足时间 - o -> o.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(1)))); - notifyTaskMapper.insert(dbTask06); - // mock 方法(lock) - mockLock(dbTask01.getId()); - mockLock(dbTask02.getId()); - mockLock(dbTask03.getId()); - - // 调用 - int count = notifyService.executeNotify(); - // 断言,数量 - assertEquals(count, 3); - } - - @Test // 由于 HttpUtil 不好 mock,所以只测试异常的情况 - public void testExecuteNotify0_exception() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, o -> o.setType(-1) - .setNotifyTimes(0).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - - // 调用 - notifyService.executeNotify0(task); - // 断言,task - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertNotEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 1); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()); - // 断言,log - PayNotifyLogDO dbLog = notifyLogMapper.selectOne(null); - assertEquals(dbLog.getTaskId(), task.getId()); - assertEquals(dbLog.getNotifyTimes(), 1); - assertTrue(dbLog.getResponse().contains("未知的通知任务类型:")); - assertEquals(dbLog.getStatus(), PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()); - } - - @Test - public void testProcessNotifyResult_success() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, - o -> o.setNotifyTimes(0).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - // 准备参数 - CommonResult invokeResult = CommonResult.success(randomString()); - - // 调用 - notifyService.processNotifyResult(task, invokeResult, null); - // 断言 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 1); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.SUCCESS.getStatus()); - } - - @Test - public void testProcessNotifyResult_failure() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, - o -> o.setNotifyTimes(8).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - // 准备参数 - CommonResult invokeResult = CommonResult.error(BAD_REQUEST); - - // 调用 - notifyService.processNotifyResult(task, invokeResult, null); - // 断言 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 9); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.FAILURE.getStatus()); - } - - @Test - public void testProcessNotifyResult_requestFailure() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, - o -> o.setNotifyTimes(0).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - // 准备参数 - CommonResult invokeResult = CommonResult.error(BAD_REQUEST); - - // 调用 - notifyService.processNotifyResult(task, invokeResult, null); - // 断言 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertNotEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 1); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.REQUEST_SUCCESS.getStatus()); - } - - @Test - public void testProcessNotifyResult_requestSuccess() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, - o -> o.setNotifyTimes(0).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - // 准备参数 - CommonResult invokeResult = CommonResult.error(BAD_REQUEST); - RuntimeException invokeException = new RuntimeException(); - - // 调用 - notifyService.processNotifyResult(task, invokeResult, invokeException); - // 断言 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertNotEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 1); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()); - } - - @Test - public void testGetNotifyTask() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class); - notifyTaskMapper.insert(task); - // 准备参数 - Long id = task.getId(); - - // 调用 - PayNotifyTaskDO dbTask = notifyService.getNotifyTask(id); - // 断言 - assertPojoEquals(dbTask, task); - } - - @Test - public void testGetNotifyTaskPage() { - // mock 数据 - PayNotifyTaskDO dbTask = randomPojo(PayNotifyTaskDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setType(PayNotifyTypeEnum.REFUND.getType()); - o.setDataId(100L); - o.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()); - o.setMerchantOrderId("P110"); - o.setCreateTime(buildTime(2023, 2, 3)); - }); - notifyTaskMapper.insert(dbTask); - // 测试 appId 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setAppId(2L))); - // 测试 type 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setType(PayNotifyTypeEnum.ORDER.getType()))); - // 测试 dataId 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setDataId(200L))); - // 测试 status 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setStatus(PayNotifyStatusEnum.FAILURE.getStatus()))); - // 测试 merchantOrderId 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setMerchantOrderId(randomString()))); - // 测试 createTime 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setCreateTime(buildTime(2023, 1, 1)))); - // 准备参数 - PayNotifyTaskPageReqVO reqVO = new PayNotifyTaskPageReqVO(); - reqVO.setAppId(1L); - reqVO.setType(PayNotifyTypeEnum.REFUND.getType()); - reqVO.setDataId(100L); - reqVO.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()); - reqVO.setMerchantOrderId("P110"); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = notifyService.getNotifyTaskPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbTask, pageResult.getList().get(0)); - } - - @Test - public void testGetNotifyLogList() { - // mock 数据 - PayNotifyLogDO dbLog = randomPojo(PayNotifyLogDO.class); - notifyLogMapper.insert(dbLog); - PayNotifyLogDO dbLog02 = randomPojo(PayNotifyLogDO.class); - notifyLogMapper.insert(dbLog02); - // 准备参数 - Long taskId = dbLog.getTaskId(); - - // 调用 - List logList = notifyService.getNotifyLogList(taskId); - // 断言 - assertEquals(logList.size(), 1); - assertPojoEquals(dbLog, logList.get(0)); - } - - private void mockLock(Long id) { - RLock lock = mock(RLock.class); - if (id == null) { - when(redissonClient.getLock(anyString())) - .thenReturn(lock); - } else { - when(redissonClient.getLock(eq("pay_notify:lock:" + id))) - .thenReturn(lock); - } - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java deleted file mode 100755 index 5dfe018a8a..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java +++ /dev/null @@ -1,1102 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.order; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderExtensionMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - -/** - * {@link PayOrderServiceImpl} 的单元测试类 - * - * @author 芋艿 - */ -@Import({PayOrderServiceImpl.class, PayNoRedisDAO.class}) -public class PayOrderServiceTest extends BaseDbAndRedisUnitTest { - - @Resource - private PayOrderServiceImpl orderService; - - @Resource - private PayOrderMapper orderMapper; - @Resource - private PayOrderExtensionMapper orderExtensionMapper; - - @MockBean - private PayProperties properties; - @MockBean - private PayAppService appService; - @MockBean - private PayChannelService channelService; - @MockBean - private PayNotifyService notifyService; - - @BeforeEach - public void setUp() { - when(properties.getOrderNotifyUrl()).thenReturn("http://127.0.0.1"); - } - - @Test - public void testGetOrder_id() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class); - orderMapper.insert(order); - // 准备参数 - Long id = order.getId(); - - // 调用 - PayOrderDO dbOrder = orderService.getOrder(id); - // 断言 - assertPojoEquals(dbOrder, order); - } - - @Test - public void testGetOrder_appIdAndMerchantOrderId() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class); - orderMapper.insert(order); - // 准备参数 - Long appId = order.getAppId(); - String merchantOrderId = order.getMerchantOrderId(); - - // 调用 - PayOrderDO dbOrder = orderService.getOrder(appId, merchantOrderId); - // 断言 - assertPojoEquals(dbOrder, order); - } - - @Test - public void testGetOrderCountByAppId() { - // mock 数据(PayOrderDO) - PayOrderDO order01 = randomPojo(PayOrderDO.class); - orderMapper.insert(order01); - PayOrderDO order02 = randomPojo(PayOrderDO.class); - orderMapper.insert(order02); - // 准备参数 - Long appId = order01.getAppId(); - - // 调用 - Long count = orderService.getOrderCountByAppId(appId); - // 断言 - assertEquals(count, 1L); - } - - @Test - public void testGetOrderPage() { - // mock 数据 - PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - o.setMerchantOrderId("110"); - o.setChannelOrderNo("220"); - o.setNo("330"); - o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - o.setCreateTime(buildTime(2018, 1, 15)); - }); - orderMapper.insert(dbOrder); - // 测试 appId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setAppId(2L))); - // 测试 channelCode 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); - // 测试 merchantOrderId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setMerchantOrderId(randomString()))); - // 测试 channelOrderNo 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelOrderNo(randomString()))); - // 测试 no 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setNo(randomString()))); - // 测试 status 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()))); - // 测试 createTime 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setCreateTime(buildTime(2019, 1, 1)))); - // 准备参数 - PayOrderPageReqVO reqVO = new PayOrderPageReqVO(); - reqVO.setAppId(1L); - reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqVO.setMerchantOrderId("11"); - reqVO.setChannelOrderNo("22"); - reqVO.setNo("33"); - reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2018, 1, 10, 2018, 1, 30)); - - // 调用 - PageResult pageResult = orderService.getOrderPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbOrder, pageResult.getList().get(0)); - } - - @Test - public void testGetOrderList() { - // mock 数据 - PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - o.setMerchantOrderId("110"); - o.setChannelOrderNo("220"); - o.setNo("330"); - o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - o.setCreateTime(buildTime(2018, 1, 15)); - }); - orderMapper.insert(dbOrder); - // 测试 appId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setAppId(2L))); - // 测试 channelCode 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); - // 测试 merchantOrderId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setMerchantOrderId(randomString()))); - // 测试 channelOrderNo 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelOrderNo(randomString()))); - // 测试 no 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setNo(randomString()))); - // 测试 status 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()))); - // 测试 createTime 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setCreateTime(buildTime(2019, 1, 1)))); - // 准备参数 - PayOrderExportReqVO reqVO = new PayOrderExportReqVO(); - reqVO.setAppId(1L); - reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqVO.setMerchantOrderId("11"); - reqVO.setChannelOrderNo("22"); - reqVO.setNo("33"); - reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2018, 1, 10, 2018, 1, 30)); - - // 调用 - List list = orderService.getOrderList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbOrder, list.get(0)); - } - - @Test - public void testCreateOrder_success() { - // mock 参数 - PayOrderCreateReqDTO reqDTO = randomPojo(PayOrderCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("10") - .setSubject(randomString()).setBody(randomString())); - // mock 方法 - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L).setOrderNotifyUrl("http://127.0.0.1")); - when(appService.validPayApp(eq(reqDTO.getAppId()))).thenReturn(app); - - // 调用 - Long orderId = orderService.createOrder(reqDTO); - // 断言 - PayOrderDO order = orderMapper.selectById(orderId); - assertPojoEquals(order, reqDTO); - assertEquals(order.getAppId(), 1L); - assertEquals(order.getNotifyUrl(), "http://127.0.0.1"); - assertEquals(order.getStatus(), PayOrderStatusEnum.WAITING.getStatus()); - assertEquals(order.getRefundPrice(), 0); - } - - @Test - public void testCreateOrder_exists() { - // mock 参数 - PayOrderCreateReqDTO reqDTO = randomPojo(PayOrderCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("10")); - // mock 数据 - PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> o.setAppId(1L).setMerchantOrderId("10")); - orderMapper.insert(dbOrder); - - // 调用 - Long orderId = orderService.createOrder(reqDTO); - // 断言 - PayOrderDO order = orderMapper.selectById(orderId); - assertPojoEquals(dbOrder, order); - } - - @Test - public void testSubmitOrder_notFound() { - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class); - String userIp = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_NOT_FOUND); - } - - @Test - public void testSubmitOrder_notWaiting() { - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.REFUND.getStatus())); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId())); - String userIp = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_STATUS_IS_NOT_WAITING); - } - - @Test - public void testSubmitOrder_isSuccess() { - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId())); - String userIp = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_STATUS_IS_SUCCESS); - } - - @Test - public void testSubmitOrder_expired() { - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofDays(-1)))); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId())); - String userIp = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_IS_EXPIRED); - } - - @Test - public void testSubmitOrder_channelNotFound() { - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setAppId(1L).setExpireTime(addTime(Duration.ofDays(1)))); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId()) - .setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - String userIp = randomString(); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L), eq(PayChannelEnum.ALIPAY_APP.getCode()))) - .thenReturn(channel); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), CHANNEL_NOT_FOUND); - } - - @Test // 调用 unifiedOrder 接口,返回存在渠道错误 - public void testSubmitOrder_channelError() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setAppId(1L).setExpireTime(addTime(Duration.ofDays(1)))); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId()) - .setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - String userIp = randomString(); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L), eq(PayChannelEnum.ALIPAY_APP.getCode()))) - .thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法() - PayOrderRespDTO unifiedOrderResp = randomPojo(PayOrderRespDTO.class, o -> - o.setChannelErrorCode("001").setChannelErrorMsg("模拟异常")); - when(client.unifiedOrder(argThat(payOrderUnifiedReqDTO -> { - assertNotNull(payOrderUnifiedReqDTO.getOutTradeNo()); - assertThat(payOrderUnifiedReqDTO) - .extracting("subject", "body", "notifyUrl", "returnUrl", "price", "expireTime") - .containsExactly(order.getSubject(), order.getBody(), "http://127.0.0.1/10", - reqVO.getReturnUrl(), order.getPrice(), order.getExpireTime()); - return true; - }))).thenReturn(unifiedOrderResp); - - // 调用,并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), - PAY_ORDER_SUBMIT_CHANNEL_ERROR, "001", "模拟异常"); - // 断言,数据记录(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = orderExtensionMapper.selectOne(null); - assertNotNull(orderExtension); - assertThat(orderExtension).extracting("no", "orderId").isNotNull(); - assertThat(orderExtension) - .extracting("channelId", "channelCode","userIp" ,"status", "channelExtras", - "channelErrorCode", "channelErrorMsg", "channelNotifyData") - .containsExactly(10L, PayChannelEnum.ALIPAY_APP.getCode(), userIp, - PayOrderStatusEnum.WAITING.getStatus(), reqVO.getChannelExtras(), - null, null, null); - } - } - - @Test - public void testSubmitOrder_success() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setAppId(1L).setExpireTime(addTime(Duration.ofDays(1)))); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId()) - .setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - String userIp = randomString(); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L), eq(PayChannelEnum.ALIPAY_APP.getCode()))) - .thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(支付渠道的调用) - PayOrderRespDTO unifiedOrderResp = randomPojo(PayOrderRespDTO.class, o -> o.setChannelErrorCode(null).setChannelErrorMsg(null) - .setDisplayMode(PayOrderDisplayModeEnum.URL.getMode()).setDisplayContent("tudou")); - when(client.unifiedOrder(argThat(payOrderUnifiedReqDTO -> { - assertNotNull(payOrderUnifiedReqDTO.getOutTradeNo()); - assertThat(payOrderUnifiedReqDTO) - .extracting("subject", "body", "notifyUrl", "returnUrl", "price", "expireTime") - .containsExactly(order.getSubject(), order.getBody(), "http://127.0.0.1/10", - reqVO.getReturnUrl(), order.getPrice(), order.getExpireTime()); - return true; - }))).thenReturn(unifiedOrderResp); - - // 调用 - PayOrderSubmitRespVO result = orderService.submitOrder(reqVO, userIp); - // 断言,数据记录(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = orderExtensionMapper.selectOne(null); - assertNotNull(orderExtension); - assertThat(orderExtension).extracting("no", "orderId").isNotNull(); - assertThat(orderExtension) - .extracting("channelId", "channelCode","userIp" ,"status", "channelExtras", - "channelErrorCode", "channelErrorMsg", "channelNotifyData") - .containsExactly(10L, PayChannelEnum.ALIPAY_APP.getCode(), userIp, - PayOrderStatusEnum.WAITING.getStatus(), reqVO.getChannelExtras(), - null, null, null); - // 断言,返回(PayOrderSubmitRespVO) - assertThat(result) - .extracting("status", "displayMode", "displayContent") - .containsExactly(PayOrderStatusEnum.WAITING.getStatus(), PayOrderDisplayModeEnum.URL.getMode(), "tudou"); - // 断言,调用 - verify(payOrderServiceImpl).notifyOrder(same(channel), same(unifiedOrderResp)); - } - } - - @Test - public void testValidateOrderActuallyPaid_dbPaid() { - // 准备参数 - Long id = randomLongId(); - // mock 方法(OrderExtension 已支付) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setOrderId(id).setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - orderExtensionMapper.insert(orderExtension); - - // 调用,并断言异常 - assertServiceException(() -> orderService.validateOrderActuallyPaid(id), - PAY_ORDER_EXTENSION_IS_PAID); - } - - @Test - public void testValidateOrderActuallyPaid_remotePaid() { - // 准备参数 - Long id = randomLongId(); - // mock 方法(OrderExtension 已支付) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setOrderId(id).setStatus(PayOrderStatusEnum.WAITING.getStatus())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient 已支付) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(orderExtension.getChannelId()))).thenReturn(client); - when(client.getOrder(eq(orderExtension.getNo()))).thenReturn(randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()))); - - // 调用,并断言异常 - assertServiceException(() -> orderService.validateOrderActuallyPaid(id), - PAY_ORDER_EXTENSION_IS_PAID); - } - - @Test - public void testValidateOrderActuallyPaid_success() { - // 准备参数 - Long id = randomLongId(); - // mock 方法(OrderExtension 已支付) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setOrderId(id).setStatus(PayOrderStatusEnum.WAITING.getStatus())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient 已支付) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(orderExtension.getChannelId()))).thenReturn(client); - when(client.getOrder(eq(orderExtension.getNo()))).thenReturn(randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()))); - - // 调用,并断言异常 - orderService.validateOrderActuallyPaid(id); - } - - @Test - public void testNotifyOrder_channelId() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - // 准备参数 - Long channelId = 10L; - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - orderService.notifyOrder(channelId, notify); - // 断言 - verify(payOrderServiceImpl).notifyOrder(same(channel), same(notify)); - } - } - - @Test - public void testNotifyOrderSuccess_orderExtension_notFound() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus())); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_EXTENSION_NOT_FOUND); - } - - @Test - public void testNotifyOrderSuccess_orderExtension_closed() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - - @Test - public void testNotifyOrderSuccess_order_notFound() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_NOT_FOUND); - // 断言 PayOrderExtensionDO :数据更新被回滚 - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - } - - @Test - public void testNotifyOrderSuccess_order_closed() { - testNotifyOrderSuccess_order_closedOrRefund(PayOrderStatusEnum.CLOSED.getStatus()); - } - - @Test - public void testNotifyOrderSuccess_order_refund() { - testNotifyOrderSuccess_order_closedOrRefund(PayOrderStatusEnum.REFUND.getStatus()); - } - - private void testNotifyOrderSuccess_order_closedOrRefund(Integer status) { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(status)); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setNo("P110") - .setOrderId(order.getId())); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_STATUS_IS_NOT_WAITING); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - } - - @Test - public void testNotifyOrderSuccess_order_paid() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setNo("P110") - .setOrderId(order.getId())); - orderExtensionMapper.insert(orderExtension); - // 重要:需要将 order 的 extensionId 更新下 - order.setExtensionId(orderExtension.getId()); - orderMapper.updateById(order); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - // 断言 PayOrderDO :数据未更新,因为它是 SUCCESS - assertPojoEquals(order, orderMapper.selectOne(null)); - // 断言,调用 - verify(notifyService, never()).createPayNotifyTask(anyInt(), anyLong()); - } - - @Test - public void testNotifyOrderSuccess_order_waiting() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setPrice(10)); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setNo("P110") - .setOrderId(order.getId())); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setFeeRate(10D)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS - orderExtension.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setChannelNotifyData(toJsonString(notify)); - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null), - "updateTime", "updater"); - // 断言 PayOrderDO :数据未更新,因为它是 SUCCESS - order.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setChannelId(10L).setChannelCode(channel.getCode()) - .setSuccessTime(notify.getSuccessTime()).setExtensionId(orderExtension.getId()).setNo(orderExtension.getNo()) - .setChannelOrderNo(notify.getChannelOrderNo()).setChannelUserId(notify.getChannelUserId()) - .setChannelFeeRate(10D).setChannelFeePrice(1); - assertPojoEquals(order, orderMapper.selectOne(null), - "updateTime", "updater"); - // 断言,调用 - verify(notifyService).createPayNotifyTask(eq(PayNotifyTypeEnum.ORDER.getType()), - eq(orderExtension.getOrderId())); - } - - @Test - public void testNotifyOrderClosed_orderExtension_notFound() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus())); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_EXTENSION_NOT_FOUND); - } - - @Test - public void testNotifyOrderClosed_orderExtension_closed() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 CLOSED - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - } - - @Test - public void testNotifyOrderClosed_orderExtension_paid() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - } - - @Test - public void testNotifyOrderClosed_orderExtension_refund() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - - @Test - public void testNotifyOrderClosed_orderExtension_waiting() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()) - .setOutTradeNo("P110")); - - // 调用 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO - orderExtension.setStatus(PayOrderStatusEnum.CLOSED.getStatus()).setChannelNotifyData(toJsonString(notify)) - .setChannelErrorCode(notify.getChannelErrorCode()).setChannelErrorMsg(notify.getChannelErrorMsg()); - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null), - "updateTime", "updater"); - } - - @Test - public void testUpdateOrderRefundPrice_notFound() { - // 准备参数 - Long id = randomLongId(); - Integer incrRefundPrice = randomInteger(); - - // 调用,并断言异常 - assertServiceException(() -> orderService.updateOrderRefundPrice(id, incrRefundPrice), - PAY_ORDER_NOT_FOUND); - } - - @Test - public void testUpdateOrderRefundPrice_waiting() { - testUpdateOrderRefundPrice_waitingOrClosed(PayOrderStatusEnum.WAITING.getStatus()); - } - - @Test - public void testUpdateOrderRefundPrice_closed() { - testUpdateOrderRefundPrice_waitingOrClosed(PayOrderStatusEnum.CLOSED.getStatus()); - } - - private void testUpdateOrderRefundPrice_waitingOrClosed(Integer status) { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(status)); - orderMapper.insert(order); - // 准备参数 - Long id = order.getId(); - Integer incrRefundPrice = randomInteger(); - - // 调用,并断言异常 - assertServiceException(() -> orderService.updateOrderRefundPrice(id, incrRefundPrice), - PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - - @Test - public void testUpdateOrderRefundPrice_priceExceed() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setRefundPrice(1).setPrice(10)); - orderMapper.insert(order); - // 准备参数 - Long id = order.getId(); - Integer incrRefundPrice = 10; - - // 调用,并断言异常 - assertServiceException(() -> orderService.updateOrderRefundPrice(id, incrRefundPrice), - REFUND_PRICE_EXCEED); - } - - @Test - public void testUpdateOrderRefundPrice_refund() { - testUpdateOrderRefundPrice_refundOrSuccess(PayOrderStatusEnum.REFUND.getStatus()); - } - - @Test - public void testUpdateOrderRefundPrice_success() { - testUpdateOrderRefundPrice_refundOrSuccess(PayOrderStatusEnum.SUCCESS.getStatus()); - } - - private void testUpdateOrderRefundPrice_refundOrSuccess(Integer status) { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(status).setRefundPrice(1).setPrice(10)); - orderMapper.insert(order); - // 准备参数 - Long id = order.getId(); - Integer incrRefundPrice = 8; - - // 调用 - orderService.updateOrderRefundPrice(id, incrRefundPrice); - // 断言 - order.setRefundPrice(9).setStatus(PayOrderStatusEnum.REFUND.getStatus()); - assertPojoEquals(order, orderMapper.selectOne(null), - "updateTime", "updater"); - } - - @Test - public void testGetOrderExtension() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - Long id = orderExtension.getId(); - - // 调用 - PayOrderExtensionDO dbOrderExtension = orderService.getOrderExtension(id); - // 断言 - assertPojoEquals(dbOrderExtension, orderExtension); - } - - @Test - public void testSyncOrder_payClientNotFound() { - // 准备参数 - LocalDateTime minCreateTime = LocalDateTime.now().minus(Duration.ofMinutes(10)); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setCreateTime(LocalDateTime.now())); - orderExtensionMapper.insert(orderExtension); - - // 调用 - int count = orderService.syncOrder(minCreateTime); - // 断言 - assertEquals(count, 0); - } - - @Test - public void testSyncOrder_exception() { - // 准备参数 - LocalDateTime minCreateTime = LocalDateTime.now().minus(Duration.ofMinutes(10)); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setChannelId(10L) - .setCreateTime(LocalDateTime.now())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 异常) - when(client.getOrder(any())).thenThrow(new RuntimeException()); - - // 调用 - int count = orderService.syncOrder(minCreateTime); - // 断言 - assertEquals(count, 0); - } - - @Test - public void testSyncOrder_orderSuccess() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // 准备参数 - LocalDateTime minCreateTime = LocalDateTime.now().minus(Duration.ofMinutes(10)); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setChannelId(10L).setNo("P110") - .setCreateTime(LocalDateTime.now())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 成功返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - // mock 方法(PayChannelDO) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - int count = orderService.syncOrder(minCreateTime); - // 断言 - assertEquals(count, 1); - verify(payOrderServiceImpl).notifyOrder(same(channel), same(respDTO)); - } - } - - @Test - public void testSyncOrder_orderClosed() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // 准备参数 - LocalDateTime minCreateTime = LocalDateTime.now().minus(Duration.ofMinutes(10)); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setChannelId(10L).setNo("P110") - .setCreateTime(LocalDateTime.now())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 成功返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - // mock 方法(PayChannelDO) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - int count = orderService.syncOrder(minCreateTime); - // 断言 - assertEquals(count, 0); - verify(payOrderServiceImpl).notifyOrder(same(channel), same(respDTO)); - } - } - - @Test - public void testExpireOrder_orderExtension_isSuccess() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 已支付) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setOrderId(order.getId())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 0); - // 断言 order 没有变化,因为没更新 - assertPojoEquals(order, orderMapper.selectOne(null)); - } - - @Test - public void testExpireOrder_payClient_notFound() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 等待中) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setOrderId(order.getId()) - .setChannelId(10L)); - orderExtensionMapper.insert(orderExtension); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 0); - // 断言 order 没有变化,因为没更新 - assertPojoEquals(order, orderMapper.selectOne(null)); - } - - @Test - public void testExpireOrder_getOrder_isRefund() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 等待中) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setOrderId(order.getId()).setNo("P110") - .setChannelId(10L)); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 退款返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.REFUND.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 0); - // 断言 order 没有变化,因为没更新 - assertPojoEquals(order, orderMapper.selectOne(null)); - } - - @Test - public void testExpireOrder_getOrder_isSuccess() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 等待中) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setOrderId(order.getId()).setNo("P110") - .setChannelId(10L)); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 成功返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - // mock 方法(PayChannelDO) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 0); - // 断言 order 没有变化,因为没更新 - assertPojoEquals(order, orderMapper.selectOne(null)); - verify(payOrderServiceImpl).notifyOrder(same(channel), same(respDTO)); - } - } - - @Test - public void testExpireOrder_success() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 等待中) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setOrderId(order.getId()).setNo("P110") - .setChannelId(10L)); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 关闭返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 1); - // 断言 extension 变化 - orderExtension.setStatus(PayOrderStatusEnum.CLOSED.getStatus()) - .setChannelNotifyData(toJsonString(respDTO)); - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null), - "updateTime", "updater"); - // 断言 order 变化 - order.setStatus(PayOrderStatusEnum.CLOSED.getStatus()); - assertPojoEquals(order, orderMapper.selectOne(null), - "updateTime", "updater"); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java deleted file mode 100755 index 7429d6c586..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java +++ /dev/null @@ -1,700 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.refund; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.mysql.refund.PayRefundMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -/** - * {@link PayRefundServiceImpl} 的单元测试类 - * - * @author 芋艿 - */ -@Import({PayRefundServiceImpl.class, PayNoRedisDAO.class}) -public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { - - @Resource - private PayRefundServiceImpl refundService; - - @Resource - private PayRefundMapper refundMapper; - - @MockBean - private PayProperties payProperties; - @MockBean - private PayOrderService orderService; - @MockBean - private PayAppService appService; - @MockBean - private PayChannelService channelService; - @MockBean - private PayNotifyService notifyService; - - @BeforeEach - public void setUp() { - when(payProperties.getRefundNotifyUrl()).thenReturn("http://127.0.0.1"); - } - - @Test - public void testGetRefund() { - // mock 数据 - PayRefundDO refund = randomPojo(PayRefundDO.class); - refundMapper.insert(refund); - // 准备参数 - Long id = refund.getId(); - - // 调用 - PayRefundDO dbRefund = refundService.getRefund(id); - // 断言 - assertPojoEquals(dbRefund, refund); - } - - @Test - public void testGetRefundCountByAppId() { - // mock 数据 - PayRefundDO refund01 = randomPojo(PayRefundDO.class); - refundMapper.insert(refund01); - PayRefundDO refund02 = randomPojo(PayRefundDO.class); - refundMapper.insert(refund02); - // 准备参数 - Long appId = refund01.getAppId(); - - // 调用 - Long count = refundService.getRefundCountByAppId(appId); - // 断言 - assertEquals(count, 1); - } - - @Test - public void testGetRefundPage() { - // mock 数据 - PayRefundDO dbRefund = randomPojo(PayRefundDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - o.setMerchantOrderId("MOT0000001"); - o.setMerchantRefundId("MRF0000001"); - o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - o.setChannelOrderNo("CH0000001"); - o.setChannelRefundNo("CHR0000001"); - o.setCreateTime(buildTime(2021, 1, 10)); - }); - refundMapper.insert(dbRefund); - // 测试 appId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L))); - // 测试 channelCode 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); - // 测试 merchantOrderId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantOrderId(randomString()))); - // 测试 merchantRefundId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantRefundId(randomString()))); - // 测试 channelOrderNo 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelOrderNo(randomString()))); - // 测试 channelRefundNo 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelRefundNo(randomString()))); - // 测试 status 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()))); - // 测试 createTime 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setCreateTime(buildTime(2021, 1, 1)))); - // 准备参数 - PayRefundPageReqVO reqVO = new PayRefundPageReqVO(); - reqVO.setAppId(1L); - reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqVO.setMerchantOrderId("MOT0000001"); - reqVO.setMerchantRefundId("MRF0000001"); - reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - reqVO.setChannelOrderNo("CH0000001"); - reqVO.setChannelRefundNo("CHR0000001"); - reqVO.setCreateTime(buildBetweenTime(2021, 1, 9, 2021, 1, 11)); - - // 调用 - PageResult pageResult = refundService.getRefundPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbRefund, pageResult.getList().get(0)); - } - - @Test - public void testGetRefundList() { - // mock 数据 - PayRefundDO dbRefund = randomPojo(PayRefundDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - o.setMerchantOrderId("MOT0000001"); - o.setMerchantRefundId("MRF0000001"); - o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - o.setChannelOrderNo("CH0000001"); - o.setChannelRefundNo("CHR0000001"); - o.setCreateTime(buildTime(2021, 1, 10)); - }); - refundMapper.insert(dbRefund); - // 测试 appId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L))); - // 测试 channelCode 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); - // 测试 merchantOrderId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantOrderId(randomString()))); - // 测试 merchantRefundId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantRefundId(randomString()))); - // 测试 channelOrderNo 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelOrderNo(randomString()))); - // 测试 channelRefundNo 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelRefundNo(randomString()))); - // 测试 status 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()))); - // 测试 createTime 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setCreateTime(buildTime(2021, 1, 1)))); - // 准备参数 - PayRefundExportReqVO reqVO = new PayRefundExportReqVO(); - reqVO.setAppId(1L); - reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqVO.setMerchantOrderId("MOT0000001"); - reqVO.setMerchantRefundId("MRF0000001"); - reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - reqVO.setChannelOrderNo("CH0000001"); - reqVO.setChannelRefundNo("CHR0000001"); - reqVO.setCreateTime(buildBetweenTime(2021, 1, 9, 2021, 1, 11)); - - // 调用 - List list = refundService.getRefundList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbRefund, list.get(0)); - } - - @Test - public void testCreateRefund_orderNotFound() { - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L)); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - PAY_ORDER_NOT_FOUND); - } - - @Test - public void testCreateRefund_orderWaiting() { - testCreateRefund_orderWaitingOrClosed(PayOrderStatusEnum.WAITING.getStatus()); - } - - @Test - public void testCreateRefund_orderClosed() { - testCreateRefund_orderWaitingOrClosed(PayOrderStatusEnum.CLOSED.getStatus()); - } - - private void testCreateRefund_orderWaitingOrClosed(Integer status) { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100")); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(status)); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - - @Test - public void testCreateRefund_refundPriceExceed() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(10)); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1)); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - REFUND_PRICE_EXCEED); - } - - @Test - public void testCreateRefund_orderHasRefunding() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(10)); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1)); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 数据(refund 在退款中) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> - o.setOrderId(order.getId()).setStatus(PayOrderStatusEnum.WAITING.getStatus())); - refundMapper.insert(refund); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - REFUND_PRICE_EXCEED); - } - - @Test - public void testCreateRefund_channelNotFound() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9)); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1) - .setChannelId(1L).setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L))).thenReturn(channel); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - CHANNEL_NOT_FOUND); - } - - @Test - public void testCreateRefund_refundExists() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9) - .setMerchantRefundId("200").setReason("测试退款")); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1) - .setChannelId(1L).setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L))).thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 数据(refund 已存在) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> - o.setAppId(1L).setMerchantRefundId("200")); - refundMapper.insert(refund); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - REFUND_EXISTS); - } - - @Test - public void testCreateRefund_invokeException() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9) - .setMerchantRefundId("200").setReason("测试退款")); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1) - .setChannelId(10L).setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(client 调用发生异常) - when(client.unifiedRefund(any(PayRefundUnifiedReqDTO.class))).thenThrow(new RuntimeException()); - - // 调用 - Long refundId = refundService.createPayRefund(reqDTO); - // 断言 - PayRefundDO refundDO = refundMapper.selectById(refundId); - assertPojoEquals(reqDTO, refundDO); - assertNotNull(refundDO.getNo()); - assertThat(refundDO) - .extracting("orderId", "orderNo", "channelId", "channelCode", - "notifyUrl", "channelOrderNo", "status", "payPrice", "refundPrice") - .containsExactly(order.getId(), order.getNo(), channel.getId(), channel.getCode(), - app.getRefundNotifyUrl(), order.getChannelOrderNo(), PayRefundStatusEnum.WAITING.getStatus(), - order.getPrice(), reqDTO.getPrice()); - } - - @Test - public void testCreateRefund_invokeSuccess() { - PayRefundServiceImpl payRefundServiceImpl = mock(PayRefundServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayRefundServiceImpl.class))) - .thenReturn(payRefundServiceImpl); - - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9) - .setMerchantRefundId("200").setReason("测试退款")); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1) - .setChannelId(10L).setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(client 成功) - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class); - when(client.unifiedRefund(argThat(unifiedReqDTO -> { - assertNotNull(unifiedReqDTO.getOutRefundNo()); - assertThat(unifiedReqDTO) - .extracting("payPrice", "refundPrice", "outTradeNo", - "notifyUrl", "reason") - .containsExactly(order.getPrice(), reqDTO.getPrice(), order.getNo(), - "http://127.0.0.1/10", reqDTO.getReason()); - return true; - }))).thenReturn(refundRespDTO); - - // 调用 - Long refundId = refundService.createPayRefund(reqDTO); - // 断言 - PayRefundDO refundDO = refundMapper.selectById(refundId); - assertPojoEquals(reqDTO, refundDO); - assertNotNull(refundDO.getNo()); - assertThat(refundDO) - .extracting("orderId", "orderNo", "channelId", "channelCode", - "notifyUrl", "channelOrderNo", "status", "payPrice", "refundPrice") - .containsExactly(order.getId(), order.getNo(), channel.getId(), channel.getCode(), - app.getRefundNotifyUrl(), order.getChannelOrderNo(), PayRefundStatusEnum.WAITING.getStatus(), - order.getPrice(), reqDTO.getPrice()); - // 断言调用 - verify(payRefundServiceImpl).notifyRefund(same(channel), same(refundRespDTO)); - } - } - - @Test - public void testNotifyRefund() { - PayRefundServiceImpl payRefundServiceImpl = mock(PayRefundServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayRefundServiceImpl.class))) - .thenReturn(payRefundServiceImpl); - - // 准备参数 - Long channelId = 10L; - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - refundService.notifyRefund(channelId, refundRespDTO); - // 断言 - verify(payRefundServiceImpl).notifyRefund(same(channel), same(refundRespDTO)); - } - } - - @Test - public void testNotifyRefundSuccess_notFound() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - - // 调用,并断言异常 - assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO), - REFUND_NOT_FOUND); - } - - @Test - public void testNotifyRefundSuccess_isSuccess() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.SUCCESS.getStatus())); - refundMapper.insert(refund); - - // 调用 - refundService.notifyRefund(channel, refundRespDTO); - // 断言,refund 没有更新,因为已经退款成功 - assertPojoEquals(refund, refundMapper.selectById(refund.getId())); - } - - @Test - public void testNotifyRefundSuccess_failure() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.FAILURE.getStatus())); - refundMapper.insert(refund); - - // 调用,并断言异常 - assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO), - REFUND_STATUS_IS_NOT_WAITING); - } - - @Test - public void testNotifyRefundSuccess_updateOrderException() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderId(100L).setRefundPrice(23)); - refundMapper.insert(refund); - // mock 方法(order + 更新异常) - doThrow(new RuntimeException()).when(orderService) - .updateOrderRefundPrice(eq(100L), eq(23)); - - // 调用,并断言异常 - assertThrows(RuntimeException.class, () -> refundService.notifyRefund(channel, refundRespDTO)); - // 断言,refund 没有更新,因为事务回滚了 - assertPojoEquals(refund, refundMapper.selectById(refund.getId())); - } - - @Test - public void testNotifyRefundSuccess_success() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderId(100L).setRefundPrice(23)); - refundMapper.insert(refund); - - // 调用 - refundService.notifyRefund(channel, refundRespDTO); - // 断言,refund - refund.setSuccessTime(refundRespDTO.getSuccessTime()) - .setChannelRefundNo(refundRespDTO.getChannelRefundNo()) - .setStatus(PayRefundStatusEnum.SUCCESS.getStatus()) - .setChannelNotifyData(toJsonString(refundRespDTO)); - assertPojoEquals(refund, refundMapper.selectById(refund.getId()), - "updateTime", "updater"); - // 断言,调用 - verify(orderService).updateOrderRefundPrice(eq(100L), eq(23)); - verify(notifyService).createPayNotifyTask(eq(PayNotifyTypeEnum.REFUND.getType()), - eq(refund.getId())); - } - - @Test - public void testNotifyRefundFailure_notFound() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100")); - - // 调用,并断言异常 - assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO), - REFUND_NOT_FOUND); - } - - @Test - public void testNotifyRefundFailure_isFailure() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 退款失败) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.FAILURE.getStatus())); - refundMapper.insert(refund); - - // 调用 - refundService.notifyRefund(channel, refundRespDTO); - // 断言,refund 没有更新,因为已经退款失败 - assertPojoEquals(refund, refundMapper.selectById(refund.getId())); - } - - @Test - public void testNotifyRefundFailure_isSuccess() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.SUCCESS.getStatus())); - refundMapper.insert(refund); - - // 调用,并断言异常 - assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO), - REFUND_STATUS_IS_NOT_WAITING); - } - - @Test - public void testNotifyRefundFailure_success() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderId(100L).setRefundPrice(23)); - refundMapper.insert(refund); - - // 调用 - refundService.notifyRefund(channel, refundRespDTO); - // 断言,refund - refund.setChannelRefundNo(refundRespDTO.getChannelRefundNo()) - .setStatus(PayRefundStatusEnum.FAILURE.getStatus()) - .setChannelNotifyData(toJsonString(refundRespDTO)) - .setChannelErrorCode(refundRespDTO.getChannelErrorCode()) - .setChannelErrorMsg(refundRespDTO.getChannelErrorMsg()); - assertPojoEquals(refund, refundMapper.selectById(refund.getId()), - "updateTime", "updater"); - // 断言,调用 - verify(notifyService).createPayNotifyTask(eq(PayNotifyTypeEnum.REFUND.getType()), - eq(refund.getId())); - } - - @Test - public void testSyncRefund_notFound() { - // 准备参数 - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L) - .setStatus(PayRefundStatusEnum.WAITING.getStatus())); - refundMapper.insert(refund); - - // 调用 - int count = refundService.syncRefund(); - // 断言 - assertEquals(count, 0); - } - - @Test - public void testSyncRefund_waiting() { - assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusRespEnum.WAITING.getStatus()), 0); - } - - @Test - public void testSyncRefund_success() { - assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusRespEnum.SUCCESS.getStatus()), 1); - } - - @Test - public void testSyncRefund_failure() { - assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusRespEnum.FAILURE.getStatus()), 1); - } - - private int testSyncRefund_waitingOrSuccessOrFailure(Integer status) { - PayRefundServiceImpl payRefundServiceImpl = mock(PayRefundServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayRefundServiceImpl.class))) - .thenReturn(payRefundServiceImpl); - - // 准备参数 - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setChannelId(10L) - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderNo("P110").setNo("R220")); - refundMapper.insert(refund); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(client 返回指定状态) - PayRefundRespDTO respDTO = randomPojo(PayRefundRespDTO.class, o -> o.setStatus(status)); - when(client.getRefund(eq("P110"), eq("R220"))).thenReturn(respDTO); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - return refundService.syncRefund(); - } - } - - @Test - public void testSyncRefund_exception() { - // 准备参数 - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setChannelId(10L) - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderNo("P110").setNo("R220")); - refundMapper.insert(refund); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(client 抛出异常) - when(client.getRefund(eq("P110"), eq("R220"))).thenThrow(new RuntimeException()); - - // 调用 - int count = refundService.syncRefund(); - // 断言 - assertEquals(count, 0); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 7b76570fd8..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,50 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/logback.xml b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff0..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/clean.sql b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index 91fff0caee..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,7 +0,0 @@ -DELETE FROM pay_app; -DELETE FROM pay_channel; -DELETE FROM pay_order; -DELETE FROM pay_order_extension; -DELETE FROM pay_refund; -DELETE FROM pay_notify_task; -DELETE FROM pay_notify_log; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/create_tables.sql b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 6ae2ce2d44..0000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,146 +0,0 @@ -CREATE TABLE IF NOT EXISTS "pay_app" ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(64) NOT NULL, - "status" tinyint NOT NULL, - "remark" varchar(255) DEFAULT NULL, - `order_notify_url` varchar(1024) NOT NULL, - `refund_notify_url` varchar(1024) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '支付应用'; - -CREATE TABLE IF NOT EXISTS "pay_channel" ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "code" varchar(32) NOT NULL, - "status" tinyint(4) NOT NULL, - "remark" varchar(255) DEFAULT NULL, - "fee_rate" double NOT NULL DEFAULT 0, - "app_id" bigint(20) NOT NULL, - "config" varchar(10240) NOT NULL, - "creator" varchar(64) NULL DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) NULL DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit(1) NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT = '支付渠道'; - -CREATE TABLE IF NOT EXISTS `pay_order` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `app_id` bigint(20) NOT NULL, - `channel_id` bigint(20) DEFAULT NULL, - `channel_code` varchar(32) DEFAULT NULL, - `merchant_order_id` varchar(64) NOT NULL, - `subject` varchar(32) NOT NULL, - `body` varchar(128) NOT NULL, - `notify_url` varchar(1024) NOT NULL, - `price` bigint(20) NOT NULL, - `channel_fee_rate` double DEFAULT 0, - `channel_fee_price` bigint(20) DEFAULT 0, - `status` tinyint(4) NOT NULL, - `user_ip` varchar(50) NOT NULL, - `expire_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `success_time` datetime(0) DEFAULT CURRENT_TIMESTAMP, - `notify_time` datetime(0) DEFAULT CURRENT_TIMESTAMP, - `extension_id` bigint(20) DEFAULT NULL, - `no` varchar(64) NULL, - `refund_price` bigint(20) NOT NULL, - `channel_user_id` varchar(255) DEFAULT NULL, - `channel_order_no` varchar(64) DEFAULT NULL, - `creator` varchar(64) DEFAULT '', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) DEFAULT '', - `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '支付订单'; - -CREATE TABLE IF NOT EXISTS `pay_order_extension` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `no` varchar(64) NOT NULL, - `order_id` bigint(20) NOT NULL, - `channel_id` bigint(20) NOT NULL, - `channel_code` varchar(32) NOT NULL, - `user_ip` varchar(50) NULL DEFAULT NULL, - `status` tinyint(4) NOT NULL, - `channel_extras` varchar(1024) NULL DEFAULT NULL, - `channel_error_code` varchar(64) NULL, - `channel_error_msg` varchar(64) NULL, - `channel_notify_data` varchar(1024) NULL, - `creator` varchar(64) NULL DEFAULT '', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) NULL DEFAULT '', - `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '支付订单拓展'; - -CREATE TABLE IF NOT EXISTS `pay_refund` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `no` varchar(64) NOT NULL, - `app_id` bigint(20) NOT NULL, - `channel_id` bigint(20) NOT NULL, - `channel_code` varchar(32) NOT NULL, - `order_id` bigint(20) NOT NULL, - `order_no` varchar(64) NOT NULL, - `merchant_order_id` varchar(64) NOT NULL, - `merchant_refund_id` varchar(64) NOT NULL, - `notify_url` varchar(1024) NOT NULL, - `status` tinyint(4) NOT NULL, - `pay_price` bigint(20) NOT NULL, - `refund_price` bigint(20) NOT NULL, - `reason` varchar(256) NOT NULL, - `user_ip` varchar(50) NULL DEFAULT NULL, - `channel_order_no` varchar(64) NOT NULL, - `channel_refund_no` varchar(64) NULL DEFAULT NULL, - `success_time` datetime(0) NULL DEFAULT NULL, - `channel_error_code` varchar(128) NULL DEFAULT NULL, - `channel_error_msg` varchar(256) NULL DEFAULT NULL, - `channel_notify_data` varchar(1024) NULL, - `creator` varchar(64) NULL DEFAULT '', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) NULL DEFAULT '', - `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '退款订单'; - -CREATE TABLE IF NOT EXISTS `pay_notify_task` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `app_id` bigint(20) NOT NULL, - `type` tinyint(4) NOT NULL, - `data_id` bigint(20) NOT NULL, - `merchant_order_id` varchar(64) NOT NULL, - `status` tinyint(4) NOT NULL, - `next_notify_time` datetime(0) NULL DEFAULT NULL, - `last_execute_time` datetime(0) NULL DEFAULT NULL, - `notify_times` int NOT NULL, - `max_notify_times` int NOT NULL, - `notify_url` varchar(1024) NOT NULL, - `creator` varchar(64) NULL DEFAULT '', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) NULL DEFAULT '', - `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT FALSE, - `tenant_id` bigint(20) NOT NULL DEFAULT 0, - PRIMARY KEY ("id") -) COMMENT = '支付通知任务'; - -CREATE TABLE IF NOT EXISTS `pay_notify_log` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `task_id` bigint(20) NOT NULL, - `notify_times` int NOT NULL, - `response` varchar(1024) NOT NULL, - `status` tinyint(4) NOT NULL, - `creator` varchar(64) NULL DEFAULT '', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) NULL DEFAULT '', - `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '支付通知日志'; diff --git a/yudao-module-report/pom.xml b/yudao-module-report/pom.xml deleted file mode 100644 index fadb0740bf..0000000000 --- a/yudao-module-report/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - cn.iocoder.boot - yudao - ${revision} - - 4.0.0 - - yudao-module-report-api - yudao-module-report-biz - - yudao-module-report - pom - - ${project.artifactId} - - report 模块,主要实现数据可视化报表等功能。 - - - diff --git a/yudao-module-report/yudao-module-report-api/pom.xml b/yudao-module-report/yudao-module-report-api/pom.xml deleted file mode 100644 index 3effa43234..0000000000 --- a/yudao-module-report/yudao-module-report-api/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-report - ${revision} - - 4.0.0 - - yudao-module-report-api - jar - - ${project.artifactId} - - report 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - yudao-common - - - diff --git a/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/api/package-info.java b/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/api/package-info.java deleted file mode 100644 index 827bef3fd0..0000000000 --- a/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位,避免 api 目录无文件时,git 无法提交 - */ -package cn.iocoder.yudao.module.report.api; diff --git a/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/enums/ErrorCodeConstants.java b/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/enums/ErrorCodeConstants.java deleted file mode 100644 index c0992f44d4..0000000000 --- a/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.report.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Report 错误码枚举类 - * - * report 系统,使用 1-003-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== GoView 模块 1-003-000-000 ========== - ErrorCode GO_VIEW_PROJECT_NOT_EXISTS = new ErrorCode(1_003_000_000, "GoView 项目不存在"); - - // ========== UREPORT 模块 1-003-001-000 ========== - ErrorCode UREPORT_DATA_NOT_EXISTS = new ErrorCode(1_003_001_001, "Ureport2 报表不存在"); - ErrorCode UREPORT_DATABASE_NOT_EXISTS = new ErrorCode(1_003_001_002, "Ureport2 报表数据源不存在"); - -} diff --git a/yudao-module-report/yudao-module-report-biz/pom.xml b/yudao-module-report/yudao-module-report-biz/pom.xml deleted file mode 100644 index 83461f5fe3..0000000000 --- a/yudao-module-report/yudao-module-report-biz/pom.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-report - ${revision} - - 4.0.0 - - yudao-module-report-biz - jar - - ${project.artifactId} - - report 模块,主要实现数据可视化报表等功能: - 1. 基于「积木报表」实现,打印设计、报表设计、图形设计、大屏设计等。 - - - - cn.iocoder.boot - yudao-module-report-api - ${revision} - - - - cn.iocoder.boot - yudao-module-system-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.boot - yudao-spring-boot-starter-web - - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - - - - - org.jeecgframework.jimureport - jimureport-spring-boot-starter - - - - xerces - xercesImpl - - - - com.bstek.ureport - ureport2-console - - - - cn.iocoder.boot - yudao-spring-boot-starter-excel - - - - diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ajreport/package-info.java deleted file mode 100644 index e32b8b9169..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ajreport/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewDataController.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewDataController.java deleted file mode 100644 index cc41dc814d..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewDataController.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataGetBySqlReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO; -import cn.iocoder.yudao.module.report.service.goview.GoViewDataService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import java.util.*; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - GoView 数据", description = "提供 SQL、HTTP 等数据查询的能力") -@RestController -@RequestMapping("/report/go-view/data") -@Validated -public class GoViewDataController { - - @Resource - private GoViewDataService goViewDataService; - - @RequestMapping("/get-by-sql") - @Operation(summary = "使用 SQL 查询数据") - @PreAuthorize("@ss.hasPermission('report:go-view-data:get-by-sql')") - @OperateLog(enable = false) // 不记录操作日志,因为不需要 - public CommonResult getDataBySQL(@Valid @RequestBody GoViewDataGetBySqlReqVO reqVO) { - return success(goViewDataService.getDataBySQL(reqVO.getSql())); - } - - @RequestMapping("/get-by-http") - @Operation(summary = "使用 HTTP 查询数据", description = "这个只是示例接口,实际应该每个查询,都要写一个接口") - @PreAuthorize("@ss.hasPermission('report:go-view-data:get-by-http')") - @OperateLog(enable = false) // 不记录操作日志,因为不需要 - public CommonResult getDataByHttp( - @RequestParam(required = false) Map params, - @RequestBody(required = false) String body) { // params、body 按照需要去接收,这里仅仅是示例 - GoViewDataRespVO respVO = new GoViewDataRespVO(); - // 1. 数据维度 - respVO.setDimensions(Arrays.asList("日期", "PV", "UV")); // PV 是每天访问次数;UV 是每天访问人数 - // 2. 明细数据列表 - // 目前通过随机的方式生成。一般来说,这里你可以写逻辑来实现数据的返回 - respVO.setSource(new LinkedList<>()); - for (int i = 1; i <= 12; i++) { - String date = "2021-" + (i < 10 ? "0" + i : i); - Integer pv = RandomUtil.randomInt(1000, 10000); - Integer uv = RandomUtil.randomInt(100, 1000); - respVO.getSource().add(MapUtil.builder().put("日期", date) - .put("PV", pv).put("UV", uv).build()); - } - return success(respVO); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewProjectController.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewProjectController.java deleted file mode 100644 index 460cd8c482..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewProjectController.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectRespVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.convert.goview.GoViewProjectConvert; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import cn.iocoder.yudao.module.report.service.goview.GoViewProjectService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - GoView 项目") -@RestController -@RequestMapping("/report/go-view/project") -@Validated -public class GoViewProjectController { - - @Resource - private GoViewProjectService goViewProjectService; - - @PostMapping("/create") - @Operation(summary = "创建项目") - @PreAuthorize("@ss.hasPermission('report:go-view-project:create')") - public CommonResult createProject(@Valid @RequestBody GoViewProjectCreateReqVO createReqVO) { - return success(goViewProjectService.createProject(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新项目") - @PreAuthorize("@ss.hasPermission('report:go-view-project:update')") - public CommonResult updateProject(@Valid @RequestBody GoViewProjectUpdateReqVO updateReqVO) { - goViewProjectService.updateProject(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除 GoView 项目") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('report:go-view-project:delete')") - public CommonResult deleteProject(@RequestParam("id") Long id) { - goViewProjectService.deleteProject(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得项目") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('report:go-view-project:query')") - public CommonResult getProject(@RequestParam("id") Long id) { - GoViewProjectDO project = goViewProjectService.getProject(id); - return success(GoViewProjectConvert.INSTANCE.convert(project)); - } - - @GetMapping("/my-page") - @Operation(summary = "获得我的项目分页") - @PreAuthorize("@ss.hasPermission('report:go-view-project:query')") - public CommonResult> getMyProjectPage(@Valid PageParam pageVO) { - PageResult pageResult = goViewProjectService.getMyProjectPage( - pageVO, getLoginUserId()); - return success(GoViewProjectConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataGetBySqlReqVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataGetBySqlReqVO.java deleted file mode 100644 index d8537ff73b..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataGetBySqlReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.data; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - GoView 使用 SQL 查询数据 Request VO") -@Data -public class GoViewDataGetBySqlReqVO { - - @Schema(description = "SQL 语句", requiredMode = Schema.RequiredMode.REQUIRED, example = "SELECT * FROM user") - @NotEmpty(message = "SQL 语句不能为空") - private String sql; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataRespVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataRespVO.java deleted file mode 100644 index 38251ddfa5..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.data; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - GoView 数据 Response VO") -@Data -public class GoViewDataRespVO { - - @Schema(description = "数据维度", requiredMode = Schema.RequiredMode.REQUIRED, example = "['product', 'data1', 'data2']") - private List dimensions; - - @Schema(description = "数据明细列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List> source; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectCreateReqVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectCreateReqVO.java deleted file mode 100644 index f8bf63166a..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectCreateReqVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.project; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.*; - -@Schema(description = "管理后台 - GoView 项目创建 Request VO") -@Data -public class GoViewProjectCreateReqVO { - - @Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotEmpty(message = "项目名称不能为空") - private String name; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectRespVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectRespVO.java deleted file mode 100644 index 3197d995c0..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectRespVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.project; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - GoView 项目 Response VO") -@Data -public class GoViewProjectRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18993") - private Long id; - - @Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "发布状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "报表内容") // JSON 格式 - private String content; - - @Schema(description = "预览图片 URL", example = "https://www.iocoder.cn") - private String picUrl; - - @Schema(description = "项目备注", example = "你猜") - private String remark; - - @Schema(description = "创建人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String creator; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectUpdateReqVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectUpdateReqVO.java deleted file mode 100644 index 204e66125d..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectUpdateReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.project; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import jakarta.validation.constraints.*; - -@Schema(description = "管理后台 - GoView 项目更新 Request VO") -@Data -public class GoViewProjectUpdateReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18993") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "发布状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = CommonStatusEnum.class, message = "发布状态必须是 {value}") - private Integer status; - - @Schema(description = "报表内容") // JSON 格式 - private String content; - - @Schema(description = "预览图片 URL", example = "https://www.iocoder.cn") - private String picUrl; - - @Schema(description = "项目备注", example = "你猜") - private String remark; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/UReportDataController.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/UReportDataController.java deleted file mode 100644 index eef261337d..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/UReportDataController.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.ureport; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UReportDataPageReqVO; -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UReportDataRespVO; -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UReportDataSaveReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UReportDataDO; -import cn.iocoder.yudao.module.report.service.ureport.UReportDataService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; - -@Tag(name = "管理后台 - Ureport2 报表") -@RestController -@RequestMapping("/report/ureport-data") -@Validated -public class UReportDataController { - - @Resource - private UReportDataService uReportDataService; - - @PostMapping("/create") - @Operation(summary = "创建 Ureport2 报表") - @PreAuthorize("@ss.hasPermission('report:ureport-data:create')") - public CommonResult createUReportData(@Valid @RequestBody UReportDataSaveReqVO createReqVO) { - return success(uReportDataService.createUReportData(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新 Ureport2 报表") - @PreAuthorize("@ss.hasPermission('report:ureport-data:update')") - public CommonResult updateUReportData(@Valid @RequestBody UReportDataSaveReqVO updateReqVO) { - uReportDataService.updateUReportData(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除 Ureport2 报表") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('report:ureport-data:delete')") - public CommonResult deleteUReportData(@RequestParam("id") Long id) { - uReportDataService.deleteUReportData(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得Ureport2报表") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('report:ureport-data:query')") - public CommonResult getUReportData(@RequestParam("id") Long id) { - UReportDataDO uReportData = uReportDataService.getUReportData(id); - return success(BeanUtils.toBean(uReportData, UReportDataRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得Ureport2报表分页") - @PreAuthorize("@ss.hasPermission('report:ureport-data:query')") - public CommonResult> getUReportDataPage(@Valid UReportDataPageReqVO pageReqVO) { - PageResult pageResult = uReportDataService.getUReportDataPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, UReportDataRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出 Ureport2 报表 Excel") - @PreAuthorize("@ss.hasPermission('report:ureport-data:export')") - @OperateLog(type = EXPORT) - public void exportUReportDataExcel(@Valid UReportDataPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = uReportDataService.getUReportDataPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "Ureport2 报表.xls", "数据", UReportDataRespVO.class, - BeanUtils.toBean(list, UReportDataRespVO.class)); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UReportDataPageReqVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UReportDataPageReqVO.java deleted file mode 100644 index d3c1a57190..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UReportDataPageReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.ureport.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - Ureport2 报表分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class UReportDataPageReqVO extends PageParam { - - @Schema(description = "文件名称", example = "李四") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UReportDataRespVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UReportDataRespVO.java deleted file mode 100644 index f0b3ab1d1c..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UReportDataRespVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.ureport.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - Ureport2 报表 Response VO") -@Data -@ExcelIgnoreUnannotated -public class UReportDataRespVO { - - @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26175") - @ExcelProperty("ID") - private Long id; - - @Schema(description = "文件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("文件名称") - private String name; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @Schema(description = "文件内容") - @ExcelProperty("文件内容") - private String content; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UReportDataSaveReqVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UReportDataSaveReqVO.java deleted file mode 100644 index 222eeadffd..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UReportDataSaveReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.ureport.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - -@Schema(description = "管理后台 - Ureport2 报表新增/修改 Request VO") -@Data -public class UReportDataSaveReqVO { - - @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26175") - private Long id; - - @Schema(description = "文件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotEmpty(message = "文件名称不能为空") - private String name; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "文件内容") - private String content; - - @Schema(description = "备注", example = "你猜") - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/package-info.java deleted file mode 100644 index ccbf9bb19b..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.report.controller; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/ajreport/package-info.java deleted file mode 100644 index 72860791f2..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/ajreport/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位,后续删除 - */ -package cn.iocoder.yudao.module.report.convert.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/goview/GoViewProjectConvert.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/goview/GoViewProjectConvert.java deleted file mode 100644 index 9c993a19cf..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/goview/GoViewProjectConvert.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.report.convert.goview; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectRespVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface GoViewProjectConvert { - - GoViewProjectConvert INSTANCE = Mappers.getMapper(GoViewProjectConvert.class); - - GoViewProjectDO convert(GoViewProjectCreateReqVO bean); - - GoViewProjectDO convert(GoViewProjectUpdateReqVO bean); - - GoViewProjectRespVO convert(GoViewProjectDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ajreport/package-info.java deleted file mode 100644 index 922ec6fd45..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ajreport/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占位,待删除 - */ -package cn.iocoder.yudao.module.report.dal.dataobject.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/goview/GoViewProjectDO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/goview/GoViewProjectDO.java deleted file mode 100644 index 38730d29e3..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/goview/GoViewProjectDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.report.dal.dataobject.goview; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * GoView 项目表 - * - * 每个大屏图标,对应一个项目 - * - * @author 芋道源码 - */ -@TableName(value = "report_go_view_project", autoResultMap = true) // 由于 SQL Server 的 system_user 是关键字,所以使用 system_users -@KeySequence("report_go_view_project_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class GoViewProjectDO extends BaseDO { - - /** - * 编号,数据库自增 - */ - @TableId - private Long id; - /** - * 项目名称 - */ - private String name; - /** - * 预览图片 URL - */ - private String picUrl; - /** - * 报表内容 - * - * JSON 配置,使用字符串存储 - */ - private String content; - /** - * 发布状态 - * - * 0 - 已发布 - * 1 - 未发布 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 项目备注 - */ - private String remark; -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ureport/UReportDataDO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ureport/UReportDataDO.java deleted file mode 100644 index 6aab35a087..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ureport/UReportDataDO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.report.dal.dataobject.ureport; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -// TODO @赤焰:这个是不是可以支持多租户? -/** - * Ureport2 报表 DO - * - * @author 芋道源码 - */ -@TableName("report_ureport_data") -@KeySequence("report_ureport_data_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class UReportDataDO extends BaseDO { - - /** - * ID - */ - @TableId - private Long id; - /** - * 文件名称 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum#getStatus()} - */ - private Integer status; - /** - * 文件内容 - */ - private String content; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ajreport/package-info.java deleted file mode 100644 index 0fb86173d9..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ajreport/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占位,待删除 - */ -package cn.iocoder.yudao.module.report.dal.mysql.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/goview/GoViewProjectMapper.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/goview/GoViewProjectMapper.java deleted file mode 100644 index af1ca6345c..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/goview/GoViewProjectMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.report.dal.mysql.goview; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface GoViewProjectMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long userId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(GoViewProjectDO::getCreator, userId) - .orderByDesc(GoViewProjectDO::getId)); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ureport/UReportDataMapper.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ureport/UReportDataMapper.java deleted file mode 100644 index c64b771fa9..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ureport/UReportDataMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.report.dal.mysql.ureport; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UReportDataPageReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UReportDataDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * Ureport2报表 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface UReportDataMapper extends BaseMapperX { - - default PageResult selectPage(UReportDataPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(UReportDataDO::getName, reqVO.getName()) - .eqIfPresent(UReportDataDO::getStatus, reqVO.getStatus()) - .eqIfPresent(UReportDataDO::getRemark, reqVO.getRemark()) - .betweenIfPresent(UReportDataDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(UReportDataDO::getId)); - } - - default List selectListByName(String name) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(UReportDataDO::getName,name)); - } - - default UReportDataDO selectByName(String name){ - return selectOne(new LambdaQueryWrapperX() - .eqIfPresent(UReportDataDO::getName,name)); - } - - default int deleteByName(String name) { - return delete(new LambdaQueryWrapperX() - .eqIfPresent(UReportDataDO::getName,name)); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/config/JmReportConfiguration.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/config/JmReportConfiguration.java deleted file mode 100644 index 3c99b28586..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/config/JmReportConfiguration.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.jmreport.config; - -import cn.iocoder.yudao.framework.security.config.SecurityProperties; -import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; -import cn.iocoder.yudao.module.report.framework.jmreport.core.service.JmReportTokenServiceImpl; -import org.jeecg.modules.jmreport.api.JmReportTokenServiceI; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * 积木报表的配置类 - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -@ComponentScan(basePackages = "org.jeecg.modules.jmreport") // 扫描积木报表的包 -public class JmReportConfiguration { - - @Bean - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - public JmReportTokenServiceI jmReportTokenService(OAuth2TokenApi oAuth2TokenApi, SecurityProperties securityProperties) { - return new JmReportTokenServiceImpl(oAuth2TokenApi, securityProperties); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/service/JmReportTokenServiceImpl.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/service/JmReportTokenServiceImpl.java deleted file mode 100644 index ad4240f2fa..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/service/JmReportTokenServiceImpl.java +++ /dev/null @@ -1,131 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.jmreport.core.service; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; -import cn.iocoder.yudao.framework.security.config.SecurityProperties; -import cn.iocoder.yudao.framework.security.core.LoginUser; -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; -import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO; -import lombok.RequiredArgsConstructor; -import org.jeecg.modules.jmreport.api.JmReportTokenServiceI; -import org.springframework.http.HttpHeaders; - -import jakarta.servlet.http.HttpServletRequest; -import java.util.Objects; - -/** - * {@link JmReportTokenServiceI} 实现类,提供积木报表的 Token 校验、用户信息的查询等功能 - * - * @author 随心 - */ -@RequiredArgsConstructor -public class JmReportTokenServiceImpl implements JmReportTokenServiceI { - - /** - * 积木 token head 头 - */ - private static final String JM_TOKEN_HEADER = "X-Access-Token"; - /** - * auth 相关格式 - */ - private static final String AUTHORIZATION_FORMAT = SecurityFrameworkUtils.AUTHORIZATION_BEARER + " %s"; - - private final OAuth2TokenApi oauth2TokenApi; - - private final SecurityProperties securityProperties; - - /** - * 自定义 API 数据集appian自定义 Header,解决 Token 传递。 - * 参考 api数据集token机制详解 文档 - * - * @return 新 head - */ - @Override - public HttpHeaders customApiHeader() { - // 读取积木标标系统的 token - HttpServletRequest request = ServletUtils.getRequest(); - String token = request.getHeader(JM_TOKEN_HEADER); - - // 设置到 yudao 系统的 token - HttpHeaders headers = new HttpHeaders(); - headers.add(securityProperties.getTokenHeader(), String.format(AUTHORIZATION_FORMAT, token)); - return headers; - } - - /** - * 校验 Token 是否有效,即验证通过 - * - * @param token JmReport 前端传递的 token - * @return 是否认证通过 - */ - @Override - public Boolean verifyToken(String token) { - Long userId = SecurityFrameworkUtils.getLoginUserId(); - if (!Objects.isNull(userId)) { - return true; - } - return buildLoginUserByToken(token) != null; - } - - /** - * 获得用户编号 - *

- * 虽然方法名获得的是 username,实际对应到项目中是用户编号 - * - * @param token JmReport 前端传递的 token - * @return 用户编号 - */ - @Override - public String getUsername(String token) { - Long userId = SecurityFrameworkUtils.getLoginUserId(); - if (ObjectUtil.isNotNull(userId)) { - return String.valueOf(userId); - } - LoginUser user = buildLoginUserByToken(token); - return user == null ? null : String.valueOf(user.getId()); - } - - /** - * 基于 token 构建登录用户 - * - * @param token token - * @return 返回 token 对应的用户信息 - */ - private LoginUser buildLoginUserByToken(String token) { - if (StrUtil.isEmpty(token)) { - return null; - } - // TODO 如下的实现不算特别优雅,主要咱是不想搞的太复杂,所以参考对应的 Filter 先实现了 - - // ① 参考 TokenAuthenticationFilter 的认证逻辑(Security 的上下文清理,交给 Spring Security 完成) - // 目的:实现基于 JmReport 前端传递的 token,实现认证 - TenantContextHolder.setIgnore(true); // 忽略租户,保证可查询到 token 信息 - LoginUser user = null; - try { - OAuth2AccessTokenCheckRespDTO accessToken = oauth2TokenApi.checkAccessToken(token); - if (accessToken == null) { - return null; - } - user = new LoginUser().setId(accessToken.getUserId()).setUserType(accessToken.getUserType()) - .setTenantId(accessToken.getTenantId()).setScopes(accessToken.getScopes()); - } catch (ServiceException ignored) { - // do nothing:如果报错,说明认证失败,则返回 false 即可 - } - if (user == null) { - return null; - } - SecurityFrameworkUtils.setLoginUser(user, WebFrameworkUtils.getRequest()); - - // ② 参考 TenantContextWebFilter 实现(Tenant 的上下文清理,交给 TenantContextWebFilter 完成) - // 目的:基于 LoginUser 获得到的租户编号,设置到 Tenant 上下文,避免查询数据库时的报错 - TenantContextHolder.setIgnore(false); - TenantContextHolder.setTenantId(user.getTenantId()); - return user; - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/web/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/web/package-info.java deleted file mode 100644 index e082e3bdce..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/web/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位,后续会基于 Filter 实现积木报表的认证等功能,替代 {@link cn.iocoder.yudao.module.report.framework.jmreport.core.service.JmReportTokenServiceImpl} - */ -package cn.iocoder.yudao.module.report.framework.jmreport.core.web; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/package-info.java deleted file mode 100644 index c2163d8cde..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 report 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.report.framework; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/config/SecurityConfiguration.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 3f2e359750..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.security.config; - -import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum; -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.framework.security.config.SecurityProperties; -import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; -import org.springframework.util.StringUtils; - -import jakarta.annotation.Resource; - -/** - * Report 模块的 Security 配置 - */ -@Configuration("reportSecurityConfiguration") -public class SecurityConfiguration { - - @Resource - private OAuth2TokenApi oauth2TokenApi; - - @Bean("reportAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - @Override - public void customize(AuthorizeHttpRequestsConfigurer.AuthorizationManagerRequestMatcherRegistry registry) { - registry.requestMatchers("/jmreport/**").permitAll(); // 积木报表 - registry.requestMatchers("/ureport/**").permitAll(); // UReport 报表 - } - }; - } - - /** - * 创建 UReportFilter 过滤器,响应 header 设置 token - */ - /*@Bean - public FilterRegistrationBean uReportFilterFilterRegistrationBean() { - FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - registrationBean.setFilter(new UReportFilter(oauth2TokenApi)); - registrationBean.setOrder(WebFilterOrderEnum.TRACE_FILTER); - return registrationBean; - }*/ - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/core/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/core/package-info.java deleted file mode 100644 index 61083268f4..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.report.framework.security.core; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/config/UReportConfiguration.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/config/UReportConfiguration.java deleted file mode 100644 index 3cf09c6aac..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/config/UReportConfiguration.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.ureport.config; - -import com.bstek.ureport.console.UReportServlet; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.web.servlet.ServletRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; -import org.springframework.context.annotation.PropertySource; - -import jakarta.servlet.Servlet; - -/** - * UReport2 配置类 - * - * @author 赤焰 - */ -@Configuration -@ImportResource({"classpath:ureport-console-context.xml"}) -@PropertySource(value = {"classpath:ureport.properties"}) // TODO @赤焰:这个可以搞到 application.yaml 里么? -@EnableConfigurationProperties({UReportProperties.class}) -public class UReportConfiguration { - - @Bean - public ServletRegistrationBean uReportRegistrationBean() { - return new ServletRegistrationBean<>(new UReportServlet(), "/ureport/*"); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/config/UReportProperties.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/config/UReportProperties.java deleted file mode 100644 index b3d41cd2fb..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/config/UReportProperties.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.ureport.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * UReport2 配置类 - * - * @author 赤焰 - */ -@Data -@ConfigurationProperties(prefix = "ureport.provider.database") -public class UReportProperties { - - // TODO @赤焰:每个字段的注释写下哈; - private String name = "数据库文件系统"; - - private String prefix = "db-"; - - private boolean disabled = false; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UReportDataSource.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UReportDataSource.java deleted file mode 100644 index eb5d5e48c3..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UReportDataSource.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.ureport.core; - -import com.bstek.ureport.definition.datasource.BuildinDatasource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.SQLException; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.UREPORT_DATABASE_NOT_EXISTS; - -/** - * UReport2 内置数据源 - * - * @author 赤焰 - */ -@Slf4j -@Component -public class UReportDataSource implements BuildinDatasource { - - private static final String NAME = "UReportDataSource"; - - @Resource - private DataSource dataSource; - - /** - * @return 数据源名称 - */ - @Override - public String name() { - return NAME; - } - - /** - * @return 获取连接 - */ - @Override - public Connection getConnection() { - try { - return dataSource.getConnection(); - } catch (SQLException e) { - log.error("[getConnection][获取连接失败!]", e); - throw exception(UREPORT_DATABASE_NOT_EXISTS); - } - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UReportDatabaseProvider.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UReportDatabaseProvider.java deleted file mode 100644 index d04c088bcd..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UReportDatabaseProvider.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.ureport.core; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UReportDataSaveReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UReportDataDO; -import cn.iocoder.yudao.module.report.framework.ureport.config.UReportProperties; -import cn.iocoder.yudao.module.report.service.ureport.UReportDataService; -import com.bstek.ureport.provider.report.ReportFile; -import com.bstek.ureport.provider.report.ReportProvider; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import jakarta.annotation.Resource; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * 基于数据库的 {@link ReportProvider} 实现类 - * - * @author 赤焰 - */ -// TODO @赤焰:这个 bean 的注解,交给 UReportConfiguration 搞 -@Component -@Slf4j -@Setter -public class UReportDatabaseProvider implements ReportProvider { - - @Autowired - private UReportProperties uReportProperties; - @Resource - private UReportDataService uReportDataService; - - @Override - public InputStream loadReport(String name) { - uReportDataService.validateUReportDataExists(getCorrectName(name)); - UReportDataDO uReportDataDO = uReportDataService.selectOneByName(getCorrectName(name)); - String content = uReportDataDO.getContent(); - return new ByteArrayInputStream(content.getBytes()); - } - - @Override - public void deleteReport(String name) { - uReportDataService.deleteByName(getCorrectName(name)); - } - - @Override - public List getReportFiles() { - List list = uReportDataService.getReportDataList(); - // TODO @赤焰:这里,不用判空,CollectionUtils.convertList 已经处理了哈。 - if(CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - return convertList(list, report -> new ReportFile(report.getName(), DateUtils.of(report.getUpdateTime()))); - } - - @Override - public void saveReport(String name, String content) { - // TODO @赤焰:收到 uReportDataService 里面实现一个 saveUReportData 方法,然后这里调用即可。 - name = getCorrectName(name); - UReportDataDO uReportDataDO = uReportDataService.selectOneByName(name); - UReportDataSaveReqVO saveReqVO = new UReportDataSaveReqVO(); - if (uReportDataDO == null) { - saveReqVO.setName(name); - saveReqVO.setContent(content); - saveReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - uReportDataService.createUReportData(saveReqVO); - } else { - saveReqVO.setId(uReportDataDO.getId()); - saveReqVO.setName(name); - saveReqVO.setContent(content); - saveReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - uReportDataService.updateUReportData(saveReqVO); - } - } - - @Override - public String getName() { - return uReportProperties.getName(); - } - - @Override - public boolean disabled() { - return uReportProperties.isDisabled(); - } - - @Override - public String getPrefix() { - return uReportProperties.getPrefix(); - } - - /** - * 去除存储媒介,获取报表名字 - * - * @param name 前端传入的报表带存储媒介的名字 - * @return 表名字 - */ - private String getCorrectName(String name) { - return StrUtil.removePrefix(name,getPrefix()); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UReportFilter.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UReportFilter.java deleted file mode 100644 index 02e3674f61..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/core/UReportFilter.java +++ /dev/null @@ -1,79 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.ureport.core; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; -import cn.iocoder.yudao.framework.security.core.LoginUser; -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; -import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.filter.OncePerRequestFilter; - -import jakarta.servlet.FilterChain; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Map; - -/** - * UReport 认证过滤器 - * @author 赤焰 - */ -@Slf4j -@RequiredArgsConstructor -public class UReportFilter extends OncePerRequestFilter { - - private final static String TOKEN = "token"; - - private final OAuth2TokenApi oauth2TokenApi; - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) - throws ServletException, IOException { - - if(log.isDebugEnabled()){ - log.debug("UReportFilter自定义过滤器"); - } - - Map paramMap = ServletUtils.getParamMap(request); - String requestURI = request.getRequestURI(); - boolean contains = requestURI.contains("/ureport"); - if (paramMap.containsKey(TOKEN)&&contains) { - String token = request.getParameter(TOKEN); - if(log.isDebugEnabled()){ - log.debug("UReportFilter自定义过滤器 token="+token); - } - - response.addHeader(TOKEN,token); - - TenantContextHolder.setIgnore(true); // 忽略租户,保证可查询到 token 信息 - LoginUser user = null; - try { - OAuth2AccessTokenCheckRespDTO accessToken = oauth2TokenApi.checkAccessToken(token); - if (accessToken != null) { - user = new LoginUser().setId(accessToken.getUserId()).setUserType(accessToken.getUserType()) - .setTenantId(accessToken.getTenantId()).setScopes(accessToken.getScopes()); - if (user != null) { - SecurityFrameworkUtils.setLoginUser(user, WebFrameworkUtils.getRequest()); - - // ② 参考 TenantContextWebFilter 实现(Tenant 的上下文清理,交给 TenantContextWebFilter 完成) - // 目的:基于 LoginUser 获得到的租户编号,设置到 Tenant 上下文,避免查询数据库时的报错 - TenantContextHolder.setIgnore(false); - TenantContextHolder.setTenantId(user.getTenantId()); - } - } - } catch (ServiceException ignored) { - chain.doFilter(request, response); - } - - } - - // 继续过滤 - chain.doFilter(request, response); - - } -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/package-info.java deleted file mode 100644 index a4e2e8bf13..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * ureport2:https://github.com/youseries/ureport - * - * ureport2 和 jimurepot 是相同类型的产品,不过停更了,最好发布时间是 2018 年。 - * 它们之间的功能对比,可见 https://juejin.cn/post/6939836480269320200 地址 - */ -package cn.iocoder.yudao.module.report.framework.ureport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/package-info.java deleted file mode 100644 index 3306c0ebb3..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * report 模块,主要实现数据可视化报表等功能: - * 1. 基于「积木报表」实现,打印设计、报表设计、图形设计、大屏设计等。URL 前缀是 /jmreport,表名前缀是 jimu_ - * - * 由于「积木报表」的大屏设计器需要收费,后续会自研,对应的是: - * 1. Controller URL:以 /report/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 report_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.report; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ajreport/package-info.java deleted file mode 100644 index 2512e50ed2..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ajreport/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占位,待删除 - */ -package cn.iocoder.yudao.module.report.service.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataService.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataService.java deleted file mode 100644 index b912373b17..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataService.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO; - -/** - * GoView 数据 Service 接口 - * - * @author 芋道源码 - */ -public interface GoViewDataService { - - /** - * 使用 SQL 查询数据 - * - * @param sql SQL 语句 - * @return 数据 - */ - GoViewDataRespVO getDataBySQL(String sql); - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImpl.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImpl.java deleted file mode 100644 index 4a7f46687e..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO; -import com.google.common.collect.Maps; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.support.rowset.SqlRowSet; -import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.Map; - -/** - * GoView 数据 Service 实现类 - * - * 补充说明: - * 1. 目前默认使用 jdbcTemplate 查询项目配置的数据源。如果你想查询其它数据源,可以新建对应数据源的 jdbcTemplate 来实现。 - * 2. 默认数据源是 MySQL 关系数据源,可能数据量比较大的情况下,会比较慢,可以考虑后续使用 Click House 等等。 - * - * @author 芋道源码 - */ -@Service -@Validated -public class GoViewDataServiceImpl implements GoViewDataService { - - @Resource - private JdbcTemplate jdbcTemplate; - - @Override - public GoViewDataRespVO getDataBySQL(String sql) { - // 1. 执行查询 - SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet(sql); - - // 2. 构建返回结果 - GoViewDataRespVO respVO = new GoViewDataRespVO(); - // 2.1 解析元数据 - SqlRowSetMetaData metaData = sqlRowSet.getMetaData(); - String[] columnNames = metaData.getColumnNames(); - respVO.setDimensions(Arrays.asList(columnNames)); - // 2.2 解析数据明细 - respVO.setSource(new LinkedList<>()); // 由于数据量不确认,使用 LinkedList 虽然内存占用大一点,但是不存在扩容复制的问题 - while (sqlRowSet.next()) { - Map data = Maps.newHashMapWithExpectedSize(columnNames.length); - for (String columnName : columnNames) { - data.put(columnName, sqlRowSet.getObject(columnName)); - } - respVO.getSource().add(data); - } - return respVO; - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectService.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectService.java deleted file mode 100644 index 961b1bb90e..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectService.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; - -import jakarta.validation.Valid; - -/** - * GoView 项目 Service 接口 - * - * @author 芋道源码 - */ -public interface GoViewProjectService { - - /** - * 创建项目 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProject(@Valid GoViewProjectCreateReqVO createReqVO); - - /** - * 更新项目 - * - * @param updateReqVO 更新信息 - */ - void updateProject(@Valid GoViewProjectUpdateReqVO updateReqVO); - - /** - * 删除项目 - * - * @param id 编号 - */ - void deleteProject(Long id); - - /** - * 获得项目 - * - * @param id 编号 - * @return 项目 - */ - GoViewProjectDO getProject(Long id); - - /** - * 获得我的项目分页 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return GoView 项目分页 - */ - PageResult getMyProjectPage(PageParam pageReqVO, Long userId); - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImpl.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImpl.java deleted file mode 100644 index 16bda8731d..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.convert.goview.GoViewProjectConvert; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import cn.iocoder.yudao.module.report.dal.mysql.goview.GoViewProjectMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.GO_VIEW_PROJECT_NOT_EXISTS; - -/** - * GoView 项目 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class GoViewProjectServiceImpl implements GoViewProjectService { - - @Resource - private GoViewProjectMapper goViewProjectMapper; - - @Override - public Long createProject(GoViewProjectCreateReqVO createReqVO) { - // 插入 - GoViewProjectDO goViewProject = GoViewProjectConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.DISABLE.getStatus()); - goViewProjectMapper.insert(goViewProject); - // 返回 - return goViewProject.getId(); - } - - @Override - public void updateProject(GoViewProjectUpdateReqVO updateReqVO) { - // 校验存在 - validateProjectExists(updateReqVO.getId()); - // 更新 - GoViewProjectDO updateObj = GoViewProjectConvert.INSTANCE.convert(updateReqVO); - goViewProjectMapper.updateById(updateObj); - } - - @Override - public void deleteProject(Long id) { - // 校验存在 - validateProjectExists(id); - // 删除 - goViewProjectMapper.deleteById(id); - } - - private void validateProjectExists(Long id) { - if (goViewProjectMapper.selectById(id) == null) { - throw exception(GO_VIEW_PROJECT_NOT_EXISTS); - } - } - - @Override - public GoViewProjectDO getProject(Long id) { - return goViewProjectMapper.selectById(id); - } - - @Override - public PageResult getMyProjectPage(PageParam pageReqVO, Long userId) { - return goViewProjectMapper.selectPage(pageReqVO, userId); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ureport/UReportDataService.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ureport/UReportDataService.java deleted file mode 100644 index 292d82f794..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ureport/UReportDataService.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.report.service.ureport; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UReportDataPageReqVO; -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UReportDataSaveReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UReportDataDO; - -import jakarta.validation.Valid; -import java.util.List; - -/** - * Ureport2 报表 Service 接口 - * - * @author 芋道源码 - */ -public interface UReportDataService { - - /** - * 创建 Ureport2 报表 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createUReportData(@Valid UReportDataSaveReqVO createReqVO); - - /** - * 更新 Ureport2 报表 - * - * @param updateReqVO 更新信息 - */ - void updateUReportData(@Valid UReportDataSaveReqVO updateReqVO); - - /** - * 删除 Ureport2 报表 - * - * @param id 编号 - */ - void deleteUReportData(Long id); - - /** - * 获得 Ureport2 报表 - * - * @param id 编号 - * @return Ureport2 报表 - */ - UReportDataDO getUReportData(Long id); - - /** - * 获得 Ureport2 报表分页 - * - * @param pageReqVO 分页查询 - * @return Ureport2 报表分页 - */ - PageResult getUReportDataPage(UReportDataPageReqVO pageReqVO); - - // TODO @赤焰:可以不用返回 int。如果不需要哈。 - /** - * 根据名称删除报表 - * - * @param name 报表名称 - * @return - */ - int deleteByName(String name); - - // TODO @赤焰:这里直接返回 UReportDataDO 是不是更好?上层业务直接使用啦 - /** - * 根据名称校验报表是否存在 - * - * @param name 报表名称 - */ - void validateUReportDataExists(String name); - - // TODO @赤焰:这里方法名改成 getUReportDataByName。select 只用于 mapper; - /** - * 根据名称查询报表 - * - * @param name 报表名称 - * @return Ureport2 报表 - */ - UReportDataDO selectOneByName(String name); - - /** - * 获取全部报表 - * - * @return 全部报表 - */ - List getReportDataList(); - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ureport/UReportDataServiceImpl.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ureport/UReportDataServiceImpl.java deleted file mode 100644 index 578133e4a6..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ureport/UReportDataServiceImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.report.service.ureport; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UReportDataPageReqVO; -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UReportDataSaveReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UReportDataDO; -import cn.iocoder.yudao.module.report.dal.mysql.ureport.UReportDataMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.UREPORT_DATA_NOT_EXISTS; - -/** - * Ureport2报表 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class UReportDataServiceImpl implements UReportDataService { - - @Resource - private UReportDataMapper uReportDataMapper; - - @Override - public Long createUReportData(UReportDataSaveReqVO createReqVO) { - // TODO @赤焰:名字不要重复的校验,要加下 - UReportDataDO uReportData = BeanUtils.toBean(createReqVO, UReportDataDO.class); - uReportDataMapper.insert(uReportData); - return uReportData.getId(); - } - - @Override - public void updateUReportData(UReportDataSaveReqVO updateReqVO) { - // 校验存在 - validateUReportDataExists(updateReqVO.getId()); - // TODO @赤焰:名字不要重复的校验,要加下 - // 更新 - UReportDataDO updateObj = BeanUtils.toBean(updateReqVO, UReportDataDO.class); - uReportDataMapper.updateById(updateObj); - } - - @Override - public void deleteUReportData(Long id) { - // 校验存在 - validateUReportDataExists(id); - // 删除 - uReportDataMapper.deleteById(id); - } - - private void validateUReportDataExists(Long id) { - if (uReportDataMapper.selectById(id) == null) { - throw exception(UREPORT_DATA_NOT_EXISTS); - } - } - - @Override - public void validateUReportDataExists(String name) { - if (uReportDataMapper.selectListByName(name) == null) { - throw exception(UREPORT_DATA_NOT_EXISTS); - } - } - - @Override - public UReportDataDO getUReportData(Long id) { - return uReportDataMapper.selectById(id); - } - - @Override - public PageResult getUReportDataPage(UReportDataPageReqVO pageReqVO) { - return uReportDataMapper.selectPage(pageReqVO); - } - - @Override - public int deleteByName(String name) { - return uReportDataMapper.deleteByName(name); - } - - @Override - public UReportDataDO selectOneByName(String name) { - return uReportDataMapper.selectByName(name); - } - - @Override - public List getReportDataList() { - return uReportDataMapper.selectList(); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/ureport.properties b/yudao-module-report/yudao-module-report-biz/src/main/resources/ureport.properties deleted file mode 100644 index ef576d5593..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/ureport.properties +++ /dev/null @@ -1,5 +0,0 @@ -## TODO ????????? application.yaml ????? -ureport.disableHttpSessionReportCache=true -ureport.disableFileProvider=true -ureport.fileStoreDir=/WEB-INF/ureportfiles -ureport.debug=true \ No newline at end of file diff --git a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImplTest.java b/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImplTest.java deleted file mode 100644 index 370d3ac3f8..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImplTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.support.rowset.SqlRowSet; -import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; - -import jakarta.annotation.Resource; -import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -@Import(GoViewDataServiceImpl.class) -public class GoViewDataServiceImplTest extends BaseDbUnitTest { - - @Resource - private GoViewDataServiceImpl goViewDataService; - - @MockBean - private JdbcTemplate jdbcTemplate; - - @Test - public void testGetDataBySQL() { - // 准备参数 - String sql = "SELECT id, name FROM system_users"; - // mock 方法 - SqlRowSet sqlRowSet = mock(SqlRowSet.class); - when(jdbcTemplate.queryForRowSet(eq(sql))).thenReturn(sqlRowSet); - // mock 元数据 - SqlRowSetMetaData metaData = mock(SqlRowSetMetaData.class); - when(sqlRowSet.getMetaData()).thenReturn(metaData); - when(metaData.getColumnNames()).thenReturn(new String[]{"id", "name"}); - // mock 数据明细 - when(sqlRowSet.next()).thenReturn(true).thenReturn(true).thenReturn(false); - when(sqlRowSet.getObject("id")).thenReturn(1L).thenReturn(2L); - when(sqlRowSet.getObject("name")).thenReturn("芋道源码").thenReturn("芋道"); - - // 调用 - GoViewDataRespVO dataBySQL = goViewDataService.getDataBySQL(sql); - // 断言 - assertEquals(Arrays.asList("id", "name"), dataBySQL.getDimensions()); - assertEquals(2, dataBySQL.getDimensions().size()); - assertEquals(2, dataBySQL.getSource().get(0).size()); - assertEquals(1L, dataBySQL.getSource().get(0).get("id")); - assertEquals("芋道源码", dataBySQL.getSource().get(0).get("name")); - assertEquals(2, dataBySQL.getSource().get(1).size()); - assertEquals(2L, dataBySQL.getSource().get(1).get("id")); - assertEquals("芋道", dataBySQL.getSource().get(1).get("name")); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImplTest.java b/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImplTest.java deleted file mode 100644 index 676e4579bd..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImplTest.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import cn.iocoder.yudao.module.report.dal.mysql.goview.GoViewProjectMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.GO_VIEW_PROJECT_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link GoViewProjectServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(GoViewProjectServiceImpl.class) -public class GoViewProjectServiceImplTest extends BaseDbUnitTest { - - @Resource - private GoViewProjectServiceImpl goViewProjectService; - - @Resource - private GoViewProjectMapper goViewProjectMapper; - - @Test - public void testCreateProject_success() { - // 准备参数 - GoViewProjectCreateReqVO reqVO = randomPojo(GoViewProjectCreateReqVO.class); - - // 调用 - Long goViewProjectId = goViewProjectService.createProject(reqVO); - // 断言 - assertNotNull(goViewProjectId); - // 校验记录的属性是否正确 - GoViewProjectDO goViewProject = goViewProjectMapper.selectById(goViewProjectId); - assertPojoEquals(reqVO, goViewProject); - } - - @Test - public void testUpdateProject_success() { - // mock 数据 - GoViewProjectDO dbGoViewProject = randomPojo(GoViewProjectDO.class); - goViewProjectMapper.insert(dbGoViewProject);// @Sql: 先插入出一条存在的数据 - // 准备参数 - GoViewProjectUpdateReqVO reqVO = randomPojo(GoViewProjectUpdateReqVO.class, o -> { - o.setId(dbGoViewProject.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - }); - - // 调用 - goViewProjectService.updateProject(reqVO); - // 校验是否更新正确 - GoViewProjectDO goViewProject = goViewProjectMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, goViewProject); - } - - @Test - public void testUpdateProject_notExists() { - // 准备参数 - GoViewProjectUpdateReqVO reqVO = randomPojo(GoViewProjectUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> goViewProjectService.updateProject(reqVO), GO_VIEW_PROJECT_NOT_EXISTS); - } - - @Test - public void testDeleteProject_success() { - // mock 数据 - GoViewProjectDO dbGoViewProject = randomPojo(GoViewProjectDO.class); - goViewProjectMapper.insert(dbGoViewProject);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbGoViewProject.getId(); - - // 调用 - goViewProjectService.deleteProject(id); - // 校验数据不存在了 - assertNull(goViewProjectMapper.selectById(id)); - } - - @Test - public void testDeleteProject_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> goViewProjectService.deleteProject(id), GO_VIEW_PROJECT_NOT_EXISTS); - } - - @Test - public void testGetProject() { - // mock 数据 - GoViewProjectDO dbGoViewProject = randomPojo(GoViewProjectDO.class); - goViewProjectMapper.insert(dbGoViewProject);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbGoViewProject.getId(); - - // 调用 - GoViewProjectDO goViewProject = goViewProjectService.getProject(id); - // 断言 - assertPojoEquals(dbGoViewProject, goViewProject); - } - - @Test - public void testGetMyGoViewProjectPage() { - // mock 数据 - GoViewProjectDO dbGoViewProject = randomPojo(GoViewProjectDO.class, o -> { // 等会查询到 - o.setCreator("1"); - }); - goViewProjectMapper.insert(dbGoViewProject); - // 测试 userId 不匹配 - goViewProjectMapper.insert(cloneIgnoreId(dbGoViewProject, o -> o.setCreator("2"))); - // 准备参数 - PageParam reqVO = new PageParam(); - Long userId = 1L; - - // 调用 - PageResult pageResult = goViewProjectService.getMyProjectPage(reqVO, userId); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbGoViewProject, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/ureport/UReportDataServiceImplTest.java b/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/ureport/UReportDataServiceImplTest.java deleted file mode 100644 index a8f19eebf6..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/ureport/UReportDataServiceImplTest.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.report.service.ureport; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UReportDataPageReqVO; -import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UReportDataSaveReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UReportDataDO; -import cn.iocoder.yudao.module.report.dal.mysql.ureport.UReportDataMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.UREPORT_DATA_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -// TODO 芋艿:最后搞单测 -/** - * {@link UReportDataServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(UReportDataServiceImpl.class) -public class UReportDataServiceImplTest extends BaseDbUnitTest { - - @Resource - private UReportDataServiceImpl uReportDataService; - - @Resource - private UReportDataMapper uReportDataMapper; - - @Test - public void testCreateUReportData_success() { - // 准备参数 - UReportDataSaveReqVO createReqVO = randomPojo(UReportDataSaveReqVO.class).setId(null); - - // 调用 - Long uReportDataId = uReportDataService.createUReportData(createReqVO); - // 断言 - assertNotNull(uReportDataId); - // 校验记录的属性是否正确 - UReportDataDO uReportData = uReportDataMapper.selectById(uReportDataId); - assertPojoEquals(createReqVO, uReportData, "id"); - } - - @Test - public void testUpdateUReportData_success() { - // mock 数据 - UReportDataDO dbUReportData = randomPojo(UReportDataDO.class); - uReportDataMapper.insert(dbUReportData);// @Sql: 先插入出一条存在的数据 - // 准备参数 - UReportDataSaveReqVO updateReqVO = randomPojo(UReportDataSaveReqVO.class, o -> { - o.setId(dbUReportData.getId()); // 设置更新的 ID - }); - - // 调用 - uReportDataService.updateUReportData(updateReqVO); - // 校验是否更新正确 - UReportDataDO uReportData = uReportDataMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, uReportData); - } - - @Test - public void testUpdateUReportData_notExists() { - // 准备参数 - UReportDataSaveReqVO updateReqVO = randomPojo(UReportDataSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> uReportDataService.updateUReportData(updateReqVO), UREPORT_DATA_NOT_EXISTS); - } - - @Test - public void testDeleteUReportData_success() { - // mock 数据 - UReportDataDO dbUReportData = randomPojo(UReportDataDO.class); - uReportDataMapper.insert(dbUReportData);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbUReportData.getId(); - - // 调用 - uReportDataService.deleteUReportData(id); - // 校验数据不存在了 - assertNull(uReportDataMapper.selectById(id)); - } - - @Test - public void testDeleteUReportData_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> uReportDataService.deleteUReportData(id), UREPORT_DATA_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetUReportDataPage() { - // mock 数据 - UReportDataDO dbUReportData = randomPojo(UReportDataDO.class, o -> { // 等会查询到 - o.setName(null); - o.setStatus(null); - o.setRemark(null); - o.setCreateTime(null); - }); - uReportDataMapper.insert(dbUReportData); - // 测试 name 不匹配 - uReportDataMapper.insert(cloneIgnoreId(dbUReportData, o -> o.setName(null))); - // 测试 status 不匹配 - uReportDataMapper.insert(cloneIgnoreId(dbUReportData, o -> o.setStatus(null))); - // 测试 remark 不匹配 - uReportDataMapper.insert(cloneIgnoreId(dbUReportData, o -> o.setRemark(null))); - // 测试 createTime 不匹配 - uReportDataMapper.insert(cloneIgnoreId(dbUReportData, o -> o.setCreateTime(null))); - // 准备参数 - UReportDataPageReqVO reqVO = new UReportDataPageReqVO(); - reqVO.setName(null); - reqVO.setStatus(null); - reqVO.setRemark(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = uReportDataService.getUReportDataPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbUReportData, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml b/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 6bfd9953d7..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,55 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module - captcha: - timeout: 5m - width: 160 - height: 60 - enable: true diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/logback.xml b/yudao-module-report/yudao-module-report-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff0..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/clean.sql b/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index a55f807a15..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,2 +0,0 @@ -DELETE FROM "report_go_view_project"; -DELETE FROM "report_ureport_data"; diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/create_tables.sql b/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index bc2a21fbe4..0000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,27 +0,0 @@ -CREATE TABLE IF NOT EXISTS "report_go_view_project" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "pic_url" varchar, - "content" varchar, - "status" varchar NOT NULL, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT 'GoView 项目表'; -CREATE TABLE IF NOT EXISTS "report_ureport_data" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "content" varchar, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT 'Ureport2报表'; diff --git a/yudao-module-system/yudao-module-system-biz/pom.xml b/yudao-module-system/yudao-module-system-biz/pom.xml index dc8a1b4547..535a91ab0f 100644 --- a/yudao-module-system/yudao-module-system-biz/pom.xml +++ b/yudao-module-system/yudao-module-system-biz/pom.xml @@ -89,13 +89,6 @@ yudao-spring-boot-starter-mq - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - - cn.iocoder.boot diff --git a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/job/SchedulerManagerTest.java b/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/job/SchedulerManagerTest.java deleted file mode 100644 index 2b145a741e..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/job/SchedulerManagerTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.system.job; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; -import cn.iocoder.yudao.module.system.job.auth.UserSessionTimeoutJob; -import cn.iocoder.yudao.module.system.test.BaseDbUnitTest; -import org.junit.jupiter.api.Test; -import org.quartz.SchedulerException; - -import jakarta.annotation.Resource; - -public class SchedulerManagerTest extends BaseDbUnitTest { - - @Resource - private SchedulerManager schedulerManager; - - @Test - public void testAddJob() throws SchedulerException { - String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName()); - schedulerManager.addJob(1L, jobHandlerName, "test", "0/10 * * * * ? *", 0, 0); - } - - @Test - public void testUpdateJob() throws SchedulerException { - String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName()); - schedulerManager.updateJob(jobHandlerName, "hahaha", "0/20 * * * * ? *", 0, 0); - } - - @Test - public void testDeleteJob() throws SchedulerException { - String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName()); - schedulerManager.deleteJob(jobHandlerName); - } - - @Test - public void testPauseJob() throws SchedulerException { - String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName()); - schedulerManager.pauseJob(jobHandlerName); - } - - @Test - public void testResumeJob() throws SchedulerException { - String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName()); - schedulerManager.resumeJob(jobHandlerName); - } - - @Test - public void testTriggerJob() throws SchedulerException { - String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName()); - schedulerManager.triggerJob(1L, jobHandlerName, "niubi!!!"); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/mq/RedisStreamTest.java b/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/mq/RedisStreamTest.java deleted file mode 100644 index 9d431c288e..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/mq/RedisStreamTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.system.mq; - -import cn.hutool.core.thread.ThreadUtil; -import cn.iocoder.yudao.framework.mq.core.RedisMQTemplate; -import cn.iocoder.yudao.module.system.mq.consumer.mail.MailSendConsumer; -import cn.iocoder.yudao.module.system.mq.consumer.sms.SmsSendConsumer; -import cn.iocoder.yudao.module.system.mq.message.mail.MailSendMessage; -import cn.iocoder.yudao.module.system.mq.message.sms.SmsSendMessage; -import cn.iocoder.yudao.module.system.test.BaseRedisIntegrationTest; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; -import org.springframework.data.redis.core.RedisTemplate; - -import jakarta.annotation.Resource; -import java.util.concurrent.TimeUnit; - -public class RedisStreamTest { - - @Import({SmsSendConsumer.class, MailSendConsumer.class}) - @Disabled - public static class ConsumerTest extends BaseRedisIntegrationTest { - - @Test - public void testConsumer() { - ThreadUtil.sleep(1, TimeUnit.DAYS); - } - - } - - @Disabled - public static class ProducerTest extends BaseRedisIntegrationTest { - - @Resource - private RedisMQTemplate redisMQTemplate; - - @Resource - private RedisTemplate redisTemplate; - - @Test - public void testProducer01() { - for (int i = 0; i < 100; i++) { - // 创建消息 - SmsSendMessage message = new SmsSendMessage(); - message.setMobile("15601691300").setApiTemplateId("test:" + i); - // 发送消息 - redisMQTemplate.send(message); - } - } - - @Test - public void testProducer02() { - // 创建消息 - MailSendMessage message = new MailSendMessage(); - message.setAddress("fangfang@mihayou.com").setTemplateCode("test"); - // 发送消息 - redisMQTemplate.send(message); - } - - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/service/package-info.java b/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/service/package-info.java deleted file mode 100644 index 7b475e53e4..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/service/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.system.service; diff --git a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/service/sms/SmsServiceIntegrationTest.java b/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/service/sms/SmsServiceIntegrationTest.java deleted file mode 100644 index a8ce00a192..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/service/sms/SmsServiceIntegrationTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.system.service.sms; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.thread.ThreadUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.sms.config.YudaoSmsAutoConfiguration; -import cn.iocoder.yudao.module.system.test.BaseDbAndRedisIntegrationTest; -import cn.iocoder.yudao.module.system.mq.consumer.sms.SmsSendConsumer; -import cn.iocoder.yudao.module.system.mq.producer.sms.SmsProducer; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -// TODO @芋艿:需要迁移 -@Import({YudaoSmsAutoConfiguration.class, - SmsChannelServiceImpl.class, SmsSendServiceImpl.class, SmsTemplateServiceImpl.class, SmsLogServiceImpl.class, - SmsProducer.class, SmsSendConsumer.class}) -public class SmsServiceIntegrationTest extends BaseDbAndRedisIntegrationTest { - - @Resource - private SmsSendServiceImpl smsService; - @Resource - private SmsChannelServiceImpl smsChannelService; - - @MockBean - private AdminUserService userService; - - @Test - public void testSendSingleSms_aliyunSuccess() { - // 参数准备 - String mobile = "15601691399"; - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - String templateCode = "test_02"; - Map templateParams = MapUtil.builder() - .put("code", "1234").build(); - // 调用 - smsService.sendSingleSms(mobile, userId, userType, templateCode, templateParams); - - // 等待 MQ 消费 - ThreadUtil.sleep(1, TimeUnit.HOURS); - } - -// @Test -// public void testDoSendSms() { -// // 等待 MQ 消费 -// ThreadUtil.sleep(1, TimeUnit.HOURS); -// } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/test/BaseDbAndRedisIntegrationTest.java b/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/test/BaseDbAndRedisIntegrationTest.java deleted file mode 100644 index 5b9b21ffd5..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/test/BaseDbAndRedisIntegrationTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.system.test; - -import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; -import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration; -import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; -import org.redisson.spring.starter.RedissonAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbAndRedisIntegrationTest.Application.class) -@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 -public class BaseDbAndRedisIntegrationTest { - - @Import({ - // DB 配置类 - DynamicDataSourceAutoConfiguration.class, // Dynamic Datasource 配置类 - YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 - DataSourceAutoConfiguration.class, // Spring DB 自动配置类 - DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 - // MyBatis 配置类 - YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 - MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 - - // Redis 配置类 - RedisAutoConfiguration.class, // Spring Redis 自动配置类 - YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 - RedissonAutoConfiguration.class, // Redisson 自动高配置类 - }) - public static class Application { - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/test/BaseRedisIntegrationTest.java b/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/test/BaseRedisIntegrationTest.java deleted file mode 100644 index f48b2891df..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/test/BaseRedisIntegrationTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.system.test; - -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import org.redisson.spring.starter.RedissonAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseRedisIntegrationTest.Application.class) -@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 -public class BaseRedisIntegrationTest { - - @Import({ - // Redis 配置类 - RedisAutoConfiguration.class, // Spring Redis 自动配置类 - YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 - RedissonAutoConfiguration.class, // Redisson 自动高配置类 - }) - public static class Application { - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test-integration/resources/application-integration-test.yaml b/yudao-module-system/yudao-module-system-biz/src/test-integration/resources/application-integration-test.yaml deleted file mode 100644 index 4a1880178f..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test-integration/resources/application-integration-test.yaml +++ /dev/null @@ -1,109 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - name: ruoyi-vue-pro - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT - driver-class-name: com.mysql.jdbc.Driver - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 - name: ruoyi-vue-pro - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT - driver-class-name: com.mysql.jdbc.Driver - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 -resilience4j: - ratelimiter: - instances: - backendA: - limit-for-period: 1 # 每个周期内,允许的请求数。默认为 50 - limit-refresh-period: 60s # 每个周期的时长,单位:微秒。默认为 500 - timeout-duration: 1s # 被限流时,阻塞等待的时长,单位:微秒。默认为 5s - register-health-indicator: true # 是否注册到健康监测 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - security: - token-header: Authorization - token-secret: abcdefghijklmnopqrstuvwxyz - token-timeout: 1d - session-timeout: 30m - mock-enable: true - mock-secret: test - swagger: - enable: false # 单元测试,禁用 Swagger - file: - base-path: http://127.0.0.1:${server.port}/${yudao.web.api-prefix}/file/get/ - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenControllerTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenControllerTest.java deleted file mode 100644 index 7848272c02..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenControllerTest.java +++ /dev/null @@ -1,337 +0,0 @@ -package cn.iocoder.yudao.module.system.controller.admin.oauth2; - -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.exception.ErrorCode; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.open.OAuth2OpenAccessTokenRespVO; -import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.open.OAuth2OpenAuthorizeInfoRespVO; -import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.open.OAuth2OpenCheckTokenRespVO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ApproveDO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; -import cn.iocoder.yudao.module.system.enums.oauth2.OAuth2GrantTypeEnum; -import cn.iocoder.yudao.module.system.service.oauth2.OAuth2ApproveService; -import cn.iocoder.yudao.module.system.service.oauth2.OAuth2ClientService; -import cn.iocoder.yudao.module.system.service.oauth2.OAuth2GrantService; -import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import jakarta.servlet.http.HttpServletRequest; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static java.util.Arrays.asList; -import static org.hamcrest.CoreMatchers.anyOf; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * {@link OAuth2OpenController} 的单元测试 - * - * @author 芋道源码 - */ -public class OAuth2OpenControllerTest extends BaseMockitoUnitTest { - - @InjectMocks - private OAuth2OpenController oauth2OpenController; - - @Mock - private OAuth2GrantService oauth2GrantService; - @Mock - private OAuth2ClientService oauth2ClientService; - @Mock - private OAuth2ApproveService oauth2ApproveService; - @Mock - private OAuth2TokenService oauth2TokenService; - - @Test - public void testPostAccessToken_authorizationCode() { - // 准备参数 - String granType = OAuth2GrantTypeEnum.AUTHORIZATION_CODE.getGrantType(); - String code = randomString(); - String redirectUri = randomString(); - String state = randomString(); - HttpServletRequest request = mockRequest("test_client_id", "test_client_secret"); - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("test_client_id"); - when(oauth2ClientService.validOAuthClientFromCache(eq("test_client_id"), eq("test_client_secret"), eq(granType), eq(new ArrayList<>()), eq(redirectUri))).thenReturn(client); - - // mock 方法(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 30000L, ChronoUnit.MILLIS)); - when(oauth2GrantService.grantAuthorizationCodeForAccessToken(eq("test_client_id"), - eq(code), eq(redirectUri), eq(state))).thenReturn(accessTokenDO); - - // 调用 - CommonResult result = oauth2OpenController.postAccessToken(request, granType, - code, redirectUri, state, null, null, null, null); - // 断言 - assertEquals(0, result.getCode()); - assertPojoEquals(accessTokenDO, result.getData()); - assertTrue(ObjectUtils.equalsAny(result.getData().getExpiresIn(), 29L, 30L)); // 执行过程会过去几毫秒 - } - - @Test - public void testPostAccessToken_password() { - // 准备参数 - String granType = OAuth2GrantTypeEnum.PASSWORD.getGrantType(); - String username = randomString(); - String password = randomString(); - String scope = "write read"; - HttpServletRequest request = mockRequest("test_client_id", "test_client_secret"); - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("test_client_id"); - when(oauth2ClientService.validOAuthClientFromCache(eq("test_client_id"), eq("test_client_secret"), - eq(granType), eq(Lists.newArrayList("write", "read")), isNull())).thenReturn(client); - - // mock 方法(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 30000L, ChronoUnit.MILLIS)); - when(oauth2GrantService.grantPassword(eq(username), eq(password), eq("test_client_id"), - eq(Lists.newArrayList("write", "read")))).thenReturn(accessTokenDO); - - // 调用 - CommonResult result = oauth2OpenController.postAccessToken(request, granType, - null, null, null, username, password, scope, null); - // 断言 - assertEquals(0, result.getCode()); - assertPojoEquals(accessTokenDO, result.getData()); - assertTrue(ObjectUtils.equalsAny(result.getData().getExpiresIn(), 29L, 30L)); // 执行过程会过去几毫秒 - } - - @Test - public void testPostAccessToken_refreshToken() { - // 准备参数 - String granType = OAuth2GrantTypeEnum.REFRESH_TOKEN.getGrantType(); - String refreshToken = randomString(); - String password = randomString(); - HttpServletRequest request = mockRequest("test_client_id", "test_client_secret"); - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("test_client_id"); - when(oauth2ClientService.validOAuthClientFromCache(eq("test_client_id"), eq("test_client_secret"), - eq(granType), eq(Lists.newArrayList()), isNull())).thenReturn(client); - - // mock 方法(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 30000L, ChronoUnit.MILLIS)); - when(oauth2GrantService.grantRefreshToken(eq(refreshToken), eq("test_client_id"))).thenReturn(accessTokenDO); - - // 调用 - CommonResult result = oauth2OpenController.postAccessToken(request, granType, - null, null, null, null, password, null, refreshToken); - // 断言 - assertEquals(0, result.getCode()); - assertPojoEquals(accessTokenDO, result.getData()); - assertTrue(ObjectUtils.equalsAny(result.getData().getExpiresIn(), 29L, 30L)); // 执行过程会过去几毫秒 - } - - @Test - public void testPostAccessToken_implicit() { - // 调用,并断言 - assertServiceException(() -> oauth2OpenController.postAccessToken(null, - OAuth2GrantTypeEnum.IMPLICIT.getGrantType(), null, null, null, - null, null, null, null), - new ErrorCode(400, "Token 接口不支持 implicit 授权模式")); - } - - @Test - public void testRevokeToken() { - // 准备参数 - HttpServletRequest request = mockRequest("demo_client_id", "demo_client_secret"); - String token = randomString(); - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("demo_client_id"); - when(oauth2ClientService.validOAuthClientFromCache(eq("demo_client_id"), - eq("demo_client_secret"), isNull(), isNull(), isNull())).thenReturn(client); - // mock 方法(移除) - when(oauth2GrantService.revokeToken(eq("demo_client_id"), eq(token))).thenReturn(true); - - // 调用 - CommonResult result = oauth2OpenController.revokeToken(request, token); - // 断言 - assertEquals(0, result.getCode()); - assertTrue(result.getData()); - } - - @Test - public void testCheckToken() { - // 准备参数 - HttpServletRequest request = mockRequest("demo_client_id", "demo_client_secret"); - String token = randomString(); - // mock 方法 - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class).setUserType(UserTypeEnum.ADMIN.getValue()).setExpiresTime(LocalDateTimeUtil.of(1653485731195L)); - when(oauth2TokenService.checkAccessToken(eq(token))).thenReturn(accessTokenDO); - - // 调用 - CommonResult result = oauth2OpenController.checkToken(request, token); - // 断言 - assertEquals(0, result.getCode()); - assertPojoEquals(accessTokenDO, result.getData()); - assertEquals(1653485731L, result.getData().getExp()); // 执行过程会过去几毫秒 - } - - @Test - public void testAuthorize() { - // 准备参数 - String clientId = randomString(); - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("demo_client_id").setScopes(ListUtil.toList("read", "write", "all")); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))).thenReturn(client); - // mock 方法(approve) - List approves = asList( - randomPojo(OAuth2ApproveDO.class).setScope("read").setApproved(true), - randomPojo(OAuth2ApproveDO.class).setScope("write").setApproved(false)); - when(oauth2ApproveService.getApproveList(isNull(), eq(UserTypeEnum.ADMIN.getValue()), eq(clientId))).thenReturn(approves); - - // 调用 - CommonResult result = oauth2OpenController.authorize(clientId); - // 断言 - assertEquals(0, result.getCode()); - assertPojoEquals(client, result.getData().getClient()); - assertEquals(new KeyValue<>("read", true), result.getData().getScopes().get(0)); - assertEquals(new KeyValue<>("write", false), result.getData().getScopes().get(1)); - assertEquals(new KeyValue<>("all", false), result.getData().getScopes().get(2)); - } - - @Test - public void testApproveOrDeny_grantTypeError() { - // 调用,并断言 - assertServiceException(() -> oauth2OpenController.approveOrDeny(randomString(), null, - null, null, null, null), - new ErrorCode(400, "response_type 参数值只允许 code 和 token")); - } - - @Test // autoApprove = true,但是不通过 - public void testApproveOrDeny_autoApproveNo() { - // 准备参数 - String responseType = "code"; - String clientId = randomString(); - String scope = "{\"read\": true, \"write\": false}"; - String redirectUri = randomString(); - String state = randomString(); - // mock 方法 - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId), isNull(), eq("authorization_code"), - eq(asSet("read", "write")), eq(redirectUri))).thenReturn(client); - - // 调用 - CommonResult result = oauth2OpenController.approveOrDeny(responseType, clientId, - scope, redirectUri, true, state); - // 断言 - assertEquals(0, result.getCode()); - assertNull(result.getData()); - } - - @Test // autoApprove = false,但是不通过 - public void testApproveOrDeny_ApproveNo() { - // 准备参数 - String responseType = "token"; - String clientId = randomString(); - String scope = "{\"read\": true, \"write\": false}"; - String redirectUri = "https://www.iocoder.cn"; - String state = "test"; - // mock 方法 - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId), isNull(), eq("implicit"), - eq(asSet("read", "write")), eq(redirectUri))).thenReturn(client); - - // 调用 - CommonResult result = oauth2OpenController.approveOrDeny(responseType, clientId, - scope, redirectUri, false, state); - // 断言 - assertEquals(0, result.getCode()); - assertEquals("https://www.iocoder.cn#error=access_denied&error_description=User%20denied%20access&state=test", result.getData()); - } - - @Test // autoApprove = true,通过 + token - public void testApproveOrDeny_autoApproveWithToken() { - // 准备参数 - String responseType = "token"; - String clientId = randomString(); - String scope = "{\"read\": true, \"write\": false}"; - String redirectUri = "https://www.iocoder.cn"; - String state = "test"; - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId(clientId).setAdditionalInformation(null); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId), isNull(), eq("implicit"), - eq(asSet("read", "write")), eq(redirectUri))).thenReturn(client); - // mock 方法(场景一) - when(oauth2ApproveService.checkForPreApproval(isNull(), eq(UserTypeEnum.ADMIN.getValue()), - eq(clientId), eq(SetUtils.asSet("read", "write")))).thenReturn(true); - // mock 方法(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setAccessToken("test_access_token").setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 30010L, ChronoUnit.MILLIS)); - when(oauth2GrantService.grantImplicit(isNull(), eq(UserTypeEnum.ADMIN.getValue()), - eq(clientId), eq(ListUtil.toList("read")))).thenReturn(accessTokenDO); - - // 调用 - CommonResult result = oauth2OpenController.approveOrDeny(responseType, clientId, - scope, redirectUri, true, state); - // 断言 - assertEquals(0, result.getCode()); - assertThat(result.getData(), anyOf( // 29 和 30 都有一定概率,主要是时间计算 - is("https://www.iocoder.cn#access_token=test_access_token&token_type=bearer&state=test&expires_in=29&scope=read"), - is("https://www.iocoder.cn#access_token=test_access_token&token_type=bearer&state=test&expires_in=30&scope=read") - )); - } - - @Test // autoApprove = false,通过 + code - public void testApproveOrDeny_approveWithCode() { - // 准备参数 - String responseType = "code"; - String clientId = randomString(); - String scope = "{\"read\": true, \"write\": false}"; - String redirectUri = "https://www.iocoder.cn"; - String state = "test"; - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId(clientId).setAdditionalInformation(null); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId), isNull(), eq("authorization_code"), - eq(asSet("read", "write")), eq(redirectUri))).thenReturn(client); - // mock 方法(场景二) - when(oauth2ApproveService.updateAfterApproval(isNull(), eq(UserTypeEnum.ADMIN.getValue()), eq(clientId), - eq(MapUtil.builder(new LinkedHashMap()).put("read", true).put("write", false).build()))) - .thenReturn(true); - // mock 方法(访问令牌) - String authorizationCode = "test_code"; - when(oauth2GrantService.grantAuthorizationCodeForCode(isNull(), eq(UserTypeEnum.ADMIN.getValue()), - eq(clientId), eq(ListUtil.toList("read")), eq(redirectUri), eq(state))).thenReturn(authorizationCode); - - // 调用 - CommonResult result = oauth2OpenController.approveOrDeny(responseType, clientId, - scope, redirectUri, false, state); - // 断言 - assertEquals(0, result.getCode()); - assertEquals("https://www.iocoder.cn?code=test_code&state=test", result.getData()); - } - - private HttpServletRequest mockRequest(String clientId, String secret) { - HttpServletRequest request = mock(HttpServletRequest.class); - when(request.getParameter(eq("client_id"))).thenReturn(clientId); - when(request.getParameter(eq("client_secret"))).thenReturn(secret); - return request; - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.java deleted file mode 100644 index cd6c81f9fa..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.java +++ /dev/null @@ -1,372 +0,0 @@ -package cn.iocoder.yudao.module.system.service.auth; - -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO; -import cn.iocoder.yudao.module.system.controller.admin.auth.vo.*; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.enums.logger.LoginLogTypeEnum; -import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import cn.iocoder.yudao.module.system.service.logger.LoginLogService; -import cn.iocoder.yudao.module.system.service.member.MemberService; -import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; -import cn.iocoder.yudao.module.system.service.social.SocialUserService; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import com.xingyuv.captcha.model.common.ResponseModel; -import com.xingyuv.captcha.service.CaptchaService; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import jakarta.validation.ConstraintViolationException; -import jakarta.validation.Validation; -import jakarta.validation.Validator; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -@Import(AdminAuthServiceImpl.class) -public class AdminAuthServiceImplTest extends BaseDbUnitTest { - - @Resource - private AdminAuthServiceImpl authService; - - @MockBean - private AdminUserService userService; - @MockBean - private CaptchaService captchaService; - @MockBean - private LoginLogService loginLogService; - @MockBean - private SocialUserService socialUserService; - @MockBean - private SmsCodeApi smsCodeApi; - @MockBean - private OAuth2TokenService oauth2TokenService; - @MockBean - private MemberService memberService; - @MockBean - private Validator validator; - - @BeforeEach - public void setUp() { - ReflectUtil.setFieldValue(authService, "captchaEnable", true); - // 注入一个 Validator 对象 - ReflectUtil.setFieldValue(authService, "validator", - Validation.buildDefaultValidatorFactory().getValidator()); - } - - @Test - public void testAuthenticate_success() { - // 准备参数 - String username = randomString(); - String password = randomString(); - // mock user 数据 - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setUsername(username) - .setPassword(password).setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(userService.getUserByUsername(eq(username))).thenReturn(user); - // mock password 匹配 - when(userService.isPasswordMatch(eq(password), eq(user.getPassword()))).thenReturn(true); - - // 调用 - AdminUserDO loginUser = authService.authenticate(username, password); - // 校验 - assertPojoEquals(user, loginUser); - } - - @Test - public void testAuthenticate_userNotFound() { - // 准备参数 - String username = randomString(); - String password = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> authService.authenticate(username, password), - AUTH_LOGIN_BAD_CREDENTIALS); - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType()) - && o.getResult().equals(LoginResultEnum.BAD_CREDENTIALS.getResult()) - && o.getUserId() == null) - ); - } - - @Test - public void testAuthenticate_badCredentials() { - // 准备参数 - String username = randomString(); - String password = randomString(); - // mock user 数据 - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setUsername(username) - .setPassword(password).setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(userService.getUserByUsername(eq(username))).thenReturn(user); - - // 调用, 并断言异常 - assertServiceException(() -> authService.authenticate(username, password), - AUTH_LOGIN_BAD_CREDENTIALS); - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType()) - && o.getResult().equals(LoginResultEnum.BAD_CREDENTIALS.getResult()) - && o.getUserId().equals(user.getId())) - ); - } - - @Test - public void testAuthenticate_userDisabled() { - // 准备参数 - String username = randomString(); - String password = randomString(); - // mock user 数据 - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setUsername(username) - .setPassword(password).setStatus(CommonStatusEnum.DISABLE.getStatus())); - when(userService.getUserByUsername(eq(username))).thenReturn(user); - // mock password 匹配 - when(userService.isPasswordMatch(eq(password), eq(user.getPassword()))).thenReturn(true); - - // 调用, 并断言异常 - assertServiceException(() -> authService.authenticate(username, password), - AUTH_LOGIN_USER_DISABLED); - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType()) - && o.getResult().equals(LoginResultEnum.USER_DISABLED.getResult()) - && o.getUserId().equals(user.getId())) - ); - } - - @Test - public void testLogin_success() { - // 准备参数 - AuthLoginReqVO reqVO = randomPojo(AuthLoginReqVO.class, o -> - o.setUsername("test_username").setPassword("test_password") - .setSocialType(randomEle(SocialTypeEnum.values()).getType())); - - // mock 验证码正确 - ReflectUtil.setFieldValue(authService, "captchaEnable", false); - // mock user 数据 - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setId(1L).setUsername("test_username") - .setPassword("test_password").setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(userService.getUserByUsername(eq("test_username"))).thenReturn(user); - // mock password 匹配 - when(userService.isPasswordMatch(eq("test_password"), eq(user.getPassword()))).thenReturn(true); - // mock 缓存登录用户到 Redis - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class, o -> o.setUserId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - when(oauth2TokenService.createAccessToken(eq(1L), eq(UserTypeEnum.ADMIN.getValue()), eq("default"), isNull())) - .thenReturn(accessTokenDO); - - // 调用,并校验 - AuthLoginRespVO loginRespVO = authService.login(reqVO); - assertPojoEquals(accessTokenDO, loginRespVO); - // 校验调用参数 - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType()) - && o.getResult().equals(LoginResultEnum.SUCCESS.getResult()) - && o.getUserId().equals(user.getId())) - ); - verify(socialUserService).bindSocialUser(eq(new SocialUserBindReqDTO( - user.getId(), UserTypeEnum.ADMIN.getValue(), - reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState()))); - } - - @Test - public void testSendSmsCode() { - // 准备参数 - String mobile = randomString(); - Integer scene = randomEle(SmsSceneEnum.values()).getScene(); - AuthSmsSendReqVO reqVO = new AuthSmsSendReqVO(mobile, scene); - // mock 方法(用户信息) - AdminUserDO user = randomPojo(AdminUserDO.class); - when(userService.getUserByMobile(eq(mobile))).thenReturn(user); - - // 调用 - authService.sendSmsCode(reqVO); - // 断言 - verify(smsCodeApi).sendSmsCode(argThat(sendReqDTO -> { - assertEquals(mobile, sendReqDTO.getMobile()); - assertEquals(scene, sendReqDTO.getScene()); - return true; - })); - } - - @Test - public void testSmsLogin_success() { - // 准备参数 - String mobile = randomString(); - String scene = randomString(); - AuthSmsLoginReqVO reqVO = new AuthSmsLoginReqVO(mobile, scene); - // mock 方法(用户信息) - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setId(1L)); - when(userService.getUserByMobile(eq(mobile))).thenReturn(user); - // mock 缓存登录用户到 Redis - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class, o -> o.setUserId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - when(oauth2TokenService.createAccessToken(eq(1L), eq(UserTypeEnum.ADMIN.getValue()), eq("default"), isNull())) - .thenReturn(accessTokenDO); - - // 调用,并断言 - AuthLoginRespVO loginRespVO = authService.smsLogin(reqVO); - assertPojoEquals(accessTokenDO, loginRespVO); - // 断言调用 - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_MOBILE.getType()) - && o.getResult().equals(LoginResultEnum.SUCCESS.getResult()) - && o.getUserId().equals(user.getId())) - ); - } - - @Test - public void testSocialLogin_success() { - // 准备参数 - AuthSocialLoginReqVO reqVO = randomPojo(AuthSocialLoginReqVO.class); - // mock 方法(绑定的用户编号) - Long userId = 1L; - when(socialUserService.getSocialUser(eq(UserTypeEnum.ADMIN.getValue()), eq(reqVO.getType()), - eq(reqVO.getCode()), eq(reqVO.getState()))).thenReturn(new SocialUserRespDTO(randomString(), userId)); - // mock(用户) - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setId(userId)); - when(userService.getUser(eq(userId))).thenReturn(user); - // mock 缓存登录用户到 Redis - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class, o -> o.setUserId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - when(oauth2TokenService.createAccessToken(eq(1L), eq(UserTypeEnum.ADMIN.getValue()), eq("default"), isNull())) - .thenReturn(accessTokenDO); - - // 调用,并断言 - AuthLoginRespVO loginRespVO = authService.socialLogin(reqVO); - assertPojoEquals(accessTokenDO, loginRespVO); - // 断言调用 - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_SOCIAL.getType()) - && o.getResult().equals(LoginResultEnum.SUCCESS.getResult()) - && o.getUserId().equals(user.getId())) - ); - } - - @Test - public void testValidateCaptcha_successWithEnable() { - // 准备参数 - AuthLoginReqVO reqVO = randomPojo(AuthLoginReqVO.class); - - // mock 验证码打开 - ReflectUtil.setFieldValue(authService, "captchaEnable", true); - // mock 验证通过 - when(captchaService.verification(argThat(captchaVO -> { - assertEquals(reqVO.getCaptchaVerification(), captchaVO.getCaptchaVerification()); - return true; - }))).thenReturn(ResponseModel.success()); - - // 调用,无需断言 - authService.validateCaptcha(reqVO); - } - - @Test - public void testValidateCaptcha_successWithDisable() { - // 准备参数 - AuthLoginReqVO reqVO = randomPojo(AuthLoginReqVO.class); - - // mock 验证码关闭 - ReflectUtil.setFieldValue(authService, "captchaEnable", false); - - // 调用,无需断言 - authService.validateCaptcha(reqVO); - } - - @Test - public void testValidateCaptcha_constraintViolationException() { - // 准备参数 - AuthLoginReqVO reqVO = randomPojo(AuthLoginReqVO.class).setCaptchaVerification(null); - - // mock 验证码打开 - ReflectUtil.setFieldValue(authService, "captchaEnable", true); - - // 调用,并断言异常 - assertThrows(ConstraintViolationException.class, () -> authService.validateCaptcha(reqVO), - "验证码不能为空"); - } - - - @Test - public void testCaptcha_fail() { - // 准备参数 - AuthLoginReqVO reqVO = randomPojo(AuthLoginReqVO.class); - - // mock 验证码打开 - ReflectUtil.setFieldValue(authService, "captchaEnable", true); - // mock 验证通过 - when(captchaService.verification(argThat(captchaVO -> { - assertEquals(reqVO.getCaptchaVerification(), captchaVO.getCaptchaVerification()); - return true; - }))).thenReturn(ResponseModel.errorMsg("就是不对")); - - // 调用, 并断言异常 - assertServiceException(() -> authService.validateCaptcha(reqVO), AUTH_LOGIN_CAPTCHA_CODE_ERROR, "就是不对"); - // 校验调用参数 - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType()) - && o.getResult().equals(LoginResultEnum.CAPTCHA_CODE_ERROR.getResult())) - ); - } - - @Test - public void testRefreshToken() { - // 准备参数 - String refreshToken = randomString(); - // mock 方法 - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class); - when(oauth2TokenService.refreshAccessToken(eq(refreshToken), eq("default"))) - .thenReturn(accessTokenDO); - - // 调用 - AuthLoginRespVO loginRespVO = authService.refreshToken(refreshToken); - // 断言 - assertPojoEquals(accessTokenDO, loginRespVO); - } - - @Test - public void testLogout_success() { - // 准备参数 - String token = randomString(); - // mock - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class, o -> o.setUserId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - when(oauth2TokenService.removeAccessToken(eq(token))).thenReturn(accessTokenDO); - - // 调用 - authService.logout(token, LoginLogTypeEnum.LOGOUT_SELF.getType()); - // 校验调用参数 - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGOUT_SELF.getType()) - && o.getResult().equals(LoginResultEnum.SUCCESS.getResult())) - ); - // 调用,并校验 - - } - - @Test - public void testLogout_fail() { - // 准备参数 - String token = randomString(); - - // 调用 - authService.logout(token, LoginLogTypeEnum.LOGOUT_SELF.getType()); - // 校验调用参数 - verify(loginLogService, never()).createLoginLog(any()); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImplTest.java deleted file mode 100644 index bcf55bda66..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImplTest.java +++ /dev/null @@ -1,296 +0,0 @@ -package cn.iocoder.yudao.module.system.service.dept; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO; -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; -import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link DeptServiceImpl} 的单元测试类 - * - * @author niudehua - */ -@Import(DeptServiceImpl.class) -public class DeptServiceImplTest extends BaseDbUnitTest { - - @Resource - private DeptServiceImpl deptService; - @Resource - private DeptMapper deptMapper; - - @Test - public void testCreateDept() { - // 准备参数 - DeptSaveReqVO reqVO = randomPojo(DeptSaveReqVO.class, o -> { - o.setId(null); // 防止 id 被设置 - o.setParentId(DeptDO.PARENT_ID_ROOT); - o.setStatus(randomCommonStatus()); - }); - - // 调用 - Long deptId = deptService.createDept(reqVO); - // 断言 - assertNotNull(deptId); - // 校验记录的属性是否正确 - DeptDO deptDO = deptMapper.selectById(deptId); - assertPojoEquals(reqVO, deptDO, "id"); - } - - @Test - public void testUpdateDept() { - // mock 数据 - DeptDO dbDeptDO = randomPojo(DeptDO.class, o -> o.setStatus(randomCommonStatus())); - deptMapper.insert(dbDeptDO);// @Sql: 先插入出一条存在的数据 - // 准备参数 - DeptSaveReqVO reqVO = randomPojo(DeptSaveReqVO.class, o -> { - // 设置更新的 ID - o.setParentId(DeptDO.PARENT_ID_ROOT); - o.setId(dbDeptDO.getId()); - o.setStatus(randomCommonStatus()); - }); - - // 调用 - deptService.updateDept(reqVO); - // 校验是否更新正确 - DeptDO deptDO = deptMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, deptDO); - } - - @Test - public void testDeleteDept_success() { - // mock 数据 - DeptDO dbDeptDO = randomPojo(DeptDO.class); - deptMapper.insert(dbDeptDO);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDeptDO.getId(); - - // 调用 - deptService.deleteDept(id); - // 校验数据不存在了 - assertNull(deptMapper.selectById(id)); - } - - @Test - public void testDeleteDept_exitsChildren() { - // mock 数据 - DeptDO parentDept = randomPojo(DeptDO.class); - deptMapper.insert(parentDept);// @Sql: 先插入出一条存在的数据 - // 准备参数 - DeptDO childrenDeptDO = randomPojo(DeptDO.class, o -> { - o.setParentId(parentDept.getId()); - o.setStatus(randomCommonStatus()); - }); - // 插入子部门 - deptMapper.insert(childrenDeptDO); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.deleteDept(parentDept.getId()), DEPT_EXITS_CHILDREN); - } - - @Test - public void testValidateDeptExists_notFound() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.validateDeptExists(id), DEPT_NOT_FOUND); - } - - @Test - public void testValidateParentDept_parentError() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.validateParentDept(id, id), - DEPT_PARENT_ERROR); - } - - @Test - public void testValidateParentDept_parentIsChild() { - // mock 数据(父节点) - DeptDO parentDept = randomPojo(DeptDO.class); - deptMapper.insert(parentDept); - // mock 数据(子节点) - DeptDO childDept = randomPojo(DeptDO.class, o -> { - o.setParentId(parentDept.getId()); - }); - deptMapper.insert(childDept); - - // 准备参数 - Long id = parentDept.getId(); - Long parentId = childDept.getId(); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.validateParentDept(id, parentId), DEPT_PARENT_IS_CHILD); - } - - @Test - public void testValidateNameUnique_duplicate() { - // mock 数据 - DeptDO deptDO = randomPojo(DeptDO.class); - deptMapper.insert(deptDO); - - // 准备参数 - Long id = randomLongId(); - Long parentId = deptDO.getParentId(); - String name = deptDO.getName(); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.validateDeptNameUnique(id, parentId, name), - DEPT_NAME_DUPLICATE); - } - - @Test - public void testGetDept() { - // mock 数据 - DeptDO deptDO = randomPojo(DeptDO.class); - deptMapper.insert(deptDO); - // 准备参数 - Long id = deptDO.getId(); - - // 调用 - DeptDO dbDept = deptService.getDept(id); - // 断言 - assertEquals(deptDO, dbDept); - } - - @Test - public void testGetDeptList_ids() { - // mock 数据 - DeptDO deptDO01 = randomPojo(DeptDO.class); - deptMapper.insert(deptDO01); - DeptDO deptDO02 = randomPojo(DeptDO.class); - deptMapper.insert(deptDO02); - // 准备参数 - List ids = Arrays.asList(deptDO01.getId(), deptDO02.getId()); - - // 调用 - List deptDOList = deptService.getDeptList(ids); - // 断言 - assertEquals(2, deptDOList.size()); - assertEquals(deptDO01, deptDOList.get(0)); - assertEquals(deptDO02, deptDOList.get(1)); - } - - @Test - public void testGetDeptList_reqVO() { - // mock 数据 - DeptDO dept = randomPojo(DeptDO.class, o -> { // 等会查询到 - o.setName("开发部"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - deptMapper.insert(dept); - // 测试 name 不匹配 - deptMapper.insert(ObjectUtils.cloneIgnoreId(dept, o -> o.setName("发"))); - // 测试 status 不匹配 - deptMapper.insert(ObjectUtils.cloneIgnoreId(dept, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 准备参数 - DeptListReqVO reqVO = new DeptListReqVO(); - reqVO.setName("开"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - List sysDeptDOS = deptService.getDeptList(reqVO); - // 断言 - assertEquals(1, sysDeptDOS.size()); - assertPojoEquals(dept, sysDeptDOS.get(0)); - } - - @Test - public void testGetChildDeptList() { - // mock 数据(1 级别子节点) - DeptDO dept1 = randomPojo(DeptDO.class, o -> o.setName("1")); - deptMapper.insert(dept1); - DeptDO dept2 = randomPojo(DeptDO.class, o -> o.setName("2")); - deptMapper.insert(dept2); - // mock 数据(2 级子节点) - DeptDO dept1a = randomPojo(DeptDO.class, o -> o.setName("1-a").setParentId(dept1.getId())); - deptMapper.insert(dept1a); - DeptDO dept2a = randomPojo(DeptDO.class, o -> o.setName("2-a").setParentId(dept2.getId())); - deptMapper.insert(dept2a); - // 准备参数 - Long id = dept1.getParentId(); - - // 调用 - List result = deptService.getChildDeptList(id); - // 断言 - assertEquals(result.size(), 2); - assertPojoEquals(dept1, result.get(0)); - assertPojoEquals(dept1a, result.get(1)); - } - - @Test - public void testGetChildDeptListFromCache() { - // mock 数据(1 级别子节点) - DeptDO dept1 = randomPojo(DeptDO.class, o -> o.setName("1")); - deptMapper.insert(dept1); - DeptDO dept2 = randomPojo(DeptDO.class, o -> o.setName("2")); - deptMapper.insert(dept2); - // mock 数据(2 级子节点) - DeptDO dept1a = randomPojo(DeptDO.class, o -> o.setName("1-a").setParentId(dept1.getId())); - deptMapper.insert(dept1a); - DeptDO dept2a = randomPojo(DeptDO.class, o -> o.setName("2-a").setParentId(dept2.getId())); - deptMapper.insert(dept2a); - // 准备参数 - Long id = dept1.getParentId(); - - // 调用 - Set result = deptService.getChildDeptIdListFromCache(id); - // 断言 - assertEquals(result.size(), 2); - assertTrue(result.contains(dept1.getId())); - assertTrue(result.contains(dept1a.getId())); - } - - @Test - public void testValidateDeptList_success() { - // mock 数据 - DeptDO deptDO = randomPojo(DeptDO.class).setStatus(CommonStatusEnum.ENABLE.getStatus()); - deptMapper.insert(deptDO); - // 准备参数 - List ids = singletonList(deptDO.getId()); - - // 调用,无需断言 - deptService.validateDeptList(ids); - } - - @Test - public void testValidateDeptList_notFound() { - // 准备参数 - List ids = singletonList(randomLongId()); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.validateDeptList(ids), DEPT_NOT_FOUND); - } - - @Test - public void testValidateDeptList_notEnable() { - // mock 数据 - DeptDO deptDO = randomPojo(DeptDO.class).setStatus(CommonStatusEnum.DISABLE.getStatus()); - deptMapper.insert(deptDO); - // 准备参数 - List ids = singletonList(deptDO.getId()); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.validateDeptList(ids), DEPT_NOT_ENABLE, deptDO.getName()); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/PostServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/PostServiceImplTest.java deleted file mode 100644 index 657c09d7c8..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/PostServiceImplTest.java +++ /dev/null @@ -1,248 +0,0 @@ -package cn.iocoder.yudao.module.system.service.dept; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO; -import cn.iocoder.yudao.module.system.dal.mysql.dept.PostMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Arrays; -import java.util.List; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link PostServiceImpl} 的单元测试类 - * - * @author niudehua - */ -@Import(PostServiceImpl.class) -public class PostServiceImplTest extends BaseDbUnitTest { - - @Resource - private PostServiceImpl postService; - - @Resource - private PostMapper postMapper; - - @Test - public void testCreatePost_success() { - // 准备参数 - PostSaveReqVO reqVO = randomPojo(PostSaveReqVO.class, - o -> o.setStatus(randomEle(CommonStatusEnum.values()).getStatus())) - .setId(null); // 防止 id 被设置 - // 调用 - Long postId = postService.createPost(reqVO); - - // 断言 - assertNotNull(postId); - // 校验记录的属性是否正确 - PostDO post = postMapper.selectById(postId); - assertPojoEquals(reqVO, post, "id"); - } - - @Test - public void testUpdatePost_success() { - // mock 数据 - PostDO postDO = randomPostDO(); - postMapper.insert(postDO);// @Sql: 先插入出一条存在的数据 - // 准备参数 - PostSaveReqVO reqVO = randomPojo(PostSaveReqVO.class, o -> { - // 设置更新的 ID - o.setId(postDO.getId()); - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); - }); - - // 调用 - postService.updatePost(reqVO); - // 校验是否更新正确 - PostDO post = postMapper.selectById(reqVO.getId()); - assertPojoEquals(reqVO, post); - } - - @Test - public void testDeletePost_success() { - // mock 数据 - PostDO postDO = randomPostDO(); - postMapper.insert(postDO); - // 准备参数 - Long id = postDO.getId(); - - // 调用 - postService.deletePost(id); - assertNull(postMapper.selectById(id)); - } - - @Test - public void testValidatePost_notFoundForDelete() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> postService.deletePost(id), POST_NOT_FOUND); - } - - @Test - public void testValidatePost_nameDuplicateForCreate() { - // mock 数据 - PostDO postDO = randomPostDO(); - postMapper.insert(postDO);// @Sql: 先插入出一条存在的数据 - // 准备参数 - PostSaveReqVO reqVO = randomPojo(PostSaveReqVO.class, - // 模拟 name 重复 - o -> o.setName(postDO.getName())); - assertServiceException(() -> postService.createPost(reqVO), POST_NAME_DUPLICATE); - } - - @Test - public void testValidatePost_codeDuplicateForUpdate() { - // mock 数据 - PostDO postDO = randomPostDO(); - postMapper.insert(postDO); - // mock 数据:稍后模拟重复它的 code - PostDO codePostDO = randomPostDO(); - postMapper.insert(codePostDO); - // 准备参数 - PostSaveReqVO reqVO = randomPojo(PostSaveReqVO.class, o -> { - // 设置更新的 ID - o.setId(postDO.getId()); - // 模拟 code 重复 - o.setCode(codePostDO.getCode()); - }); - - // 调用, 并断言异常 - assertServiceException(() -> postService.updatePost(reqVO), POST_CODE_DUPLICATE); - } - - @Test - public void testGetPostPage() { - // mock 数据 - PostDO postDO = randomPojo(PostDO.class, o -> { - o.setName("码仔"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - postMapper.insert(postDO); - // 测试 name 不匹配 - postMapper.insert(cloneIgnoreId(postDO, o -> o.setName("程序员"))); - // 测试 status 不匹配 - postMapper.insert(cloneIgnoreId(postDO, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 准备参数 - PostPageReqVO reqVO = new PostPageReqVO(); - reqVO.setName("码"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - PageResult pageResult = postService.getPostPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(postDO, pageResult.getList().get(0)); - } - - @Test - public void testGetPostList() { - // mock 数据 - PostDO postDO01 = randomPojo(PostDO.class); - postMapper.insert(postDO01); - // 测试 id 不匹配 - PostDO postDO02 = randomPojo(PostDO.class); - postMapper.insert(postDO02); - // 准备参数 - List ids = singletonList(postDO01.getId()); - - // 调用 - List list = postService.getPostList(ids); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(postDO01, list.get(0)); - } - - @Test - public void testGetPostList_idsAndStatus() { - // mock 数据 - PostDO postDO01 = randomPojo(PostDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - postMapper.insert(postDO01); - // 测试 status 不匹配 - PostDO postDO02 = randomPojo(PostDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - postMapper.insert(postDO02); - // 准备参数 - List ids = Arrays.asList(postDO01.getId(), postDO02.getId()); - - // 调用 - List list = postService.getPostList(ids, singletonList(CommonStatusEnum.ENABLE.getStatus())); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(postDO01, list.get(0)); - } - - @Test - public void testGetPost() { - // mock 数据 - PostDO dbPostDO = randomPostDO(); - postMapper.insert(dbPostDO); - // 准备参数 - Long id = dbPostDO.getId(); - // 调用 - PostDO post = postService.getPost(id); - // 断言 - assertNotNull(post); - assertPojoEquals(dbPostDO, post); - } - - @Test - public void testValidatePostList_success() { - // mock 数据 - PostDO postDO = randomPostDO().setStatus(CommonStatusEnum.ENABLE.getStatus()); - postMapper.insert(postDO); - // 准备参数 - List ids = singletonList(postDO.getId()); - - // 调用,无需断言 - postService.validatePostList(ids); - } - - @Test - public void testValidatePostList_notFound() { - // 准备参数 - List ids = singletonList(randomLongId()); - - // 调用, 并断言异常 - assertServiceException(() -> postService.validatePostList(ids), POST_NOT_FOUND); - } - - @Test - public void testValidatePostList_notEnable() { - // mock 数据 - PostDO postDO = randomPostDO().setStatus(CommonStatusEnum.DISABLE.getStatus()); - postMapper.insert(postDO); - // 准备参数 - List ids = singletonList(postDO.getId()); - - // 调用, 并断言异常 - assertServiceException(() -> postService.validatePostList(ids), POST_NOT_ENABLE, - postDO.getName()); - } - - @SafeVarargs - private static PostDO randomPostDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(randomCommonStatus()); // 保证 status 的范围 - }; - return randomPojo(PostDO.class, ArrayUtils.append(consumer, consumers)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImplTest.java deleted file mode 100644 index 999570ee60..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImplTest.java +++ /dev/null @@ -1,352 +0,0 @@ -package cn.iocoder.yudao.module.system.service.dict; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; -import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO; -import cn.iocoder.yudao.module.system.dal.mysql.dict.DictDataMapper; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.function.Consumer; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -@Import(DictDataServiceImpl.class) -public class DictDataServiceImplTest extends BaseDbUnitTest { - - @Resource - private DictDataServiceImpl dictDataService; - - @Resource - private DictDataMapper dictDataMapper; - @MockBean - private DictTypeService dictTypeService; - - @Test - public void testGetDictDataList() { - // mock 数据 - DictDataDO dictDataDO01 = randomDictDataDO().setDictType("yunai").setSort(2) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - dictDataMapper.insert(dictDataDO01); - DictDataDO dictDataDO02 = randomDictDataDO().setDictType("yunai").setSort(1) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - dictDataMapper.insert(dictDataDO02); - DictDataDO dictDataDO03 = randomDictDataDO().setDictType("yunai").setSort(3) - .setStatus(CommonStatusEnum.DISABLE.getStatus()); - dictDataMapper.insert(dictDataDO03); - DictDataDO dictDataDO04 = randomDictDataDO().setDictType("yunai2").setSort(3) - .setStatus(CommonStatusEnum.DISABLE.getStatus()); - dictDataMapper.insert(dictDataDO04); - // 准备参数 - Integer status = CommonStatusEnum.ENABLE.getStatus(); - String dictType = "yunai"; - - // 调用 - List dictDataDOList = dictDataService.getDictDataList(status, dictType); - // 断言 - assertEquals(2, dictDataDOList.size()); - assertPojoEquals(dictDataDO02, dictDataDOList.get(0)); - assertPojoEquals(dictDataDO01, dictDataDOList.get(1)); - } - - @Test - public void testGetDictDataPage() { - // mock 数据 - DictDataDO dbDictData = randomPojo(DictDataDO.class, o -> { // 等会查询到 - o.setLabel("芋艿"); - o.setDictType("yunai"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - dictDataMapper.insert(dbDictData); - // 测试 label 不匹配 - dictDataMapper.insert(cloneIgnoreId(dbDictData, o -> o.setLabel("艿"))); - // 测试 dictType 不匹配 - dictDataMapper.insert(cloneIgnoreId(dbDictData, o -> o.setDictType("nai"))); - // 测试 status 不匹配 - dictDataMapper.insert(cloneIgnoreId(dbDictData, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 准备参数 - DictDataPageReqVO reqVO = new DictDataPageReqVO(); - reqVO.setLabel("芋"); - reqVO.setDictType("yunai"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - PageResult pageResult = dictDataService.getDictDataPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbDictData, pageResult.getList().get(0)); - } - - @Test - public void testGetDictData() { - // mock 数据 - DictDataDO dbDictData = randomDictDataDO(); - dictDataMapper.insert(dbDictData); - // 准备参数 - Long id = dbDictData.getId(); - - // 调用 - DictDataDO dictData = dictDataService.getDictData(id); - // 断言 - assertPojoEquals(dbDictData, dictData); - } - - @Test - public void testCreateDictData_success() { - // 准备参数 - DictDataSaveReqVO reqVO = randomPojo(DictDataSaveReqVO.class, - o -> o.setStatus(randomCommonStatus())) - .setId(null); // 防止 id 被赋值 - // mock 方法 - when(dictTypeService.getDictType(eq(reqVO.getDictType()))).thenReturn(randomDictTypeDO(reqVO.getDictType())); - - // 调用 - Long dictDataId = dictDataService.createDictData(reqVO); - // 断言 - assertNotNull(dictDataId); - // 校验记录的属性是否正确 - DictDataDO dictData = dictDataMapper.selectById(dictDataId); - assertPojoEquals(reqVO, dictData, "id"); - } - - @Test - public void testUpdateDictData_success() { - // mock 数据 - DictDataDO dbDictData = randomDictDataDO(); - dictDataMapper.insert(dbDictData);// @Sql: 先插入出一条存在的数据 - // 准备参数 - DictDataSaveReqVO reqVO = randomPojo(DictDataSaveReqVO.class, o -> { - o.setId(dbDictData.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - }); - // mock 方法,字典类型 - when(dictTypeService.getDictType(eq(reqVO.getDictType()))).thenReturn(randomDictTypeDO(reqVO.getDictType())); - - // 调用 - dictDataService.updateDictData(reqVO); - // 校验是否更新正确 - DictDataDO dictData = dictDataMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, dictData); - } - - @Test - public void testDeleteDictData_success() { - // mock 数据 - DictDataDO dbDictData = randomDictDataDO(); - dictDataMapper.insert(dbDictData);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDictData.getId(); - - // 调用 - dictDataService.deleteDictData(id); - // 校验数据不存在了 - assertNull(dictDataMapper.selectById(id)); - } - - @Test - public void testValidateDictDataExists_success() { - // mock 数据 - DictDataDO dbDictData = randomDictDataDO(); - dictDataMapper.insert(dbDictData);// @Sql: 先插入出一条存在的数据 - - // 调用成功 - dictDataService.validateDictDataExists(dbDictData.getId()); - } - - @Test - public void testValidateDictDataExists_notExists() { - assertServiceException(() -> dictDataService.validateDictDataExists(randomLongId()), DICT_DATA_NOT_EXISTS); - } - - @Test - public void testValidateDictTypeExists_success() { - // mock 方法,数据类型被禁用 - String type = randomString(); - when(dictTypeService.getDictType(eq(type))).thenReturn(randomDictTypeDO(type)); - - // 调用, 成功 - dictDataService.validateDictTypeExists(type); - } - - @Test - public void testValidateDictTypeExists_notExists() { - assertServiceException(() -> dictDataService.validateDictTypeExists(randomString()), DICT_TYPE_NOT_EXISTS); - } - - @Test - public void testValidateDictTypeExists_notEnable() { - // mock 方法,数据类型被禁用 - String dictType = randomString(); - when(dictTypeService.getDictType(eq(dictType))).thenReturn( - randomPojo(DictTypeDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - - // 调用, 并断言异常 - assertServiceException(() -> dictDataService.validateDictTypeExists(dictType), DICT_TYPE_NOT_ENABLE); - } - - @Test - public void testValidateDictDataValueUnique_success() { - // 调用,成功 - dictDataService.validateDictDataValueUnique(randomLongId(), randomString(), randomString()); - } - - @Test - public void testValidateDictDataValueUnique_valueDuplicateForCreate() { - // 准备参数 - String dictType = randomString(); - String value = randomString(); - // mock 数据 - dictDataMapper.insert(randomDictDataDO(o -> { - o.setDictType(dictType); - o.setValue(value); - })); - - // 调用,校验异常 - assertServiceException(() -> dictDataService.validateDictDataValueUnique(null, dictType, value), - DICT_DATA_VALUE_DUPLICATE); - } - - @Test - public void testValidateDictDataValueUnique_valueDuplicateForUpdate() { - // 准备参数 - Long id = randomLongId(); - String dictType = randomString(); - String value = randomString(); - // mock 数据 - dictDataMapper.insert(randomDictDataDO(o -> { - o.setDictType(dictType); - o.setValue(value); - })); - - // 调用,校验异常 - assertServiceException(() -> dictDataService.validateDictDataValueUnique(id, dictType, value), - DICT_DATA_VALUE_DUPLICATE); - } - - @Test - public void testGetDictDataCountByDictType() { - // mock 数据 - dictDataMapper.insert(randomDictDataDO(o -> o.setDictType("yunai"))); - dictDataMapper.insert(randomDictDataDO(o -> o.setDictType("tudou"))); - dictDataMapper.insert(randomDictDataDO(o -> o.setDictType("yunai"))); - // 准备参数 - String dictType = "yunai"; - - // 调用 - long count = dictDataService.getDictDataCountByDictType(dictType); - // 校验 - assertEquals(2L, count); - } - - @Test - public void testValidateDictDataList_success() { - // mock 数据 - DictDataDO dictDataDO = randomDictDataDO().setStatus(CommonStatusEnum.ENABLE.getStatus()); - dictDataMapper.insert(dictDataDO); - // 准备参数 - String dictType = dictDataDO.getDictType(); - List values = singletonList(dictDataDO.getValue()); - - // 调用,无需断言 - dictDataService.validateDictDataList(dictType, values); - } - - @Test - public void testValidateDictDataList_notFound() { - // 准备参数 - String dictType = randomString(); - List values = singletonList(randomString()); - - // 调用, 并断言异常 - assertServiceException(() -> dictDataService.validateDictDataList(dictType, values), DICT_DATA_NOT_EXISTS); - } - - @Test - public void testValidateDictDataList_notEnable() { - // mock 数据 - DictDataDO dictDataDO = randomDictDataDO().setStatus(CommonStatusEnum.DISABLE.getStatus()); - dictDataMapper.insert(dictDataDO); - // 准备参数 - String dictType = dictDataDO.getDictType(); - List values = singletonList(dictDataDO.getValue()); - - // 调用, 并断言异常 - assertServiceException(() -> dictDataService.validateDictDataList(dictType, values), - DICT_DATA_NOT_ENABLE, dictDataDO.getLabel()); - } - - @Test - public void testGetDictData_dictType() { - // mock 数据 - DictDataDO dictDataDO = randomDictDataDO().setDictType("yunai").setValue("1"); - dictDataMapper.insert(dictDataDO); - DictDataDO dictDataDO02 = randomDictDataDO().setDictType("yunai").setValue("2"); - dictDataMapper.insert(dictDataDO02); - // 准备参数 - String dictType = "yunai"; - String value = "1"; - - // 调用 - DictDataDO dbDictData = dictDataService.getDictData(dictType, value); - // 断言 - assertEquals(dictDataDO, dbDictData); - } - - @Test - public void testParseDictData() { - // mock 数据 - DictDataDO dictDataDO = randomDictDataDO().setDictType("yunai").setLabel("1"); - dictDataMapper.insert(dictDataDO); - DictDataDO dictDataDO02 = randomDictDataDO().setDictType("yunai").setLabel("2"); - dictDataMapper.insert(dictDataDO02); - // 准备参数 - String dictType = "yunai"; - String label = "1"; - - // 调用 - DictDataDO dbDictData = dictDataService.parseDictData(dictType, label); - // 断言 - assertEquals(dictDataDO, dbDictData); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static DictDataDO randomDictDataDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(randomCommonStatus()); // 保证 status 的范围 - }; - return randomPojo(DictDataDO.class, ArrayUtils.append(consumer, consumers)); - } - - /** - * 生成一个有效的字典类型 - * - * @param type 字典类型 - * @return DictTypeDO 对象 - */ - private static DictTypeDO randomDictTypeDO(String type) { - return randomPojo(DictTypeDO.class, o -> { - o.setType(type); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 保证 status 是开启 - }); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictTypeServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictTypeServiceImplTest.java deleted file mode 100644 index e04b96f4b3..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictTypeServiceImplTest.java +++ /dev/null @@ -1,271 +0,0 @@ -package cn.iocoder.yudao.module.system.service.dict; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO; -import cn.iocoder.yudao.module.system.dal.mysql.dict.DictTypeMapper; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -@Import(DictTypeServiceImpl.class) -public class DictTypeServiceImplTest extends BaseDbUnitTest { - - @Resource - private DictTypeServiceImpl dictTypeService; - - @Resource - private DictTypeMapper dictTypeMapper; - @MockBean - private DictDataService dictDataService; - - @Test - public void testGetDictTypePage() { - // mock 数据 - DictTypeDO dbDictType = randomPojo(DictTypeDO.class, o -> { // 等会查询到 - o.setName("yunai"); - o.setType("芋艿"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2021, 1, 15)); - }); - dictTypeMapper.insert(dbDictType); - // 测试 name 不匹配 - dictTypeMapper.insert(cloneIgnoreId(dbDictType, o -> o.setName("tudou"))); - // 测试 type 不匹配 - dictTypeMapper.insert(cloneIgnoreId(dbDictType, o -> o.setType("土豆"))); - // 测试 status 不匹配 - dictTypeMapper.insert(cloneIgnoreId(dbDictType, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - dictTypeMapper.insert(cloneIgnoreId(dbDictType, o -> o.setCreateTime(buildTime(2021, 1, 1)))); - // 准备参数 - DictTypePageReqVO reqVO = new DictTypePageReqVO(); - reqVO.setName("nai"); - reqVO.setType("艿"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2021, 1, 10, 2021, 1, 20)); - - // 调用 - PageResult pageResult = dictTypeService.getDictTypePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbDictType, pageResult.getList().get(0)); - } - - @Test - public void testGetDictType_id() { - // mock 数据 - DictTypeDO dbDictType = randomDictTypeDO(); - dictTypeMapper.insert(dbDictType); - // 准备参数 - Long id = dbDictType.getId(); - - // 调用 - DictTypeDO dictType = dictTypeService.getDictType(id); - // 断言 - assertNotNull(dictType); - assertPojoEquals(dbDictType, dictType); - } - - @Test - public void testGetDictType_type() { - // mock 数据 - DictTypeDO dbDictType = randomDictTypeDO(); - dictTypeMapper.insert(dbDictType); - // 准备参数 - String type = dbDictType.getType(); - - // 调用 - DictTypeDO dictType = dictTypeService.getDictType(type); - // 断言 - assertNotNull(dictType); - assertPojoEquals(dbDictType, dictType); - } - - @Test - public void testCreateDictType_success() { - // 准备参数 - DictTypeSaveReqVO reqVO = randomPojo(DictTypeSaveReqVO.class, - o -> o.setStatus(randomEle(CommonStatusEnum.values()).getStatus())) - .setId(null); // 避免 id 被赋值 - - // 调用 - Long dictTypeId = dictTypeService.createDictType(reqVO); - // 断言 - assertNotNull(dictTypeId); - // 校验记录的属性是否正确 - DictTypeDO dictType = dictTypeMapper.selectById(dictTypeId); - assertPojoEquals(reqVO, dictType, "id"); - } - - @Test - public void testUpdateDictType_success() { - // mock 数据 - DictTypeDO dbDictType = randomDictTypeDO(); - dictTypeMapper.insert(dbDictType);// @Sql: 先插入出一条存在的数据 - // 准备参数 - DictTypeSaveReqVO reqVO = randomPojo(DictTypeSaveReqVO.class, o -> { - o.setId(dbDictType.getId()); // 设置更新的 ID - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); - }); - - // 调用 - dictTypeService.updateDictType(reqVO); - // 校验是否更新正确 - DictTypeDO dictType = dictTypeMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, dictType); - } - - @Test - public void testDeleteDictType_success() { - // mock 数据 - DictTypeDO dbDictType = randomDictTypeDO(); - dictTypeMapper.insert(dbDictType);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDictType.getId(); - - // 调用 - dictTypeService.deleteDictType(id); - // 校验数据不存在了 - assertNull(dictTypeMapper.selectById(id)); - } - - @Test - public void testDeleteDictType_hasChildren() { - // mock 数据 - DictTypeDO dbDictType = randomDictTypeDO(); - dictTypeMapper.insert(dbDictType);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDictType.getId(); - // mock 方法 - when(dictDataService.getDictDataCountByDictType(eq(dbDictType.getType()))).thenReturn(1L); - - // 调用, 并断言异常 - assertServiceException(() -> dictTypeService.deleteDictType(id), DICT_TYPE_HAS_CHILDREN); - } - - @Test - public void testGetDictTypeList() { - // 准备参数 - DictTypeDO dictTypeDO01 = randomDictTypeDO(); - dictTypeMapper.insert(dictTypeDO01); - DictTypeDO dictTypeDO02 = randomDictTypeDO(); - dictTypeMapper.insert(dictTypeDO02); - // mock 方法 - - // 调用 - List dictTypeDOList = dictTypeService.getDictTypeList(); - // 断言 - assertEquals(2, dictTypeDOList.size()); - assertPojoEquals(dictTypeDO01, dictTypeDOList.get(0)); - assertPojoEquals(dictTypeDO02, dictTypeDOList.get(1)); - } - - @Test - public void testValidateDictDataExists_success() { - // mock 数据 - DictTypeDO dbDictType = randomDictTypeDO(); - dictTypeMapper.insert(dbDictType);// @Sql: 先插入出一条存在的数据 - - // 调用成功 - dictTypeService.validateDictTypeExists(dbDictType.getId()); - } - - @Test - public void testValidateDictDataExists_notExists() { - assertServiceException(() -> dictTypeService.validateDictTypeExists(randomLongId()), DICT_TYPE_NOT_EXISTS); - } - - @Test - public void testValidateDictTypeUnique_success() { - // 调用,成功 - dictTypeService.validateDictTypeUnique(randomLongId(), randomString()); - } - - @Test - public void testValidateDictTypeUnique_valueDuplicateForCreate() { - // 准备参数 - String type = randomString(); - // mock 数据 - dictTypeMapper.insert(randomDictTypeDO(o -> o.setType(type))); - - // 调用,校验异常 - assertServiceException(() -> dictTypeService.validateDictTypeUnique(null, type), - DICT_TYPE_TYPE_DUPLICATE); - } - - @Test - public void testValidateDictTypeUnique_valueDuplicateForUpdate() { - // 准备参数 - Long id = randomLongId(); - String type = randomString(); - // mock 数据 - dictTypeMapper.insert(randomDictTypeDO(o -> o.setType(type))); - - // 调用,校验异常 - assertServiceException(() -> dictTypeService.validateDictTypeUnique(id, type), - DICT_TYPE_TYPE_DUPLICATE); - } - - @Test - public void testValidateDictTypNameUnique_success() { - // 调用,成功 - dictTypeService.validateDictTypeNameUnique(randomLongId(), randomString()); - } - - @Test - public void testValidateDictTypeNameUnique_nameDuplicateForCreate() { - // 准备参数 - String name = randomString(); - // mock 数据 - dictTypeMapper.insert(randomDictTypeDO(o -> o.setName(name))); - - // 调用,校验异常 - assertServiceException(() -> dictTypeService.validateDictTypeNameUnique(null, name), - DICT_TYPE_NAME_DUPLICATE); - } - - @Test - public void testValidateDictTypeNameUnique_nameDuplicateForUpdate() { - // 准备参数 - Long id = randomLongId(); - String name = randomString(); - // mock 数据 - dictTypeMapper.insert(randomDictTypeDO(o -> o.setName(name))); - - // 调用,校验异常 - assertServiceException(() -> dictTypeService.validateDictTypeNameUnique(id, name), - DICT_TYPE_NAME_DUPLICATE); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static DictTypeDO randomDictTypeDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - }; - return randomPojo(DictTypeDO.class, ArrayUtils.append(consumer, consumers)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeServiceTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeServiceTest.java deleted file mode 100644 index b337e037af..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/errorcode/ErrorCodeServiceTest.java +++ /dev/null @@ -1,308 +0,0 @@ -package cn.iocoder.yudao.module.system.service.errorcode; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeAutoGenerateReqDTO; -import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeRespDTO; -import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.errorcode.ErrorCodeDO; -import cn.iocoder.yudao.module.system.dal.mysql.errorcode.ErrorCodeMapper; -import cn.iocoder.yudao.module.system.enums.errorcode.ErrorCodeTypeEnum; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.ERROR_CODE_DUPLICATE; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.ERROR_CODE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -@Import(ErrorCodeServiceImpl.class) -public class ErrorCodeServiceTest extends BaseDbUnitTest { - - @Resource - private ErrorCodeServiceImpl errorCodeService; - - @Resource - private ErrorCodeMapper errorCodeMapper; - - @Test - public void testCreateErrorCode_success() { - // 准备参数 - ErrorCodeSaveReqVO reqVO = randomPojo(ErrorCodeSaveReqVO.class) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long errorCodeId = errorCodeService.createErrorCode(reqVO); - // 断言 - assertNotNull(errorCodeId); - // 校验记录的属性是否正确 - ErrorCodeDO errorCode = errorCodeMapper.selectById(errorCodeId); - assertPojoEquals(reqVO, errorCode, "id"); - assertEquals(ErrorCodeTypeEnum.MANUAL_OPERATION.getType(), errorCode.getType()); - } - - @Test - public void testUpdateErrorCode_success() { - // mock 数据 - ErrorCodeDO dbErrorCode = randomErrorCodeDO(); - errorCodeMapper.insert(dbErrorCode);// @Sql: 先插入出一条存在的数据 - // 准备参数 - ErrorCodeSaveReqVO reqVO = randomPojo(ErrorCodeSaveReqVO.class, o -> { - o.setId(dbErrorCode.getId()); // 设置更新的 ID - }); - - // 调用 - errorCodeService.updateErrorCode(reqVO); - // 校验是否更新正确 - ErrorCodeDO errorCode = errorCodeMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, errorCode); - assertEquals(ErrorCodeTypeEnum.MANUAL_OPERATION.getType(), errorCode.getType()); - } - - @Test - public void testDeleteErrorCode_success() { - // mock 数据 - ErrorCodeDO dbErrorCode = randomErrorCodeDO(); - errorCodeMapper.insert(dbErrorCode);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbErrorCode.getId(); - - // 调用 - errorCodeService.deleteErrorCode(id); - // 校验数据不存在了 - assertNull(errorCodeMapper.selectById(id)); - } - - @Test - public void testGetErrorCodePage() { - // mock 数据 - ErrorCodeDO dbErrorCode = initGetErrorCodePage(); - // 准备参数 - ErrorCodePageReqVO reqVO = new ErrorCodePageReqVO(); - reqVO.setType(ErrorCodeTypeEnum.AUTO_GENERATION.getType()); - reqVO.setApplicationName("tu"); - reqVO.setCode(1); - reqVO.setMessage("ma"); - reqVO.setCreateTime(buildBetweenTime(2020, 11, 1, 2020, 11, 30)); - - // 调用 - PageResult pageResult = errorCodeService.getErrorCodePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbErrorCode, pageResult.getList().get(0)); - } - - /** - * 初始化 getErrorCodePage 方法的测试数据 - */ - private ErrorCodeDO initGetErrorCodePage() { - ErrorCodeDO dbErrorCode = randomErrorCodeDO(o -> { // 等会查询到 - o.setType(ErrorCodeTypeEnum.AUTO_GENERATION.getType()); - o.setApplicationName("tudou"); - o.setCode(1); - o.setMessage("yuanma"); - o.setCreateTime(buildTime(2020, 11, 11)); - }); - errorCodeMapper.insert(dbErrorCode); - // 测试 type 不匹配 - errorCodeMapper.insert(cloneIgnoreId(dbErrorCode, o -> o.setType(ErrorCodeTypeEnum.MANUAL_OPERATION.getType()))); - // 测试 applicationName 不匹配 - errorCodeMapper.insert(cloneIgnoreId(dbErrorCode, o -> o.setApplicationName("yuan"))); - // 测试 code 不匹配 - errorCodeMapper.insert(cloneIgnoreId(dbErrorCode, o -> o.setCode(2))); - // 测试 message 不匹配 - errorCodeMapper.insert(cloneIgnoreId(dbErrorCode, o -> o.setMessage("nai"))); - // 测试 createTime 不匹配 - errorCodeMapper.insert(cloneIgnoreId(dbErrorCode, o -> o.setCreateTime(buildTime(2020, 12, 12)))); - return dbErrorCode; - } - - @Test - public void testValidateCodeDuplicate_codeDuplicateForCreate() { - // 准备参数 - Integer code = randomInteger(); - // mock 数据 - errorCodeMapper.insert(randomErrorCodeDO(o -> o.setCode(code))); - - // 调用,校验异常 - assertServiceException(() -> errorCodeService.validateCodeDuplicate(code, null), - ERROR_CODE_DUPLICATE); - } - - @Test - public void testValidateCodeDuplicate_codeDuplicateForUpdate() { - // 准备参数 - Long id = randomLongId(); - Integer code = randomInteger(); - // mock 数据 - errorCodeMapper.insert(randomErrorCodeDO(o -> o.setCode(code))); - - // 调用,校验异常 - assertServiceException(() -> errorCodeService.validateCodeDuplicate(code, id), - ERROR_CODE_DUPLICATE); - } - - @Test - public void testValidateErrorCodeExists_notExists() { - assertServiceException(() -> errorCodeService.validateErrorCodeExists(null), - ERROR_CODE_NOT_EXISTS); - } - - /** - * 情况 1,错误码不存在的情况 - */ - @Test - public void testAutoGenerateErrorCodes_01() { - // 准备参数 - ErrorCodeAutoGenerateReqDTO generateReqDTO = randomPojo(ErrorCodeAutoGenerateReqDTO.class); - // mock 方法 - - // 调用 - errorCodeService.autoGenerateErrorCodes(Lists.newArrayList(generateReqDTO)); - // 断言 - ErrorCodeDO errorCode = errorCodeMapper.selectOne(null); - assertPojoEquals(generateReqDTO, errorCode); - assertEquals(ErrorCodeTypeEnum.AUTO_GENERATION.getType(), errorCode.getType()); - } - - /** - * 情况 2.1,错误码存在,但是是 ErrorCodeTypeEnum.MANUAL_OPERATION 类型 - */ - @Test - public void testAutoGenerateErrorCodes_021() { - // mock 数据 - ErrorCodeDO dbErrorCode = randomErrorCodeDO(o -> o.setType(ErrorCodeTypeEnum.MANUAL_OPERATION.getType())); - errorCodeMapper.insert(dbErrorCode); - // 准备参数 - ErrorCodeAutoGenerateReqDTO generateReqDTO = randomPojo(ErrorCodeAutoGenerateReqDTO.class, - o -> o.setCode(dbErrorCode.getCode())); - // mock 方法 - - // 调用 - errorCodeService.autoGenerateErrorCodes(Lists.newArrayList(generateReqDTO)); - // 断言,相等,说明不会更新 - ErrorCodeDO errorCode = errorCodeMapper.selectById(dbErrorCode.getId()); - assertPojoEquals(dbErrorCode, errorCode); - } - - /** - * 情况 2.2,错误码存在,但是是 applicationName 不匹配 - */ - @Test - public void testAutoGenerateErrorCodes_022() { - // mock 数据 - ErrorCodeDO dbErrorCode = randomErrorCodeDO(o -> o.setType(ErrorCodeTypeEnum.AUTO_GENERATION.getType())); - errorCodeMapper.insert(dbErrorCode); - // 准备参数 - ErrorCodeAutoGenerateReqDTO generateReqDTO = randomPojo(ErrorCodeAutoGenerateReqDTO.class, - o -> o.setCode(dbErrorCode.getCode()).setApplicationName(randomString())); - // mock 方法 - - // 调用 - errorCodeService.autoGenerateErrorCodes(Lists.newArrayList(generateReqDTO)); - // 断言,相等,说明不会更新 - ErrorCodeDO errorCode = errorCodeMapper.selectById(dbErrorCode.getId()); - assertPojoEquals(dbErrorCode, errorCode); - } - - /** - * 情况 2.3,错误码存在,但是是 message 相同 - */ - @Test - public void testAutoGenerateErrorCodes_023() { - // mock 数据 - ErrorCodeDO dbErrorCode = randomErrorCodeDO(o -> o.setType(ErrorCodeTypeEnum.AUTO_GENERATION.getType())); - errorCodeMapper.insert(dbErrorCode); - // 准备参数 - ErrorCodeAutoGenerateReqDTO generateReqDTO = randomPojo(ErrorCodeAutoGenerateReqDTO.class, - o -> o.setCode(dbErrorCode.getCode()).setApplicationName(dbErrorCode.getApplicationName()) - .setMessage(dbErrorCode.getMessage())); - // mock 方法 - - // 调用 - errorCodeService.autoGenerateErrorCodes(Lists.newArrayList(generateReqDTO)); - // 断言,相等,说明不会更新 - ErrorCodeDO errorCode = errorCodeMapper.selectById(dbErrorCode.getId()); - assertPojoEquals(dbErrorCode, errorCode); - } - - /** - * 情况 2.3,错误码存在,但是是 message 不同,则进行更新 - */ - @Test - public void testAutoGenerateErrorCodes_024() { - // mock 数据 - ErrorCodeDO dbErrorCode = randomErrorCodeDO(o -> o.setType(ErrorCodeTypeEnum.AUTO_GENERATION.getType())); - errorCodeMapper.insert(dbErrorCode); - // 准备参数 - ErrorCodeAutoGenerateReqDTO generateReqDTO = randomPojo(ErrorCodeAutoGenerateReqDTO.class, - o -> o.setCode(dbErrorCode.getCode()).setApplicationName(dbErrorCode.getApplicationName())); - // mock 方法 - - // 调用 - errorCodeService.autoGenerateErrorCodes(Lists.newArrayList(generateReqDTO)); - // 断言,匹配 - ErrorCodeDO errorCode = errorCodeMapper.selectById(dbErrorCode.getId()); - assertPojoEquals(generateReqDTO, errorCode); - } - - @Test - public void testGetErrorCode() { - // 准备参数 - ErrorCodeDO errorCodeDO = randomErrorCodeDO(); - errorCodeMapper.insert(errorCodeDO); - // mock 方法 - Long id = errorCodeDO.getId(); - - // 调用 - ErrorCodeDO dbErrorCode = errorCodeService.getErrorCode(id); - // 断言 - assertPojoEquals(errorCodeDO, dbErrorCode); - } - - @Test - public void testGetErrorCodeList() { - // 准备参数 - ErrorCodeDO errorCodeDO01 = randomErrorCodeDO( - o -> o.setApplicationName("yunai_server").setUpdateTime(buildTime(2022, 1, 10))); - errorCodeMapper.insert(errorCodeDO01); - ErrorCodeDO errorCodeDO02 = randomErrorCodeDO( - o -> o.setApplicationName("yunai_server").setUpdateTime(buildTime(2022, 1, 12))); - errorCodeMapper.insert(errorCodeDO02); - // mock 方法 - String applicationName = "yunai_server"; - LocalDateTime minUpdateTime = buildTime(2022, 1, 11); - - // 调用 - List errorCodeList = errorCodeService.getErrorCodeList(applicationName, minUpdateTime); - // 断言 - assertEquals(1, errorCodeList.size()); - assertPojoEquals(errorCodeDO02, errorCodeList.get(0)); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static ErrorCodeDO randomErrorCodeDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setType(randomEle(ErrorCodeTypeEnum.values()).getType()); // 保证 key 的范围 - }; - return randomPojo(ErrorCodeDO.class, ArrayUtils.append(consumer, consumers)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImplTest.java deleted file mode 100644 index f5135da4a3..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImplTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.system.service.logger; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.api.logger.dto.LoginLogCreateReqDTO; -import cn.iocoder.yudao.module.system.controller.admin.logger.vo.loginlog.LoginLogPageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.logger.LoginLogDO; -import cn.iocoder.yudao.module.system.dal.mysql.logger.LoginLogMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.CAPTCHA_CODE_ERROR; -import static cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.SUCCESS; -import static org.junit.jupiter.api.Assertions.assertEquals; - -@Import(LoginLogServiceImpl.class) -public class LoginLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private LoginLogServiceImpl loginLogService; - - @Resource - private LoginLogMapper loginLogMapper; - - @Test - public void testGetLoginLogPage() { - // mock 数据 - LoginLogDO loginLogDO = randomPojo(LoginLogDO.class, o -> { - o.setUserIp("192.168.199.16"); - o.setUsername("wang"); - o.setResult(SUCCESS.getResult()); - o.setCreateTime(buildTime(2021, 3, 6)); - }); - loginLogMapper.insert(loginLogDO); - // 测试 status 不匹配 - loginLogMapper.insert(cloneIgnoreId(loginLogDO, o -> o.setResult(CAPTCHA_CODE_ERROR.getResult()))); - // 测试 ip 不匹配 - loginLogMapper.insert(cloneIgnoreId(loginLogDO, o -> o.setUserIp("192.168.128.18"))); - // 测试 username 不匹配 - loginLogMapper.insert(cloneIgnoreId(loginLogDO, o -> o.setUsername("yunai"))); - // 测试 createTime 不匹配 - loginLogMapper.insert(cloneIgnoreId(loginLogDO, o -> o.setCreateTime(buildTime(2021, 2, 6)))); - // 构造调用参数 - LoginLogPageReqVO reqVO = new LoginLogPageReqVO(); - reqVO.setUsername("wang"); - reqVO.setUserIp("192.168.199"); - reqVO.setStatus(true); - reqVO.setCreateTime(buildBetweenTime(2021, 3, 5, 2021, 3, 7)); - - // 调用 - PageResult pageResult = loginLogService.getLoginLogPage(reqVO); - // 断言,只查到了一条符合条件的 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(loginLogDO, pageResult.getList().get(0)); - } - - @Test - public void testCreateLoginLog() { - LoginLogCreateReqDTO reqDTO = randomPojo(LoginLogCreateReqDTO.class); - - // 调用 - loginLogService.createLoginLog(reqDTO); - // 断言 - LoginLogDO loginLogDO = loginLogMapper.selectOne(null); - assertPojoEquals(reqDTO, loginLogDO); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java deleted file mode 100644 index a01c6644f3..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.system.service.logger; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.framework.test.core.util.RandomUtils; -import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO; -import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogPageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.dal.mysql.logger.OperateLogMapper; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Collections; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.when; - -@Import({OperateLogServiceImpl.class}) -public class OperateLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private OperateLogService operateLogServiceImpl; - - @Resource - private OperateLogMapper operateLogMapper; - - @MockBean - private AdminUserService userService; - - @Test - public void testCreateOperateLog() { - OperateLogCreateReqDTO reqVO = RandomUtils.randomPojo(OperateLogCreateReqDTO.class, - o -> o.setExts(MapUtil.builder("orderId", randomLongId()).build())); - - // 调研 - operateLogServiceImpl.createOperateLog(reqVO); - // 断言 - OperateLogDO operateLogDO = operateLogMapper.selectOne(null); - assertPojoEquals(reqVO, operateLogDO); - } - - @Test - public void testGetOperateLogPage() { - // mock(用户信息) - AdminUserDO user = RandomUtils.randomPojo(AdminUserDO.class, o -> { - o.setNickname("wang"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - when(userService.getUserListByNickname("wang")).thenReturn(Collections.singletonList(user)); - Long userId = user.getId(); - - // 构造操作日志 - OperateLogDO operateLogDO = RandomUtils.randomPojo(OperateLogDO.class, o -> { - o.setUserId(userId); - o.setUserType(randomEle(UserTypeEnum.values()).getValue()); - o.setModule("order"); - o.setType(OperateTypeEnum.CREATE.getType()); - o.setStartTime(buildTime(2021, 3, 6)); - o.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode()); - o.setExts(MapUtil.builder("orderId", randomLongId()).build()); - }); - operateLogMapper.insert(operateLogDO); - // 测试 userId 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setUserId(userId + 1))); - // 测试 module 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setModule("user"))); - // 测试 type 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setType(OperateTypeEnum.IMPORT.getType()))); - // 测试 createTime 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setStartTime(buildTime(2021, 2, 6)))); - // 测试 resultCode 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setResultCode(BAD_REQUEST.getCode()))); - - // 构造调用参数 - OperateLogPageReqVO reqVO = new OperateLogPageReqVO(); - reqVO.setUserNickname("wang"); - reqVO.setModule("order"); - reqVO.setType(OperateTypeEnum.CREATE.getType()); - reqVO.setStartTime(buildBetweenTime(2021, 3, 5, 2021, 3, 7)); - reqVO.setSuccess(true); - - // 调用 - PageResult pageResult = operateLogServiceImpl.getOperateLogPage(reqVO); - // 断言,只查到了一条符合条件的 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(operateLogDO, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailAccountServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailAccountServiceImplTest.java deleted file mode 100755 index a3f237e86e..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailAccountServiceImplTest.java +++ /dev/null @@ -1,179 +0,0 @@ -package cn.iocoder.yudao.module.system.service.mail; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; -import cn.iocoder.yudao.module.system.dal.mysql.mail.MailAccountMapper; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.MAIL_ACCOUNT_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link MailAccountServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(MailAccountServiceImpl.class) -public class MailAccountServiceImplTest extends BaseDbUnitTest { - - @Resource - private MailAccountServiceImpl mailAccountService; - - @Resource - private MailAccountMapper mailAccountMapper; - - @MockBean - private MailTemplateService mailTemplateService; - - @Test - public void testCreateMailAccount_success() { - // 准备参数 - MailAccountSaveReqVO reqVO = randomPojo(MailAccountSaveReqVO.class, o -> o.setMail(randomEmail())) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long mailAccountId = mailAccountService.createMailAccount(reqVO); - // 断言 - assertNotNull(mailAccountId); - // 校验记录的属性是否正确 - MailAccountDO mailAccount = mailAccountMapper.selectById(mailAccountId); - assertPojoEquals(reqVO, mailAccount, "id"); - } - - @Test - public void testUpdateMailAccount_success() { - // mock 数据 - MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class); - mailAccountMapper.insert(dbMailAccount);// @Sql: 先插入出一条存在的数据 - // 准备参数 - MailAccountSaveReqVO reqVO = randomPojo(MailAccountSaveReqVO.class, o -> { - o.setId(dbMailAccount.getId()); // 设置更新的 ID - o.setMail(randomEmail()); - }); - - // 调用 - mailAccountService.updateMailAccount(reqVO); - // 校验是否更新正确 - MailAccountDO mailAccount = mailAccountMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, mailAccount); - } - - @Test - public void testUpdateMailAccount_notExists() { - // 准备参数 - MailAccountSaveReqVO reqVO = randomPojo(MailAccountSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> mailAccountService.updateMailAccount(reqVO), MAIL_ACCOUNT_NOT_EXISTS); - } - - @Test - public void testDeleteMailAccount_success() { - // mock 数据 - MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class); - mailAccountMapper.insert(dbMailAccount);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbMailAccount.getId(); - // mock 方法(无关联模版) - when(mailTemplateService.getMailTemplateCountByAccountId(eq(id))).thenReturn(0L); - - // 调用 - mailAccountService.deleteMailAccount(id); - // 校验数据不存在了 - assertNull(mailAccountMapper.selectById(id)); - } - - @Test - public void testGetMailAccountFromCache() { - // mock 数据 - MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class); - mailAccountMapper.insert(dbMailAccount);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbMailAccount.getId(); - - // 调用 - MailAccountDO mailAccount = mailAccountService.getMailAccountFromCache(id); - // 断言 - assertPojoEquals(dbMailAccount, mailAccount); - } - - @Test - public void testDeleteMailAccount_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> mailAccountService.deleteMailAccount(id), MAIL_ACCOUNT_NOT_EXISTS); - } - - @Test - public void testGetMailAccountPage() { - // mock 数据 - MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class, o -> { // 等会查询到 - o.setMail("768@qq.com"); - o.setUsername("yunai"); - }); - mailAccountMapper.insert(dbMailAccount); - // 测试 mail 不匹配 - mailAccountMapper.insert(cloneIgnoreId(dbMailAccount, o -> o.setMail("788@qq.com"))); - // 测试 username 不匹配 - mailAccountMapper.insert(cloneIgnoreId(dbMailAccount, o -> o.setUsername("tudou"))); - // 准备参数 - MailAccountPageReqVO reqVO = new MailAccountPageReqVO(); - reqVO.setMail("768"); - reqVO.setUsername("yu"); - - // 调用 - PageResult pageResult = mailAccountService.getMailAccountPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbMailAccount, pageResult.getList().get(0)); - } - - @Test - public void testGetMailAccount() { - // mock 数据 - MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class); - mailAccountMapper.insert(dbMailAccount);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbMailAccount.getId(); - - // 调用 - MailAccountDO mailAccount = mailAccountService.getMailAccount(id); - // 断言 - assertPojoEquals(dbMailAccount, mailAccount); - } - - @Test - public void testGetMailAccountList() { - // mock 数据 - MailAccountDO dbMailAccount01 = randomPojo(MailAccountDO.class); - mailAccountMapper.insert(dbMailAccount01); - MailAccountDO dbMailAccount02 = randomPojo(MailAccountDO.class); - mailAccountMapper.insert(dbMailAccount02); - // 准备参数 - - // 调用 - List list = mailAccountService.getMailAccountList(); - // 断言 - assertEquals(2, list.size()); - assertPojoEquals(dbMailAccount01, list.get(0)); - assertPojoEquals(dbMailAccount02, list.get(1)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailLogServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailLogServiceImplTest.java deleted file mode 100755 index 482aa5aeee..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailLogServiceImplTest.java +++ /dev/null @@ -1,183 +0,0 @@ -package cn.iocoder.yudao.module.system.service.mail; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogPageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; -import cn.iocoder.yudao.module.system.dal.mysql.mail.MailLogMapper; -import cn.iocoder.yudao.module.system.enums.mail.MailSendStatusEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Map; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link MailLogServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(MailLogServiceImpl.class) -public class MailLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private MailLogServiceImpl mailLogService; - - @Resource - private MailLogMapper mailLogMapper; - - @Test - public void testCreateMailLog() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String toMail = randomEmail(); - MailAccountDO account = randomPojo(MailAccountDO.class); - MailTemplateDO template = randomPojo(MailTemplateDO.class); - String templateContent = randomString(); - Map templateParams = randomTemplateParams(); - Boolean isSend = true; - // mock 方法 - - // 调用 - Long logId = mailLogService.createMailLog(userId, userType, toMail, account, template, templateContent, templateParams, isSend); - // 断言 - MailLogDO log = mailLogMapper.selectById(logId); - assertNotNull(log); - assertEquals(MailSendStatusEnum.INIT.getStatus(), log.getSendStatus()); - assertEquals(userId, log.getUserId()); - assertEquals(userType, log.getUserType()); - assertEquals(toMail, log.getToMail()); - assertEquals(account.getId(), log.getAccountId()); - assertEquals(account.getMail(), log.getFromMail()); - assertEquals(template.getId(), log.getTemplateId()); - assertEquals(template.getCode(), log.getTemplateCode()); - assertEquals(template.getNickname(), log.getTemplateNickname()); - assertEquals(template.getTitle(), log.getTemplateTitle()); - assertEquals(templateContent, log.getTemplateContent()); - assertEquals(templateParams, log.getTemplateParams()); - } - - @Test - public void testUpdateMailSendResult_success() { - // mock 数据 - MailLogDO log = randomPojo(MailLogDO.class, o -> { - o.setSendStatus(MailSendStatusEnum.INIT.getStatus()); - o.setSendTime(null).setSendMessageId(null).setSendException(null) - .setTemplateParams(randomTemplateParams()); - }); - mailLogMapper.insert(log); - // 准备参数 - Long logId = log.getId(); - String messageId = randomString(); - - // 调用 - mailLogService.updateMailSendResult(logId, messageId, null); - // 断言 - MailLogDO dbLog = mailLogMapper.selectById(logId); - assertEquals(MailSendStatusEnum.SUCCESS.getStatus(), dbLog.getSendStatus()); - assertNotNull(dbLog.getSendTime()); - assertEquals(messageId, dbLog.getSendMessageId()); - assertNull(dbLog.getSendException()); - } - - @Test - public void testUpdateMailSendResult_exception() { - // mock 数据 - MailLogDO log = randomPojo(MailLogDO.class, o -> { - o.setSendStatus(MailSendStatusEnum.INIT.getStatus()); - o.setSendTime(null).setSendMessageId(null).setSendException(null) - .setTemplateParams(randomTemplateParams()); - }); - mailLogMapper.insert(log); - // 准备参数 - Long logId = log.getId(); - Exception exception = new NullPointerException("测试异常"); - - // 调用 - mailLogService.updateMailSendResult(logId, null, exception); - // 断言 - MailLogDO dbLog = mailLogMapper.selectById(logId); - assertEquals(MailSendStatusEnum.FAILURE.getStatus(), dbLog.getSendStatus()); - assertNotNull(dbLog.getSendTime()); - assertNull(dbLog.getSendMessageId()); - assertEquals("NullPointerException: 测试异常", dbLog.getSendException()); - } - - @Test - public void testGetMailLog() { - // mock 数据 - MailLogDO dbMailLog = randomPojo(MailLogDO.class, o -> o.setTemplateParams(randomTemplateParams())); - mailLogMapper.insert(dbMailLog); - // 准备参数 - Long id = dbMailLog.getId(); - - // 调用 - MailLogDO mailLog = mailLogService.getMailLog(id); - // 断言 - assertPojoEquals(dbMailLog, mailLog); - } - - @Test - public void testGetMailLogPage() { - // mock 数据 - MailLogDO dbMailLog = randomPojo(MailLogDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setToMail("768@qq.com"); - o.setAccountId(10L); - o.setTemplateId(100L); - o.setSendStatus(MailSendStatusEnum.INIT.getStatus()); - o.setSendTime(buildTime(2023, 2, 10)); - o.setTemplateParams(randomTemplateParams()); - }); - mailLogMapper.insert(dbMailLog); - // 测试 userId 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 toMail 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setToMail("788@.qq.com"))); - // 测试 accountId 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setAccountId(11L))); - // 测试 templateId 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setTemplateId(101L))); - // 测试 sendStatus 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setSendStatus(MailSendStatusEnum.SUCCESS.getStatus()))); - // 测试 sendTime 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setSendTime(buildTime(2023, 3, 10)))); - // 准备参数 - MailLogPageReqVO reqVO = new MailLogPageReqVO(); - reqVO.setUserId(1L); - reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); - reqVO.setToMail("768"); - reqVO.setAccountId(10L); - reqVO.setTemplateId(100L); - reqVO.setSendStatus(MailSendStatusEnum.INIT.getStatus()); - reqVO.setSendTime((buildBetweenTime(2023, 2, 1, 2023, 2, 15))); - - // 调用 - PageResult pageResult = mailLogService.getMailLogPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbMailLog, pageResult.getList().get(0)); - } - - private static Map randomTemplateParams() { - return MapUtil.builder().put(randomString(), randomString()) - .put(randomString(), randomString()).build(); - } -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImplTest.java deleted file mode 100644 index eaea39fe96..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImplTest.java +++ /dev/null @@ -1,330 +0,0 @@ -package cn.iocoder.yudao.module.system.service.mail; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.framework.test.core.util.RandomUtils; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.mq.message.mail.MailSendMessage; -import cn.iocoder.yudao.module.system.mq.producer.mail.MailProducer; -import cn.iocoder.yudao.module.system.service.member.MemberService; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import org.assertj.core.util.Lists; -import org.dromara.hutool.extra.mail.MailAccount; -import org.dromara.hutool.extra.mail.MailUtil; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockedStatic; - -import java.util.HashMap; -import java.util.Map; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -public class MailSendServiceImplTest extends BaseMockitoUnitTest { - - @InjectMocks - private MailSendServiceImpl mailSendService; - - @Mock - private AdminUserService adminUserService; - @Mock - private MemberService memberService; - @Mock - private MailAccountService mailAccountService; - @Mock - private MailTemplateService mailTemplateService; - @Mock - private MailLogService mailLogService; - @Mock - private MailProducer mailProducer; - - /** - * 用于快速测试你的邮箱账号是否正常 - */ - @Test - @Disabled - public void testDemo() { - MailAccount mailAccount = new MailAccount() -// .setFrom("奥特曼 ") - .setFrom("ydym_test@163.com") // 邮箱地址 - .setHost("smtp.163.com").setPort(465).setSslEnable(true) // SMTP 服务器 - .setAuth(true).setUser("ydym_test@163.com").setPass("WBZTEINMIFVRYSOE".toCharArray()); // 登录账号密码 - String messageId = MailUtil.send(mailAccount, "7685413@qq.com", "主题", "内容", false); - System.out.println("发送结果:" + messageId); - } - - @Test - public void testSendSingleMailToAdmin() { - // 准备参数 - Long userId = randomLongId(); - String templateCode = RandomUtils.randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock adminUserService 的方法 - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setMobile("15601691300")); - when(adminUserService.getUser(eq(userId))).thenReturn(user); - - // mock MailTemplateService 的方法 - MailTemplateDO template = randomPojo(MailTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String title = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams))) - .thenReturn(title); - String content = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock MailAccountService 的方法 - MailAccountDO account = randomPojo(MailAccountDO.class); - when(mailAccountService.getMailAccountFromCache(eq(template.getAccountId()))).thenReturn(account); - // mock MailLogService 的方法 - Long mailLogId = randomLongId(); - when(mailLogService.createMailLog(eq(userId), eq(UserTypeEnum.ADMIN.getValue()), eq(user.getEmail()), - eq(account), eq(template), eq(content), eq(templateParams), eq(true))).thenReturn(mailLogId); - - // 调用 - Long resultMailLogId = mailSendService.sendSingleMailToAdmin(null, userId, templateCode, templateParams); - // 断言 - assertEquals(mailLogId, resultMailLogId); - // 断言调用 - verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(user.getEmail()), - eq(account.getId()), eq(template.getNickname()), eq(title), eq(content)); - } - - @Test - public void testSendSingleMailToMember() { - // 准备参数 - Long userId = randomLongId(); - String templateCode = RandomUtils.randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock memberService 的方法 - String mail = randomEmail(); - when(memberService.getMemberUserEmail(eq(userId))).thenReturn(mail); - - // mock MailTemplateService 的方法 - MailTemplateDO template = randomPojo(MailTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String title = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams))) - .thenReturn(title); - String content = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock MailAccountService 的方法 - MailAccountDO account = randomPojo(MailAccountDO.class); - when(mailAccountService.getMailAccountFromCache(eq(template.getAccountId()))).thenReturn(account); - // mock MailLogService 的方法 - Long mailLogId = randomLongId(); - when(mailLogService.createMailLog(eq(userId), eq(UserTypeEnum.MEMBER.getValue()), eq(mail), - eq(account), eq(template), eq(content), eq(templateParams), eq(true))).thenReturn(mailLogId); - - // 调用 - Long resultMailLogId = mailSendService.sendSingleMailToMember(null, userId, templateCode, templateParams); - // 断言 - assertEquals(mailLogId, resultMailLogId); - // 断言调用 - verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(mail), - eq(account.getId()), eq(template.getNickname()), eq(title), eq(content)); - } - - /** - * 发送成功,当短信模板开启时 - */ - @Test - public void testSendSingleMail_successWhenMailTemplateEnable() { - // 准备参数 - String mail = randomEmail(); - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String templateCode = RandomUtils.randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock MailTemplateService 的方法 - MailTemplateDO template = randomPojo(MailTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String title = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams))) - .thenReturn(title); - String content = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock MailAccountService 的方法 - MailAccountDO account = randomPojo(MailAccountDO.class); - when(mailAccountService.getMailAccountFromCache(eq(template.getAccountId()))).thenReturn(account); - // mock MailLogService 的方法 - Long mailLogId = randomLongId(); - when(mailLogService.createMailLog(eq(userId), eq(userType), eq(mail), - eq(account), eq(template), eq(content), eq(templateParams), eq(true))).thenReturn(mailLogId); - - // 调用 - Long resultMailLogId = mailSendService.sendSingleMail(mail, userId, userType, templateCode, templateParams); - // 断言 - assertEquals(mailLogId, resultMailLogId); - // 断言调用 - verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(mail), - eq(account.getId()), eq(template.getNickname()), eq(title), eq(content)); - } - - /** - * 发送成功,当短信模板关闭时 - */ - @Test - public void testSendSingleMail_successWhenSmsTemplateDisable() { - // 准备参数 - String mail = randomEmail(); - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String templateCode = RandomUtils.randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock MailTemplateService 的方法 - MailTemplateDO template = randomPojo(MailTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String title = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams))) - .thenReturn(title); - String content = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock MailAccountService 的方法 - MailAccountDO account = randomPojo(MailAccountDO.class); - when(mailAccountService.getMailAccountFromCache(eq(template.getAccountId()))).thenReturn(account); - // mock MailLogService 的方法 - Long mailLogId = randomLongId(); - when(mailLogService.createMailLog(eq(userId), eq(userType), eq(mail), - eq(account), eq(template), eq(content), eq(templateParams), eq(false))).thenReturn(mailLogId); - - // 调用 - Long resultMailLogId = mailSendService.sendSingleMail(mail, userId, userType, templateCode, templateParams); - // 断言 - assertEquals(mailLogId, resultMailLogId); - // 断言调用 - verify(mailProducer, times(0)).sendMailSendMessage(anyLong(), anyString(), - anyLong(), anyString(), anyString(), anyString()); - } - - @Test - public void testValidateMailTemplateValid_notExists() { - // 准备参数 - String templateCode = RandomUtils.randomString(); - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> mailSendService.validateMailTemplate(templateCode), - MAIL_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testValidateTemplateParams_paramMiss() { - // 准备参数 - MailTemplateDO template = randomPojo(MailTemplateDO.class, - o -> o.setParams(Lists.newArrayList("code"))); - Map templateParams = new HashMap<>(); - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> mailSendService.validateTemplateParams(template, templateParams), - MAIL_SEND_TEMPLATE_PARAM_MISS, "code"); - } - - @Test - public void testValidateMail_notExists() { - // 准备参数 - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> mailSendService.validateMail(null), - MAIL_SEND_MAIL_NOT_EXISTS); - } - - @Test - public void testDoSendMail_success() { - try (final MockedStatic mailUtilMock = mockStatic(MailUtil.class)) { - // 准备参数 - MailSendMessage message = randomPojo(MailSendMessage.class, o -> o.setNickname("芋艿")); - // mock 方法(获得邮箱账号) - MailAccountDO account = randomPojo(MailAccountDO.class, o -> o.setMail("7685@qq.com")); - when(mailAccountService.getMailAccountFromCache(eq(message.getAccountId()))) - .thenReturn(account); - - // mock 方法(发送邮件) - String messageId = randomString(); - mailUtilMock.when(() -> MailUtil.send( - argThat(mailAccount -> { - assertEquals("芋艿 <7685@qq.com>", mailAccount.getFrom()); - assertTrue(mailAccount.isAuth()); - assertEquals(account.getUsername(), mailAccount.getUser()); - assertArrayEquals(account.getPassword().toCharArray(), mailAccount.getPass()); - assertEquals(account.getHost(), mailAccount.getHost()); - assertEquals(account.getPort(), mailAccount.getPort()); - assertEquals(account.getSslEnable(), mailAccount.isSslEnable()); - return true; - }), eq(message.getMail()), eq(message.getTitle()), eq(message.getContent()), eq(true))) - .thenReturn(messageId); - - // 调用 - mailSendService.doSendMail(message); - // 断言 - verify(mailLogService).updateMailSendResult(eq(message.getLogId()), eq(messageId), isNull()); - } - } - - @Test - public void testDoSendMail_exception() { - try (MockedStatic mailUtilMock = mockStatic(MailUtil.class)) { - // 准备参数 - MailSendMessage message = randomPojo(MailSendMessage.class, o -> o.setNickname("芋艿")); - // mock 方法(获得邮箱账号) - MailAccountDO account = randomPojo(MailAccountDO.class, o -> o.setMail("7685@qq.com")); - when(mailAccountService.getMailAccountFromCache(eq(message.getAccountId()))) - .thenReturn(account); - - // mock 方法(发送邮件) - Exception e = new NullPointerException("啦啦啦"); - mailUtilMock.when(() -> MailUtil.send(argThat(mailAccount -> { - assertEquals("芋艿 <7685@qq.com>", mailAccount.getFrom()); - assertTrue(mailAccount.isAuth()); - assertEquals(account.getUsername(), mailAccount.getUser()); - assertArrayEquals(account.getPassword().toCharArray(), mailAccount.getPass()); - assertEquals(account.getHost(), mailAccount.getHost()); - assertEquals(account.getPort(), mailAccount.getPort()); - assertEquals(account.getSslEnable(), mailAccount.isSslEnable()); - return true; - }), eq(message.getMail()), eq(message.getTitle()), eq(message.getContent()), eq(true))).thenThrow(e); - - // 调用 - mailSendService.doSendMail(message); - // 断言 - verify(mailLogService).updateMailSendResult(eq(message.getLogId()), isNull(), same(e)); - } - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateServiceImplTest.java deleted file mode 100755 index 70059b233c..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateServiceImplTest.java +++ /dev/null @@ -1,215 +0,0 @@ -package cn.iocoder.yudao.module.system.service.mail; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateSaveReqVO; -import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplatePageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; -import cn.iocoder.yudao.module.system.dal.mysql.mail.MailTemplateMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.MAIL_TEMPLATE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link MailTemplateServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(MailTemplateServiceImpl.class) -public class MailTemplateServiceImplTest extends BaseDbUnitTest { - - @Resource - private MailTemplateServiceImpl mailTemplateService; - - @Resource - private MailTemplateMapper mailTemplateMapper; - - @Test - public void testCreateMailTemplate_success() { - // 准备参数 - MailTemplateSaveReqVO reqVO = randomPojo(MailTemplateSaveReqVO.class) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long mailTemplateId = mailTemplateService.createMailTemplate(reqVO); - // 断言 - assertNotNull(mailTemplateId); - // 校验记录的属性是否正确 - MailTemplateDO mailTemplate = mailTemplateMapper.selectById(mailTemplateId); - assertPojoEquals(reqVO, mailTemplate, "id"); - } - - @Test - public void testUpdateMailTemplate_success() { - // mock 数据 - MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - MailTemplateSaveReqVO reqVO = randomPojo(MailTemplateSaveReqVO.class, o -> { - o.setId(dbMailTemplate.getId()); // 设置更新的 ID - }); - - // 调用 - mailTemplateService.updateMailTemplate(reqVO); - // 校验是否更新正确 - MailTemplateDO mailTemplate = mailTemplateMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, mailTemplate); - } - - @Test - public void testUpdateMailTemplate_notExists() { - // 准备参数 - MailTemplateSaveReqVO reqVO = randomPojo(MailTemplateSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> mailTemplateService.updateMailTemplate(reqVO), MAIL_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testDeleteMailTemplate_success() { - // mock 数据 - MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbMailTemplate.getId(); - - // 调用 - mailTemplateService.deleteMailTemplate(id); - // 校验数据不存在了 - assertNull(mailTemplateMapper.selectById(id)); - } - - @Test - public void testDeleteMailTemplate_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> mailTemplateService.deleteMailTemplate(id), MAIL_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testGetMailTemplatePage() { - // mock 数据 - MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class, o -> { // 等会查询到 - o.setName("源码"); - o.setCode("test_01"); - o.setAccountId(1L); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2023, 2, 3)); - }); - mailTemplateMapper.insert(dbMailTemplate); - // 测试 name 不匹配 - mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setName("芋道"))); - // 测试 code 不匹配 - mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setCode("test_02"))); - // 测试 accountId 不匹配 - mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setAccountId(2L))); - // 测试 status 不匹配 - mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setCreateTime(buildTime(2023, 1, 5)))); - // 准备参数 - MailTemplatePageReqVO reqVO = new MailTemplatePageReqVO(); - reqVO.setName("源"); - reqVO.setCode("est_01"); - reqVO.setAccountId(1L); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 5)); - - // 调用 - PageResult pageResult = mailTemplateService.getMailTemplatePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbMailTemplate, pageResult.getList().get(0)); - } - - @Test - public void testGetMailTemplateList() { - // mock 数据 - MailTemplateDO dbMailTemplate01 = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate01); - MailTemplateDO dbMailTemplate02 = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate02); - - // 调用 - List list = mailTemplateService.getMailTemplateList(); - // 断言 - assertEquals(2, list.size()); - assertEquals(dbMailTemplate01, list.get(0)); - assertEquals(dbMailTemplate02, list.get(1)); - } - - @Test - public void testGetMailTemplate() { - // mock 数据 - MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate); - // 准备参数 - Long id = dbMailTemplate.getId(); - - // 调用 - MailTemplateDO mailTemplate = mailTemplateService.getMailTemplate(id); - // 断言 - assertPojoEquals(dbMailTemplate, mailTemplate); - } - - @Test - public void testGetMailTemplateByCodeFromCache() { - // mock 数据 - MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate); - // 准备参数 - String code = dbMailTemplate.getCode(); - - // 调用 - MailTemplateDO mailTemplate = mailTemplateService.getMailTemplateByCodeFromCache(code); - // 断言 - assertPojoEquals(dbMailTemplate, mailTemplate); - } - - @Test - public void testFormatMailTemplateContent() { - // 准备参数 - Map params = new HashMap<>(); - params.put("name", "小红"); - params.put("what", "饭"); - - // 调用,并断言 - assertEquals("小红,你好,饭吃了吗?", - mailTemplateService.formatMailTemplateContent("{name},你好,{what}吃了吗?", params)); - } - - @Test - public void testCountByAccountId() { - // mock 数据 - MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate); - // 测试 accountId 不匹配 - mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setAccountId(2L))); - // 准备参数 - Long accountId = dbMailTemplate.getAccountId(); - - // 调用 - long count = mailTemplateService.getMailTemplateCountByAccountId(accountId); - // 断言 - assertEquals(1, count); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notice/NoticeServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notice/NoticeServiceImplTest.java deleted file mode 100644 index 7b40af3c3f..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notice/NoticeServiceImplTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package cn.iocoder.yudao.module.system.service.notice; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; -import cn.iocoder.yudao.module.system.dal.mysql.notice.NoticeMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTICE_NOT_FOUND; -import static org.junit.jupiter.api.Assertions.*; - -@Import(NoticeServiceImpl.class) -class NoticeServiceImplTest extends BaseDbUnitTest { - - @Resource - private NoticeServiceImpl noticeService; - - @Resource - private NoticeMapper noticeMapper; - - @Test - public void testGetNoticePage_success() { - // 插入前置数据 - NoticeDO dbNotice = randomPojo(NoticeDO.class, o -> { - o.setTitle("尼古拉斯赵四来啦!"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - noticeMapper.insert(dbNotice); - // 测试 title 不匹配 - noticeMapper.insert(cloneIgnoreId(dbNotice, o -> o.setTitle("尼古拉斯凯奇也来啦!"))); - // 测试 status 不匹配 - noticeMapper.insert(cloneIgnoreId(dbNotice, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 准备参数 - NoticePageReqVO reqVO = new NoticePageReqVO(); - reqVO.setTitle("尼古拉斯赵四来啦!"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - PageResult pageResult = noticeService.getNoticePage(reqVO); - // 验证查询结果经过筛选 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbNotice, pageResult.getList().get(0)); - } - - @Test - public void testGetNotice_success() { - // 插入前置数据 - NoticeDO dbNotice = randomPojo(NoticeDO.class); - noticeMapper.insert(dbNotice); - - // 查询 - NoticeDO notice = noticeService.getNotice(dbNotice.getId()); - - // 验证插入与读取对象是否一致 - assertNotNull(notice); - assertPojoEquals(dbNotice, notice); - } - - @Test - public void testCreateNotice_success() { - // 准备参数 - NoticeSaveReqVO reqVO = randomPojo(NoticeSaveReqVO.class) - .setId(null); // 避免 id 被赋值 - - // 调用 - Long noticeId = noticeService.createNotice(reqVO); - // 校验插入属性是否正确 - assertNotNull(noticeId); - NoticeDO notice = noticeMapper.selectById(noticeId); - assertPojoEquals(reqVO, notice, "id"); - } - - @Test - public void testUpdateNotice_success() { - // 插入前置数据 - NoticeDO dbNoticeDO = randomPojo(NoticeDO.class); - noticeMapper.insert(dbNoticeDO); - - // 准备更新参数 - NoticeSaveReqVO reqVO = randomPojo(NoticeSaveReqVO.class, o -> o.setId(dbNoticeDO.getId())); - - // 更新 - noticeService.updateNotice(reqVO); - // 检验是否更新成功 - NoticeDO notice = noticeMapper.selectById(reqVO.getId()); - assertPojoEquals(reqVO, notice); - } - - @Test - public void testDeleteNotice_success() { - // 插入前置数据 - NoticeDO dbNotice = randomPojo(NoticeDO.class); - noticeMapper.insert(dbNotice); - - // 删除 - noticeService.deleteNotice(dbNotice.getId()); - - // 检查是否删除成功 - assertNull(noticeMapper.selectById(dbNotice.getId())); - } - - @Test - public void testValidateNoticeExists_success() { - // 插入前置数据 - NoticeDO dbNotice = randomPojo(NoticeDO.class); - noticeMapper.insert(dbNotice); - - // 成功调用 - noticeService.validateNoticeExists(dbNotice.getId()); - } - - @Test - public void testValidateNoticeExists_noExists() { - assertServiceException(() -> - noticeService.validateNoticeExists(randomLongId()), NOTICE_NOT_FOUND); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImplTest.java deleted file mode 100644 index 48a68e43f9..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImplTest.java +++ /dev/null @@ -1,280 +0,0 @@ -package cn.iocoder.yudao.module.system.service.notify; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO; -import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; -import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper; -import com.baomidou.mybatisplus.annotation.DbType; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link NotifyMessageServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Import(NotifyMessageServiceImpl.class) -public class NotifyMessageServiceImplTest extends BaseDbUnitTest { - - @Resource - private NotifyMessageServiceImpl notifyMessageService; - - @Resource - private NotifyMessageMapper notifyMessageMapper; - - @Test - public void testCreateNotifyMessage_success() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class); - String templateContent = randomString(); - Map templateParams = randomTemplateParams(); - // mock 方法 - - // 调用 - Long messageId = notifyMessageService.createNotifyMessage(userId, userType, - template, templateContent, templateParams); - // 断言 - NotifyMessageDO message = notifyMessageMapper.selectById(messageId); - assertNotNull(message); - assertEquals(userId, message.getUserId()); - assertEquals(userType, message.getUserType()); - assertEquals(template.getId(), message.getTemplateId()); - assertEquals(template.getCode(), message.getTemplateCode()); - assertEquals(template.getType(), message.getTemplateType()); - assertEquals(template.getNickname(), message.getTemplateNickname()); - assertEquals(templateContent, message.getTemplateContent()); - assertEquals(templateParams, message.getTemplateParams()); - assertEquals(false, message.getReadStatus()); - assertNull(message.getReadTime()); - } - - @Test - public void testGetNotifyMessagePage() { - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setTemplateCode("test_01"); - o.setTemplateType(10); - o.setCreateTime(buildTime(2022, 1, 2)); - o.setTemplateParams(randomTemplateParams()); - }); - notifyMessageMapper.insert(dbNotifyMessage); - // 测试 userId 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 templateCode 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setTemplateCode("test_11"))); - // 测试 templateType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setTemplateType(20))); - // 测试 createTime 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setCreateTime(buildTime(2022, 2, 1)))); - // 准备参数 - NotifyMessagePageReqVO reqVO = new NotifyMessagePageReqVO(); - reqVO.setUserId(1L); - reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); - reqVO.setTemplateCode("est_01"); - reqVO.setTemplateType(10); - reqVO.setCreateTime(buildBetweenTime(2022, 1, 1, 2022, 1, 10)); - - // 调用 - PageResult pageResult = notifyMessageService.getNotifyMessagePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbNotifyMessage, pageResult.getList().get(0)); - } - - @Test - public void testGetNotifyMessage() { - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, - o -> o.setTemplateParams(randomTemplateParams())); - notifyMessageMapper.insert(dbNotifyMessage); - // 准备参数 - Long id = dbNotifyMessage.getId(); - - // 调用 - NotifyMessageDO notifyMessage = notifyMessageService.getNotifyMessage(id); - assertPojoEquals(dbNotifyMessage, notifyMessage); - } - - @Test - public void testGetMyNotifyMessagePage() { - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setReadStatus(true); - o.setCreateTime(buildTime(2022, 1, 2)); - o.setTemplateParams(randomTemplateParams()); - }); - notifyMessageMapper.insert(dbNotifyMessage); - // 测试 userId 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 readStatus 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(false))); - // 测试 createTime 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setCreateTime(buildTime(2022, 2, 1)))); - // 准备参数 - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - NotifyMessageMyPageReqVO reqVO = new NotifyMessageMyPageReqVO(); - reqVO.setReadStatus(true); - reqVO.setCreateTime(buildBetweenTime(2022, 1, 1, 2022, 1, 10)); - - // 调用 - PageResult pageResult = notifyMessageService.getMyMyNotifyMessagePage(reqVO, userId, userType); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbNotifyMessage, pageResult.getList().get(0)); - } - - @Test - public void testGetUnreadNotifyMessageList() { - SqlConstants.init(DbType.MYSQL); - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setReadStatus(false); - o.setTemplateParams(randomTemplateParams()); - }); - notifyMessageMapper.insert(dbNotifyMessage); - // 测试 userId 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 readStatus 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true))); - // 准备参数 - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - Integer size = 10; - - // 调用 - List list = notifyMessageService.getUnreadNotifyMessageList(userId, userType, size); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbNotifyMessage, list.get(0)); - } - - @Test - public void testGetUnreadNotifyMessageCount() { - SqlConstants.init(DbType.MYSQL); - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setReadStatus(false); - o.setTemplateParams(randomTemplateParams()); - }); - notifyMessageMapper.insert(dbNotifyMessage); - // 测试 userId 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 readStatus 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true))); - // 准备参数 - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - - // 调用,并断言 - assertEquals(1, notifyMessageService.getUnreadNotifyMessageCount(userId, userType)); - } - - @Test - public void testUpdateNotifyMessageRead() { - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setReadStatus(false); - o.setReadTime(null); - o.setTemplateParams(randomTemplateParams()); - }); - notifyMessageMapper.insert(dbNotifyMessage); - // 测试 userId 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 readStatus 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true))); - // 准备参数 - Collection ids = Arrays.asList(dbNotifyMessage.getId(), dbNotifyMessage.getId() + 1, - dbNotifyMessage.getId() + 2, dbNotifyMessage.getId() + 3); - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - - // 调用 - int updateCount = notifyMessageService.updateNotifyMessageRead(ids, userId, userType); - // 断言 - assertEquals(1, updateCount); - NotifyMessageDO notifyMessage = notifyMessageMapper.selectById(dbNotifyMessage.getId()); - assertTrue(notifyMessage.getReadStatus()); - assertNotNull(notifyMessage.getReadTime()); - } - - @Test - public void testUpdateAllNotifyMessageRead() { - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setReadStatus(false); - o.setReadTime(null); - o.setTemplateParams(randomTemplateParams()); - }); - notifyMessageMapper.insert(dbNotifyMessage); - // 测试 userId 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 readStatus 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true))); - // 准备参数 - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - - // 调用 - int updateCount = notifyMessageService.updateAllNotifyMessageRead(userId, userType); - // 断言 - assertEquals(1, updateCount); - NotifyMessageDO notifyMessage = notifyMessageMapper.selectById(dbNotifyMessage.getId()); - assertTrue(notifyMessage.getReadStatus()); - assertNotNull(notifyMessage.getReadTime()); - } - - private static Map randomTemplateParams() { - return MapUtil.builder().put(randomString(), randomString()) - .put(randomString(), randomString()).build(); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImplTest.java deleted file mode 100644 index 9dbdac431d..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImplTest.java +++ /dev/null @@ -1,190 +0,0 @@ -package cn.iocoder.yudao.module.system.service.notify; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.HashMap; -import java.util.Map; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTICE_NOT_FOUND; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTIFY_SEND_TEMPLATE_PARAM_MISS; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -class NotifySendServiceImplTest extends BaseMockitoUnitTest { - - @InjectMocks - private NotifySendServiceImpl notifySendService; - - @Mock - private NotifyTemplateService notifyTemplateService; - @Mock - private NotifyMessageService notifyMessageService; - - @Test - public void testSendSingleNotifyToAdmin() { - // 准备参数 - Long userId = randomLongId(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock NotifyTemplateService 的方法 - NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(notifyTemplateService.formatNotifyTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock NotifyMessageService 的方法 - Long messageId = randomLongId(); - when(notifyMessageService.createNotifyMessage(eq(userId), eq(UserTypeEnum.ADMIN.getValue()), - eq(template), eq(content), eq(templateParams))).thenReturn(messageId); - - // 调用 - Long resultMessageId = notifySendService.sendSingleNotifyToAdmin(userId, templateCode, templateParams); - // 断言 - assertEquals(messageId, resultMessageId); - } - - @Test - public void testSendSingleNotifyToMember() { - // 准备参数 - Long userId = randomLongId(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock NotifyTemplateService 的方法 - NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(notifyTemplateService.formatNotifyTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock NotifyMessageService 的方法 - Long messageId = randomLongId(); - when(notifyMessageService.createNotifyMessage(eq(userId), eq(UserTypeEnum.MEMBER.getValue()), - eq(template), eq(content), eq(templateParams))).thenReturn(messageId); - - // 调用 - Long resultMessageId = notifySendService.sendSingleNotifyToMember(userId, templateCode, templateParams); - // 断言 - assertEquals(messageId, resultMessageId); - } - - /** - * 发送成功,当短信模板开启时 - */ - @Test - public void testSendSingleNotify_successWhenMailTemplateEnable() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock NotifyTemplateService 的方法 - NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(notifyTemplateService.formatNotifyTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock NotifyMessageService 的方法 - Long messageId = randomLongId(); - when(notifyMessageService.createNotifyMessage(eq(userId), eq(userType), - eq(template), eq(content), eq(templateParams))).thenReturn(messageId); - - // 调用 - Long resultMessageId = notifySendService.sendSingleNotify(userId, userType, templateCode, templateParams); - // 断言 - assertEquals(messageId, resultMessageId); - } - - /** - * 发送成功,当短信模板关闭时 - */ - @Test - public void testSendSingleMail_successWhenSmsTemplateDisable() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock NotifyTemplateService 的方法 - NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - - // 调用 - Long resultMessageId = notifySendService.sendSingleNotify(userId, userType, templateCode, templateParams); - // 断言 - assertNull(resultMessageId); - verify(notifyTemplateService, never()).formatNotifyTemplateContent(anyString(), anyMap()); - verify(notifyMessageService, never()).createNotifyMessage(anyLong(), anyInt(), any(), anyString(), anyMap()); - } - - @Test - public void testCheckMailTemplateValid_notExists() { - // 准备参数 - String templateCode = randomString(); - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> notifySendService.validateNotifyTemplate(templateCode), - NOTICE_NOT_FOUND); - } - - @Test - public void testCheckTemplateParams_paramMiss() { - // 准备参数 - NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, - o -> o.setParams(Lists.newArrayList("code"))); - Map templateParams = new HashMap<>(); - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> notifySendService.validateTemplateParams(template, templateParams), - NOTIFY_SEND_TEMPLATE_PARAM_MISS, "code"); - } - - @Test - public void testSendBatchNotify() { - // 准备参数 - // mock 方法 - - // 调用 - UnsupportedOperationException exception = Assertions.assertThrows( - UnsupportedOperationException.class, - () -> notifySendService.sendBatchNotify(null, null, null, null, null) - ); - // 断言 - assertEquals("暂时不支持该操作,感兴趣可以实现该功能哟!", exception.getMessage()); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImplTest.java deleted file mode 100644 index ba1f98e22c..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImplTest.java +++ /dev/null @@ -1,178 +0,0 @@ -package cn.iocoder.yudao.module.system.service.notify; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; -import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTIFY_TEMPLATE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link NotifyTemplateServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(NotifyTemplateServiceImpl.class) -public class NotifyTemplateServiceImplTest extends BaseDbUnitTest { - - @Resource - private NotifyTemplateServiceImpl notifyTemplateService; - - @Resource - private NotifyTemplateMapper notifyTemplateMapper; - - @Test - public void testCreateNotifyTemplate_success() { - // 准备参数 - NotifyTemplateSaveReqVO reqVO = randomPojo(NotifyTemplateSaveReqVO.class, - o -> o.setStatus(randomCommonStatus())) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long notifyTemplateId = notifyTemplateService.createNotifyTemplate(reqVO); - // 断言 - assertNotNull(notifyTemplateId); - // 校验记录的属性是否正确 - NotifyTemplateDO notifyTemplate = notifyTemplateMapper.selectById(notifyTemplateId); - assertPojoEquals(reqVO, notifyTemplate, "id"); - } - - @Test - public void testUpdateNotifyTemplate_success() { - // mock 数据 - NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class); - notifyTemplateMapper.insert(dbNotifyTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - NotifyTemplateSaveReqVO reqVO = randomPojo(NotifyTemplateSaveReqVO.class, o -> { - o.setId(dbNotifyTemplate.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - }); - - // 调用 - notifyTemplateService.updateNotifyTemplate(reqVO); - // 校验是否更新正确 - NotifyTemplateDO notifyTemplate = notifyTemplateMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, notifyTemplate); - } - - @Test - public void testUpdateNotifyTemplate_notExists() { - // 准备参数 - NotifyTemplateSaveReqVO reqVO = randomPojo(NotifyTemplateSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> notifyTemplateService.updateNotifyTemplate(reqVO), NOTIFY_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testDeleteNotifyTemplate_success() { - // mock 数据 - NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class); - notifyTemplateMapper.insert(dbNotifyTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbNotifyTemplate.getId(); - - // 调用 - notifyTemplateService.deleteNotifyTemplate(id); - // 校验数据不存在了 - assertNull(notifyTemplateMapper.selectById(id)); - } - - @Test - public void testDeleteNotifyTemplate_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> notifyTemplateService.deleteNotifyTemplate(id), NOTIFY_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testGetNotifyTemplatePage() { - // mock 数据 - NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class, o -> { // 等会查询到 - o.setName("芋头"); - o.setCode("test_01"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2022, 2, 3)); - }); - notifyTemplateMapper.insert(dbNotifyTemplate); - // 测试 name 不匹配 - notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setName("投"))); - // 测试 code 不匹配 - notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setCode("test_02"))); - // 测试 status 不匹配 - notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setCreateTime(buildTime(2022, 1, 5)))); - // 准备参数 - NotifyTemplatePageReqVO reqVO = new NotifyTemplatePageReqVO(); - reqVO.setName("芋"); - reqVO.setCode("est_01"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2022, 2, 1, 2022, 2, 5)); - - // 调用 - PageResult pageResult = notifyTemplateService.getNotifyTemplatePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbNotifyTemplate, pageResult.getList().get(0)); - } - - @Test - public void testGetNotifyTemplate() { - // mock 数据 - NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class); - notifyTemplateMapper.insert(dbNotifyTemplate); - // 准备参数 - Long id = dbNotifyTemplate.getId(); - - // 调用 - NotifyTemplateDO notifyTemplate = notifyTemplateService.getNotifyTemplate(id); - // 断言 - assertPojoEquals(dbNotifyTemplate, notifyTemplate); - } - - @Test - public void testGetNotifyTemplateByCodeFromCache() { - // mock 数据 - NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class); - notifyTemplateMapper.insert(dbNotifyTemplate); - // 准备参数 - String code = dbNotifyTemplate.getCode(); - - // 调用 - NotifyTemplateDO notifyTemplate = notifyTemplateService.getNotifyTemplateByCodeFromCache(code); - // 断言 - assertPojoEquals(dbNotifyTemplate, notifyTemplate); - } - - @Test - public void testFormatNotifyTemplateContent() { - // 准备参数 - Map params = new HashMap<>(); - params.put("name", "小红"); - params.put("what", "饭"); - - // 调用,并断言 - assertEquals("小红,你好,饭吃了吗?", - notifyTemplateService.formatNotifyTemplateContent("{name},你好,{what}吃了吗?", params)); - } -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImplTest.java deleted file mode 100644 index 91a96769df..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImplTest.java +++ /dev/null @@ -1,269 +0,0 @@ -package cn.iocoder.yudao.module.system.service.oauth2; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ApproveDO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; -import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2ApproveMapper; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.temporal.ChronoUnit; -import java.util.*; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link OAuth2ApproveServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(OAuth2ApproveServiceImpl.class) -public class OAuth2ApproveServiceImplTest extends BaseDbUnitTest { - - @Resource - private OAuth2ApproveServiceImpl oauth2ApproveService; - - @Resource - private OAuth2ApproveMapper oauth2ApproveMapper; - - @MockBean - private OAuth2ClientService oauth2ClientService; - - @Test - public void checkForPreApproval_clientAutoApprove() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List requestedScopes = Lists.newArrayList("read"); - // mock 方法 - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))) - .thenReturn(randomPojo(OAuth2ClientDO.class).setAutoApproveScopes(requestedScopes)); - - // 调用 - boolean success = oauth2ApproveService.checkForPreApproval(userId, userType, - clientId, requestedScopes); - // 断言 - assertTrue(success); - List result = oauth2ApproveMapper.selectList(); - assertEquals(1, result.size()); - assertEquals(userId, result.get(0).getUserId()); - assertEquals(userType, result.get(0).getUserType()); - assertEquals(clientId, result.get(0).getClientId()); - assertEquals("read", result.get(0).getScope()); - assertTrue(result.get(0).getApproved()); - assertFalse(DateUtils.isExpired(result.get(0).getExpiresTime())); - } - - @Test - public void checkForPreApproval_approve() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List requestedScopes = Lists.newArrayList("read"); - // mock 方法 - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))) - .thenReturn(randomPojo(OAuth2ClientDO.class).setAutoApproveScopes(null)); - // mock 数据 - OAuth2ApproveDO approve = randomPojo(OAuth2ApproveDO.class).setUserId(userId) - .setUserType(userType).setClientId(clientId).setScope("read") - .setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 1L, ChronoUnit.DAYS)).setApproved(true); // 同意 - oauth2ApproveMapper.insert(approve); - - // 调用 - boolean success = oauth2ApproveService.checkForPreApproval(userId, userType, - clientId, requestedScopes); - // 断言 - assertTrue(success); - } - - @Test - public void checkForPreApproval_reject() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List requestedScopes = Lists.newArrayList("read"); - // mock 方法 - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))) - .thenReturn(randomPojo(OAuth2ClientDO.class).setAutoApproveScopes(null)); - // mock 数据 - OAuth2ApproveDO approve = randomPojo(OAuth2ApproveDO.class).setUserId(userId) - .setUserType(userType).setClientId(clientId).setScope("read") - .setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 1L, ChronoUnit.DAYS)).setApproved(false); // 拒绝 - oauth2ApproveMapper.insert(approve); - - // 调用 - boolean success = oauth2ApproveService.checkForPreApproval(userId, userType, - clientId, requestedScopes); - // 断言 - assertFalse(success); - } - - @Test - public void testUpdateAfterApproval_none() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - - // 调用 - boolean success = oauth2ApproveService.updateAfterApproval(userId, userType, clientId, - null); - // 断言 - assertTrue(success); - List result = oauth2ApproveMapper.selectList(); - assertEquals(0, result.size()); - } - - @Test - public void testUpdateAfterApproval_approved() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - Map requestedScopes = new LinkedHashMap<>(); // 有序,方便判断 - requestedScopes.put("read", true); - requestedScopes.put("write", false); - // mock 方法 - - // 调用 - boolean success = oauth2ApproveService.updateAfterApproval(userId, userType, clientId, - requestedScopes); - // 断言 - assertTrue(success); - List result = oauth2ApproveMapper.selectList(); - assertEquals(2, result.size()); - // read - assertEquals(userId, result.get(0).getUserId()); - assertEquals(userType, result.get(0).getUserType()); - assertEquals(clientId, result.get(0).getClientId()); - assertEquals("read", result.get(0).getScope()); - assertTrue(result.get(0).getApproved()); - assertFalse(DateUtils.isExpired(result.get(0).getExpiresTime())); - // write - assertEquals(userId, result.get(1).getUserId()); - assertEquals(userType, result.get(1).getUserType()); - assertEquals(clientId, result.get(1).getClientId()); - assertEquals("write", result.get(1).getScope()); - assertFalse(result.get(1).getApproved()); - assertFalse(DateUtils.isExpired(result.get(1).getExpiresTime())); - } - - @Test - public void testUpdateAfterApproval_reject() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - Map requestedScopes = new LinkedHashMap<>(); - requestedScopes.put("write", false); - // mock 方法 - - // 调用 - boolean success = oauth2ApproveService.updateAfterApproval(userId, userType, clientId, - requestedScopes); - // 断言 - assertFalse(success); - List result = oauth2ApproveMapper.selectList(); - assertEquals(1, result.size()); - // write - assertEquals(userId, result.get(0).getUserId()); - assertEquals(userType, result.get(0).getUserType()); - assertEquals(clientId, result.get(0).getClientId()); - assertEquals("write", result.get(0).getScope()); - assertFalse(result.get(0).getApproved()); - assertFalse(DateUtils.isExpired(result.get(0).getExpiresTime())); - } - - @Test - public void testGetApproveList() { - // 准备参数 - Long userId = 10L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - String clientId = randomString(); - // mock 数据 - OAuth2ApproveDO approve = randomPojo(OAuth2ApproveDO.class).setUserId(userId) - .setUserType(userType).setClientId(clientId).setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 1L, ChronoUnit.DAYS)); - oauth2ApproveMapper.insert(approve); // 未过期 - oauth2ApproveMapper.insert(ObjectUtil.clone(approve).setId(null) - .setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), -1L, ChronoUnit.DAYS))); // 已过期 - - // 调用 - List result = oauth2ApproveService.getApproveList(userId, userType, clientId); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(approve, result.get(0)); - } - - @Test - public void testSaveApprove_insert() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - String scope = randomString(); - Boolean approved = randomBoolean(); - LocalDateTime expireTime = LocalDateTime.ofInstant(randomDay(1, 30).toInstant(), ZoneId.systemDefault()); - // mock 方法 - - // 调用 - oauth2ApproveService.saveApprove(userId, userType, clientId, - scope, approved, expireTime); - // 断言 - List result = oauth2ApproveMapper.selectList(); - assertEquals(1, result.size()); - assertEquals(userId, result.get(0).getUserId()); - assertEquals(userType, result.get(0).getUserType()); - assertEquals(clientId, result.get(0).getClientId()); - assertEquals(scope, result.get(0).getScope()); - assertEquals(approved, result.get(0).getApproved()); - assertEquals(expireTime, result.get(0).getExpiresTime()); - } - - @Test - public void testSaveApprove_update() { - // mock 数据 - OAuth2ApproveDO approve = randomPojo(OAuth2ApproveDO.class); - oauth2ApproveMapper.insert(approve); - // 准备参数 - Long userId = approve.getUserId(); - Integer userType = approve.getUserType(); - String clientId = approve.getClientId(); - String scope = approve.getScope(); - Boolean approved = randomBoolean(); - LocalDateTime expireTime = LocalDateTime.ofInstant(randomDay(1, 30).toInstant(), ZoneId.systemDefault()); - // mock 方法 - - // 调用 - oauth2ApproveService.saveApprove(userId, userType, clientId, - scope, approved, expireTime); - // 断言 - List result = oauth2ApproveMapper.selectList(); - assertEquals(1, result.size()); - assertEquals(approve.getId(), result.get(0).getId()); - assertEquals(userId, result.get(0).getUserId()); - assertEquals(userType, result.get(0).getUserType()); - assertEquals(clientId, result.get(0).getClientId()); - assertEquals(scope, result.get(0).getScope()); - assertEquals(approved, result.get(0).getApproved()); - assertEquals(expireTime, result.get(0).getExpiresTime()); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ClientServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ClientServiceImplTest.java deleted file mode 100755 index 05e85cb2ba..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ClientServiceImplTest.java +++ /dev/null @@ -1,220 +0,0 @@ -package cn.iocoder.yudao.module.system.service.oauth2; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.client.OAuth2ClientPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.client.OAuth2ClientSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; -import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2ClientMapper; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Collections; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mockStatic; - -/** - * {@link OAuth2ClientServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(OAuth2ClientServiceImpl.class) -public class OAuth2ClientServiceImplTest extends BaseDbUnitTest { - - @Resource - private OAuth2ClientServiceImpl oauth2ClientService; - - @Resource - private OAuth2ClientMapper oauth2ClientMapper; - - @Test - public void testCreateOAuth2Client_success() { - // 准备参数 - OAuth2ClientSaveReqVO reqVO = randomPojo(OAuth2ClientSaveReqVO.class, - o -> o.setLogo(randomString())) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long oauth2ClientId = oauth2ClientService.createOAuth2Client(reqVO); - // 断言 - assertNotNull(oauth2ClientId); - // 校验记录的属性是否正确 - OAuth2ClientDO oAuth2Client = oauth2ClientMapper.selectById(oauth2ClientId); - assertPojoEquals(reqVO, oAuth2Client, "id"); - } - - @Test - public void testUpdateOAuth2Client_success() { - // mock 数据 - OAuth2ClientDO dbOAuth2Client = randomPojo(OAuth2ClientDO.class); - oauth2ClientMapper.insert(dbOAuth2Client);// @Sql: 先插入出一条存在的数据 - // 准备参数 - OAuth2ClientSaveReqVO reqVO = randomPojo(OAuth2ClientSaveReqVO.class, o -> { - o.setId(dbOAuth2Client.getId()); // 设置更新的 ID - o.setLogo(randomString()); - }); - - // 调用 - oauth2ClientService.updateOAuth2Client(reqVO); - // 校验是否更新正确 - OAuth2ClientDO oAuth2Client = oauth2ClientMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, oAuth2Client); - } - - @Test - public void testUpdateOAuth2Client_notExists() { - // 准备参数 - OAuth2ClientSaveReqVO reqVO = randomPojo(OAuth2ClientSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> oauth2ClientService.updateOAuth2Client(reqVO), OAUTH2_CLIENT_NOT_EXISTS); - } - - @Test - public void testDeleteOAuth2Client_success() { - // mock 数据 - OAuth2ClientDO dbOAuth2Client = randomPojo(OAuth2ClientDO.class); - oauth2ClientMapper.insert(dbOAuth2Client);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbOAuth2Client.getId(); - - // 调用 - oauth2ClientService.deleteOAuth2Client(id); - // 校验数据不存在了 - assertNull(oauth2ClientMapper.selectById(id)); - } - - @Test - public void testDeleteOAuth2Client_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> oauth2ClientService.deleteOAuth2Client(id), OAUTH2_CLIENT_NOT_EXISTS); - } - - @Test - public void testValidateClientIdExists_withId() { - // mock 数据 - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("tudou"); - oauth2ClientMapper.insert(client); - // 准备参数 - Long id = randomLongId(); - String clientId = "tudou"; - - // 调用,不会报错 - assertServiceException(() -> oauth2ClientService.validateClientIdExists(id, clientId), OAUTH2_CLIENT_EXISTS); - } - - @Test - public void testValidateClientIdExists_noId() { - // mock 数据 - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("tudou"); - oauth2ClientMapper.insert(client); - // 准备参数 - String clientId = "tudou"; - - // 调用,不会报错 - assertServiceException(() -> oauth2ClientService.validateClientIdExists(null, clientId), OAUTH2_CLIENT_EXISTS); - } - - @Test - public void testGetOAuth2Client() { - // mock 数据 - OAuth2ClientDO clientDO = randomPojo(OAuth2ClientDO.class); - oauth2ClientMapper.insert(clientDO); - // 准备参数 - Long id = clientDO.getId(); - - // 调用,并断言 - OAuth2ClientDO dbClientDO = oauth2ClientService.getOAuth2Client(id); - assertPojoEquals(clientDO, dbClientDO); - } - - @Test - public void testGetOAuth2ClientFromCache() { - // mock 数据 - OAuth2ClientDO clientDO = randomPojo(OAuth2ClientDO.class); - oauth2ClientMapper.insert(clientDO); - // 准备参数 - String clientId = clientDO.getClientId(); - - // 调用,并断言 - OAuth2ClientDO dbClientDO = oauth2ClientService.getOAuth2ClientFromCache(clientId); - assertPojoEquals(clientDO, dbClientDO); - } - - @Test - public void testGetOAuth2ClientPage() { - // mock 数据 - OAuth2ClientDO dbOAuth2Client = randomPojo(OAuth2ClientDO.class, o -> { // 等会查询到 - o.setName("潜龙"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - oauth2ClientMapper.insert(dbOAuth2Client); - // 测试 name 不匹配 - oauth2ClientMapper.insert(cloneIgnoreId(dbOAuth2Client, o -> o.setName("凤凰"))); - // 测试 status 不匹配 - oauth2ClientMapper.insert(cloneIgnoreId(dbOAuth2Client, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 准备参数 - OAuth2ClientPageReqVO reqVO = new OAuth2ClientPageReqVO(); - reqVO.setName("龙"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - PageResult pageResult = oauth2ClientService.getOAuth2ClientPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbOAuth2Client, pageResult.getList().get(0)); - } - - @Test - public void testValidOAuthClientFromCache() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(OAuth2ClientServiceImpl.class))) - .thenReturn(oauth2ClientService); - - // mock 方法 - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("default") - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - oauth2ClientMapper.insert(client); - OAuth2ClientDO client02 = randomPojo(OAuth2ClientDO.class).setClientId("disable") - .setStatus(CommonStatusEnum.DISABLE.getStatus()); - oauth2ClientMapper.insert(client02); - - // 调用,并断言 - assertServiceException(() -> oauth2ClientService.validOAuthClientFromCache(randomString(), - null, null, null, null), OAUTH2_CLIENT_NOT_EXISTS); - assertServiceException(() -> oauth2ClientService.validOAuthClientFromCache("disable", - null, null, null, null), OAUTH2_CLIENT_DISABLE); - assertServiceException(() -> oauth2ClientService.validOAuthClientFromCache("default", - randomString(), null, null, null), OAUTH2_CLIENT_CLIENT_SECRET_ERROR); - assertServiceException(() -> oauth2ClientService.validOAuthClientFromCache("default", - null, randomString(), null, null), OAUTH2_CLIENT_AUTHORIZED_GRANT_TYPE_NOT_EXISTS); - assertServiceException(() -> oauth2ClientService.validOAuthClientFromCache("default", - null, null, Collections.singleton(randomString()), null), OAUTH2_CLIENT_SCOPE_OVER); - assertServiceException(() -> oauth2ClientService.validOAuthClientFromCache("default", - null, null, null, "test"), OAUTH2_CLIENT_REDIRECT_URI_NOT_MATCH, "test"); - // 成功调用(1:参数完整) - OAuth2ClientDO result = oauth2ClientService.validOAuthClientFromCache(client.getClientId(), client.getSecret(), - client.getAuthorizedGrantTypes().get(0), client.getScopes(), client.getRedirectUris().get(0)); - assertPojoEquals(client, result); - // 成功调用(2:只有 clientId 参数) - result = oauth2ClientService.validOAuthClientFromCache(client.getClientId()); - assertPojoEquals(client, result); - } - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2CodeServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2CodeServiceImplTest.java deleted file mode 100644 index 2601ffc974..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2CodeServiceImplTest.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.system.service.oauth2; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2CodeDO; -import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2CodeMapper; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.OAUTH2_CODE_EXPIRE; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.OAUTH2_CODE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link OAuth2CodeServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(OAuth2CodeServiceImpl.class) -class OAuth2CodeServiceImplTest extends BaseDbUnitTest { - - @Resource - private OAuth2CodeServiceImpl oauth2CodeService; - - @Resource - private OAuth2CodeMapper oauth2CodeMapper; - - @Test - public void testCreateAuthorizationCode() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = RandomUtil.randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List scopes = Lists.newArrayList("read", "write"); - String redirectUri = randomString(); - String state = randomString(); - - // 调用 - OAuth2CodeDO codeDO = oauth2CodeService.createAuthorizationCode(userId, userType, clientId, - scopes, redirectUri, state); - // 断言 - OAuth2CodeDO dbCodeDO = oauth2CodeMapper.selectByCode(codeDO.getCode()); - assertPojoEquals(codeDO, dbCodeDO, "createTime", "updateTime", "deleted"); - assertEquals(userId, codeDO.getUserId()); - assertEquals(userType, codeDO.getUserType()); - assertEquals(clientId, codeDO.getClientId()); - assertEquals(scopes, codeDO.getScopes()); - assertEquals(redirectUri, codeDO.getRedirectUri()); - assertEquals(state, codeDO.getState()); - assertFalse(DateUtils.isExpired(codeDO.getExpiresTime())); - } - - @Test - public void testConsumeAuthorizationCode_null() { - // 调用,并断言 - assertServiceException(() -> oauth2CodeService.consumeAuthorizationCode(randomString()), - OAUTH2_CODE_NOT_EXISTS); - } - - @Test - public void testConsumeAuthorizationCode_expired() { - // 准备参数 - String code = "test_code"; - // mock 数据 - OAuth2CodeDO codeDO = randomPojo(OAuth2CodeDO.class).setCode(code) - .setExpiresTime(LocalDateTime.now().minusDays(1)); - oauth2CodeMapper.insert(codeDO); - - // 调用,并断言 - assertServiceException(() -> oauth2CodeService.consumeAuthorizationCode(code), - OAUTH2_CODE_EXPIRE); - } - - @Test - public void testConsumeAuthorizationCode_success() { - // 准备参数 - String code = "test_code"; - // mock 数据 - OAuth2CodeDO codeDO = randomPojo(OAuth2CodeDO.class).setCode(code) - .setExpiresTime(LocalDateTime.now().plusDays(1)); - oauth2CodeMapper.insert(codeDO); - - // 调用 - OAuth2CodeDO result = oauth2CodeService.consumeAuthorizationCode(code); - assertPojoEquals(codeDO, result); - assertNull(oauth2CodeMapper.selectByCode(code)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2GrantServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2GrantServiceImplTest.java deleted file mode 100644 index 52c722831f..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2GrantServiceImplTest.java +++ /dev/null @@ -1,173 +0,0 @@ -package cn.iocoder.yudao.module.system.service.oauth2; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2CodeDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.service.auth.AdminAuthService; -import com.google.common.collect.Lists; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.List; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static java.util.Collections.emptyList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link OAuth2GrantServiceImpl} 的单元测试 - * - * @author 芋道源码 - */ -public class OAuth2GrantServiceImplTest extends BaseMockitoUnitTest { - - @InjectMocks - private OAuth2GrantServiceImpl oauth2GrantService; - - @Mock - private OAuth2TokenService oauth2TokenService; - @Mock - private OAuth2CodeService oauth2CodeService; - @Mock - private AdminAuthService adminAuthService; - - @Test - public void testGrantImplicit() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List scopes = Lists.newArrayList("read", "write"); - // mock 方法 - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class); - when(oauth2TokenService.createAccessToken(eq(userId), eq(userType), - eq(clientId), eq(scopes))).thenReturn(accessTokenDO); - - // 调用,并断言 - assertPojoEquals(accessTokenDO, oauth2GrantService.grantImplicit( - userId, userType, clientId, scopes)); - } - - @Test - public void testGrantAuthorizationCodeForCode() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List scopes = Lists.newArrayList("read", "write"); - String redirectUri = randomString(); - String state = randomString(); - // mock 方法 - OAuth2CodeDO codeDO = randomPojo(OAuth2CodeDO.class); - when(oauth2CodeService.createAuthorizationCode(eq(userId), eq(userType), - eq(clientId), eq(scopes), eq(redirectUri), eq(state))).thenReturn(codeDO); - - // 调用,并断言 - assertEquals(codeDO.getCode(), oauth2GrantService.grantAuthorizationCodeForCode(userId, userType, - clientId, scopes, redirectUri, state)); - } - - @Test - public void testGrantAuthorizationCodeForAccessToken() { - // 准备参数 - String clientId = randomString(); - String code = randomString(); - List scopes = Lists.newArrayList("read", "write"); - String redirectUri = randomString(); - String state = randomString(); - // mock 方法(code) - OAuth2CodeDO codeDO = randomPojo(OAuth2CodeDO.class, o -> { - o.setClientId(clientId); - o.setRedirectUri(redirectUri); - o.setState(state); - o.setScopes(scopes); - }); - when(oauth2CodeService.consumeAuthorizationCode(eq(code))).thenReturn(codeDO); - // mock 方法(创建令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class); - when(oauth2TokenService.createAccessToken(eq(codeDO.getUserId()), eq(codeDO.getUserType()), - eq(codeDO.getClientId()), eq(codeDO.getScopes()))).thenReturn(accessTokenDO); - - // 调用,并断言 - assertPojoEquals(accessTokenDO, oauth2GrantService.grantAuthorizationCodeForAccessToken( - clientId, code, redirectUri, state)); - } - - @Test - public void testGrantPassword() { - // 准备参数 - String username = randomString(); - String password = randomString(); - String clientId = randomString(); - List scopes = Lists.newArrayList("read", "write"); - // mock 方法(认证) - AdminUserDO user = randomPojo(AdminUserDO.class); - when(adminAuthService.authenticate(eq(username), eq(password))).thenReturn(user); - // mock 方法(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class); - when(oauth2TokenService.createAccessToken(eq(user.getId()), eq(UserTypeEnum.ADMIN.getValue()), - eq(clientId), eq(scopes))).thenReturn(accessTokenDO); - - // 调用,并断言 - assertPojoEquals(accessTokenDO, oauth2GrantService.grantPassword( - username, password, clientId, scopes)); - } - - @Test - public void testGrantRefreshToken() { - // 准备参数 - String refreshToken = randomString(); - String clientId = randomString(); - // mock 方法 - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class); - when(oauth2TokenService.refreshAccessToken(eq(refreshToken), eq(clientId))) - .thenReturn(accessTokenDO); - - // 调用,并断言 - assertPojoEquals(accessTokenDO, oauth2GrantService.grantRefreshToken( - refreshToken, clientId)); - } - - @Test - public void testGrantClientCredentials() { - assertThrows(UnsupportedOperationException.class, - () -> oauth2GrantService.grantClientCredentials(randomString(), emptyList()), - "暂时不支持 client_credentials 授权模式"); - } - - @Test - public void testRevokeToken_clientIdError() { - // 准备参数 - String clientId = randomString(); - String accessToken = randomString(); - // mock 方法 - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class); - when(oauth2TokenService.getAccessToken(eq(accessToken))).thenReturn(accessTokenDO); - - // 调用,并断言 - assertFalse(oauth2GrantService.revokeToken(clientId, accessToken)); - } - - @Test - public void testRevokeToken_success() { - // 准备参数 - String clientId = randomString(); - String accessToken = randomString(); - // mock 方法(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class).setClientId(clientId); - when(oauth2TokenService.getAccessToken(eq(accessToken))).thenReturn(accessTokenDO); - // mock 方法(移除) - when(oauth2TokenService.removeAccessToken(eq(accessToken))).thenReturn(accessTokenDO); - - // 调用,并断言 - assertTrue(oauth2GrantService.revokeToken(clientId, accessToken)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImplTest.java deleted file mode 100644 index d702284afa..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImplTest.java +++ /dev/null @@ -1,289 +0,0 @@ -package cn.iocoder.yudao.module.system.service.oauth2; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.exception.ErrorCode; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.token.OAuth2AccessTokenPageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2RefreshTokenDO; -import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2AccessTokenMapper; -import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2RefreshTokenMapper; -import cn.iocoder.yudao.module.system.dal.redis.oauth2.OAuth2AccessTokenRedisDAO; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link OAuth2TokenServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import({OAuth2TokenServiceImpl.class, OAuth2AccessTokenRedisDAO.class}) -public class OAuth2TokenServiceImplTest extends BaseDbAndRedisUnitTest { - - @Resource - private OAuth2TokenServiceImpl oauth2TokenService; - - @Resource - private OAuth2AccessTokenMapper oauth2AccessTokenMapper; - @Resource - private OAuth2RefreshTokenMapper oauth2RefreshTokenMapper; - - @Resource - private OAuth2AccessTokenRedisDAO oauth2AccessTokenRedisDAO; - - @MockBean - private OAuth2ClientService oauth2ClientService; - - @Test - public void testCreateAccessToken() { - TenantContextHolder.setTenantId(0L); - // 准备参数 - Long userId = randomLongId(); - Integer userType = RandomUtil.randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List scopes = Lists.newArrayList("read", "write"); - // mock 方法 - OAuth2ClientDO clientDO = randomPojo(OAuth2ClientDO.class).setClientId(clientId) - .setAccessTokenValiditySeconds(30).setRefreshTokenValiditySeconds(60); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))).thenReturn(clientDO); - - // 调用 - OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.createAccessToken(userId, userType, clientId, scopes); - // 断言访问令牌 - OAuth2AccessTokenDO dbAccessTokenDO = oauth2AccessTokenMapper.selectByAccessToken(accessTokenDO.getAccessToken()); - assertPojoEquals(accessTokenDO, dbAccessTokenDO, "createTime", "updateTime", "deleted"); - assertEquals(userId, accessTokenDO.getUserId()); - assertEquals(userType, accessTokenDO.getUserType()); - assertEquals(clientId, accessTokenDO.getClientId()); - assertEquals(scopes, accessTokenDO.getScopes()); - assertFalse(DateUtils.isExpired(accessTokenDO.getExpiresTime())); - // 断言访问令牌的缓存 - OAuth2AccessTokenDO redisAccessTokenDO = oauth2AccessTokenRedisDAO.get(accessTokenDO.getAccessToken()); - assertPojoEquals(accessTokenDO, redisAccessTokenDO, "createTime", "updateTime", "deleted"); - // 断言刷新令牌 - OAuth2RefreshTokenDO refreshTokenDO = oauth2RefreshTokenMapper.selectList().get(0); - assertPojoEquals(accessTokenDO, refreshTokenDO, "id", "expiresTime", "createTime", "updateTime", "deleted"); - assertFalse(DateUtils.isExpired(refreshTokenDO.getExpiresTime())); - } - - @Test - public void testRefreshAccessToken_null() { - // 准备参数 - String refreshToken = randomString(); - String clientId = randomString(); - // mock 方法 - - // 调用,并断言 - assertServiceException(() -> oauth2TokenService.refreshAccessToken(refreshToken, clientId), - new ErrorCode(400, "无效的刷新令牌")); - } - - @Test - public void testRefreshAccessToken_clientIdError() { - // 准备参数 - String refreshToken = randomString(); - String clientId = randomString(); - // mock 方法 - OAuth2ClientDO clientDO = randomPojo(OAuth2ClientDO.class).setClientId(clientId); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))).thenReturn(clientDO); - // mock 数据(访问令牌) - OAuth2RefreshTokenDO refreshTokenDO = randomPojo(OAuth2RefreshTokenDO.class) - .setRefreshToken(refreshToken).setClientId("error"); - oauth2RefreshTokenMapper.insert(refreshTokenDO); - - // 调用,并断言 - assertServiceException(() -> oauth2TokenService.refreshAccessToken(refreshToken, clientId), - new ErrorCode(400, "刷新令牌的客户端编号不正确")); - } - - @Test - public void testRefreshAccessToken_expired() { - // 准备参数 - String refreshToken = randomString(); - String clientId = randomString(); - // mock 方法 - OAuth2ClientDO clientDO = randomPojo(OAuth2ClientDO.class).setClientId(clientId); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))).thenReturn(clientDO); - // mock 数据(访问令牌) - OAuth2RefreshTokenDO refreshTokenDO = randomPojo(OAuth2RefreshTokenDO.class) - .setRefreshToken(refreshToken).setClientId(clientId) - .setExpiresTime(LocalDateTime.now().minusDays(1)); - oauth2RefreshTokenMapper.insert(refreshTokenDO); - - // 调用,并断言 - assertServiceException(() -> oauth2TokenService.refreshAccessToken(refreshToken, clientId), - new ErrorCode(401, "刷新令牌已过期")); - assertEquals(0, oauth2RefreshTokenMapper.selectCount()); - } - - @Test - public void testRefreshAccessToken_success() { - TenantContextHolder.setTenantId(0L); - // 准备参数 - String refreshToken = randomString(); - String clientId = randomString(); - // mock 方法 - OAuth2ClientDO clientDO = randomPojo(OAuth2ClientDO.class).setClientId(clientId) - .setAccessTokenValiditySeconds(30); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))).thenReturn(clientDO); - // mock 数据(访问令牌) - OAuth2RefreshTokenDO refreshTokenDO = randomPojo(OAuth2RefreshTokenDO.class) - .setRefreshToken(refreshToken).setClientId(clientId) - .setExpiresTime(LocalDateTime.now().plusDays(1)); - oauth2RefreshTokenMapper.insert(refreshTokenDO); - // mock 数据(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class).setRefreshToken(refreshToken); - oauth2AccessTokenMapper.insert(accessTokenDO); - oauth2AccessTokenRedisDAO.set(accessTokenDO); - - // 调用 - OAuth2AccessTokenDO newAccessTokenDO = oauth2TokenService.refreshAccessToken(refreshToken, clientId); - // 断言,老的访问令牌被删除 - assertNull(oauth2AccessTokenMapper.selectByAccessToken(accessTokenDO.getAccessToken())); - assertNull(oauth2AccessTokenRedisDAO.get(accessTokenDO.getAccessToken())); - // 断言,新的访问令牌 - OAuth2AccessTokenDO dbAccessTokenDO = oauth2AccessTokenMapper.selectByAccessToken(newAccessTokenDO.getAccessToken()); - assertPojoEquals(newAccessTokenDO, dbAccessTokenDO, "createTime", "updateTime", "deleted"); - assertPojoEquals(newAccessTokenDO, refreshTokenDO, "id", "expiresTime", "createTime", "updateTime", "deleted", - "creator", "updater"); - assertFalse(DateUtils.isExpired(newAccessTokenDO.getExpiresTime())); - // 断言,新的访问令牌的缓存 - OAuth2AccessTokenDO redisAccessTokenDO = oauth2AccessTokenRedisDAO.get(newAccessTokenDO.getAccessToken()); - assertPojoEquals(newAccessTokenDO, redisAccessTokenDO, "createTime", "updateTime", "deleted"); - } - - @Test - public void testGetAccessToken() { - // mock 数据(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTime.now().plusDays(1)); - oauth2AccessTokenMapper.insert(accessTokenDO); - // 准备参数 - String accessToken = accessTokenDO.getAccessToken(); - - // 调用 - OAuth2AccessTokenDO result = oauth2TokenService.getAccessToken(accessToken); - // 断言 - assertPojoEquals(accessTokenDO, result, "createTime", "updateTime", "deleted", - "creator", "updater"); - assertPojoEquals(accessTokenDO, oauth2AccessTokenRedisDAO.get(accessToken), "createTime", "updateTime", "deleted", - "creator", "updater"); - } - - @Test - public void testCheckAccessToken_null() { - // 调研,并断言 - assertServiceException(() -> oauth2TokenService.checkAccessToken(randomString()), - new ErrorCode(401, "访问令牌不存在")); - } - - @Test - public void testCheckAccessToken_expired() { - // mock 数据(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTime.now().minusDays(1)); - oauth2AccessTokenMapper.insert(accessTokenDO); - // 准备参数 - String accessToken = accessTokenDO.getAccessToken(); - - // 调研,并断言 - assertServiceException(() -> oauth2TokenService.checkAccessToken(accessToken), - new ErrorCode(401, "访问令牌已过期")); - } - - @Test - public void testCheckAccessToken_success() { - // mock 数据(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTime.now().plusDays(1)); - oauth2AccessTokenMapper.insert(accessTokenDO); - // 准备参数 - String accessToken = accessTokenDO.getAccessToken(); - - // 调研,并断言 - OAuth2AccessTokenDO result = oauth2TokenService.getAccessToken(accessToken); - // 断言 - assertPojoEquals(accessTokenDO, result, "createTime", "updateTime", "deleted", - "creator", "updater"); - } - - @Test - public void testRemoveAccessToken_null() { - // 调用,并断言 - assertNull(oauth2TokenService.removeAccessToken(randomString())); - } - - @Test - public void testRemoveAccessToken_success() { - // mock 数据(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTime.now().plusDays(1)); - oauth2AccessTokenMapper.insert(accessTokenDO); - // mock 数据(刷新令牌) - OAuth2RefreshTokenDO refreshTokenDO = randomPojo(OAuth2RefreshTokenDO.class) - .setRefreshToken(accessTokenDO.getRefreshToken()); - oauth2RefreshTokenMapper.insert(refreshTokenDO); - // 调用 - OAuth2AccessTokenDO result = oauth2TokenService.removeAccessToken(accessTokenDO.getAccessToken()); - assertPojoEquals(accessTokenDO, result, "createTime", "updateTime", "deleted", - "creator", "updater"); - // 断言数据 - assertNull(oauth2AccessTokenMapper.selectByAccessToken(accessTokenDO.getAccessToken())); - assertNull(oauth2RefreshTokenMapper.selectByRefreshToken(accessTokenDO.getRefreshToken())); - assertNull(oauth2AccessTokenRedisDAO.get(accessTokenDO.getAccessToken())); - } - - - @Test - public void testGetAccessTokenPage() { - // mock 数据 - OAuth2AccessTokenDO dbAccessToken = randomPojo(OAuth2AccessTokenDO.class, o -> { // 等会查询到 - o.setUserId(10L); - o.setUserType(1); - o.setClientId("test_client"); - o.setExpiresTime(LocalDateTime.now().plusDays(1)); - }); - oauth2AccessTokenMapper.insert(dbAccessToken); - // 测试 userId 不匹配 - oauth2AccessTokenMapper.insert(cloneIgnoreId(dbAccessToken, o -> o.setUserId(20L))); - // 测试 userType 不匹配 - oauth2AccessTokenMapper.insert(cloneIgnoreId(dbAccessToken, o -> o.setUserType(2))); - // 测试 userType 不匹配 - oauth2AccessTokenMapper.insert(cloneIgnoreId(dbAccessToken, o -> o.setClientId("it_client"))); - // 测试 expireTime 不匹配 - oauth2AccessTokenMapper.insert(cloneIgnoreId(dbAccessToken, o -> o.setExpiresTime(LocalDateTimeUtil.now()))); - // 准备参数 - OAuth2AccessTokenPageReqVO reqVO = new OAuth2AccessTokenPageReqVO(); - reqVO.setUserId(10L); - reqVO.setUserType(1); - reqVO.setClientId("test"); - - // 调用 - PageResult pageResult = oauth2TokenService.getAccessTokenPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbAccessToken, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java deleted file mode 100644 index 27f1efb36c..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java +++ /dev/null @@ -1,331 +0,0 @@ -package cn.iocoder.yudao.module.system.service.permission; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuListReqVO; -import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuSaveVO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO; -import cn.iocoder.yudao.module.system.dal.mysql.permission.MenuMapper; -import cn.iocoder.yudao.module.system.enums.permission.MenuTypeEnum; -import cn.iocoder.yudao.module.system.service.tenant.TenantService; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO.ID_ROOT; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.verify; - -@Import(MenuServiceImpl.class) -public class MenuServiceImplTest extends BaseDbUnitTest { - - @Resource - private MenuServiceImpl menuService; - - @Resource - private MenuMapper menuMapper; - - @MockBean - private PermissionService permissionService; - @MockBean - private TenantService tenantService; - - @Test - public void testCreateMenu_success() { - // mock 数据(构造父菜单) - MenuDO menuDO = buildMenuDO(MenuTypeEnum.MENU, - "parent", 0L); - menuMapper.insert(menuDO); - Long parentId = menuDO.getId(); - // 准备参数 - MenuSaveVO reqVO = randomPojo(MenuSaveVO.class, o -> { - o.setParentId(parentId); - o.setName("testSonName"); - o.setType(MenuTypeEnum.MENU.getType()); - }).setId(null); // 防止 id 被赋值 - Long menuId = menuService.createMenu(reqVO); - - // 校验记录的属性是否正确 - MenuDO dbMenu = menuMapper.selectById(menuId); - assertPojoEquals(reqVO, dbMenu, "id"); - } - - @Test - public void testUpdateMenu_success() { - // mock 数据(构造父子菜单) - MenuDO sonMenuDO = createParentAndSonMenu(); - Long sonId = sonMenuDO.getId(); - // 准备参数 - MenuSaveVO reqVO = randomPojo(MenuSaveVO.class, o -> { - o.setId(sonId); - o.setName("testSonName"); // 修改名字 - o.setParentId(sonMenuDO.getParentId()); - o.setType(MenuTypeEnum.MENU.getType()); - }); - - // 调用 - menuService.updateMenu(reqVO); - // 校验记录的属性是否正确 - MenuDO dbMenu = menuMapper.selectById(sonId); - assertPojoEquals(reqVO, dbMenu); - } - - @Test - public void testUpdateMenu_sonIdNotExist() { - // 准备参数 - MenuSaveVO reqVO = randomPojo(MenuSaveVO.class); - // 调用,并断言异常 - assertServiceException(() -> menuService.updateMenu(reqVO), MENU_NOT_EXISTS); - } - - @Test - public void testDeleteMenu_success() { - // mock 数据 - MenuDO menuDO = randomPojo(MenuDO.class); - menuMapper.insert(menuDO); - // 准备参数 - Long id = menuDO.getId(); - - // 调用 - menuService.deleteMenu(id); - // 断言 - MenuDO dbMenuDO = menuMapper.selectById(id); - assertNull(dbMenuDO); - verify(permissionService).processMenuDeleted(id); - } - - @Test - public void testDeleteMenu_menuNotExist() { - assertServiceException(() -> menuService.deleteMenu(randomLongId()), - MENU_NOT_EXISTS); - } - - @Test - public void testDeleteMenu_existChildren() { - // mock 数据(构造父子菜单) - MenuDO sonMenu = createParentAndSonMenu(); - // 准备参数 - Long parentId = sonMenu.getParentId(); - - // 调用并断言异常 - assertServiceException(() -> menuService.deleteMenu(parentId), MENU_EXISTS_CHILDREN); - } - - @Test - public void testGetMenuList_all() { - // mock 数据 - MenuDO menu100 = randomPojo(MenuDO.class); - menuMapper.insert(menu100); - MenuDO menu101 = randomPojo(MenuDO.class); - menuMapper.insert(menu101); - // 准备参数 - - // 调用 - List list = menuService.getMenuList(); - // 断言 - assertEquals(2, list.size()); - assertPojoEquals(menu100, list.get(0)); - assertPojoEquals(menu101, list.get(1)); - } - - @Test - public void testGetMenuList() { - // mock 数据 - MenuDO menuDO = randomPojo(MenuDO.class, o -> o.setName("芋艿").setStatus(CommonStatusEnum.ENABLE.getStatus())); - menuMapper.insert(menuDO); - // 测试 status 不匹配 - menuMapper.insert(cloneIgnoreId(menuDO, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 name 不匹配 - menuMapper.insert(cloneIgnoreId(menuDO, o -> o.setName("艿"))); - // 准备参数 - MenuListReqVO reqVO = new MenuListReqVO().setName("芋").setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - List result = menuService.getMenuList(reqVO); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(menuDO, result.get(0)); - } - - @Test - public void testGetMenuListByTenant() { - // mock 数据 - MenuDO menu100 = randomPojo(MenuDO.class, o -> o.setId(100L).setStatus(CommonStatusEnum.ENABLE.getStatus())); - menuMapper.insert(menu100); - MenuDO menu101 = randomPojo(MenuDO.class, o -> o.setId(101L).setStatus(CommonStatusEnum.DISABLE.getStatus())); - menuMapper.insert(menu101); - MenuDO menu102 = randomPojo(MenuDO.class, o -> o.setId(102L).setStatus(CommonStatusEnum.ENABLE.getStatus())); - menuMapper.insert(menu102); - // mock 过滤菜单 - Set menuIds = asSet(100L, 101L); - doNothing().when(tenantService).handleTenantMenu(argThat(handler -> { - handler.handle(menuIds); - return true; - })); - // 准备参数 - MenuListReqVO reqVO = new MenuListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - List result = menuService.getMenuListByTenant(reqVO); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(menu100, result.get(0)); - } - - @Test - public void testGetMenuIdListByPermissionFromCache() { - // mock 数据 - MenuDO menu100 = randomPojo(MenuDO.class); - menuMapper.insert(menu100); - MenuDO menu101 = randomPojo(MenuDO.class); - menuMapper.insert(menu101); - // 准备参数 - String permission = menu100.getPermission(); - - // 调用 - List ids = menuService.getMenuIdListByPermissionFromCache(permission); - // 断言 - assertEquals(1, ids.size()); - assertEquals(menu100.getId(), ids.get(0)); - } - - @Test - public void testGetMenuList_ids() { - // mock 数据 - MenuDO menu100 = randomPojo(MenuDO.class); - menuMapper.insert(menu100); - MenuDO menu101 = randomPojo(MenuDO.class); - menuMapper.insert(menu101); - // 准备参数 - Collection ids = Collections.singleton(menu100.getId()); - - // 调用 - List list = menuService.getMenuList(ids); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(menu100, list.get(0)); - } - - @Test - public void testGetMenu() { - // mock 数据 - MenuDO menu = randomPojo(MenuDO.class); - menuMapper.insert(menu); - // 准备参数 - Long id = menu.getId(); - - // 调用 - MenuDO dbMenu = menuService.getMenu(id); - // 断言 - assertPojoEquals(menu, dbMenu); - } - - @Test - public void testValidateParentMenu_success() { - // mock 数据 - MenuDO menuDO = buildMenuDO(MenuTypeEnum.MENU, "parent", 0L); - menuMapper.insert(menuDO); - // 准备参数 - Long parentId = menuDO.getId(); - - // 调用,无需断言 - menuService.validateParentMenu(parentId, null); - } - - @Test - public void testValidateParentMenu_canNotSetSelfToBeParent() { - // 调用,并断言异常 - assertServiceException(() -> menuService.validateParentMenu(1L, 1L), - MENU_PARENT_ERROR); - } - - @Test - public void testValidateParentMenu_parentNotExist() { - // 调用,并断言异常 - assertServiceException(() -> menuService.validateParentMenu(randomLongId(), null), - MENU_PARENT_NOT_EXISTS); - } - - @Test - public void testValidateParentMenu_parentTypeError() { - // mock 数据 - MenuDO menuDO = buildMenuDO(MenuTypeEnum.BUTTON, "parent", 0L); - menuMapper.insert(menuDO); - // 准备参数 - Long parentId = menuDO.getId(); - - // 调用,并断言异常 - assertServiceException(() -> menuService.validateParentMenu(parentId, null), - MENU_PARENT_NOT_DIR_OR_MENU); - } - - @Test - public void testValidateMenu_success() { - // mock 父子菜单 - MenuDO sonMenu = createParentAndSonMenu(); - // 准备参数 - Long parentId = sonMenu.getParentId(); - Long otherSonMenuId = randomLongId(); - String otherSonMenuName = randomString(); - - // 调用,无需断言 - menuService.validateMenu(parentId, otherSonMenuName, otherSonMenuId); - } - - @Test - public void testValidateMenu_sonMenuNameDuplicate() { - // mock 父子菜单 - MenuDO sonMenu = createParentAndSonMenu(); - // 准备参数 - Long parentId = sonMenu.getParentId(); - Long otherSonMenuId = randomLongId(); - String otherSonMenuName = sonMenu.getName(); //相同名称 - - // 调用,并断言异常 - assertServiceException(() -> menuService.validateMenu(parentId, otherSonMenuName, otherSonMenuId), - MENU_NAME_DUPLICATE); - } - - // ====================== 初始化方法 ====================== - - /** - * 插入父子菜单,返回子菜单 - * - * @return 子菜单 - */ - private MenuDO createParentAndSonMenu() { - // 构造父子菜单 - MenuDO parentMenuDO = buildMenuDO(MenuTypeEnum.MENU, "parent", ID_ROOT); - menuMapper.insert(parentMenuDO); - // 构建子菜单 - MenuDO sonMenuDO = buildMenuDO(MenuTypeEnum.MENU, "testSonName", - parentMenuDO.getParentId()); - menuMapper.insert(sonMenuDO); - return sonMenuDO; - } - - private MenuDO buildMenuDO(MenuTypeEnum type, String name, Long parentId) { - return buildMenuDO(type, name, parentId, randomCommonStatus()); - } - - private MenuDO buildMenuDO(MenuTypeEnum type, String name, Long parentId, Integer status) { - return randomPojo(MenuDO.class, o -> o.setId(null).setName(name).setParentId(parentId) - .setType(type.getType()).setStatus(status)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceTest.java deleted file mode 100644 index 6e6de3f833..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceTest.java +++ /dev/null @@ -1,527 +0,0 @@ -package cn.iocoder.yudao.module.system.service.permission; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespDTO; -import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleMenuDO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.dal.mysql.permission.RoleMenuMapper; -import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper; -import cn.iocoder.yudao.module.system.enums.permission.DataScopeEnum; -import cn.iocoder.yudao.module.system.service.dept.DeptService; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import static cn.hutool.core.collection.ListUtil.toList; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -@Import({PermissionServiceImpl.class}) -public class PermissionServiceTest extends BaseDbUnitTest { - - @Resource - private PermissionServiceImpl permissionService; - - @Resource - private RoleMenuMapper roleMenuMapper; - @Resource - private UserRoleMapper userRoleMapper; - - @MockBean - private RoleService roleService; - @MockBean - private MenuService menuService; - @MockBean - private DeptService deptService; - @MockBean - private AdminUserService userService; - - @Test - public void testHasAnyPermissions_superAdmin() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - String[] roles = new String[]{"system:user:query", "system:user:create"}; - // mock 用户登录的角色 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(100L)); - RoleDO role = randomPojo(RoleDO.class, o -> o.setId(100L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(100L)))).thenReturn(toList(role)); - // mock 其它方法 - when(roleService.hasAnySuperAdmin(eq(asSet(100L)))).thenReturn(true); - - // 调用,并断言 - assertTrue(permissionService.hasAnyPermissions(userId, roles)); - } - } - - @Test - public void testHasAnyPermissions_normal() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - String[] roles = new String[]{"system:user:query", "system:user:create"}; - // mock 用户登录的角色 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(100L)); - RoleDO role = randomPojo(RoleDO.class, o -> o.setId(100L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(100L)))).thenReturn(toList(role)); - // mock 菜单 - Long menuId = 1000L; - when(menuService.getMenuIdListByPermissionFromCache( - eq("system:user:create"))).thenReturn(singletonList(menuId)); - roleMenuMapper.insert(randomPojo(RoleMenuDO.class).setRoleId(100L).setMenuId(1000L)); - - // 调用,并断言 - assertTrue(permissionService.hasAnyPermissions(userId, roles)); - } - } - - @Test - public void testHasAnyRoles() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - String[] roles = new String[]{"yunai", "tudou"}; - // mock 用户与角色的缓存 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(100L)); - RoleDO role = randomPojo(RoleDO.class, o -> o.setId(100L).setCode("tudou") - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(100L)))).thenReturn(toList(role)); - - // 调用,并断言 - assertTrue(permissionService.hasAnyRoles(userId, roles)); - } - } - - // ========== 角色-菜单的相关方法 ========== - - @Test - public void testAssignRoleMenu() { - // 准备参数 - Long roleId = 1L; - Set menuIds = asSet(200L, 300L); - // mock 数据 - RoleMenuDO roleMenu01 = randomPojo(RoleMenuDO.class).setRoleId(1L).setMenuId(100L); - roleMenuMapper.insert(roleMenu01); - RoleMenuDO roleMenu02 = randomPojo(RoleMenuDO.class).setRoleId(1L).setMenuId(200L); - roleMenuMapper.insert(roleMenu02); - - // 调用 - permissionService.assignRoleMenu(roleId, menuIds); - // 断言 - List roleMenuList = roleMenuMapper.selectList(); - assertEquals(2, roleMenuList.size()); - assertEquals(1L, roleMenuList.get(0).getRoleId()); - assertEquals(200L, roleMenuList.get(0).getMenuId()); - assertEquals(1L, roleMenuList.get(1).getRoleId()); - assertEquals(300L, roleMenuList.get(1).getMenuId()); - } - - @Test - public void testProcessRoleDeleted() { - // 准备参数 - Long roleId = randomLongId(); - // mock 数据 UserRole - UserRoleDO userRoleDO01 = randomPojo(UserRoleDO.class, o -> o.setRoleId(roleId)); // 被删除 - userRoleMapper.insert(userRoleDO01); - UserRoleDO userRoleDO02 = randomPojo(UserRoleDO.class); // 不被删除 - userRoleMapper.insert(userRoleDO02); - // mock 数据 RoleMenu - RoleMenuDO roleMenuDO01 = randomPojo(RoleMenuDO.class, o -> o.setRoleId(roleId)); // 被删除 - roleMenuMapper.insert(roleMenuDO01); - RoleMenuDO roleMenuDO02 = randomPojo(RoleMenuDO.class); // 不被删除 - roleMenuMapper.insert(roleMenuDO02); - - // 调用 - permissionService.processRoleDeleted(roleId); - // 断言数据 RoleMenuDO - List dbRoleMenus = roleMenuMapper.selectList(); - assertEquals(1, dbRoleMenus.size()); - assertPojoEquals(dbRoleMenus.get(0), roleMenuDO02); - // 断言数据 UserRoleDO - List dbUserRoles = userRoleMapper.selectList(); - assertEquals(1, dbUserRoles.size()); - assertPojoEquals(dbUserRoles.get(0), userRoleDO02); - } - - @Test - public void testProcessMenuDeleted() { - // 准备参数 - Long menuId = randomLongId(); - // mock 数据 - RoleMenuDO roleMenuDO01 = randomPojo(RoleMenuDO.class, o -> o.setMenuId(menuId)); // 被删除 - roleMenuMapper.insert(roleMenuDO01); - RoleMenuDO roleMenuDO02 = randomPojo(RoleMenuDO.class); // 不被删除 - roleMenuMapper.insert(roleMenuDO02); - - // 调用 - permissionService.processMenuDeleted(menuId); - // 断言数据 - List dbRoleMenus = roleMenuMapper.selectList(); - assertEquals(1, dbRoleMenus.size()); - assertPojoEquals(dbRoleMenus.get(0), roleMenuDO02); - } - - @Test - public void testGetRoleMenuIds_superAdmin() { - // 准备参数 - Long roleId = 100L; - // mock 方法 - when(roleService.hasAnySuperAdmin(eq(singleton(100L)))).thenReturn(true); - List menuList = singletonList(randomPojo(MenuDO.class).setId(1L)); - when(menuService.getMenuList()).thenReturn(menuList); - - // 调用 - Set menuIds = permissionService.getRoleMenuListByRoleId(roleId); - // 断言 - assertEquals(singleton(1L), menuIds); - } - - @Test - public void testGetRoleMenuIds_normal() { - // 准备参数 - Long roleId = 100L; - // mock 数据 - RoleMenuDO roleMenu01 = randomPojo(RoleMenuDO.class).setRoleId(100L).setMenuId(1L); - roleMenuMapper.insert(roleMenu01); - RoleMenuDO roleMenu02 = randomPojo(RoleMenuDO.class).setRoleId(100L).setMenuId(2L); - roleMenuMapper.insert(roleMenu02); - - // 调用 - Set menuIds = permissionService.getRoleMenuListByRoleId(roleId); - // 断言 - assertEquals(asSet(1L, 2L), menuIds); - } - - @Test - public void testGetMenuRoleIdListByMenuIdFromCache() { - // 准备参数 - Long menuId = 1L; - // mock 数据 - RoleMenuDO roleMenu01 = randomPojo(RoleMenuDO.class).setRoleId(100L).setMenuId(1L); - roleMenuMapper.insert(roleMenu01); - RoleMenuDO roleMenu02 = randomPojo(RoleMenuDO.class).setRoleId(200L).setMenuId(1L); - roleMenuMapper.insert(roleMenu02); - - // 调用 - Set roleIds = permissionService.getMenuRoleIdListByMenuIdFromCache(menuId); - // 断言 - assertEquals(asSet(100L, 200L), roleIds); - } - - // ========== 用户-角色的相关方法 ========== - - @Test - public void testAssignUserRole() { - // 准备参数 - Long userId = 1L; - Set roleIds = asSet(200L, 300L); - // mock 数据 - UserRoleDO userRole01 = randomPojo(UserRoleDO.class).setUserId(1L).setRoleId(100L); - userRoleMapper.insert(userRole01); - UserRoleDO userRole02 = randomPojo(UserRoleDO.class).setUserId(1L).setRoleId(200L); - userRoleMapper.insert(userRole02); - - // 调用 - permissionService.assignUserRole(userId, roleIds); - // 断言 - List userRoleDOList = userRoleMapper.selectList(); - assertEquals(2, userRoleDOList.size()); - assertEquals(1L, userRoleDOList.get(0).getUserId()); - assertEquals(200L, userRoleDOList.get(0).getRoleId()); - assertEquals(1L, userRoleDOList.get(1).getUserId()); - assertEquals(300L, userRoleDOList.get(1).getRoleId()); - } - - @Test - public void testProcessUserDeleted() { - // 准备参数 - Long userId = randomLongId(); - // mock 数据 - UserRoleDO userRoleDO01 = randomPojo(UserRoleDO.class, o -> o.setUserId(userId)); // 被删除 - userRoleMapper.insert(userRoleDO01); - UserRoleDO userRoleDO02 = randomPojo(UserRoleDO.class); // 不被删除 - userRoleMapper.insert(userRoleDO02); - - // 调用 - permissionService.processUserDeleted(userId); - // 断言数据 - List dbUserRoles = userRoleMapper.selectList(); - assertEquals(1, dbUserRoles.size()); - assertPojoEquals(dbUserRoles.get(0), userRoleDO02); - } - - @Test - public void testGetUserRoleIdListByUserId() { - // 准备参数 - Long userId = 1L; - // mock 数据 - UserRoleDO userRoleDO01 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(10L)); - userRoleMapper.insert(userRoleDO01); - UserRoleDO roleMenuDO02 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(20L)); - userRoleMapper.insert(roleMenuDO02); - - // 调用 - Set result = permissionService.getUserRoleIdListByUserId(userId); - // 断言 - assertEquals(asSet(10L, 20L), result); - } - - @Test - public void testGetUserRoleIdListByUserIdFromCache() { - // 准备参数 - Long userId = 1L; - // mock 数据 - UserRoleDO userRoleDO01 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(10L)); - userRoleMapper.insert(userRoleDO01); - UserRoleDO roleMenuDO02 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(20L)); - userRoleMapper.insert(roleMenuDO02); - - // 调用 - Set result = permissionService.getUserRoleIdListByUserIdFromCache(userId); - // 断言 - assertEquals(asSet(10L, 20L), result); - } - - @Test - public void testGetUserRoleIdsFromCache() { - // 准备参数 - Long userId = 1L; - // mock 数据 - UserRoleDO userRoleDO01 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(10L)); - userRoleMapper.insert(userRoleDO01); - UserRoleDO roleMenuDO02 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(20L)); - userRoleMapper.insert(roleMenuDO02); - - // 调用 - Set result = permissionService.getUserRoleIdListByUserIdFromCache(userId); - // 断言 - assertEquals(asSet(10L, 20L), result); - } - - @Test - public void testGetUserRoleIdListByRoleId() { - // 准备参数 - Collection roleIds = asSet(10L, 20L); - // mock 数据 - UserRoleDO userRoleDO01 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(10L)); - userRoleMapper.insert(userRoleDO01); - UserRoleDO roleMenuDO02 = randomPojo(UserRoleDO.class, o -> o.setUserId(2L).setRoleId(20L)); - userRoleMapper.insert(roleMenuDO02); - - // 调用 - Set result = permissionService.getUserRoleIdListByRoleId(roleIds); - // 断言 - assertEquals(asSet(1L, 2L), result); - } - - @Test - public void testGetEnableUserRoleListByUserIdFromCache() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - // mock 用户登录的角色 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(100L)); - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(200L)); - RoleDO role01 = randomPojo(RoleDO.class, o -> o.setId(100L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - RoleDO role02 = randomPojo(RoleDO.class, o -> o.setId(200L) - .setStatus(CommonStatusEnum.DISABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(asSet(100L, 200L)))) - .thenReturn(toList(role01, role02)); - - // 调用 - List result = permissionService.getEnableUserRoleListByUserIdFromCache(userId); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(role01, result.get(0)); - } - } - - // ========== 用户-部门的相关方法 ========== - - @Test - public void testAssignRoleDataScope() { - // 准备参数 - Long roleId = 1L; - Integer dataScope = 2; - Set dataScopeDeptIds = asSet(10L, 20L); - - // 调用 - permissionService.assignRoleDataScope(roleId, dataScope, dataScopeDeptIds); - // 断言 - verify(roleService).updateRoleDataScope(eq(roleId), eq(dataScope), eq(dataScopeDeptIds)); - } - - @Test - public void testGetDeptDataPermission_All() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - // mock 用户的角色编号 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(2L)); - // mock 获得用户的角色 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setDataScope(DataScopeEnum.ALL.getScope()) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(2L)))).thenReturn(toList(roleDO)); - - // 调用 - DeptDataPermissionRespDTO result = permissionService.getDeptDataPermission(userId); - // 断言 - assertTrue(result.getAll()); - assertFalse(result.getSelf()); - assertTrue(CollUtil.isEmpty(result.getDeptIds())); - } - } - - @Test - public void testGetDeptDataPermission_DeptCustom() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - // mock 用户的角色编号 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(2L)); - // mock 获得用户的角色 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setDataScope(DataScopeEnum.DEPT_CUSTOM.getScope()) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(2L)))).thenReturn(toList(roleDO)); - // mock 部门的返回 - when(userService.getUser(eq(1L))).thenReturn(new AdminUserDO().setDeptId(3L), - null, null); // 最后返回 null 的目的,看看会不会重复调用 - - // 调用 - DeptDataPermissionRespDTO result = permissionService.getDeptDataPermission(userId); - // 断言 - assertFalse(result.getAll()); - assertFalse(result.getSelf()); - assertEquals(roleDO.getDataScopeDeptIds().size() + 1, result.getDeptIds().size()); - assertTrue(CollUtil.containsAll(result.getDeptIds(), roleDO.getDataScopeDeptIds())); - assertTrue(CollUtil.contains(result.getDeptIds(), 3L)); - } - } - - @Test - public void testGetDeptDataPermission_DeptOnly() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - // mock 用户的角色编号 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(2L)); - // mock 获得用户的角色 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setDataScope(DataScopeEnum.DEPT_ONLY.getScope()) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(2L)))).thenReturn(toList(roleDO)); - // mock 部门的返回 - when(userService.getUser(eq(1L))).thenReturn(new AdminUserDO().setDeptId(3L), - null, null); // 最后返回 null 的目的,看看会不会重复调用 - - // 调用 - DeptDataPermissionRespDTO result = permissionService.getDeptDataPermission(userId); - // 断言 - assertFalse(result.getAll()); - assertFalse(result.getSelf()); - assertEquals(1, result.getDeptIds().size()); - assertTrue(CollUtil.contains(result.getDeptIds(), 3L)); - } - } - - @Test - public void testGetDeptDataPermission_DeptAndChild() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - // mock 用户的角色编号 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(2L)); - // mock 获得用户的角色 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setDataScope(DataScopeEnum.DEPT_AND_CHILD.getScope()) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(2L)))).thenReturn(toList(roleDO)); - // mock 部门的返回 - when(userService.getUser(eq(1L))).thenReturn(new AdminUserDO().setDeptId(3L), - null, null); // 最后返回 null 的目的,看看会不会重复调用 - // mock 方法(部门) - DeptDO deptDO = randomPojo(DeptDO.class); - when(deptService.getChildDeptIdListFromCache(eq(3L))).thenReturn(singleton(deptDO.getId())); - - // 调用 - DeptDataPermissionRespDTO result = permissionService.getDeptDataPermission(userId); - // 断言 - assertFalse(result.getAll()); - assertFalse(result.getSelf()); - assertEquals(2, result.getDeptIds().size()); - assertTrue(CollUtil.contains(result.getDeptIds(), deptDO.getId())); - assertTrue(CollUtil.contains(result.getDeptIds(), 3L)); - } - } - - @Test - public void testGetDeptDataPermission_Self() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - // mock 用户的角色编号 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(2L)); - // mock 获得用户的角色 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setDataScope(DataScopeEnum.SELF.getScope()) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(2L)))).thenReturn(toList(roleDO)); - - // 调用 - DeptDataPermissionRespDTO result = permissionService.getDeptDataPermission(userId); - // 断言 - assertFalse(result.getAll()); - assertTrue(result.getSelf()); - assertTrue(CollUtil.isEmpty(result.getDeptIds())); - } - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java deleted file mode 100644 index d2c4007191..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java +++ /dev/null @@ -1,388 +0,0 @@ -package cn.iocoder.yudao.module.system.service.permission; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; -import cn.iocoder.yudao.module.system.dal.mysql.permission.RoleMapper; -import cn.iocoder.yudao.module.system.enums.permission.DataScopeEnum; -import cn.iocoder.yudao.module.system.enums.permission.RoleTypeEnum; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.verify; - -@Import(RoleServiceImpl.class) -public class RoleServiceImplTest extends BaseDbUnitTest { - - @Resource - private RoleServiceImpl roleService; - - @Resource - private RoleMapper roleMapper; - - @MockBean - private PermissionService permissionService; - - @Test - public void testCreateRole() { - // 准备参数 - RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long roleId = roleService.createRole(reqVO, null); - // 断言 - RoleDO roleDO = roleMapper.selectById(roleId); - assertPojoEquals(reqVO, roleDO, "id"); - assertEquals(RoleTypeEnum.CUSTOM.getType(), roleDO.getType()); - assertEquals(CommonStatusEnum.ENABLE.getStatus(), roleDO.getStatus()); - assertEquals(DataScopeEnum.ALL.getScope(), roleDO.getDataScope()); - } - - @Test - public void testUpdateRole() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setType(RoleTypeEnum.CUSTOM.getType())); - roleMapper.insert(roleDO); - // 准备参数 - Long id = roleDO.getId(); - RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class, o -> o.setId(id)); - - // 调用 - roleService.updateRole(reqVO); - // 断言 - RoleDO newRoleDO = roleMapper.selectById(id); - assertPojoEquals(reqVO, newRoleDO); - } - - @Test - public void testUpdateRoleStatus() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setType(RoleTypeEnum.CUSTOM.getType())); - roleMapper.insert(roleDO); - - // 准备参数 - Long roleId = roleDO.getId(); - - // 调用 - roleService.updateRoleStatus(roleId, CommonStatusEnum.DISABLE.getStatus()); - // 断言 - RoleDO dbRoleDO = roleMapper.selectById(roleId); - assertEquals(CommonStatusEnum.DISABLE.getStatus(), dbRoleDO.getStatus()); - } - - @Test - public void testUpdateRoleDataScope() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setType(RoleTypeEnum.CUSTOM.getType())); - roleMapper.insert(roleDO); - // 准备参数 - Long id = roleDO.getId(); - Integer dataScope = randomEle(DataScopeEnum.values()).getScope(); - Set dataScopeRoleIds = randomSet(Long.class); - - // 调用 - roleService.updateRoleDataScope(id, dataScope, dataScopeRoleIds); - // 断言 - RoleDO dbRoleDO = roleMapper.selectById(id); - assertEquals(dataScope, dbRoleDO.getDataScope()); - assertEquals(dataScopeRoleIds, dbRoleDO.getDataScopeDeptIds()); - } - - @Test - public void testDeleteRole() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setType(RoleTypeEnum.CUSTOM.getType())); - roleMapper.insert(roleDO); - // 参数准备 - Long id = roleDO.getId(); - - // 调用 - roleService.deleteRole(id); - // 断言 - assertNull(roleMapper.selectById(id)); - // verify 删除相关数据 - verify(permissionService).processRoleDeleted(id); - } - - @Test - public void testValidateRoleDuplicate_success() { - // 调用,不会抛异常 - roleService.validateRoleDuplicate(randomString(), randomString(), null); - } - - @Test - public void testValidateRoleDuplicate_nameDuplicate() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setName("role_name")); - roleMapper.insert(roleDO); - // 准备参数 - String name = "role_name"; - - // 调用,并断言异常 - assertServiceException(() -> roleService.validateRoleDuplicate(name, randomString(), null), - ROLE_NAME_DUPLICATE, name); - } - - @Test - public void testValidateRoleDuplicate_codeDuplicate() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setCode("code")); - roleMapper.insert(roleDO); - // 准备参数 - String code = "code"; - - // 调用,并断言异常 - assertServiceException(() -> roleService.validateRoleDuplicate(randomString(), code, null), - ROLE_CODE_DUPLICATE, code); - } - - @Test - public void testValidateUpdateRole_success() { - RoleDO roleDO = randomPojo(RoleDO.class); - roleMapper.insert(roleDO); - // 准备参数 - Long id = roleDO.getId(); - - // 调用,无异常 - roleService.validateRoleForUpdate(id); - } - - @Test - public void testValidateUpdateRole_roleIdNotExist() { - assertServiceException(() -> roleService.validateRoleForUpdate(randomLongId()), ROLE_NOT_EXISTS); - } - - @Test - public void testValidateUpdateRole_systemRoleCanNotBeUpdate() { - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setType(RoleTypeEnum.SYSTEM.getType())); - roleMapper.insert(roleDO); - // 准备参数 - Long id = roleDO.getId(); - - assertServiceException(() -> roleService.validateRoleForUpdate(id), - ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE); - } - - @Test - public void testGetRole() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class); - roleMapper.insert(roleDO); - // 参数准备 - Long id = roleDO.getId(); - - // 调用 - RoleDO dbRoleDO = roleService.getRole(id); - // 断言 - assertPojoEquals(roleDO, dbRoleDO); - } - - @Test - public void testGetRoleFromCache() { - // mock 数据(缓存) - RoleDO roleDO = randomPojo(RoleDO.class); - roleMapper.insert(roleDO); - // 参数准备 - Long id = roleDO.getId(); - - // 调用 - RoleDO dbRoleDO = roleService.getRoleFromCache(id); - // 断言 - assertPojoEquals(roleDO, dbRoleDO); - } - - @Test - public void testGetRoleListByStatus() { - // mock 数据 - RoleDO dbRole01 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - roleMapper.insert(dbRole01); - RoleDO dbRole02 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - roleMapper.insert(dbRole02); - - // 调用 - List list = roleService.getRoleListByStatus( - singleton(CommonStatusEnum.ENABLE.getStatus())); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbRole01, list.get(0)); - } - - @Test - public void testGetRoleList() { - // mock 数据 - RoleDO dbRole01 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - roleMapper.insert(dbRole01); - RoleDO dbRole02 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - roleMapper.insert(dbRole02); - - // 调用 - List list = roleService.getRoleList(); - // 断言 - assertEquals(2, list.size()); - assertPojoEquals(dbRole01, list.get(0)); - assertPojoEquals(dbRole02, list.get(1)); - } - - @Test - public void testGetRoleList_ids() { - // mock 数据 - RoleDO dbRole01 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - roleMapper.insert(dbRole01); - RoleDO dbRole02 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - roleMapper.insert(dbRole02); - // 准备参数 - Collection ids = singleton(dbRole01.getId()); - - // 调用 - List list = roleService.getRoleList(ids); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbRole01, list.get(0)); - } - - @Test - public void testGetRoleListFromCache() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(RoleServiceImpl.class))) - .thenReturn(roleService); - - // mock 数据 - RoleDO dbRole = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - roleMapper.insert(dbRole); - // 测试 id 不匹配 - roleMapper.insert(cloneIgnoreId(dbRole, o -> {})); - // 准备参数 - Collection ids = singleton(dbRole.getId()); - - // 调用 - List list = roleService.getRoleListFromCache(ids); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbRole, list.get(0)); - } - } - - @Test - public void testGetRolePage() { - // mock 数据 - RoleDO dbRole = randomPojo(RoleDO.class, o -> { // 等会查询到 - o.setName("土豆"); - o.setCode("tudou"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2022, 2, 8)); - }); - roleMapper.insert(dbRole); - // 测试 name 不匹配 - roleMapper.insert(cloneIgnoreId(dbRole, o -> o.setName("红薯"))); - // 测试 code 不匹配 - roleMapper.insert(cloneIgnoreId(dbRole, o -> o.setCode("hong"))); - // 测试 createTime 不匹配 - roleMapper.insert(cloneIgnoreId(dbRole, o -> o.setCreateTime(buildTime(2022, 2, 16)))); - // 准备参数 - RolePageReqVO reqVO = new RolePageReqVO(); - reqVO.setName("土豆"); - reqVO.setCode("tu"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2022, 2, 1, 2022, 2, 12)); - - // 调用 - PageResult pageResult = roleService.getRolePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbRole, pageResult.getList().get(0)); - } - - @Test - public void testHasAnySuperAdmin_true() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(RoleServiceImpl.class))) - .thenReturn(roleService); - - // mock 数据 - RoleDO dbRole = randomPojo(RoleDO.class).setCode("super_admin"); - roleMapper.insert(dbRole); - // 准备参数 - Long id = dbRole.getId(); - - // 调用,并调用 - assertTrue(roleService.hasAnySuperAdmin(singletonList(id))); - } - } - - @Test - public void testHasAnySuperAdmin_false() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(RoleServiceImpl.class))) - .thenReturn(roleService); - - // mock 数据 - RoleDO dbRole = randomPojo(RoleDO.class).setCode("tenant_admin"); - roleMapper.insert(dbRole); - // 准备参数 - Long id = dbRole.getId(); - - // 调用,并调用 - assertFalse(roleService.hasAnySuperAdmin(singletonList(id))); - } - } - - @Test - public void testValidateRoleList_success() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - roleMapper.insert(roleDO); - // 准备参数 - List ids = singletonList(roleDO.getId()); - - // 调用,无需断言 - roleService.validateRoleList(ids); - } - - @Test - public void testValidateRoleList_notFound() { - // 准备参数 - List ids = singletonList(randomLongId()); - - // 调用, 并断言异常 - assertServiceException(() -> roleService.validateRoleList(ids), ROLE_NOT_EXISTS); - } - - @Test - public void testValidateRoleList_notEnable() { - // mock 数据 - RoleDO RoleDO = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - roleMapper.insert(RoleDO); - // 准备参数 - List ids = singletonList(RoleDO.getId()); - - // 调用, 并断言异常 - assertServiceException(() -> roleService.validateRoleList(ids), ROLE_IS_DISABLE, RoleDO.getName()); - } -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sensitiveword/SensitiveWordServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sensitiveword/SensitiveWordServiceImplTest.java deleted file mode 100644 index ed5c896342..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sensitiveword/SensitiveWordServiceImplTest.java +++ /dev/null @@ -1,303 +0,0 @@ -package cn.iocoder.yudao.module.system.service.sensitiveword; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.sensitiveword.vo.SensitiveWordPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.sensitiveword.vo.SensitiveWordSaveVO; -import cn.iocoder.yudao.module.system.dal.dataobject.sensitiveword.SensitiveWordDO; -import cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.SENSITIVE_WORD_NOT_EXISTS; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link SensitiveWordServiceImpl} 的单元测试类 - * - * @author 永不言败 - */ -@Import(SensitiveWordServiceImpl.class) -public class SensitiveWordServiceImplTest extends BaseDbUnitTest { - - @Resource - private SensitiveWordServiceImpl sensitiveWordService; - - @Resource - private SensitiveWordMapper sensitiveWordMapper; - - @BeforeEach - public void setUp() { - SensitiveWordServiceImpl.ENABLED = true; - } - - @Test - public void testInitLocalCache() { - SensitiveWordDO wordDO1 = randomPojo(SensitiveWordDO.class, o -> o.setName("傻瓜") - .setTags(singletonList("论坛")).setStatus(CommonStatusEnum.ENABLE.getStatus())); - sensitiveWordMapper.insert(wordDO1); - SensitiveWordDO wordDO2 = randomPojo(SensitiveWordDO.class, o -> o.setName("笨蛋") - .setTags(singletonList("蔬菜")).setStatus(CommonStatusEnum.ENABLE.getStatus())); - sensitiveWordMapper.insert(wordDO2); - SensitiveWordDO wordDO3 = randomPojo(SensitiveWordDO.class, o -> o.setName("白") - .setTags(singletonList("测试")).setStatus(CommonStatusEnum.ENABLE.getStatus())); - sensitiveWordMapper.insert(wordDO3); - SensitiveWordDO wordDO4 = randomPojo(SensitiveWordDO.class, o -> o.setName("白痴") - .setTags(singletonList("测试")).setStatus(CommonStatusEnum.ENABLE.getStatus())); - sensitiveWordMapper.insert(wordDO4); - - // 调用 - sensitiveWordService.initLocalCache(); - // 断言 sensitiveWordTagsCache 缓存 - assertEquals(SetUtils.asSet("论坛", "蔬菜", "测试"), sensitiveWordService.getSensitiveWordTagSet()); - // 断言 sensitiveWordCache - assertEquals(4, sensitiveWordService.getSensitiveWordCache().size()); - assertPojoEquals(wordDO1, sensitiveWordService.getSensitiveWordCache().get(0)); - assertPojoEquals(wordDO2, sensitiveWordService.getSensitiveWordCache().get(1)); - assertPojoEquals(wordDO3, sensitiveWordService.getSensitiveWordCache().get(2)); - // 断言 tagSensitiveWordTries 缓存 - assertNotNull(sensitiveWordService.getDefaultSensitiveWordTrie()); - assertEquals(3, sensitiveWordService.getTagSensitiveWordTries().size()); - assertNotNull(sensitiveWordService.getTagSensitiveWordTries().get("论坛")); - assertNotNull(sensitiveWordService.getTagSensitiveWordTries().get("蔬菜")); - assertNotNull(sensitiveWordService.getTagSensitiveWordTries().get("测试")); - } - - @Test - public void testRefreshLocalCache() { - // mock 数据 - SensitiveWordDO wordDO1 = randomPojo(SensitiveWordDO.class, o -> o.setName("傻瓜") - .setTags(singletonList("论坛")).setStatus(CommonStatusEnum.ENABLE.getStatus())); - wordDO1.setUpdateTime(LocalDateTime.now()); - sensitiveWordMapper.insert(wordDO1); - sensitiveWordService.initLocalCache(); - // mock 数据 ② - SensitiveWordDO wordDO2 = randomPojo(SensitiveWordDO.class, o -> o.setName("笨蛋") - .setTags(singletonList("蔬菜")).setStatus(CommonStatusEnum.ENABLE.getStatus())); - wordDO2.setUpdateTime(LocalDateTimeUtils.addTime(Duration.ofMinutes(1))); // 避免时间相同 - sensitiveWordMapper.insert(wordDO2); - - // 调用 - sensitiveWordService.refreshLocalCache(); - // 断言 sensitiveWordTagsCache 缓存 - assertEquals(SetUtils.asSet("论坛", "蔬菜"), sensitiveWordService.getSensitiveWordTagSet()); - // 断言 sensitiveWordCache - assertEquals(2, sensitiveWordService.getSensitiveWordCache().size()); - assertPojoEquals(wordDO1, sensitiveWordService.getSensitiveWordCache().get(0)); - assertPojoEquals(wordDO2, sensitiveWordService.getSensitiveWordCache().get(1)); - // 断言 tagSensitiveWordTries 缓存 - assertNotNull(sensitiveWordService.getDefaultSensitiveWordTrie()); - assertEquals(2, sensitiveWordService.getTagSensitiveWordTries().size()); - assertNotNull(sensitiveWordService.getTagSensitiveWordTries().get("论坛")); - assertNotNull(sensitiveWordService.getTagSensitiveWordTries().get("蔬菜")); - } - - @Test - public void testCreateSensitiveWord_success() { - // 准备参数 - SensitiveWordSaveVO reqVO = randomPojo(SensitiveWordSaveVO.class) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long sensitiveWordId = sensitiveWordService.createSensitiveWord(reqVO); - // 断言 - assertNotNull(sensitiveWordId); - // 校验记录的属性是否正确 - SensitiveWordDO sensitiveWord = sensitiveWordMapper.selectById(sensitiveWordId); - assertPojoEquals(reqVO, sensitiveWord, "id"); - } - - @Test - public void testUpdateSensitiveWord_success() { - // mock 数据 - SensitiveWordDO dbSensitiveWord = randomPojo(SensitiveWordDO.class); - sensitiveWordMapper.insert(dbSensitiveWord);// @Sql: 先插入出一条存在的数据 - // 准备参数 - SensitiveWordSaveVO reqVO = randomPojo(SensitiveWordSaveVO.class, o -> { - o.setId(dbSensitiveWord.getId()); // 设置更新的 ID - }); - - // 调用 - sensitiveWordService.updateSensitiveWord(reqVO); - // 校验是否更新正确 - SensitiveWordDO sensitiveWord = sensitiveWordMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, sensitiveWord); - } - - @Test - public void testUpdateSensitiveWord_notExists() { - // 准备参数 - SensitiveWordSaveVO reqVO = randomPojo(SensitiveWordSaveVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> sensitiveWordService.updateSensitiveWord(reqVO), SENSITIVE_WORD_NOT_EXISTS); - } - - @Test - public void testDeleteSensitiveWord_success() { - // mock 数据 - SensitiveWordDO dbSensitiveWord = randomPojo(SensitiveWordDO.class); - sensitiveWordMapper.insert(dbSensitiveWord);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSensitiveWord.getId(); - - // 调用 - sensitiveWordService.deleteSensitiveWord(id); - // 校验数据不存在了 - assertNull(sensitiveWordMapper.selectById(id)); - } - - @Test - public void testDeleteSensitiveWord_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> sensitiveWordService.deleteSensitiveWord(id), SENSITIVE_WORD_NOT_EXISTS); - } - - @Test - public void testGetSensitiveWord() { - // mock 数据 - SensitiveWordDO sensitiveWord = randomPojo(SensitiveWordDO.class); - sensitiveWordMapper.insert(sensitiveWord); - // 准备参数 - Long id = sensitiveWord.getId(); - - // 调用 - SensitiveWordDO dbSensitiveWord = sensitiveWordService.getSensitiveWord(id); - // 断言 - assertPojoEquals(sensitiveWord, dbSensitiveWord); - } - - @Test - public void testGetSensitiveWordList() { - // mock 数据 - SensitiveWordDO sensitiveWord01 = randomPojo(SensitiveWordDO.class); - sensitiveWordMapper.insert(sensitiveWord01); - SensitiveWordDO sensitiveWord02 = randomPojo(SensitiveWordDO.class); - sensitiveWordMapper.insert(sensitiveWord02); - - // 调用 - List list = sensitiveWordService.getSensitiveWordList(); - // 断言 - assertEquals(2, list.size()); - assertEquals(sensitiveWord01, list.get(0)); - assertEquals(sensitiveWord02, list.get(1)); - } - - @Test - public void testGetSensitiveWordPage() { - // mock 数据 - SensitiveWordDO dbSensitiveWord = randomPojo(SensitiveWordDO.class, o -> { // 等会查询到 - o.setName("笨蛋"); - o.setTags(Arrays.asList("论坛", "蔬菜")); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2022, 2, 8)); - }); - sensitiveWordMapper.insert(dbSensitiveWord); - // 测试 name 不匹配 - sensitiveWordMapper.insert(cloneIgnoreId(dbSensitiveWord, o -> o.setName("傻瓜"))); - // 测试 tags 不匹配 - sensitiveWordMapper.insert(cloneIgnoreId(dbSensitiveWord, o -> o.setTags(Arrays.asList("短信", "日用品")))); - // 测试 createTime 不匹配 - sensitiveWordMapper.insert(cloneIgnoreId(dbSensitiveWord, o -> o.setCreateTime(buildTime(2022, 2, 16)))); - // 准备参数 - SensitiveWordPageReqVO reqVO = new SensitiveWordPageReqVO(); - reqVO.setName("笨"); - reqVO.setTag("论坛"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2022, 2, 1, 2022, 2, 12)); - - // 调用 - PageResult pageResult = sensitiveWordService.getSensitiveWordPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSensitiveWord, pageResult.getList().get(0)); - } - - @Test - public void testValidateText_noTag() { - testInitLocalCache(); - // 准备参数 - String text = "你是傻瓜,你是笨蛋"; - // 调用 - List result = sensitiveWordService.validateText(text, null); - // 断言 - assertEquals(Arrays.asList("傻瓜", "笨蛋"), result); - - // 准备参数 - String text2 = "你是傻瓜,你是笨蛋,你是白"; - // 调用 - List result2 = sensitiveWordService.validateText(text2, null); - // 断言 - assertEquals(Arrays.asList("傻瓜", "笨蛋","白"), result2); - } - - @Test - public void testValidateText_hasTag() { - testInitLocalCache(); - // 准备参数 - String text = "你是傻瓜,你是笨蛋"; - // 调用 - List result = sensitiveWordService.validateText(text, singletonList("论坛")); - // 断言 - assertEquals(singletonList("傻瓜"), result); - - - // 准备参数 - String text2 = "你是白"; - // 调用 - List result2 = sensitiveWordService.validateText(text2, singletonList("测试")); - // 断言 - assertEquals(singletonList("白"), result2); - } - - @Test - public void testIsTestValid_noTag() { - testInitLocalCache(); - // 准备参数 - String text = "你是傻瓜,你是笨蛋"; - // 调用,断言 - assertFalse(sensitiveWordService.isTextValid(text, null)); - - // 准备参数 - String text2 = "你是白"; - // 调用,断言 - assertFalse(sensitiveWordService.isTextValid(text2, null)); - } - - @Test - public void testIsTestValid_hasTag() { - testInitLocalCache(); - // 准备参数 - String text = "你是傻瓜,你是笨蛋"; - // 调用,断言 - assertFalse(sensitiveWordService.isTextValid(text, singletonList("论坛"))); - - // 准备参数 - String text2 = "你是白"; - // 调用,断言 - assertFalse(sensitiveWordService.isTextValid(text2, singletonList("测试"))); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsChannelServiceTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsChannelServiceTest.java deleted file mode 100644 index 02842ea284..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsChannelServiceTest.java +++ /dev/null @@ -1,236 +0,0 @@ -package cn.iocoder.yudao.module.system.service.sms; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.sms.core.client.SmsClient; -import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; -import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; -import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.SMS_CHANNEL_HAS_CHILDREN; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.SMS_CHANNEL_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -@Import(SmsChannelServiceImpl.class) -public class SmsChannelServiceTest extends BaseDbUnitTest { - - @Resource - private SmsChannelServiceImpl smsChannelService; - - @Resource - private SmsChannelMapper smsChannelMapper; - - @MockBean - private SmsClientFactory smsClientFactory; - @MockBean - private SmsTemplateService smsTemplateService; - - @Test - public void testCreateSmsChannel_success() { - // 准备参数 - SmsChannelSaveReqVO reqVO = randomPojo(SmsChannelSaveReqVO.class, o -> o.setStatus(randomCommonStatus())) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long smsChannelId = smsChannelService.createSmsChannel(reqVO); - // 断言 - assertNotNull(smsChannelId); - // 校验记录的属性是否正确 - SmsChannelDO smsChannel = smsChannelMapper.selectById(smsChannelId); - assertPojoEquals(reqVO, smsChannel, "id"); - // 断言 cache - assertNull(smsChannelService.getIdClientCache().getIfPresent(smsChannel.getId())); - assertNull(smsChannelService.getCodeClientCache().getIfPresent(smsChannel.getCode())); - } - - @Test - public void testUpdateSmsChannel_success() { - // mock 数据 - SmsChannelDO dbSmsChannel = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(dbSmsChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - SmsChannelSaveReqVO reqVO = randomPojo(SmsChannelSaveReqVO.class, o -> { - o.setId(dbSmsChannel.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - o.setCallbackUrl(randomString()); - }); - - // 调用 - smsChannelService.updateSmsChannel(reqVO); - // 校验是否更新正确 - SmsChannelDO smsChannel = smsChannelMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, smsChannel); - // 断言 cache - assertNull(smsChannelService.getIdClientCache().getIfPresent(smsChannel.getId())); - assertNull(smsChannelService.getCodeClientCache().getIfPresent(smsChannel.getCode())); - } - - @Test - public void testUpdateSmsChannel_notExists() { - // 准备参数 - SmsChannelSaveReqVO reqVO = randomPojo(SmsChannelSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> smsChannelService.updateSmsChannel(reqVO), SMS_CHANNEL_NOT_EXISTS); - } - - @Test - public void testDeleteSmsChannel_success() { - // mock 数据 - SmsChannelDO dbSmsChannel = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(dbSmsChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSmsChannel.getId(); - - // 调用 - smsChannelService.deleteSmsChannel(id); - // 校验数据不存在了 - assertNull(smsChannelMapper.selectById(id)); - // 断言 cache - assertNull(smsChannelService.getIdClientCache().getIfPresent(dbSmsChannel.getId())); - assertNull(smsChannelService.getCodeClientCache().getIfPresent(dbSmsChannel.getCode())); - } - - @Test - public void testDeleteSmsChannel_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> smsChannelService.deleteSmsChannel(id), SMS_CHANNEL_NOT_EXISTS); - } - - @Test - public void testDeleteSmsChannel_hasChildren() { - // mock 数据 - SmsChannelDO dbSmsChannel = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(dbSmsChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSmsChannel.getId(); - // mock 方法 - when(smsTemplateService.getSmsTemplateCountByChannelId(eq(id))).thenReturn(10L); - - // 调用, 并断言异常 - assertServiceException(() -> smsChannelService.deleteSmsChannel(id), SMS_CHANNEL_HAS_CHILDREN); - } - - @Test - public void testGetSmsChannel() { - // mock 数据 - SmsChannelDO dbSmsChannel = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(dbSmsChannel); // @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSmsChannel.getId(); - - // 调用,并断言 - assertPojoEquals(dbSmsChannel, smsChannelService.getSmsChannel(id)); - } - - @Test - public void testGetSmsChannelList() { - // mock 数据 - SmsChannelDO dbSmsChannel01 = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(dbSmsChannel01); - SmsChannelDO dbSmsChannel02 = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(dbSmsChannel02); - // 准备参数 - - // 调用 - List list = smsChannelService.getSmsChannelList(); - // 断言 - assertEquals(2, list.size()); - assertPojoEquals(dbSmsChannel01, list.get(0)); - assertPojoEquals(dbSmsChannel02, list.get(1)); - } - - @Test - public void testGetSmsChannelPage() { - // mock 数据 - SmsChannelDO dbSmsChannel = randomPojo(SmsChannelDO.class, o -> { // 等会查询到 - o.setSignature("芋道源码"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2020, 12, 12)); - }); - smsChannelMapper.insert(dbSmsChannel); - // 测试 signature 不匹配 - smsChannelMapper.insert(cloneIgnoreId(dbSmsChannel, o -> o.setSignature("源码"))); - // 测试 status 不匹配 - smsChannelMapper.insert(cloneIgnoreId(dbSmsChannel, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - smsChannelMapper.insert(cloneIgnoreId(dbSmsChannel, o -> o.setCreateTime(buildTime(2020, 11, 11)))); - // 准备参数 - SmsChannelPageReqVO reqVO = new SmsChannelPageReqVO(); - reqVO.setSignature("芋道"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2020, 12, 1, 2020, 12, 24)); - - // 调用 - PageResult pageResult = smsChannelService.getSmsChannelPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSmsChannel, pageResult.getList().get(0)); - } - - @Test - public void testGetSmsClient_id() { - // mock 数据 - SmsChannelDO channel = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(channel); - // mock 参数 - Long id = channel.getId(); - // mock 方法 - SmsClient mockClient = mock(SmsClient.class); - when(smsClientFactory.getSmsClient(eq(id))).thenReturn(mockClient); - - // 调用 - SmsClient client = smsChannelService.getSmsClient(id); - // 断言 - assertSame(client, mockClient); - verify(smsClientFactory).createOrUpdateSmsClient(argThat(arg -> { - SmsChannelProperties properties = BeanUtils.toBean(channel, SmsChannelProperties.class); - return properties.equals(arg); - })); - } - - @Test - public void testGetSmsClient_code() { - // mock 数据 - SmsChannelDO channel = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(channel); - // mock 参数 - String code = channel.getCode(); - // mock 方法 - SmsClient mockClient = mock(SmsClient.class); - when(smsClientFactory.getSmsClient(eq(code))).thenReturn(mockClient); - - // 调用 - SmsClient client = smsChannelService.getSmsClient(code); - // 断言 - assertSame(client, mockClient); - verify(smsClientFactory).createOrUpdateSmsClient(argThat(arg -> { - SmsChannelProperties properties = BeanUtils.toBean(channel, SmsChannelProperties.class); - return properties.equals(arg); - })); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsCodeServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsCodeServiceImplTest.java deleted file mode 100644 index 2888dcefe7..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsCodeServiceImplTest.java +++ /dev/null @@ -1,209 +0,0 @@ -package cn.iocoder.yudao.module.system.service.sms; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeSendReqDTO; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeValidateReqDTO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsCodeDO; -import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsCodeMapper; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import cn.iocoder.yudao.module.system.framework.sms.SmsCodeProperties; -import com.baomidou.mybatisplus.annotation.DbType; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -@Import(SmsCodeServiceImpl.class) -public class SmsCodeServiceImplTest extends BaseDbUnitTest { - - @Resource - private SmsCodeServiceImpl smsCodeService; - - @Resource - private SmsCodeMapper smsCodeMapper; - - @MockBean - private SmsCodeProperties smsCodeProperties; - @MockBean - private SmsSendService smsSendService; - - @BeforeEach - public void setUp() { - when(smsCodeProperties.getExpireTimes()).thenReturn(Duration.ofMinutes(5)); - when(smsCodeProperties.getSendFrequency()).thenReturn(Duration.ofMinutes(1)); - when(smsCodeProperties.getSendMaximumQuantityPerDay()).thenReturn(10); - when(smsCodeProperties.getBeginCode()).thenReturn(9999); - when(smsCodeProperties.getEndCode()).thenReturn(9999); - } - - @Test - public void sendSmsCode_success() { - // 准备参数 - SmsCodeSendReqDTO reqDTO = randomPojo(SmsCodeSendReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(SmsSceneEnum.MEMBER_LOGIN.getScene()); - }); - // mock 方法 - SqlConstants.init(DbType.MYSQL); - - // 调用 - smsCodeService.sendSmsCode(reqDTO); - // 断言 code 验证码 - SmsCodeDO smsCodeDO = smsCodeMapper.selectOne(null); - assertPojoEquals(reqDTO, smsCodeDO); - assertEquals("9999", smsCodeDO.getCode()); - assertEquals(1, smsCodeDO.getTodayIndex()); - assertFalse(smsCodeDO.getUsed()); - // 断言调用 - verify(smsSendService).sendSingleSms(eq(reqDTO.getMobile()), isNull(), isNull(), - eq("user-sms-login"), eq(MapUtil.of("code", "9999"))); - } - - @Test - public void sendSmsCode_tooFast() { - // mock 数据 - SmsCodeDO smsCodeDO = randomPojo(SmsCodeDO.class, - o -> o.setMobile("15601691300").setTodayIndex(1)); - smsCodeMapper.insert(smsCodeDO); - // 准备参数 - SmsCodeSendReqDTO reqDTO = randomPojo(SmsCodeSendReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(SmsSceneEnum.MEMBER_LOGIN.getScene()); - }); - // mock 方法 - SqlConstants.init(DbType.MYSQL); - - // 调用,并断言异常 - assertServiceException(() -> smsCodeService.sendSmsCode(reqDTO), - SMS_CODE_SEND_TOO_FAST); - } - - @Test - public void sendSmsCode_exceedDay() { - // mock 数据 - SmsCodeDO smsCodeDO = randomPojo(SmsCodeDO.class, - o -> o.setMobile("15601691300").setTodayIndex(10).setCreateTime(LocalDateTime.now())); - smsCodeMapper.insert(smsCodeDO); - // 准备参数 - SmsCodeSendReqDTO reqDTO = randomPojo(SmsCodeSendReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(SmsSceneEnum.MEMBER_LOGIN.getScene()); - }); - // mock 方法 - SqlConstants.init(DbType.MYSQL); - when(smsCodeProperties.getSendFrequency()).thenReturn(Duration.ofMillis(0)); - - // 调用,并断言异常 - assertServiceException(() -> smsCodeService.sendSmsCode(reqDTO), - SMS_CODE_EXCEED_SEND_MAXIMUM_QUANTITY_PER_DAY); - } - - @Test - public void testUseSmsCode_success() { - // 准备参数 - SmsCodeUseReqDTO reqDTO = randomPojo(SmsCodeUseReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(randomEle(SmsSceneEnum.values()).getScene()); - }); - // mock 数据 - SqlConstants.init(DbType.MYSQL); - smsCodeMapper.insert(randomPojo(SmsCodeDO.class, o -> { - o.setMobile(reqDTO.getMobile()).setScene(reqDTO.getScene()) - .setCode(reqDTO.getCode()).setUsed(false); - })); - - // 调用 - smsCodeService.useSmsCode(reqDTO); - // 断言 - SmsCodeDO smsCodeDO = smsCodeMapper.selectOne(null); - assertTrue(smsCodeDO.getUsed()); - assertNotNull(smsCodeDO.getUsedTime()); - assertEquals(reqDTO.getUsedIp(), smsCodeDO.getUsedIp()); - } - - @Test - public void validateSmsCode_success() { - // 准备参数 - SmsCodeValidateReqDTO reqDTO = randomPojo(SmsCodeValidateReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(randomEle(SmsSceneEnum.values()).getScene()); - }); - // mock 数据 - SqlConstants.init(DbType.MYSQL); - smsCodeMapper.insert(randomPojo(SmsCodeDO.class, o -> o.setMobile(reqDTO.getMobile()) - .setScene(reqDTO.getScene()).setCode(reqDTO.getCode()).setUsed(false))); - - // 调用 - smsCodeService.validateSmsCode(reqDTO); - } - - @Test - public void validateSmsCode_notFound() { - // 准备参数 - SmsCodeValidateReqDTO reqDTO = randomPojo(SmsCodeValidateReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(randomEle(SmsSceneEnum.values()).getScene()); - }); - // mock 数据 - SqlConstants.init(DbType.MYSQL); - - // 调用,并断言异常 - assertServiceException(() -> smsCodeService.validateSmsCode(reqDTO), - SMS_CODE_NOT_FOUND); - } - - @Test - public void validateSmsCode_expired() { - // 准备参数 - SmsCodeValidateReqDTO reqDTO = randomPojo(SmsCodeValidateReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(randomEle(SmsSceneEnum.values()).getScene()); - }); - // mock 数据 - SqlConstants.init(DbType.MYSQL); - smsCodeMapper.insert(randomPojo(SmsCodeDO.class, o -> o.setMobile(reqDTO.getMobile()) - .setScene(reqDTO.getScene()).setCode(reqDTO.getCode()).setUsed(false) - .setCreateTime(LocalDateTime.now().minusMinutes(6)))); - - // 调用,并断言异常 - assertServiceException(() -> smsCodeService.validateSmsCode(reqDTO), - SMS_CODE_EXPIRED); - } - - @Test - public void validateSmsCode_used() { - // 准备参数 - SmsCodeValidateReqDTO reqDTO = randomPojo(SmsCodeValidateReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(randomEle(SmsSceneEnum.values()).getScene()); - }); - // mock 数据 - SqlConstants.init(DbType.MYSQL); - smsCodeMapper.insert(randomPojo(SmsCodeDO.class, o -> o.setMobile(reqDTO.getMobile()) - .setScene(reqDTO.getScene()).setCode(reqDTO.getCode()).setUsed(true) - .setCreateTime(LocalDateTime.now()))); - - // 调用,并断言异常 - assertServiceException(() -> smsCodeService.validateSmsCode(reqDTO), - SMS_CODE_USED); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsLogServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsLogServiceImplTest.java deleted file mode 100644 index 570e8ceea5..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsLogServiceImplTest.java +++ /dev/null @@ -1,190 +0,0 @@ -package cn.iocoder.yudao.module.system.service.sms; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; -import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsLogMapper; -import cn.iocoder.yudao.module.system.enums.sms.SmsReceiveStatusEnum; -import cn.iocoder.yudao.module.system.enums.sms.SmsSendStatusEnum; -import cn.iocoder.yudao.module.system.enums.sms.SmsTemplateTypeEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Map; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomBoolean; -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -@Import(SmsLogServiceImpl.class) -public class SmsLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private SmsLogServiceImpl smsLogService; - - @Resource - private SmsLogMapper smsLogMapper; - - @Test - public void testGetSmsLogPage() { - // mock 数据 - SmsLogDO dbSmsLog = randomSmsLogDO(o -> { // 等会查询到 - o.setChannelId(1L); - o.setTemplateId(10L); - o.setMobile("15601691300"); - o.setSendStatus(SmsSendStatusEnum.INIT.getStatus()); - o.setSendTime(buildTime(2020, 11, 11)); - o.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus()); - o.setReceiveTime(buildTime(2021, 11, 11)); - }); - smsLogMapper.insert(dbSmsLog); - // 测试 channelId 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setChannelId(2L))); - // 测试 templateId 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setTemplateId(20L))); - // 测试 mobile 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setMobile("18818260999"))); - // 测试 sendStatus 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setSendStatus(SmsSendStatusEnum.IGNORE.getStatus()))); - // 测试 sendTime 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setSendTime(buildTime(2020, 12, 12)))); - // 测试 receiveStatus 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setReceiveStatus(SmsReceiveStatusEnum.SUCCESS.getStatus()))); - // 测试 receiveTime 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setReceiveTime(buildTime(2021, 12, 12)))); - // 准备参数 - SmsLogPageReqVO reqVO = new SmsLogPageReqVO(); - reqVO.setChannelId(1L); - reqVO.setTemplateId(10L); - reqVO.setMobile("156"); - reqVO.setSendStatus(SmsSendStatusEnum.INIT.getStatus()); - reqVO.setSendTime(buildBetweenTime(2020, 11, 1, 2020, 11, 30)); - reqVO.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus()); - reqVO.setReceiveTime(buildBetweenTime(2021, 11, 1, 2021, 11, 30)); - - // 调用 - PageResult pageResult = smsLogService.getSmsLogPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSmsLog, pageResult.getList().get(0)); - } - - @Test - public void testCreateSmsLog() { - // 准备参数 - String mobile = randomString(); - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - Boolean isSend = randomBoolean(); - SmsTemplateDO templateDO = randomPojo(SmsTemplateDO.class, - o -> o.setType(randomEle(SmsTemplateTypeEnum.values()).getType())); - String templateContent = randomString(); - Map templateParams = randomTemplateParams(); - // mock 方法 - - // 调用 - Long logId = smsLogService.createSmsLog(mobile, userId, userType, isSend, - templateDO, templateContent, templateParams); - // 断言 - SmsLogDO logDO = smsLogMapper.selectById(logId); - assertEquals(isSend ? SmsSendStatusEnum.INIT.getStatus() : SmsSendStatusEnum.IGNORE.getStatus(), - logDO.getSendStatus()); - assertEquals(mobile, logDO.getMobile()); - assertEquals(userType, logDO.getUserType()); - assertEquals(userId, logDO.getUserId()); - assertEquals(templateDO.getId(), logDO.getTemplateId()); - assertEquals(templateDO.getCode(), logDO.getTemplateCode()); - assertEquals(templateDO.getType(), logDO.getTemplateType()); - assertEquals(templateDO.getChannelId(), logDO.getChannelId()); - assertEquals(templateDO.getChannelCode(), logDO.getChannelCode()); - assertEquals(templateContent, logDO.getTemplateContent()); - assertEquals(templateParams, logDO.getTemplateParams()); - assertEquals(SmsReceiveStatusEnum.INIT.getStatus(), logDO.getReceiveStatus()); - } - - @Test - public void testUpdateSmsSendResult() { - // mock 数据 - SmsLogDO dbSmsLog = randomSmsLogDO( - o -> o.setSendStatus(SmsSendStatusEnum.IGNORE.getStatus())); - smsLogMapper.insert(dbSmsLog); - // 准备参数 - Long id = dbSmsLog.getId(); - Boolean success = randomBoolean(); - String apiSendCode = randomString(); - String apiSendMsg = randomString(); - String apiRequestId = randomString(); - String apiSerialNo = randomString(); - - // 调用 - smsLogService.updateSmsSendResult(id, success, - apiSendCode, apiSendMsg, apiRequestId, apiSerialNo); - // 断言 - dbSmsLog = smsLogMapper.selectById(id); - assertEquals(success ? SmsSendStatusEnum.SUCCESS.getStatus() : SmsSendStatusEnum.FAILURE.getStatus(), - dbSmsLog.getSendStatus()); - assertNotNull(dbSmsLog.getSendTime()); - assertEquals(apiSendCode, dbSmsLog.getApiSendCode()); - assertEquals(apiSendMsg, dbSmsLog.getApiSendMsg()); - assertEquals(apiRequestId, dbSmsLog.getApiRequestId()); - assertEquals(apiSerialNo, dbSmsLog.getApiSerialNo()); - } - - @Test - public void testUpdateSmsReceiveResult() { - // mock 数据 - SmsLogDO dbSmsLog = randomSmsLogDO( - o -> o.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus())); - smsLogMapper.insert(dbSmsLog); - // 准备参数 - Long id = dbSmsLog.getId(); - Boolean success = randomBoolean(); - LocalDateTime receiveTime = randomLocalDateTime(); - String apiReceiveCode = randomString(); - String apiReceiveMsg = randomString(); - - // 调用 - smsLogService.updateSmsReceiveResult(id, success, receiveTime, apiReceiveCode, apiReceiveMsg); - // 断言 - dbSmsLog = smsLogMapper.selectById(id); - assertEquals(success ? SmsReceiveStatusEnum.SUCCESS.getStatus() - : SmsReceiveStatusEnum.FAILURE.getStatus(), dbSmsLog.getReceiveStatus()); - assertEquals(receiveTime, dbSmsLog.getReceiveTime()); - assertEquals(apiReceiveCode, dbSmsLog.getApiReceiveCode()); - assertEquals(apiReceiveMsg, dbSmsLog.getApiReceiveMsg()); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static SmsLogDO randomSmsLogDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setTemplateParams(randomTemplateParams()); - o.setTemplateType(randomEle(SmsTemplateTypeEnum.values()).getType()); // 保证 templateType 的范围 - o.setUserType(randomEle(UserTypeEnum.values()).getValue()); // 保证 userType 的范围 - o.setSendStatus(randomEle(SmsSendStatusEnum.values()).getStatus()); // 保证 sendStatus 的范围 - o.setReceiveStatus(randomEle(SmsReceiveStatusEnum.values()).getStatus()); // 保证 receiveStatus 的范围 - }; - return randomPojo(SmsLogDO.class, ArrayUtils.append(consumer, consumers)); - } - - private static Map randomTemplateParams() { - return MapUtil.builder().put(randomString(), randomString()) - .put(randomString(), randomString()).build(); - } -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImplTest.java deleted file mode 100644 index 6e35fe31ad..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImplTest.java +++ /dev/null @@ -1,298 +0,0 @@ -package cn.iocoder.yudao.module.system.service.sms; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.sms.core.client.SmsClient; -import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO; -import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.mq.message.sms.SmsSendMessage; -import cn.iocoder.yudao.module.system.mq.producer.sms.SmsProducer; -import cn.iocoder.yudao.module.system.service.member.MemberService; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -public class SmsSendServiceImplTest extends BaseMockitoUnitTest { - - @InjectMocks - private SmsSendServiceImpl smsSendService; - - @Mock - private AdminUserService adminUserService; - @Mock - private MemberService memberService; - @Mock - private SmsChannelService smsChannelService; - @Mock - private SmsTemplateService smsTemplateService; - @Mock - private SmsLogService smsLogService; - @Mock - private SmsProducer smsProducer; - - @Test - public void testSendSingleSmsToAdmin() { - // 准备参数 - Long userId = randomLongId(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock adminUserService 的方法 - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setMobile("15601691300")); - when(adminUserService.getUser(eq(userId))).thenReturn(user); - - // mock SmsTemplateService 的方法 - SmsTemplateDO template = randomPojo(SmsTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(smsTemplateService.getSmsTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(smsTemplateService.formatSmsTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock SmsChannelService 的方法 - SmsChannelDO smsChannel = randomPojo(SmsChannelDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(smsChannelService.getSmsChannel(eq(template.getChannelId()))).thenReturn(smsChannel); - // mock SmsLogService 的方法 - Long smsLogId = randomLongId(); - when(smsLogService.createSmsLog(eq(user.getMobile()), eq(userId), eq(UserTypeEnum.ADMIN.getValue()), eq(Boolean.TRUE), eq(template), - eq(content), eq(templateParams))).thenReturn(smsLogId); - - // 调用 - Long resultSmsLogId = smsSendService.sendSingleSmsToAdmin(null, userId, templateCode, templateParams); - // 断言 - assertEquals(smsLogId, resultSmsLogId); - // 断言调用 - verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(user.getMobile()), - eq(template.getChannelId()), eq(template.getApiTemplateId()), - eq(Lists.newArrayList(new KeyValue<>("code", "1234"), new KeyValue<>("op", "login")))); - } - - @Test - public void testSendSingleSmsToUser() { - // 准备参数 - Long userId = randomLongId(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock memberService 的方法 - String mobile = "15601691300"; - when(memberService.getMemberUserMobile(eq(userId))).thenReturn(mobile); - - // mock SmsTemplateService 的方法 - SmsTemplateDO template = randomPojo(SmsTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(smsTemplateService.getSmsTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(smsTemplateService.formatSmsTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock SmsChannelService 的方法 - SmsChannelDO smsChannel = randomPojo(SmsChannelDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(smsChannelService.getSmsChannel(eq(template.getChannelId()))).thenReturn(smsChannel); - // mock SmsLogService 的方法 - Long smsLogId = randomLongId(); - when(smsLogService.createSmsLog(eq(mobile), eq(userId), eq(UserTypeEnum.MEMBER.getValue()), eq(Boolean.TRUE), eq(template), - eq(content), eq(templateParams))).thenReturn(smsLogId); - - // 调用 - Long resultSmsLogId = smsSendService.sendSingleSmsToMember(null, userId, templateCode, templateParams); - // 断言 - assertEquals(smsLogId, resultSmsLogId); - // 断言调用 - verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(mobile), - eq(template.getChannelId()), eq(template.getApiTemplateId()), - eq(Lists.newArrayList(new KeyValue<>("code", "1234"), new KeyValue<>("op", "login")))); - } - - /** - * 发送成功,当短信模板开启时 - */ - @Test - public void testSendSingleSms_successWhenSmsTemplateEnable() { - // 准备参数 - String mobile = randomString(); - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock SmsTemplateService 的方法 - SmsTemplateDO template = randomPojo(SmsTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(smsTemplateService.getSmsTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(smsTemplateService.formatSmsTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock SmsChannelService 的方法 - SmsChannelDO smsChannel = randomPojo(SmsChannelDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(smsChannelService.getSmsChannel(eq(template.getChannelId()))).thenReturn(smsChannel); - // mock SmsLogService 的方法 - Long smsLogId = randomLongId(); - when(smsLogService.createSmsLog(eq(mobile), eq(userId), eq(userType), eq(Boolean.TRUE), eq(template), - eq(content), eq(templateParams))).thenReturn(smsLogId); - - // 调用 - Long resultSmsLogId = smsSendService.sendSingleSms(mobile, userId, userType, templateCode, templateParams); - // 断言 - assertEquals(smsLogId, resultSmsLogId); - // 断言调用 - verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(mobile), - eq(template.getChannelId()), eq(template.getApiTemplateId()), - eq(Lists.newArrayList(new KeyValue<>("code", "1234"), new KeyValue<>("op", "login")))); - } - - /** - * 发送成功,当短信模板关闭时 - */ - @Test - public void testSendSingleSms_successWhenSmsTemplateDisable() { - // 准备参数 - String mobile = randomString(); - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock SmsTemplateService 的方法 - SmsTemplateDO template = randomPojo(SmsTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(smsTemplateService.getSmsTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(smsTemplateService.formatSmsTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock SmsChannelService 的方法 - SmsChannelDO smsChannel = randomPojo(SmsChannelDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(smsChannelService.getSmsChannel(eq(template.getChannelId()))).thenReturn(smsChannel); - // mock SmsLogService 的方法 - Long smsLogId = randomLongId(); - when(smsLogService.createSmsLog(eq(mobile), eq(userId), eq(userType), eq(Boolean.FALSE), eq(template), - eq(content), eq(templateParams))).thenReturn(smsLogId); - - // 调用 - Long resultSmsLogId = smsSendService.sendSingleSms(mobile, userId, userType, templateCode, templateParams); - // 断言 - assertEquals(smsLogId, resultSmsLogId); - // 断言调用 - verify(smsProducer, times(0)).sendSmsSendMessage(anyLong(), anyString(), - anyLong(), any(), anyList()); - } - - @Test - public void testCheckSmsTemplateValid_notExists() { - // 准备参数 - String templateCode = randomString(); - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> smsSendService.validateSmsTemplate(templateCode), - SMS_SEND_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testBuildTemplateParams_paramMiss() { - // 准备参数 - SmsTemplateDO template = randomPojo(SmsTemplateDO.class, - o -> o.setParams(Lists.newArrayList("code"))); - Map templateParams = new HashMap<>(); - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> smsSendService.buildTemplateParams(template, templateParams), - SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS, "code"); - } - - @Test - public void testCheckMobile_notExists() { - // 准备参数 - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> smsSendService.validateMobile(null), - SMS_SEND_MOBILE_NOT_EXISTS); - } - - @Test - public void testSendBatchNotify() { - // 准备参数 - // mock 方法 - - // 调用 - UnsupportedOperationException exception = Assertions.assertThrows( - UnsupportedOperationException.class, - () -> smsSendService.sendBatchSms(null, null, null, null, null) - ); - // 断言 - assertEquals("暂时不支持该操作,感兴趣可以实现该功能哟!", exception.getMessage()); - } - - @Test - @SuppressWarnings("unchecked") - public void testDoSendSms() throws Throwable { - // 准备参数 - SmsSendMessage message = randomPojo(SmsSendMessage.class); - // mock SmsClientFactory 的方法 - SmsClient smsClient = spy(SmsClient.class); - when(smsChannelService.getSmsClient(eq(message.getChannelId()))).thenReturn(smsClient); - // mock SmsClient 的方法 - SmsSendRespDTO sendResult = randomPojo(SmsSendRespDTO.class); - when(smsClient.sendSms(eq(message.getLogId()), eq(message.getMobile()), eq(message.getApiTemplateId()), - eq(message.getTemplateParams()))).thenReturn(sendResult); - - // 调用 - smsSendService.doSendSms(message); - // 断言 - verify(smsLogService).updateSmsSendResult(eq(message.getLogId()), - eq(sendResult.getSuccess()), eq(sendResult.getApiCode()), - eq(sendResult.getApiMsg()), eq(sendResult.getApiRequestId()), eq(sendResult.getSerialNo())); - } - - @Test - public void testReceiveSmsStatus() throws Throwable { - // 准备参数 - String channelCode = randomString(); - String text = randomString(); - // mock SmsClientFactory 的方法 - SmsClient smsClient = spy(SmsClient.class); - when(smsChannelService.getSmsClient(eq(channelCode))).thenReturn(smsClient); - // mock SmsClient 的方法 - List receiveResults = randomPojoList(SmsReceiveRespDTO.class); - - // 调用 - smsSendService.receiveSmsStatus(channelCode, text); - // 断言 - receiveResults.forEach(result -> smsLogService.updateSmsReceiveResult(eq(result.getLogId()), eq(result.getSuccess()), - eq(result.getReceiveTime()), eq(result.getErrorCode()), eq(result.getErrorCode()))); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateServiceImplTest.java deleted file mode 100644 index b4d0c0e0f1..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateServiceImplTest.java +++ /dev/null @@ -1,348 +0,0 @@ -package cn.iocoder.yudao.module.system.service.sms; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.sms.core.client.SmsClient; -import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO; -import cn.iocoder.yudao.framework.sms.core.enums.SmsTemplateAuditStatusEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; -import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsTemplateMapper; -import cn.iocoder.yudao.module.system.enums.sms.SmsTemplateTypeEnum; -import com.google.common.collect.Lists; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -@Import(SmsTemplateServiceImpl.class) -public class SmsTemplateServiceImplTest extends BaseDbUnitTest { - - @Resource - private SmsTemplateServiceImpl smsTemplateService; - - @Resource - private SmsTemplateMapper smsTemplateMapper; - - @MockBean - private SmsChannelService smsChannelService; - @MockBean - private SmsClient smsClient; - - @Test - public void testFormatSmsTemplateContent() { - // 准备参数 - String content = "正在进行登录操作{operation},您的验证码是{code}"; - Map params = MapUtil.builder("operation", "登录") - .put("code", "1234").build(); - - // 调用 - String result = smsTemplateService.formatSmsTemplateContent(content, params); - // 断言 - assertEquals("正在进行登录操作登录,您的验证码是1234", result); - } - - @Test - public void testParseTemplateContentParams() { - // 准备参数 - String content = "正在进行登录操作{operation},您的验证码是{code}"; - // mock 方法 - - // 调用 - List params = smsTemplateService.parseTemplateContentParams(content); - // 断言 - assertEquals(Lists.newArrayList("operation", "code"), params); - } - - @Test - @SuppressWarnings("unchecked") - public void testCreateSmsTemplate_success() throws Throwable { - // 准备参数 - SmsTemplateSaveReqVO reqVO = randomPojo(SmsTemplateSaveReqVO.class, o -> { - o.setContent("正在进行登录操作{operation},您的验证码是{code}"); - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setType(randomEle(SmsTemplateTypeEnum.values()).getType()); // 保证 type 的 范围 - }).setId(null); // 防止 id 被赋值 - // mock Channel 的方法 - SmsChannelDO channelDO = randomPojo(SmsChannelDO.class, o -> { - o.setId(reqVO.getChannelId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 保证 status 开启,创建必须处于这个状态 - }); - when(smsChannelService.getSmsChannel(eq(channelDO.getId()))).thenReturn(channelDO); - // mock 获得 API 短信模板成功 - when(smsChannelService.getSmsClient(eq(reqVO.getChannelId()))).thenReturn(smsClient); - when(smsClient.getSmsTemplate(eq(reqVO.getApiTemplateId()))).thenReturn( - randomPojo(SmsTemplateRespDTO.class, o -> o.setAuditStatus(SmsTemplateAuditStatusEnum.SUCCESS.getStatus()))); - - // 调用 - Long smsTemplateId = smsTemplateService.createSmsTemplate(reqVO); - // 断言 - assertNotNull(smsTemplateId); - // 校验记录的属性是否正确 - SmsTemplateDO smsTemplate = smsTemplateMapper.selectById(smsTemplateId); - assertPojoEquals(reqVO, smsTemplate, "id"); - assertEquals(Lists.newArrayList("operation", "code"), smsTemplate.getParams()); - assertEquals(channelDO.getCode(), smsTemplate.getChannelCode()); - } - - @Test - @SuppressWarnings("unchecked") - public void testUpdateSmsTemplate_success() throws Throwable { - // mock 数据 - SmsTemplateDO dbSmsTemplate = randomSmsTemplateDO(); - smsTemplateMapper.insert(dbSmsTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - SmsTemplateSaveReqVO reqVO = randomPojo(SmsTemplateSaveReqVO.class, o -> { - o.setId(dbSmsTemplate.getId()); // 设置更新的 ID - o.setContent("正在进行登录操作{operation},您的验证码是{code}"); - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setType(randomEle(SmsTemplateTypeEnum.values()).getType()); // 保证 type 的 范围 - }); - // mock 方法 - SmsChannelDO channelDO = randomPojo(SmsChannelDO.class, o -> { - o.setId(reqVO.getChannelId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 保证 status 开启,创建必须处于这个状态 - }); - when(smsChannelService.getSmsChannel(eq(channelDO.getId()))).thenReturn(channelDO); - // mock 获得 API 短信模板成功 - when(smsChannelService.getSmsClient(eq(reqVO.getChannelId()))).thenReturn(smsClient); - when(smsClient.getSmsTemplate(eq(reqVO.getApiTemplateId()))).thenReturn( - randomPojo(SmsTemplateRespDTO.class, o -> o.setAuditStatus(SmsTemplateAuditStatusEnum.SUCCESS.getStatus()))); - - // 调用 - smsTemplateService.updateSmsTemplate(reqVO); - // 校验是否更新正确 - SmsTemplateDO smsTemplate = smsTemplateMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, smsTemplate); - assertEquals(Lists.newArrayList("operation", "code"), smsTemplate.getParams()); - assertEquals(channelDO.getCode(), smsTemplate.getChannelCode()); - } - - @Test - public void testUpdateSmsTemplate_notExists() { - // 准备参数 - SmsTemplateSaveReqVO reqVO = randomPojo(SmsTemplateSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> smsTemplateService.updateSmsTemplate(reqVO), SMS_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testDeleteSmsTemplate_success() { - // mock 数据 - SmsTemplateDO dbSmsTemplate = randomSmsTemplateDO(); - smsTemplateMapper.insert(dbSmsTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSmsTemplate.getId(); - - // 调用 - smsTemplateService.deleteSmsTemplate(id); - // 校验数据不存在了 - assertNull(smsTemplateMapper.selectById(id)); - } - - @Test - public void testDeleteSmsTemplate_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> smsTemplateService.deleteSmsTemplate(id), SMS_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testGetSmsTemplate() { - // mock 数据 - SmsTemplateDO dbSmsTemplate = randomSmsTemplateDO(); - smsTemplateMapper.insert(dbSmsTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSmsTemplate.getId(); - - // 调用 - SmsTemplateDO smsTemplate = smsTemplateService.getSmsTemplate(id); - // 校验 - assertPojoEquals(dbSmsTemplate, smsTemplate); - } - - @Test - public void testGetSmsTemplateByCodeFromCache() { - // mock 数据 - SmsTemplateDO dbSmsTemplate = randomSmsTemplateDO(); - smsTemplateMapper.insert(dbSmsTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - String code = dbSmsTemplate.getCode(); - - // 调用 - SmsTemplateDO smsTemplate = smsTemplateService.getSmsTemplateByCodeFromCache(code); - // 校验 - assertPojoEquals(dbSmsTemplate, smsTemplate); - } - - @Test - public void testGetSmsTemplatePage() { - // mock 数据 - SmsTemplateDO dbSmsTemplate = randomPojo(SmsTemplateDO.class, o -> { // 等会查询到 - o.setType(SmsTemplateTypeEnum.PROMOTION.getType()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCode("tudou"); - o.setContent("芋道源码"); - o.setApiTemplateId("yunai"); - o.setChannelId(1L); - o.setCreateTime(buildTime(2021, 11, 11)); - }); - smsTemplateMapper.insert(dbSmsTemplate); - // 测试 type 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setType(SmsTemplateTypeEnum.VERIFICATION_CODE.getType()))); - // 测试 status 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 code 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setCode("yuanma"))); - // 测试 content 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setContent("源码"))); - // 测试 apiTemplateId 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setApiTemplateId("nai"))); - // 测试 channelId 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setChannelId(2L))); - // 测试 createTime 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setCreateTime(buildTime(2021, 12, 12)))); - // 准备参数 - SmsTemplatePageReqVO reqVO = new SmsTemplatePageReqVO(); - reqVO.setType(SmsTemplateTypeEnum.PROMOTION.getType()); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCode("tu"); - reqVO.setContent("芋道"); - reqVO.setApiTemplateId("yu"); - reqVO.setChannelId(1L); - reqVO.setCreateTime(buildBetweenTime(2021, 11, 1, 2021, 12, 1)); - - // 调用 - PageResult pageResult = smsTemplateService.getSmsTemplatePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSmsTemplate, pageResult.getList().get(0)); - } - - @Test - public void testGetSmsTemplateCountByChannelId() { - // mock 数据 - SmsTemplateDO dbSmsTemplate = randomPojo(SmsTemplateDO.class, o -> o.setChannelId(1L)); - smsTemplateMapper.insert(dbSmsTemplate); - // 测试 channelId 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setChannelId(2L))); - // 准备参数 - Long channelId = 1L; - - // 调用 - Long count = smsTemplateService.getSmsTemplateCountByChannelId(channelId); - // 断言 - assertEquals(1, count); - } - - @Test - public void testValidateSmsChannel_success() { - // 准备参数 - Long channelId = randomLongId(); - // mock 方法 - SmsChannelDO channelDO = randomPojo(SmsChannelDO.class, o -> { - o.setId(channelId); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 保证 status 开启,创建必须处于这个状态 - }); - when(smsChannelService.getSmsChannel(eq(channelId))).thenReturn(channelDO); - - // 调用 - SmsChannelDO returnChannelDO = smsTemplateService.validateSmsChannel(channelId); - // 断言 - assertPojoEquals(returnChannelDO, channelDO); - } - - @Test - public void testValidateSmsChannel_notExists() { - // 准备参数 - Long channelId = randomLongId(); - - // 调用,校验异常 - assertServiceException(() -> smsTemplateService.validateSmsChannel(channelId), - SMS_CHANNEL_NOT_EXISTS); - } - - @Test - public void testValidateSmsChannel_disable() { - // 准备参数 - Long channelId = randomLongId(); - // mock 方法 - SmsChannelDO channelDO = randomPojo(SmsChannelDO.class, o -> { - o.setId(channelId); - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); // 保证 status 禁用,触发失败 - }); - when(smsChannelService.getSmsChannel(eq(channelId))).thenReturn(channelDO); - - // 调用,校验异常 - assertServiceException(() -> smsTemplateService.validateSmsChannel(channelId), - SMS_CHANNEL_DISABLE); - } - - @Test - public void testValidateDictDataValueUnique_success() { - // 调用,成功 - smsTemplateService.validateSmsTemplateCodeDuplicate(randomLongId(), randomString()); - } - - @Test - public void testValidateSmsTemplateCodeDuplicate_valueDuplicateForCreate() { - // 准备参数 - String code = randomString(); - // mock 数据 - smsTemplateMapper.insert(randomSmsTemplateDO(o -> o.setCode(code))); - - // 调用,校验异常 - assertServiceException(() -> smsTemplateService.validateSmsTemplateCodeDuplicate(null, code), - SMS_TEMPLATE_CODE_DUPLICATE, code); - } - - @Test - public void testValidateDictDataValueUnique_valueDuplicateForUpdate() { - // 准备参数 - Long id = randomLongId(); - String code = randomString(); - // mock 数据 - smsTemplateMapper.insert(randomSmsTemplateDO(o -> o.setCode(code))); - - // 调用,校验异常 - assertServiceException(() -> smsTemplateService.validateSmsTemplateCodeDuplicate(id, code), - SMS_TEMPLATE_CODE_DUPLICATE, code); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static SmsTemplateDO randomSmsTemplateDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setType(randomEle(SmsTemplateTypeEnum.values()).getType()); // 保证 type 的 范围 - }; - return randomPojo(SmsTemplateDO.class, ArrayUtils.append(consumer, consumers)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImplTest.java deleted file mode 100644 index fba8ff07e6..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImplTest.java +++ /dev/null @@ -1,472 +0,0 @@ -package cn.iocoder.yudao.module.system.service.social; - -import cn.binarywang.wx.miniapp.api.WxMaService; -import cn.binarywang.wx.miniapp.api.WxMaUserService; -import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; -import cn.iocoder.yudao.module.system.dal.mysql.social.SocialClientMapper; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import com.binarywang.spring.starter.wxjava.miniapp.properties.WxMaProperties; -import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties; -import com.xingyuv.jushauth.config.AuthConfig; -import com.xingyuv.jushauth.model.AuthResponse; -import com.xingyuv.jushauth.model.AuthUser; -import com.xingyuv.jushauth.request.AuthDefaultRequest; -import com.xingyuv.jushauth.request.AuthRequest; -import com.xingyuv.jushauth.utils.AuthStateUtils; -import com.xingyuv.justauth.AuthRequestFactory; -import me.chanjar.weixin.common.bean.WxJsapiSignature; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.data.redis.core.StringRedisTemplate; - -import jakarta.annotation.Resource; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link SocialClientServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(SocialClientServiceImpl.class) -public class SocialClientServiceImplTest extends BaseDbUnitTest { - - @Resource - private SocialClientServiceImpl socialClientService; - - @Resource - private SocialClientMapper socialClientMapper; - - @MockBean - private AuthRequestFactory authRequestFactory; - - @MockBean - private WxMpService wxMpService; - @MockBean - private WxMpProperties wxMpProperties; - @MockBean - private StringRedisTemplate stringRedisTemplate; - @MockBean - private WxMaService wxMaService; - @MockBean - private WxMaProperties wxMaProperties; - - @Test - public void testGetAuthorizeUrl() { - try (MockedStatic authStateUtilsMock = mockStatic(AuthStateUtils.class)) { - // 准备参数 - Integer socialType = SocialTypeEnum.WECHAT_MP.getType(); - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - String redirectUri = "sss"; - // mock 获得对应的 AuthRequest 实现 - AuthRequest authRequest = mock(AuthRequest.class); - when(authRequestFactory.get(eq("WECHAT_MP"))).thenReturn(authRequest); - // mock 方法 - authStateUtilsMock.when(AuthStateUtils::createState).thenReturn("aoteman"); - when(authRequest.authorize(eq("aoteman"))).thenReturn("https://www.iocoder.cn?redirect_uri=yyy"); - - // 调用 - String url = socialClientService.getAuthorizeUrl(socialType, userType, redirectUri); - // 断言 - assertEquals("https://www.iocoder.cn?redirect_uri=sss", url); - } - } - - @Test - public void testAuthSocialUser_success() { - // 准备参数 - Integer socialType = SocialTypeEnum.WECHAT_MP.getType(); - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - String code = randomString(); - String state = randomString(); - // mock 方法(AuthRequest) - AuthRequest authRequest = mock(AuthRequest.class); - when(authRequestFactory.get(eq("WECHAT_MP"))).thenReturn(authRequest); - // mock 方法(AuthResponse) - AuthUser authUser = randomPojo(AuthUser.class); - AuthResponse authResponse = new AuthResponse<>(2000, null, authUser); - when(authRequest.login(argThat(authCallback -> { - assertEquals(code, authCallback.getCode()); - assertEquals(state, authCallback.getState()); - return true; - }))).thenReturn(authResponse); - - // 调用 - AuthUser result = socialClientService.getAuthUser(socialType, userType, code, state); - // 断言 - assertSame(authUser, result); - } - - @Test - public void testAuthSocialUser_fail() { - // 准备参数 - Integer socialType = SocialTypeEnum.WECHAT_MP.getType(); - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - String code = randomString(); - String state = randomString(); - // mock 方法(AuthRequest) - AuthRequest authRequest = mock(AuthRequest.class); - when(authRequestFactory.get(eq("WECHAT_MP"))).thenReturn(authRequest); - // mock 方法(AuthResponse) - AuthResponse authResponse = new AuthResponse<>(0, "模拟失败", null); - when(authRequest.login(argThat(authCallback -> { - assertEquals(code, authCallback.getCode()); - assertEquals(state, authCallback.getState()); - return true; - }))).thenReturn(authResponse); - - // 调用并断言 - assertServiceException( - () -> socialClientService.getAuthUser(socialType, userType, code, state), - SOCIAL_USER_AUTH_FAILURE, "模拟失败"); - } - - @Test - public void testBuildAuthRequest_clientNull() { - // 准备参数 - Integer socialType = SocialTypeEnum.WECHAT_MP.getType(); - Integer userType = randomPojo(SocialTypeEnum.class).getType(); - // mock 获得对应的 AuthRequest 实现 - AuthRequest authRequest = mock(AuthDefaultRequest.class); - AuthConfig authConfig = (AuthConfig) ReflectUtil.getFieldValue(authRequest, "config"); - when(authRequestFactory.get(eq("WECHAT_MP"))).thenReturn(authRequest); - - // 调用 - AuthRequest result = socialClientService.buildAuthRequest(socialType, userType); - // 断言 - assertSame(authRequest, result); - assertSame(authConfig, ReflectUtil.getFieldValue(authConfig, "config")); - } - - @Test - public void testBuildAuthRequest_clientDisable() { - // 准备参数 - Integer socialType = SocialTypeEnum.WECHAT_MP.getType(); - Integer userType = randomPojo(SocialTypeEnum.class).getType(); - // mock 获得对应的 AuthRequest 实现 - AuthRequest authRequest = mock(AuthDefaultRequest.class); - AuthConfig authConfig = (AuthConfig) ReflectUtil.getFieldValue(authRequest, "config"); - when(authRequestFactory.get(eq("WECHAT_MP"))).thenReturn(authRequest); - // mock 数据 - SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()) - .setUserType(userType).setSocialType(socialType)); - socialClientMapper.insert(client); - - // 调用 - AuthRequest result = socialClientService.buildAuthRequest(socialType, userType); - // 断言 - assertSame(authRequest, result); - assertSame(authConfig, ReflectUtil.getFieldValue(authConfig, "config")); - } - - @Test - public void testBuildAuthRequest_clientEnable() { - // 准备参数 - Integer socialType = SocialTypeEnum.WECHAT_MP.getType(); - Integer userType = randomPojo(SocialTypeEnum.class).getType(); - // mock 获得对应的 AuthRequest 实现 - AuthConfig authConfig = mock(AuthConfig.class); - AuthRequest authRequest = mock(AuthDefaultRequest.class); - ReflectUtil.setFieldValue(authRequest, "config", authConfig); - when(authRequestFactory.get(eq("WECHAT_MP"))).thenReturn(authRequest); - // mock 数据 - SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setUserType(userType).setSocialType(socialType)); - socialClientMapper.insert(client); - - // 调用 - AuthRequest result = socialClientService.buildAuthRequest(socialType, userType); - // 断言 - assertSame(authRequest, result); - assertNotSame(authConfig, ReflectUtil.getFieldValue(authRequest, "config")); - } - - // =================== 微信公众号独有 =================== - - @Test - public void testCreateWxMpJsapiSignature() throws WxErrorException { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - String url = randomString(); - // mock 方法 - WxJsapiSignature signature = randomPojo(WxJsapiSignature.class); - when(wxMpService.createJsapiSignature(eq(url))).thenReturn(signature); - - // 调用 - WxJsapiSignature result = socialClientService.createWxMpJsapiSignature(userType, url); - // 断言 - assertSame(signature, result); - } - - @Test - public void testGetWxMpService_clientNull() { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - // mock 方法 - - // 调用 - WxMpService result = socialClientService.getWxMpService(userType); - // 断言 - assertSame(wxMpService, result); - } - - @Test - public void testGetWxMpService_clientDisable() { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - // mock 数据 - SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()) - .setUserType(userType).setSocialType(SocialTypeEnum.WECHAT_MP.getType())); - socialClientMapper.insert(client); - - // 调用 - WxMpService result = socialClientService.getWxMpService(userType); - // 断言 - assertSame(wxMpService, result); - } - - @Test - public void testGetWxMpService_clientEnable() { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - // mock 数据 - SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setUserType(userType).setSocialType(SocialTypeEnum.WECHAT_MP.getType())); - socialClientMapper.insert(client); - // mock 方法 - WxMpProperties.ConfigStorage configStorage = mock(WxMpProperties.ConfigStorage.class); - when(wxMpProperties.getConfigStorage()).thenReturn(configStorage); - - // 调用 - WxMpService result = socialClientService.getWxMpService(userType); - // 断言 - assertNotSame(wxMpService, result); - assertEquals(client.getClientId(), result.getWxMpConfigStorage().getAppId()); - assertEquals(client.getClientSecret(), result.getWxMpConfigStorage().getSecret()); - } - - // =================== 微信小程序独有 =================== - - @Test - public void testGetWxMaPhoneNumberInfo_success() throws WxErrorException { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - String phoneCode = randomString(); - // mock 方法 - WxMaUserService userService = mock(WxMaUserService.class); - when(wxMaService.getUserService()).thenReturn(userService); - WxMaPhoneNumberInfo phoneNumber = randomPojo(WxMaPhoneNumberInfo.class); - when(userService.getPhoneNoInfo(eq(phoneCode))).thenReturn(phoneNumber); - - // 调用 - WxMaPhoneNumberInfo result = socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode); - // 断言 - assertSame(phoneNumber, result); - } - - @Test - public void testGetWxMaPhoneNumberInfo_exception() throws WxErrorException { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - String phoneCode = randomString(); - // mock 方法 - WxMaUserService userService = mock(WxMaUserService.class); - when(wxMaService.getUserService()).thenReturn(userService); - WxErrorException wxErrorException = new WxErrorException(new NullPointerException()); - when(userService.getPhoneNoInfo(eq(phoneCode))).thenThrow(wxErrorException); - - // 调用并断言异常 - assertServiceException(() -> socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode), - SOCIAL_CLIENT_WEIXIN_MINI_APP_PHONE_CODE_ERROR); - } - - @Test - public void testGetWxMaService_clientNull() { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - // mock 方法 - - // 调用 - WxMaService result = socialClientService.getWxMaService(userType); - // 断言 - assertSame(wxMaService, result); - } - - @Test - public void testGetWxMaService_clientDisable() { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - // mock 数据 - SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()) - .setUserType(userType).setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType())); - socialClientMapper.insert(client); - - // 调用 - WxMaService result = socialClientService.getWxMaService(userType); - // 断言 - assertSame(wxMaService, result); - } - - @Test - public void testGetWxMaService_clientEnable() { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - // mock 数据 - SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setUserType(userType).setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType())); - socialClientMapper.insert(client); - // mock 方法 - WxMaProperties.ConfigStorage configStorage = mock(WxMaProperties.ConfigStorage.class); - when(wxMaProperties.getConfigStorage()).thenReturn(configStorage); - - // 调用 - WxMaService result = socialClientService.getWxMaService(userType); - // 断言 - assertNotSame(wxMaService, result); - assertEquals(client.getClientId(), result.getWxMaConfig().getAppid()); - assertEquals(client.getClientSecret(), result.getWxMaConfig().getSecret()); - } - - // =================== 客户端管理 =================== - - @Test - public void testCreateSocialClient_success() { - // 准备参数 - SocialClientSaveReqVO reqVO = randomPojo(SocialClientSaveReqVO.class, - o -> o.setSocialType(randomEle(SocialTypeEnum.values()).getType()) - .setUserType(randomEle(UserTypeEnum.values()).getValue()) - .setStatus(randomCommonStatus())) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long socialClientId = socialClientService.createSocialClient(reqVO); - // 断言 - assertNotNull(socialClientId); - // 校验记录的属性是否正确 - SocialClientDO socialClient = socialClientMapper.selectById(socialClientId); - assertPojoEquals(reqVO, socialClient, "id"); - } - - @Test - public void testUpdateSocialClient_success() { - // mock 数据 - SocialClientDO dbSocialClient = randomPojo(SocialClientDO.class); - socialClientMapper.insert(dbSocialClient);// @Sql: 先插入出一条存在的数据 - // 准备参数 - SocialClientSaveReqVO reqVO = randomPojo(SocialClientSaveReqVO.class, o -> { - o.setId(dbSocialClient.getId()); // 设置更新的 ID - o.setSocialType(randomEle(SocialTypeEnum.values()).getType()) - .setUserType(randomEle(UserTypeEnum.values()).getValue()) - .setStatus(randomCommonStatus()); - }); - - // 调用 - socialClientService.updateSocialClient(reqVO); - // 校验是否更新正确 - SocialClientDO socialClient = socialClientMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, socialClient); - } - - @Test - public void testUpdateSocialClient_notExists() { - // 准备参数 - SocialClientSaveReqVO reqVO = randomPojo(SocialClientSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> socialClientService.updateSocialClient(reqVO), SOCIAL_CLIENT_NOT_EXISTS); - } - - @Test - public void testDeleteSocialClient_success() { - // mock 数据 - SocialClientDO dbSocialClient = randomPojo(SocialClientDO.class); - socialClientMapper.insert(dbSocialClient);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSocialClient.getId(); - - // 调用 - socialClientService.deleteSocialClient(id); - // 校验数据不存在了 - assertNull(socialClientMapper.selectById(id)); - } - - @Test - public void testDeleteSocialClient_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> socialClientService.deleteSocialClient(id), SOCIAL_CLIENT_NOT_EXISTS); - } - - @Test - public void testGetSocialClient() { - // mock 数据 - SocialClientDO dbSocialClient = randomPojo(SocialClientDO.class); - socialClientMapper.insert(dbSocialClient);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSocialClient.getId(); - - // 调用 - SocialClientDO socialClient = socialClientService.getSocialClient(id); - // 校验数据正确 - assertPojoEquals(dbSocialClient, socialClient); - } - - @Test - public void testGetSocialClientPage() { - // mock 数据 - SocialClientDO dbSocialClient = randomPojo(SocialClientDO.class, o -> { // 等会查询到 - o.setName("芋头"); - o.setSocialType(SocialTypeEnum.GITEE.getType()); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setClientId("yudao"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - socialClientMapper.insert(dbSocialClient); - // 测试 name 不匹配 - socialClientMapper.insert(cloneIgnoreId(dbSocialClient, o -> o.setName(randomString()))); - // 测试 socialType 不匹配 - socialClientMapper.insert(cloneIgnoreId(dbSocialClient, o -> o.setSocialType(SocialTypeEnum.DINGTALK.getType()))); - // 测试 userType 不匹配 - socialClientMapper.insert(cloneIgnoreId(dbSocialClient, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 clientId 不匹配 - socialClientMapper.insert(cloneIgnoreId(dbSocialClient, o -> o.setClientId("dao"))); - // 测试 status 不匹配 - socialClientMapper.insert(cloneIgnoreId(dbSocialClient, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 准备参数 - SocialClientPageReqVO reqVO = new SocialClientPageReqVO(); - reqVO.setName("芋"); - reqVO.setSocialType(SocialTypeEnum.GITEE.getType()); - reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); - reqVO.setClientId("yu"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - PageResult pageResult = socialClientService.getSocialClientPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSocialClient, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImplTest.java deleted file mode 100644 index 3685ed266f..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImplTest.java +++ /dev/null @@ -1,288 +0,0 @@ -package cn.iocoder.yudao.module.system.service.social; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO; -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserPageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserBindDO; -import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; -import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserBindMapper; -import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserMapper; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import com.xingyuv.jushauth.model.AuthUser; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.hutool.core.util.RandomUtil.randomLong; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.SOCIAL_USER_NOT_FOUND; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.eq; -import static org.mockito.Mockito.when; - -/** - * {@link SocialUserServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(SocialUserServiceImpl.class) -public class SocialUserServiceImplTest extends BaseDbUnitTest { - - @Resource - private SocialUserServiceImpl socialUserService; - - @Resource - private SocialUserMapper socialUserMapper; - @Resource - private SocialUserBindMapper socialUserBindMapper; - - @MockBean - private SocialClientService socialClientService; - - @Test - public void testGetSocialUserList() { - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - // mock 获得社交用户 - SocialUserDO socialUser = randomPojo(SocialUserDO.class).setType(SocialTypeEnum.GITEE.getType()); - socialUserMapper.insert(socialUser); // 可被查到 - socialUserMapper.insert(randomPojo(SocialUserDO.class)); // 不可被查到 - // mock 获得绑定 - socialUserBindMapper.insert(randomPojo(SocialUserBindDO.class) // 可被查询到 - .setUserId(userId).setUserType(userType).setSocialType(SocialTypeEnum.GITEE.getType()) - .setSocialUserId(socialUser.getId())); - socialUserBindMapper.insert(randomPojo(SocialUserBindDO.class) // 不可被查询到 - .setUserId(2L).setUserType(userType).setSocialType(SocialTypeEnum.DINGTALK.getType())); - - // 调用 - List result = socialUserService.getSocialUserList(userId, userType); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(socialUser, result.get(0)); - } - - @Test - public void testBindSocialUser() { - // 准备参数 - SocialUserBindReqDTO reqDTO = new SocialUserBindReqDTO() - .setUserId(1L).setUserType(UserTypeEnum.ADMIN.getValue()) - .setSocialType(SocialTypeEnum.GITEE.getType()).setCode("test_code").setState("test_state"); - // mock 数据:获得社交用户 - SocialUserDO socialUser = randomPojo(SocialUserDO.class).setType(reqDTO.getSocialType()) - .setCode(reqDTO.getCode()).setState(reqDTO.getState()); - socialUserMapper.insert(socialUser); - // mock 数据:用户可能之前已经绑定过该社交类型 - socialUserBindMapper.insert(randomPojo(SocialUserBindDO.class).setUserId(1L).setUserType(UserTypeEnum.ADMIN.getValue()) - .setSocialType(SocialTypeEnum.GITEE.getType()).setSocialUserId(-1L)); - // mock 数据:社交用户可能之前绑定过别的用户 - socialUserBindMapper.insert(randomPojo(SocialUserBindDO.class).setUserType(UserTypeEnum.ADMIN.getValue()) - .setSocialType(SocialTypeEnum.GITEE.getType()).setSocialUserId(socialUser.getId())); - - // 调用 - String openid = socialUserService.bindSocialUser(reqDTO); - // 断言 - List socialUserBinds = socialUserBindMapper.selectList(); - assertEquals(1, socialUserBinds.size()); - assertEquals(socialUser.getOpenid(), openid); - } - - @Test - public void testUnbindSocialUser_success() { - // 准备参数 - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - Integer type = SocialTypeEnum.GITEE.getType(); - String openid = "test_openid"; - // mock 数据:社交用户 - SocialUserDO socialUser = randomPojo(SocialUserDO.class).setType(type).setOpenid(openid); - socialUserMapper.insert(socialUser); - // mock 数据:社交绑定关系 - SocialUserBindDO socialUserBind = randomPojo(SocialUserBindDO.class).setUserType(userType) - .setUserId(userId).setSocialType(type); - socialUserBindMapper.insert(socialUserBind); - - // 调用 - socialUserService.unbindSocialUser(userId, userType, type, openid); - // 断言 - assertEquals(0, socialUserBindMapper.selectCount(null).intValue()); - } - - @Test - public void testUnbindSocialUser_notFound() { - // 调用,并断言 - assertServiceException( - () -> socialUserService.unbindSocialUser(randomLong(), UserTypeEnum.ADMIN.getValue(), - SocialTypeEnum.GITEE.getType(), "test_openid"), - SOCIAL_USER_NOT_FOUND); - } - - @Test - public void testGetSocialUser() { - // 准备参数 - Integer userType = UserTypeEnum.ADMIN.getValue(); - Integer type = SocialTypeEnum.GITEE.getType(); - String code = "tudou"; - String state = "yuanma"; - // mock 社交用户 - SocialUserDO socialUserDO = randomPojo(SocialUserDO.class).setType(type).setCode(code).setState(state); - socialUserMapper.insert(socialUserDO); - // mock 社交用户的绑定 - Long userId = randomLong(); - SocialUserBindDO socialUserBind = randomPojo(SocialUserBindDO.class).setUserType(userType).setUserId(userId) - .setSocialType(type).setSocialUserId(socialUserDO.getId()); - socialUserBindMapper.insert(socialUserBind); - - // 调用 - SocialUserRespDTO socialUser = socialUserService.getSocialUser(userType, type, code, state); - // 断言 - assertEquals(userId, socialUser.getUserId()); - assertEquals(socialUserDO.getOpenid(), socialUser.getOpenid()); - } - - @Test - public void testAuthSocialUser_exists() { - // 准备参数 - Integer socialType = SocialTypeEnum.GITEE.getType(); - Integer userType = randomEle(SocialTypeEnum.values()).getType(); - String code = "tudou"; - String state = "yuanma"; - // mock 方法 - SocialUserDO socialUser = randomPojo(SocialUserDO.class).setType(socialType).setCode(code).setState(state); - socialUserMapper.insert(socialUser); - - // 调用 - SocialUserDO result = socialUserService.authSocialUser(socialType, userType, code, state); - // 断言 - assertPojoEquals(socialUser, result); - } - - @Test - public void testAuthSocialUser_notNull() { - // mock 数据 - SocialUserDO socialUser = randomPojo(SocialUserDO.class, - o -> o.setType(SocialTypeEnum.GITEE.getType()).setCode("tudou").setState("yuanma")); - socialUserMapper.insert(socialUser); - // 准备参数 - Integer socialType = SocialTypeEnum.GITEE.getType(); - Integer userType = randomEle(SocialTypeEnum.values()).getType(); - String code = "tudou"; - String state = "yuanma"; - - // 调用 - SocialUserDO result = socialUserService.authSocialUser(socialType, userType, code, state); - // 断言 - assertPojoEquals(socialUser, result); - } - - @Test - public void testAuthSocialUser_insert() { - // 准备参数 - Integer socialType = SocialTypeEnum.GITEE.getType(); - Integer userType = randomEle(SocialTypeEnum.values()).getType(); - String code = "tudou"; - String state = "yuanma"; - // mock 方法 - AuthUser authUser = randomPojo(AuthUser.class); - when(socialClientService.getAuthUser(eq(socialType), eq(userType), eq(code), eq(state))).thenReturn(authUser); - - // 调用 - SocialUserDO result = socialUserService.authSocialUser(socialType, userType, code, state); - // 断言 - assertBindSocialUser(socialType, result, authUser); - assertEquals(code, result.getCode()); - assertEquals(state, result.getState()); - } - - @Test - public void testAuthSocialUser_update() { - // 准备参数 - Integer socialType = SocialTypeEnum.GITEE.getType(); - Integer userType = randomEle(SocialTypeEnum.values()).getType(); - String code = "tudou"; - String state = "yuanma"; - // mock 数据 - socialUserMapper.insert(randomPojo(SocialUserDO.class).setType(socialType).setOpenid("test_openid")); - // mock 方法 - AuthUser authUser = randomPojo(AuthUser.class); - when(socialClientService.getAuthUser(eq(socialType), eq(userType), eq(code), eq(state))).thenReturn(authUser); - - // 调用 - SocialUserDO result = socialUserService.authSocialUser(socialType, userType, code, state); - // 断言 - assertBindSocialUser(socialType, result, authUser); - assertEquals(code, result.getCode()); - assertEquals(state, result.getState()); - } - - private void assertBindSocialUser(Integer type, SocialUserDO socialUser, AuthUser authUser) { - assertEquals(authUser.getToken().getAccessToken(), socialUser.getToken()); - assertEquals(toJsonString(authUser.getToken()), socialUser.getRawTokenInfo()); - assertEquals(authUser.getNickname(), socialUser.getNickname()); - assertEquals(authUser.getAvatar(), socialUser.getAvatar()); - assertEquals(toJsonString(authUser.getRawUserInfo()), socialUser.getRawUserInfo()); - assertEquals(type, socialUser.getType()); - assertEquals(authUser.getUuid(), socialUser.getOpenid()); - } - - @Test - public void testGetSocialUser_id() { - // mock 数据 - SocialUserDO socialUserDO = randomPojo(SocialUserDO.class); - socialUserMapper.insert(socialUserDO); - // 参数准备 - Long id = socialUserDO.getId(); - - // 调用 - SocialUserDO dbSocialUserDO = socialUserService.getSocialUser(id); - // 断言 - assertPojoEquals(socialUserDO, dbSocialUserDO); - } - - @Test - public void testGetSocialUserPage() { - // mock 数据 - SocialUserDO dbSocialUser = randomPojo(SocialUserDO.class, o -> { // 等会查询到 - o.setType(SocialTypeEnum.GITEE.getType()); - o.setNickname("芋艿"); - o.setOpenid("yudaoyuanma"); - o.setCreateTime(buildTime(2020, 1, 15)); - }); - socialUserMapper.insert(dbSocialUser); - // 测试 type 不匹配 - socialUserMapper.insert(cloneIgnoreId(dbSocialUser, o -> o.setType(SocialTypeEnum.DINGTALK.getType()))); - // 测试 nickname 不匹配 - socialUserMapper.insert(cloneIgnoreId(dbSocialUser, o -> o.setNickname(randomString()))); - // 测试 openid 不匹配 - socialUserMapper.insert(cloneIgnoreId(dbSocialUser, o -> o.setOpenid("java"))); - // 测试 createTime 不匹配 - socialUserMapper.insert(cloneIgnoreId(dbSocialUser, o -> o.setCreateTime(buildTime(2020, 1, 21)))); - // 准备参数 - SocialUserPageReqVO reqVO = new SocialUserPageReqVO(); - reqVO.setType(SocialTypeEnum.GITEE.getType()); - reqVO.setNickname("芋"); - reqVO.setOpenid("yudao"); - reqVO.setCreateTime(buildBetweenTime(2020, 1, 10, 2020, 1, 20)); - - // 调用 - PageResult pageResult = socialUserService.getSocialUserPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSocialUser, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImplTest.java deleted file mode 100755 index 0e030f3b2a..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImplTest.java +++ /dev/null @@ -1,236 +0,0 @@ -package cn.iocoder.yudao.module.system.service.tenant; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; -import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; -import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantPackageMapper; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** -* {@link TenantPackageServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Import(TenantPackageServiceImpl.class) -public class TenantPackageServiceImplTest extends BaseDbUnitTest { - - @Resource - private TenantPackageServiceImpl tenantPackageService; - - @Resource - private TenantPackageMapper tenantPackageMapper; - - @MockBean - private TenantService tenantService; - - @Test - public void testCreateTenantPackage_success() { - // 准备参数 - TenantPackageSaveReqVO reqVO = randomPojo(TenantPackageSaveReqVO.class, - o -> o.setStatus(randomCommonStatus())) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long tenantPackageId = tenantPackageService.createTenantPackage(reqVO); - // 断言 - assertNotNull(tenantPackageId); - // 校验记录的属性是否正确 - TenantPackageDO tenantPackage = tenantPackageMapper.selectById(tenantPackageId); - assertPojoEquals(reqVO, tenantPackage, "id"); - } - - @Test - public void testUpdateTenantPackage_success() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class, - o -> o.setStatus(randomCommonStatus())); - tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 - // 准备参数 - TenantPackageSaveReqVO reqVO = randomPojo(TenantPackageSaveReqVO.class, o -> { - o.setId(dbTenantPackage.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - }); - // mock 方法 - Long tenantId01 = randomLongId(); - Long tenantId02 = randomLongId(); - when(tenantService.getTenantListByPackageId(eq(reqVO.getId()))).thenReturn( - asList(randomPojo(TenantDO.class, o -> o.setId(tenantId01)), - randomPojo(TenantDO.class, o -> o.setId(tenantId02)))); - - // 调用 - tenantPackageService.updateTenantPackage(reqVO); - // 校验是否更新正确 - TenantPackageDO tenantPackage = tenantPackageMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, tenantPackage); - // 校验调用租户的菜单 - verify(tenantService).updateTenantRoleMenu(eq(tenantId01), eq(reqVO.getMenuIds())); - verify(tenantService).updateTenantRoleMenu(eq(tenantId02), eq(reqVO.getMenuIds())); - } - - @Test - public void testUpdateTenantPackage_notExists() { - // 准备参数 - TenantPackageSaveReqVO reqVO = randomPojo(TenantPackageSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> tenantPackageService.updateTenantPackage(reqVO), TENANT_PACKAGE_NOT_EXISTS); - } - - @Test - public void testDeleteTenantPackage_success() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class); - tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbTenantPackage.getId(); - // mock 租户未使用该套餐 - when(tenantService.getTenantCountByPackageId(eq(id))).thenReturn(0L); - - // 调用 - tenantPackageService.deleteTenantPackage(id); - // 校验数据不存在了 - assertNull(tenantPackageMapper.selectById(id)); - } - - @Test - public void testDeleteTenantPackage_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> tenantPackageService.deleteTenantPackage(id), TENANT_PACKAGE_NOT_EXISTS); - } - - @Test - public void testDeleteTenantPackage_used() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class); - tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbTenantPackage.getId(); - // mock 租户在使用该套餐 - when(tenantService.getTenantCountByPackageId(eq(id))).thenReturn(1L); - - // 调用, 并断言异常 - assertServiceException(() -> tenantPackageService.deleteTenantPackage(id), TENANT_PACKAGE_USED); - } - - @Test - public void testGetTenantPackagePage() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setRemark("源码解析"); - o.setCreateTime(buildTime(2022, 10, 10)); - }); - tenantPackageMapper.insert(dbTenantPackage); - // 测试 name 不匹配 - tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, o -> o.setName("源码"))); - // 测试 status 不匹配 - tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 remark 不匹配 - tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, o -> o.setRemark("解析"))); - // 测试 createTime 不匹配 - tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, o -> o.setCreateTime(buildTime(2022, 11, 11)))); - // 准备参数 - TenantPackagePageReqVO reqVO = new TenantPackagePageReqVO(); - reqVO.setName("芋道"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setRemark("源码"); - reqVO.setCreateTime(buildBetweenTime(2022, 10, 9, 2022, 10, 11)); - - // 调用 - PageResult pageResult = tenantPackageService.getTenantPackagePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbTenantPackage, pageResult.getList().get(0)); - } - - @Test - public void testValidTenantPackage_success() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class, - o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 - - // 调用 - TenantPackageDO result = tenantPackageService.validTenantPackage(dbTenantPackage.getId()); - // 断言 - assertPojoEquals(dbTenantPackage, result); - } - - @Test - public void testValidTenantPackage_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> tenantPackageService.validTenantPackage(id), TENANT_PACKAGE_NOT_EXISTS); - } - - @Test - public void testValidTenantPackage_disable() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class, - o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 - - // 调用, 并断言异常 - assertServiceException(() -> tenantPackageService.validTenantPackage(dbTenantPackage.getId()), - TENANT_PACKAGE_DISABLE, dbTenantPackage.getName()); - } - - @Test - public void testGetTenantPackage() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class); - tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 - - // 调用 - TenantPackageDO result = tenantPackageService.getTenantPackage(dbTenantPackage.getId()); - // 断言 - assertPojoEquals(result, dbTenantPackage); - } - - @Test - public void testGetTenantPackageListByStatus() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class, - o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - tenantPackageMapper.insert(dbTenantPackage); - // 测试 status 不匹配 - tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, - o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - - // 调用 - List list = tenantPackageService.getTenantPackageListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - assertEquals(1, list.size()); - assertPojoEquals(dbTenantPackage, list.get(0)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java deleted file mode 100644 index f4d4f862bc..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java +++ /dev/null @@ -1,458 +0,0 @@ -package cn.iocoder.yudao.module.system.service.tenant; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.tenant.config.TenantProperties; -import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; -import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; -import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; -import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantMapper; -import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum; -import cn.iocoder.yudao.module.system.enums.permission.RoleTypeEnum; -import cn.iocoder.yudao.module.system.service.permission.MenuService; -import cn.iocoder.yudao.module.system.service.permission.PermissionService; -import cn.iocoder.yudao.module.system.service.permission.RoleService; -import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler; -import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import jakarta.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO.PACKAGE_ID_SYSTEM; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; -import static java.util.Collections.singleton; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - -/** - * {@link TenantServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(TenantServiceImpl.class) -public class TenantServiceImplTest extends BaseDbUnitTest { - - @Resource - private TenantServiceImpl tenantService; - - @Resource - private TenantMapper tenantMapper; - - @MockBean - private TenantProperties tenantProperties; - @MockBean - private TenantPackageService tenantPackageService; - @MockBean - private AdminUserService userService; - @MockBean - private RoleService roleService; - @MockBean - private MenuService menuService; - @MockBean - private PermissionService permissionService; - - @BeforeEach - public void setUp() { - // 清理租户上下文 - TenantContextHolder.clear(); - } - - @Test - public void testGetTenantIdList() { - // mock 数据 - TenantDO tenant = randomPojo(TenantDO.class, o -> o.setId(1L)); - tenantMapper.insert(tenant); - - // 调用,并断言业务异常 - List result = tenantService.getTenantIdList(); - assertEquals(Collections.singletonList(1L), result); - } - - @Test - public void testValidTenant_notExists() { - assertServiceException(() -> tenantService.validTenant(randomLongId()), TENANT_NOT_EXISTS); - } - - @Test - public void testValidTenant_disable() { - // mock 数据 - TenantDO tenant = randomPojo(TenantDO.class, o -> o.setId(1L).setStatus(CommonStatusEnum.DISABLE.getStatus())); - tenantMapper.insert(tenant); - - // 调用,并断言业务异常 - assertServiceException(() -> tenantService.validTenant(1L), TENANT_DISABLE, tenant.getName()); - } - - @Test - public void testValidTenant_expired() { - // mock 数据 - TenantDO tenant = randomPojo(TenantDO.class, o -> o.setId(1L).setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setExpireTime(buildTime(2020, 2, 2))); - tenantMapper.insert(tenant); - - // 调用,并断言业务异常 - assertServiceException(() -> tenantService.validTenant(1L), TENANT_EXPIRE, tenant.getName()); - } - - @Test - public void testValidTenant_success() { - // mock 数据 - TenantDO tenant = randomPojo(TenantDO.class, o -> o.setId(1L).setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setExpireTime(LocalDateTime.now().plusDays(1))); - tenantMapper.insert(tenant); - - // 调用,并断言业务异常 - tenantService.validTenant(1L); - } - - @Test - public void testCreateTenant() { - // mock 套餐 100L - TenantPackageDO tenantPackage = randomPojo(TenantPackageDO.class, o -> o.setId(100L)); - when(tenantPackageService.validTenantPackage(eq(100L))).thenReturn(tenantPackage); - // mock 角色 200L - when(roleService.createRole(argThat(role -> { - assertEquals(RoleCodeEnum.TENANT_ADMIN.getName(), role.getName()); - assertEquals(RoleCodeEnum.TENANT_ADMIN.getCode(), role.getCode()); - assertEquals(0, role.getSort()); - assertEquals("系统自动生成", role.getRemark()); - return true; - }), eq(RoleTypeEnum.SYSTEM.getType()))).thenReturn(200L); - // mock 用户 300L - when(userService.createUser(argThat(user -> { - assertEquals("yunai", user.getUsername()); - assertEquals("yuanma", user.getPassword()); - assertEquals("芋道", user.getNickname()); - assertEquals("15601691300", user.getMobile()); - return true; - }))).thenReturn(300L); - - // 准备参数 - TenantSaveReqVO reqVO = randomPojo(TenantSaveReqVO.class, o -> { - o.setContactName("芋道"); - o.setContactMobile("15601691300"); - o.setPackageId(100L); - o.setStatus(randomCommonStatus()); - o.setWebsite("https://www.iocoder.cn"); - o.setUsername("yunai"); - o.setPassword("yuanma"); - }).setId(null); // 设置为 null,方便后面校验 - - // 调用 - Long tenantId = tenantService.createTenant(reqVO); - // 断言 - assertNotNull(tenantId); - // 校验记录的属性是否正确 - TenantDO tenant = tenantMapper.selectById(tenantId); - assertPojoEquals(reqVO, tenant, "id"); - assertEquals(300L, tenant.getContactUserId()); - // verify 分配权限 - verify(permissionService).assignRoleMenu(eq(200L), same(tenantPackage.getMenuIds())); - // verify 分配角色 - verify(permissionService).assignUserRole(eq(300L), eq(singleton(200L))); - } - - @Test - public void testUpdateTenant_success() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setStatus(randomCommonStatus())); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - // 准备参数 - TenantSaveReqVO reqVO = randomPojo(TenantSaveReqVO.class, o -> { - o.setId(dbTenant.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - o.setWebsite(randomString()); - }); - - // mock 套餐 - TenantPackageDO tenantPackage = randomPojo(TenantPackageDO.class, - o -> o.setMenuIds(asSet(200L, 201L))); - when(tenantPackageService.validTenantPackage(eq(reqVO.getPackageId()))).thenReturn(tenantPackage); - // mock 所有角色 - RoleDO role100 = randomPojo(RoleDO.class, o -> o.setId(100L).setCode(RoleCodeEnum.TENANT_ADMIN.getCode())); - role100.setTenantId(dbTenant.getId()); - RoleDO role101 = randomPojo(RoleDO.class, o -> o.setId(101L)); - role101.setTenantId(dbTenant.getId()); - when(roleService.getRoleList()).thenReturn(asList(role100, role101)); - // mock 每个角色的权限 - when(permissionService.getRoleMenuListByRoleId(eq(101L))).thenReturn(asSet(201L, 202L)); - - // 调用 - tenantService.updateTenant(reqVO); - // 校验是否更新正确 - TenantDO tenant = tenantMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, tenant); - // verify 设置角色权限 - verify(permissionService).assignRoleMenu(eq(100L), eq(asSet(200L, 201L))); - verify(permissionService).assignRoleMenu(eq(101L), eq(asSet(201L))); - } - - @Test - public void testUpdateTenant_notExists() { - // 准备参数 - TenantSaveReqVO reqVO = randomPojo(TenantSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> tenantService.updateTenant(reqVO), TENANT_NOT_EXISTS); - } - - @Test - public void testUpdateTenant_system() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setPackageId(PACKAGE_ID_SYSTEM)); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - // 准备参数 - TenantSaveReqVO reqVO = randomPojo(TenantSaveReqVO.class, o -> { - o.setId(dbTenant.getId()); // 设置更新的 ID - }); - - // 调用,校验业务异常 - assertServiceException(() -> tenantService.updateTenant(reqVO), TENANT_CAN_NOT_UPDATE_SYSTEM); - } - - @Test - public void testDeleteTenant_success() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, - o -> o.setStatus(randomCommonStatus())); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbTenant.getId(); - - // 调用 - tenantService.deleteTenant(id); - // 校验数据不存在了 - assertNull(tenantMapper.selectById(id)); - } - - @Test - public void testDeleteTenant_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> tenantService.deleteTenant(id), TENANT_NOT_EXISTS); - } - - @Test - public void testDeleteTenant_system() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setPackageId(PACKAGE_ID_SYSTEM)); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbTenant.getId(); - - // 调用, 并断言异常 - assertServiceException(() -> tenantService.deleteTenant(id), TENANT_CAN_NOT_UPDATE_SYSTEM); - } - - @Test - public void testGetTenant() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbTenant.getId(); - - // 调用 - TenantDO result = tenantService.getTenant(id); - // 校验存在 - assertPojoEquals(result, dbTenant); - } - - @Test - public void testGetTenantPage() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - o.setContactName("芋艿"); - o.setContactMobile("15601691300"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2020, 12, 12)); - }); - tenantMapper.insert(dbTenant); - // 测试 name 不匹配 - tenantMapper.insert(cloneIgnoreId(dbTenant, o -> o.setName(randomString()))); - // 测试 contactName 不匹配 - tenantMapper.insert(cloneIgnoreId(dbTenant, o -> o.setContactName(randomString()))); - // 测试 contactMobile 不匹配 - tenantMapper.insert(cloneIgnoreId(dbTenant, o -> o.setContactMobile(randomString()))); - // 测试 status 不匹配 - tenantMapper.insert(cloneIgnoreId(dbTenant, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - tenantMapper.insert(cloneIgnoreId(dbTenant, o -> o.setCreateTime(buildTime(2021, 12, 12)))); - // 准备参数 - TenantPageReqVO reqVO = new TenantPageReqVO(); - reqVO.setName("芋道"); - reqVO.setContactName("艿"); - reqVO.setContactMobile("1560"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2020, 12, 1, 2020, 12, 24)); - - // 调用 - PageResult pageResult = tenantService.getTenantPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbTenant, pageResult.getList().get(0)); - } - - @Test - public void testGetTenantByName() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setName("芋道")); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - - // 调用 - TenantDO result = tenantService.getTenantByName("芋道"); - // 校验存在 - assertPojoEquals(result, dbTenant); - } - - @Test - public void testGetTenantByWebsite() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setWebsite("https://www.iocoder.cn")); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - - // 调用 - TenantDO result = tenantService.getTenantByWebsite("https://www.iocoder.cn"); - // 校验存在 - assertPojoEquals(result, dbTenant); - } - - @Test - public void testGetTenantListByPackageId() { - // mock 数据 - TenantDO dbTenant1 = randomPojo(TenantDO.class, o -> o.setPackageId(1L)); - tenantMapper.insert(dbTenant1);// @Sql: 先插入出一条存在的数据 - TenantDO dbTenant2 = randomPojo(TenantDO.class, o -> o.setPackageId(2L)); - tenantMapper.insert(dbTenant2);// @Sql: 先插入出一条存在的数据 - - // 调用 - List result = tenantService.getTenantListByPackageId(1L); - assertEquals(1, result.size()); - assertPojoEquals(dbTenant1, result.get(0)); - } - - @Test - public void testGetTenantCountByPackageId() { - // mock 数据 - TenantDO dbTenant1 = randomPojo(TenantDO.class, o -> o.setPackageId(1L)); - tenantMapper.insert(dbTenant1);// @Sql: 先插入出一条存在的数据 - TenantDO dbTenant2 = randomPojo(TenantDO.class, o -> o.setPackageId(2L)); - tenantMapper.insert(dbTenant2);// @Sql: 先插入出一条存在的数据 - - // 调用 - Long count = tenantService.getTenantCountByPackageId(1L); - assertEquals(1, count); - } - - @Test - public void testHandleTenantInfo_disable() { - // 准备参数 - TenantInfoHandler handler = mock(TenantInfoHandler.class); - // mock 禁用 - when(tenantProperties.getEnable()).thenReturn(false); - - // 调用 - tenantService.handleTenantInfo(handler); - // 断言 - verify(handler, never()).handle(any()); - } - - @Test - public void testHandleTenantInfo_success() { - // 准备参数 - TenantInfoHandler handler = mock(TenantInfoHandler.class); - // mock 未禁用 - when(tenantProperties.getEnable()).thenReturn(true); - // mock 租户 - TenantDO dbTenant = randomPojo(TenantDO.class); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - TenantContextHolder.setTenantId(dbTenant.getId()); - - // 调用 - tenantService.handleTenantInfo(handler); - // 断言 - verify(handler).handle(argThat(argument -> { - assertPojoEquals(dbTenant, argument); - return true; - })); - } - - @Test - public void testHandleTenantMenu_disable() { - // 准备参数 - TenantMenuHandler handler = mock(TenantMenuHandler.class); - // mock 禁用 - when(tenantProperties.getEnable()).thenReturn(false); - - // 调用 - tenantService.handleTenantMenu(handler); - // 断言 - verify(handler, never()).handle(any()); - } - - @Test // 系统租户的情况 - public void testHandleTenantMenu_system() { - // 准备参数 - TenantMenuHandler handler = mock(TenantMenuHandler.class); - // mock 未禁用 - when(tenantProperties.getEnable()).thenReturn(true); - // mock 租户 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setPackageId(PACKAGE_ID_SYSTEM)); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - TenantContextHolder.setTenantId(dbTenant.getId()); - // mock 菜单 - when(menuService.getMenuList()).thenReturn(Arrays.asList(randomPojo(MenuDO.class, o -> o.setId(100L)), - randomPojo(MenuDO.class, o -> o.setId(101L)))); - - // 调用 - tenantService.handleTenantMenu(handler); - // 断言 - verify(handler).handle(asSet(100L, 101L)); - } - - @Test // 普通租户的情况 - public void testHandleTenantMenu_normal() { - // 准备参数 - TenantMenuHandler handler = mock(TenantMenuHandler.class); - // mock 未禁用 - when(tenantProperties.getEnable()).thenReturn(true); - // mock 租户 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setPackageId(200L)); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - TenantContextHolder.setTenantId(dbTenant.getId()); - // mock 菜单 - when(tenantPackageService.getTenantPackage(eq(200L))).thenReturn(randomPojo(TenantPackageDO.class, - o -> o.setMenuIds(asSet(100L, 101L)))); - - // 调用 - tenantService.handleTenantMenu(handler); - // 断言 - verify(handler).handle(asSet(100L, 101L)); - } -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java deleted file mode 100644 index 0ddfd03d4f..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java +++ /dev/null @@ -1,762 +0,0 @@ -package cn.iocoder.yudao.module.system.service.user; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.api.file.FileApi; -import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO; -import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO; -import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*; -import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; -import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO; -import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; -import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper; -import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; -import cn.iocoder.yudao.module.system.enums.common.SexEnum; -import cn.iocoder.yudao.module.system.service.dept.DeptService; -import cn.iocoder.yudao.module.system.service.dept.PostService; -import cn.iocoder.yudao.module.system.service.permission.PermissionService; -import cn.iocoder.yudao.module.system.service.tenant.TenantService; -import org.junit.jupiter.api.Test; -import org.mockito.stubbing.Answer; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.security.crypto.password.PasswordEncoder; - -import jakarta.annotation.Resource; -import java.io.ByteArrayInputStream; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomBytes; -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static org.assertj.core.util.Lists.newArrayList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - -@Import(AdminUserServiceImpl.class) -public class AdminUserServiceImplTest extends BaseDbUnitTest { - - @Resource - private AdminUserServiceImpl userService; - - @Resource - private AdminUserMapper userMapper; - @Resource - private UserPostMapper userPostMapper; - - @MockBean - private DeptService deptService; - @MockBean - private PostService postService; - @MockBean - private PermissionService permissionService; - @MockBean - private PasswordEncoder passwordEncoder; - @MockBean - private TenantService tenantService; - @MockBean - private FileApi fileApi; - - @Test - public void testCreatUser_success() { - // 准备参数 - UserSaveReqVO reqVO = randomPojo(UserSaveReqVO.class, o -> { - o.setSex(RandomUtil.randomEle(SexEnum.values()).getSex()); - o.setMobile(randomString()); - o.setPostIds(asSet(1L, 2L)); - }).setId(null); // 避免 id 被赋值 - // mock 账户额度充足 - TenantDO tenant = randomPojo(TenantDO.class, o -> o.setAccountCount(1)); - doNothing().when(tenantService).handleTenantInfo(argThat(handler -> { - handler.handle(tenant); - return true; - })); - // mock deptService 的方法 - DeptDO dept = randomPojo(DeptDO.class, o -> { - o.setId(reqVO.getDeptId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - when(deptService.getDept(eq(dept.getId()))).thenReturn(dept); - // mock postService 的方法 - List posts = CollectionUtils.convertList(reqVO.getPostIds(), postId -> - randomPojo(PostDO.class, o -> { - o.setId(postId); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - })); - when(postService.getPostList(eq(reqVO.getPostIds()), isNull())).thenReturn(posts); - // mock passwordEncoder 的方法 - when(passwordEncoder.encode(eq(reqVO.getPassword()))).thenReturn("yudaoyuanma"); - - // 调用 - Long userId = userService.createUser(reqVO); - // 断言 - AdminUserDO user = userMapper.selectById(userId); - assertPojoEquals(reqVO, user, "password", "id"); - assertEquals("yudaoyuanma", user.getPassword()); - assertEquals(CommonStatusEnum.ENABLE.getStatus(), user.getStatus()); - // 断言关联岗位 - List userPosts = userPostMapper.selectListByUserId(user.getId()); - assertEquals(1L, userPosts.get(0).getPostId()); - assertEquals(2L, userPosts.get(1).getPostId()); - } - - @Test - public void testCreatUser_max() { - // 准备参数 - UserSaveReqVO reqVO = randomPojo(UserSaveReqVO.class); - // mock 账户额度不足 - TenantDO tenant = randomPojo(TenantDO.class, o -> o.setAccountCount(-1)); - doNothing().when(tenantService).handleTenantInfo(argThat(handler -> { - handler.handle(tenant); - return true; - })); - - // 调用,并断言异常 - assertServiceException(() -> userService.createUser(reqVO), USER_COUNT_MAX, -1); - } - - @Test - public void testUpdateUser_success() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(o -> o.setPostIds(asSet(1L, 2L))); - userMapper.insert(dbUser); - userPostMapper.insert(new UserPostDO().setUserId(dbUser.getId()).setPostId(1L)); - userPostMapper.insert(new UserPostDO().setUserId(dbUser.getId()).setPostId(2L)); - // 准备参数 - UserSaveReqVO reqVO = randomPojo(UserSaveReqVO.class, o -> { - o.setId(dbUser.getId()); - o.setSex(RandomUtil.randomEle(SexEnum.values()).getSex()); - o.setMobile(randomString()); - o.setPostIds(asSet(2L, 3L)); - }); - // mock deptService 的方法 - DeptDO dept = randomPojo(DeptDO.class, o -> { - o.setId(reqVO.getDeptId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - when(deptService.getDept(eq(dept.getId()))).thenReturn(dept); - // mock postService 的方法 - List posts = CollectionUtils.convertList(reqVO.getPostIds(), postId -> - randomPojo(PostDO.class, o -> { - o.setId(postId); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - })); - when(postService.getPostList(eq(reqVO.getPostIds()), isNull())).thenReturn(posts); - - // 调用 - userService.updateUser(reqVO); - // 断言 - AdminUserDO user = userMapper.selectById(reqVO.getId()); - assertPojoEquals(reqVO, user, "password"); - // 断言关联岗位 - List userPosts = userPostMapper.selectListByUserId(user.getId()); - assertEquals(2L, userPosts.get(0).getPostId()); - assertEquals(3L, userPosts.get(1).getPostId()); - } - - @Test - public void testUpdateUserLogin() { - // mock 数据 - AdminUserDO user = randomAdminUserDO(o -> o.setLoginDate(null)); - userMapper.insert(user); - // 准备参数 - Long id = user.getId(); - String loginIp = randomString(); - - // 调用 - userService.updateUserLogin(id, loginIp); - // 断言 - AdminUserDO dbUser = userMapper.selectById(id); - assertEquals(loginIp, dbUser.getLoginIp()); - assertNotNull(dbUser.getLoginDate()); - } - - @Test - public void testUpdateUserProfile_success() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - UserProfileUpdateReqVO reqVO = randomPojo(UserProfileUpdateReqVO.class, o -> { - o.setMobile(randomString()); - o.setSex(RandomUtil.randomEle(SexEnum.values()).getSex()); - }); - - // 调用 - userService.updateUserProfile(userId, reqVO); - // 断言 - AdminUserDO user = userMapper.selectById(userId); - assertPojoEquals(reqVO, user); - } - - @Test - public void testUpdateUserPassword_success() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(o -> o.setPassword("encode:tudou")); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - UserProfileUpdatePasswordReqVO reqVO = randomPojo(UserProfileUpdatePasswordReqVO.class, o -> { - o.setOldPassword("tudou"); - o.setNewPassword("yuanma"); - }); - // mock 方法 - when(passwordEncoder.encode(anyString())).then( - (Answer) invocationOnMock -> "encode:" + invocationOnMock.getArgument(0)); - when(passwordEncoder.matches(eq(reqVO.getOldPassword()), eq(dbUser.getPassword()))).thenReturn(true); - - // 调用 - userService.updateUserPassword(userId, reqVO); - // 断言 - AdminUserDO user = userMapper.selectById(userId); - assertEquals("encode:yuanma", user.getPassword()); - } - - @Test - public void testUpdateUserAvatar_success() throws Exception { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - byte[] avatarFileBytes = randomBytes(10); - ByteArrayInputStream avatarFile = new ByteArrayInputStream(avatarFileBytes); - // mock 方法 - String avatar = randomString(); - when(fileApi.createFile(eq( avatarFileBytes))).thenReturn(avatar); - - // 调用 - userService.updateUserAvatar(userId, avatarFile); - // 断言 - AdminUserDO user = userMapper.selectById(userId); - assertEquals(avatar, user.getAvatar()); - } - - @Test - public void testUpdateUserPassword02_success() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - String password = "yudao"; - // mock 方法 - when(passwordEncoder.encode(anyString())).then( - (Answer) invocationOnMock -> "encode:" + invocationOnMock.getArgument(0)); - - // 调用 - userService.updateUserPassword(userId, password); - // 断言 - AdminUserDO user = userMapper.selectById(userId); - assertEquals("encode:" + password, user.getPassword()); - } - - @Test - public void testUpdateUserStatus() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - Integer status = randomCommonStatus(); - - // 调用 - userService.updateUserStatus(userId, status); - // 断言 - AdminUserDO user = userMapper.selectById(userId); - assertEquals(status, user.getStatus()); - } - - @Test - public void testDeleteUser_success(){ - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - - // 调用数据 - userService.deleteUser(userId); - // 校验结果 - assertNull(userMapper.selectById(userId)); - // 校验调用次数 - verify(permissionService, times(1)).processUserDeleted(eq(userId)); - } - - @Test - public void testGetUserByUsername() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - String username = dbUser.getUsername(); - - // 调用 - AdminUserDO user = userService.getUserByUsername(username); - // 断言 - assertPojoEquals(dbUser, user); - } - - @Test - public void testGetUserByMobile() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - String mobile = dbUser.getMobile(); - - // 调用 - AdminUserDO user = userService.getUserByMobile(mobile); - // 断言 - assertPojoEquals(dbUser, user); - } - - @Test - public void testGetUserPage() { - // mock 数据 - AdminUserDO dbUser = initGetUserPageData(); - // 准备参数 - UserPageReqVO reqVO = new UserPageReqVO(); - reqVO.setUsername("tu"); - reqVO.setMobile("1560"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2020, 12, 1, 2020, 12, 24)); - reqVO.setDeptId(1L); // 其中,1L 是 2L 的父部门 - // mock 方法 - List deptList = newArrayList(randomPojo(DeptDO.class, o -> o.setId(2L))); - when(deptService.getChildDeptList(eq(reqVO.getDeptId()))).thenReturn(deptList); - - // 调用 - PageResult pageResult = userService.getUserPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbUser, pageResult.getList().get(0)); - } - - /** - * 初始化 getUserPage 方法的测试数据 - */ - private AdminUserDO initGetUserPageData() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(o -> { // 等会查询到 - o.setUsername("tudou"); - o.setMobile("15601691300"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2020, 12, 12)); - o.setDeptId(2L); - }); - userMapper.insert(dbUser); - // 测试 username 不匹配 - userMapper.insert(cloneIgnoreId(dbUser, o -> o.setUsername("dou"))); - // 测试 mobile 不匹配 - userMapper.insert(cloneIgnoreId(dbUser, o -> o.setMobile("18818260888"))); - // 测试 status 不匹配 - userMapper.insert(cloneIgnoreId(dbUser, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - userMapper.insert(cloneIgnoreId(dbUser, o -> o.setCreateTime(buildTime(2020, 11, 11)))); - // 测试 dept 不匹配 - userMapper.insert(cloneIgnoreId(dbUser, o -> o.setDeptId(0L))); - return dbUser; - } - - @Test - public void testGetUser() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - - // 调用 - AdminUserDO user = userService.getUser(userId); - // 断言 - assertPojoEquals(dbUser, user); - } - - @Test - public void testGetUserListByDeptIds() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(o -> o.setDeptId(1L)); - userMapper.insert(dbUser); - // 测试 deptId 不匹配 - userMapper.insert(cloneIgnoreId(dbUser, o -> o.setDeptId(2L))); - // 准备参数 - Collection deptIds = singleton(1L); - - // 调用 - List list = userService.getUserListByDeptIds(deptIds); - // 断言 - assertEquals(1, list.size()); - assertEquals(dbUser, list.get(0)); - } - - /** - * 情况一,校验不通过,导致插入失败 - */ - @Test - public void testImportUserList_01() { - // 准备参数 - UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { - }); - // mock 方法,模拟失败 - doThrow(new ServiceException(DEPT_NOT_FOUND)).when(deptService).validateDeptList(any()); - - // 调用 - UserImportRespVO respVO = userService.importUserList(newArrayList(importUser), true); - // 断言 - assertEquals(0, respVO.getCreateUsernames().size()); - assertEquals(0, respVO.getUpdateUsernames().size()); - assertEquals(1, respVO.getFailureUsernames().size()); - assertEquals(DEPT_NOT_FOUND.getMsg(), respVO.getFailureUsernames().get(importUser.getUsername())); - } - - /** - * 情况二,不存在,进行插入 - */ - @Test - public void testImportUserList_02() { - // 准备参数 - UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 - }); - // mock deptService 的方法 - DeptDO dept = randomPojo(DeptDO.class, o -> { - o.setId(importUser.getDeptId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - when(deptService.getDept(eq(dept.getId()))).thenReturn(dept); - // mock passwordEncoder 的方法 - when(passwordEncoder.encode(eq("yudaoyuanma"))).thenReturn("java"); - - // 调用 - UserImportRespVO respVO = userService.importUserList(newArrayList(importUser), true); - // 断言 - assertEquals(1, respVO.getCreateUsernames().size()); - AdminUserDO user = userMapper.selectByUsername(respVO.getCreateUsernames().get(0)); - assertPojoEquals(importUser, user); - assertEquals("java", user.getPassword()); - assertEquals(0, respVO.getUpdateUsernames().size()); - assertEquals(0, respVO.getFailureUsernames().size()); - } - - /** - * 情况三,存在,但是不强制更新 - */ - @Test - public void testImportUserList_03() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 - o.setUsername(dbUser.getUsername()); - }); - // mock deptService 的方法 - DeptDO dept = randomPojo(DeptDO.class, o -> { - o.setId(importUser.getDeptId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - when(deptService.getDept(eq(dept.getId()))).thenReturn(dept); - - // 调用 - UserImportRespVO respVO = userService.importUserList(newArrayList(importUser), false); - // 断言 - assertEquals(0, respVO.getCreateUsernames().size()); - assertEquals(0, respVO.getUpdateUsernames().size()); - assertEquals(1, respVO.getFailureUsernames().size()); - assertEquals(USER_USERNAME_EXISTS.getMsg(), respVO.getFailureUsernames().get(importUser.getUsername())); - } - - /** - * 情况四,存在,强制更新 - */ - @Test - public void testImportUserList_04() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 - o.setUsername(dbUser.getUsername()); - }); - // mock deptService 的方法 - DeptDO dept = randomPojo(DeptDO.class, o -> { - o.setId(importUser.getDeptId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - when(deptService.getDept(eq(dept.getId()))).thenReturn(dept); - - // 调用 - UserImportRespVO respVO = userService.importUserList(newArrayList(importUser), true); - // 断言 - assertEquals(0, respVO.getCreateUsernames().size()); - assertEquals(1, respVO.getUpdateUsernames().size()); - AdminUserDO user = userMapper.selectByUsername(respVO.getUpdateUsernames().get(0)); - assertPojoEquals(importUser, user); - assertEquals(0, respVO.getFailureUsernames().size()); - } - - @Test - public void testValidateUserExists_notExists() { - assertServiceException(() -> userService.validateUserExists(randomLongId()), USER_NOT_EXISTS); - } - - @Test - public void testValidateUsernameUnique_usernameExistsForCreate() { - // 准备参数 - String username = randomString(); - // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setUsername(username))); - - // 调用,校验异常 - assertServiceException(() -> userService.validateUsernameUnique(null, username), - USER_USERNAME_EXISTS); - } - - @Test - public void testValidateUsernameUnique_usernameExistsForUpdate() { - // 准备参数 - Long id = randomLongId(); - String username = randomString(); - // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setUsername(username))); - - // 调用,校验异常 - assertServiceException(() -> userService.validateUsernameUnique(id, username), - USER_USERNAME_EXISTS); - } - - @Test - public void testValidateEmailUnique_emailExistsForCreate() { - // 准备参数 - String email = randomString(); - // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setEmail(email))); - - // 调用,校验异常 - assertServiceException(() -> userService.validateEmailUnique(null, email), - USER_EMAIL_EXISTS); - } - - @Test - public void testValidateEmailUnique_emailExistsForUpdate() { - // 准备参数 - Long id = randomLongId(); - String email = randomString(); - // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setEmail(email))); - - // 调用,校验异常 - assertServiceException(() -> userService.validateEmailUnique(id, email), - USER_EMAIL_EXISTS); - } - - @Test - public void testValidateMobileUnique_mobileExistsForCreate() { - // 准备参数 - String mobile = randomString(); - // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setMobile(mobile))); - - // 调用,校验异常 - assertServiceException(() -> userService.validateMobileUnique(null, mobile), - USER_MOBILE_EXISTS); - } - - @Test - public void testValidateMobileUnique_mobileExistsForUpdate() { - // 准备参数 - Long id = randomLongId(); - String mobile = randomString(); - // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setMobile(mobile))); - - // 调用,校验异常 - assertServiceException(() -> userService.validateMobileUnique(id, mobile), - USER_MOBILE_EXISTS); - } - - @Test - public void testValidateOldPassword_notExists() { - assertServiceException(() -> userService.validateOldPassword(randomLongId(), randomString()), - USER_NOT_EXISTS); - } - - @Test - public void testValidateOldPassword_passwordFailed() { - // mock 数据 - AdminUserDO user = randomAdminUserDO(); - userMapper.insert(user); - // 准备参数 - Long id = user.getId(); - String oldPassword = user.getPassword(); - - // 调用,校验异常 - assertServiceException(() -> userService.validateOldPassword(id, oldPassword), - USER_PASSWORD_FAILED); - // 校验调用 - verify(passwordEncoder, times(1)).matches(eq(oldPassword), eq(user.getPassword())); - } - - @Test - public void testUserListByPostIds() { - // 准备参数 - Collection postIds = asSet(10L, 20L); - // mock user1 数据 - AdminUserDO user1 = randomAdminUserDO(o -> o.setPostIds(asSet(10L, 30L))); - userMapper.insert(user1); - userPostMapper.insert(new UserPostDO().setUserId(user1.getId()).setPostId(10L)); - userPostMapper.insert(new UserPostDO().setUserId(user1.getId()).setPostId(30L)); - // mock user2 数据 - AdminUserDO user2 = randomAdminUserDO(o -> o.setPostIds(singleton(100L))); - userMapper.insert(user2); - userPostMapper.insert(new UserPostDO().setUserId(user2.getId()).setPostId(100L)); - - // 调用 - List result = userService.getUserListByPostIds(postIds); - // 断言 - assertEquals(1, result.size()); - assertEquals(user1, result.get(0)); - } - - @Test - public void testGetUserList() { - // mock 数据 - AdminUserDO user = randomAdminUserDO(); - userMapper.insert(user); - // 测试 id 不匹配 - userMapper.insert(randomAdminUserDO()); - // 准备参数 - Collection ids = singleton(user.getId()); - - // 调用 - List result = userService.getUserList(ids); - // 断言 - assertEquals(1, result.size()); - assertEquals(user, result.get(0)); - } - - @Test - public void testGetUserMap() { - // mock 数据 - AdminUserDO user = randomAdminUserDO(); - userMapper.insert(user); - // 测试 id 不匹配 - userMapper.insert(randomAdminUserDO()); - // 准备参数 - Collection ids = singleton(user.getId()); - - // 调用 - Map result = userService.getUserMap(ids); - // 断言 - assertEquals(1, result.size()); - assertEquals(user, result.get(user.getId())); - } - - @Test - public void testGetUserListByNickname() { - // mock 数据 - AdminUserDO user = randomAdminUserDO(o -> o.setNickname("芋头")); - userMapper.insert(user); - // 测试 nickname 不匹配 - userMapper.insert(randomAdminUserDO(o -> o.setNickname("源码"))); - // 准备参数 - String nickname = "芋"; - - // 调用 - List result = userService.getUserListByNickname(nickname); - // 断言 - assertEquals(1, result.size()); - assertEquals(user, result.get(0)); - } - - @Test - public void testGetUserListByStatus() { - // mock 数据 - AdminUserDO user = randomAdminUserDO(o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - userMapper.insert(user); - // 测试 status 不匹配 - userMapper.insert(randomAdminUserDO(o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus()))); - // 准备参数 - Integer status = CommonStatusEnum.DISABLE.getStatus(); - - // 调用 - List result = userService.getUserListByStatus(status); - // 断言 - assertEquals(1, result.size()); - assertEquals(user, result.get(0)); - } - - @Test - public void testValidateUserList_success() { - // mock 数据 - AdminUserDO userDO = randomAdminUserDO().setStatus(CommonStatusEnum.ENABLE.getStatus()); - userMapper.insert(userDO); - // 准备参数 - List ids = singletonList(userDO.getId()); - - // 调用,无需断言 - userService.validateUserList(ids); - } - - @Test - public void testValidateUserList_notFound() { - // 准备参数 - List ids = singletonList(randomLongId()); - - // 调用, 并断言异常 - assertServiceException(() -> userService.validateUserList(ids), USER_NOT_EXISTS); - } - - @Test - public void testValidateUserList_notEnable() { - // mock 数据 - AdminUserDO userDO = randomAdminUserDO().setStatus(CommonStatusEnum.DISABLE.getStatus()); - userMapper.insert(userDO); - // 准备参数 - List ids = singletonList(userDO.getId()); - - // 调用, 并断言异常 - assertServiceException(() -> userService.validateUserList(ids), USER_IS_DISABLE, - userDO.getNickname()); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static AdminUserDO randomAdminUserDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 - }; - return randomPojo(AdminUserDO.class, ArrayUtils.append(consumer, consumers)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml b/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 78d1d9c68b..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,55 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module - captcha: - timeout: 5m - width: 160 - height: 60 - enable: true diff --git a/yudao-module-system/yudao-module-system-biz/src/test/resources/logback.xml b/yudao-module-system/yudao-module-system-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff0..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-system/yudao-module-system-biz/src/test/resources/sql/clean.sql b/yudao-module-system/yudao-module-system-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index 55778022ec..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,35 +0,0 @@ -DELETE FROM "system_dept"; -DELETE FROM "system_dict_data"; -DELETE FROM "system_role"; -DELETE FROM "system_role_menu"; -DELETE FROM "system_menu"; -DELETE FROM "system_user_role"; -DELETE FROM "system_dict_type"; -DELETE FROM "system_user_session"; -DELETE FROM "system_post"; -DELETE FROM "system_user_post"; -DELETE FROM "system_notice"; -DELETE FROM "system_login_log"; -DELETE FROM "system_operate_log"; -DELETE FROM "system_users"; -DELETE FROM "system_sms_channel"; -DELETE FROM "system_sms_template"; -DELETE FROM "system_sms_log"; -DELETE FROM "system_sms_code"; -DELETE FROM "system_error_code"; -DELETE FROM "system_social_client"; -DELETE FROM "system_social_user"; -DELETE FROM "system_social_user_bind"; -DELETE FROM "system_tenant"; -DELETE FROM "system_tenant_package"; -DELETE FROM "system_sensitive_word"; -DELETE FROM "system_oauth2_client"; -DELETE FROM "system_oauth2_approve"; -DELETE FROM "system_oauth2_access_token"; -DELETE FROM "system_oauth2_refresh_token"; -DELETE FROM "system_oauth2_code"; -DELETE FROM "system_mail_account"; -DELETE FROM "system_mail_template"; -DELETE FROM "system_mail_log"; -DELETE FROM "system_notify_template"; -DELETE FROM "system_notify_message"; diff --git a/yudao-module-system/yudao-module-system-biz/src/test/resources/sql/create_tables.sql b/yudao-module-system/yudao-module-system-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 78d4e83dd1..0000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,648 +0,0 @@ -CREATE TABLE IF NOT EXISTS "system_dept" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(30) NOT NULL DEFAULT '', - "parent_id" bigint NOT NULL DEFAULT '0', - "sort" int NOT NULL DEFAULT '0', - "leader_user_id" bigint DEFAULT NULL, - "phone" varchar(11) DEFAULT NULL, - "email" varchar(50) DEFAULT NULL, - "status" tinyint NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '部门表'; - -CREATE TABLE IF NOT EXISTS "system_dict_data" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "sort" int NOT NULL DEFAULT '0', - "label" varchar(100) NOT NULL DEFAULT '', - "value" varchar(100) NOT NULL DEFAULT '', - "dict_type" varchar(100) NOT NULL DEFAULT '', - "status" tinyint NOT NULL DEFAULT '0', - "color_type" varchar(100) NOT NULL DEFAULT '', - "css_class" varchar(100) NOT NULL DEFAULT '', - "remark" varchar(500) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '字典数据表'; - -CREATE TABLE IF NOT EXISTS "system_role" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(30) NOT NULL, - "code" varchar(100) NOT NULL, - "sort" int NOT NULL, - "data_scope" tinyint NOT NULL DEFAULT '1', - "data_scope_dept_ids" varchar(500) NOT NULL DEFAULT '', - "status" tinyint NOT NULL, - "type" tinyint NOT NULL, - "remark" varchar(500) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '角色信息表'; - -CREATE TABLE IF NOT EXISTS "system_role_menu" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "role_id" bigint NOT NULL, - "menu_id" bigint NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '角色和菜单关联表'; - -CREATE TABLE IF NOT EXISTS "system_menu" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(50) NOT NULL, - "permission" varchar(100) NOT NULL DEFAULT '', - "type" tinyint NOT NULL, - "sort" int NOT NULL DEFAULT '0', - "parent_id" bigint NOT NULL DEFAULT '0', - "path" varchar(200) DEFAULT '', - "icon" varchar(100) DEFAULT '#', - "component" varchar(255) DEFAULT NULL, - "component_name" varchar(255) DEFAULT NULL, - "status" tinyint NOT NULL DEFAULT '0', - "visible" bit NOT NULL DEFAULT TRUE, - "keep_alive" bit NOT NULL DEFAULT TRUE, - "always_show" bit NOT NULL DEFAULT TRUE, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '菜单权限表'; - -CREATE TABLE IF NOT EXISTS "system_user_role" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "role_id" bigint NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp DEFAULT NULL, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp DEFAULT NULL, - "deleted" bit DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '用户和角色关联表'; - -CREATE TABLE IF NOT EXISTS "system_dict_type" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(100) NOT NULL DEFAULT '', - "type" varchar(100) NOT NULL DEFAULT '', - "status" tinyint NOT NULL DEFAULT '0', - "remark" varchar(500) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "deleted_time" timestamp NOT NULL, - PRIMARY KEY ("id") -) COMMENT '字典类型表'; - -CREATE TABLE IF NOT EXISTS `system_user_session` ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `token` varchar(32) NOT NULL, - `user_id` bigint DEFAULT NULL, - "user_type" tinyint NOT NULL, - `username` varchar(50) NOT NULL DEFAULT '', - `user_ip` varchar(50) DEFAULT NULL, - `user_agent` varchar(512) DEFAULT NULL, - `session_timeout` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) DEFAULT '' , - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY (`id`) -) COMMENT '用户在线 Session'; - -CREATE TABLE IF NOT EXISTS "system_post" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "code" varchar(64) NOT NULL, - "name" varchar(50) NOT NULL, - "sort" integer NOT NULL, - "status" tinyint NOT NULL, - "remark" varchar(500) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '岗位信息表'; - -CREATE TABLE IF NOT EXISTS `system_user_post`( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint DEFAULT NULL, - "post_id" bigint DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY (`id`) -) COMMENT ='用户岗位表'; - -CREATE TABLE IF NOT EXISTS "system_notice" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "title" varchar(50) NOT NULL COMMENT '公告标题', - "content" text NOT NULL COMMENT '公告内容', - "type" tinyint NOT NULL COMMENT '公告类型(1通知 2公告)', - "status" tinyint NOT NULL DEFAULT '0' COMMENT '公告状态(0正常 1关闭)', - "creator" varchar(64) DEFAULT '' COMMENT '创建者', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - "updater" varchar(64) DEFAULT '' COMMENT '更新者', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - "deleted" bit NOT NULL DEFAULT 0 COMMENT '是否删除', - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '通知公告表'; - -CREATE TABLE IF NOT EXISTS `system_login_log` ( - `id` bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `log_type` bigint(4) NOT NULL, - "user_id" bigint not null default '0', - "user_type" tinyint NOT NULL, - `trace_id` varchar(64) NOT NULL DEFAULT '', - `username` varchar(50) NOT NULL DEFAULT '', - `result` tinyint(4) NOT NULL, - `user_ip` varchar(50) NOT NULL, - `user_agent` varchar(512) NOT NULL, - `creator` varchar(64) DEFAULT '', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) DEFAULT '', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) COMMENT ='系统访问记录'; - -CREATE TABLE IF NOT EXISTS `system_operate_log` ( - `id` bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `trace_id` varchar(64) NOT NULL DEFAULT '', - `user_id` bigint(20) NOT NULL, - "user_type" tinyint not null default '0', - `module` varchar(50) NOT NULL, - `name` varchar(50) NOT NULL, - `type` bigint(4) NOT NULL DEFAULT '0', - `content` varchar(2000) NOT NULL DEFAULT '', - `exts` varchar(512) NOT NULL DEFAULT '', - `request_method` varchar(16) DEFAULT '', - `request_url` varchar(255) DEFAULT '', - `user_ip` varchar(50) DEFAULT NULL, - `user_agent` varchar(200) DEFAULT NULL, - `java_method` varchar(512) NOT NULL DEFAULT '', - `java_method_args` varchar(8000) DEFAULT '', - `start_time` datetime NOT NULL, - `duration` int(11) NOT NULL, - `result_code` int(11) NOT NULL DEFAULT '0', - `result_msg` varchar(512) DEFAULT '', - `result_data` varchar(4000) DEFAULT '', - `creator` varchar(64) DEFAULT '', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) DEFAULT '', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT '0', - "tenant_id" bigint not null default '0', - PRIMARY KEY (`id`) -) COMMENT ='操作日志记录'; - -CREATE TABLE IF NOT EXISTS "system_users" ( - "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, - "username" varchar(30) not null, - "password" varchar(100) not null default '', - "nickname" varchar(30) not null, - "remark" varchar(500) default null, - "dept_id" bigint default null, - "post_ids" varchar(255) default null, - "email" varchar(50) default '', - "mobile" varchar(11) default '', - "sex" tinyint default '0', - "avatar" varchar(100) default '', - "status" tinyint not null default '0', - "login_ip" varchar(50) default '', - "login_date" timestamp default null, - "creator" varchar(64) default '', - "create_time" timestamp not null default current_timestamp, - "updater" varchar(64) default '', - "update_time" timestamp not null default current_timestamp, - "deleted" bit not null default false, - "tenant_id" bigint not null default '0', - primary key ("id") -) comment '用户信息表'; - -CREATE TABLE IF NOT EXISTS "system_sms_channel" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "signature" varchar(10) NOT NULL, - "code" varchar(63) NOT NULL, - "status" tinyint NOT NULL, - "remark" varchar(255) DEFAULT NULL, - "api_key" varchar(63) NOT NULL, - "api_secret" varchar(63) DEFAULT NULL, - "callback_url" varchar(255) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '短信渠道'; - -CREATE TABLE IF NOT EXISTS "system_sms_template" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "type" tinyint NOT NULL, - "status" tinyint NOT NULL, - "code" varchar(63) NOT NULL, - "name" varchar(63) NOT NULL, - "content" varchar(255) NOT NULL, - "params" varchar(255) NOT NULL, - "remark" varchar(255) DEFAULT NULL, - "api_template_id" varchar(63) NOT NULL, - "channel_id" bigint NOT NULL, - "channel_code" varchar(63) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '短信模板'; - -CREATE TABLE IF NOT EXISTS "system_sms_log" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "channel_id" bigint NOT NULL, - "channel_code" varchar(63) NOT NULL, - "template_id" bigint NOT NULL, - "template_code" varchar(63) NOT NULL, - "template_type" tinyint NOT NULL, - "template_content" varchar(255) NOT NULL, - "template_params" varchar(255) NOT NULL, - "api_template_id" varchar(63) NOT NULL, - "mobile" varchar(11) NOT NULL, - "user_id" bigint DEFAULT '0', - "user_type" tinyint DEFAULT '0', - "send_status" tinyint NOT NULL DEFAULT '0', - "send_time" timestamp DEFAULT NULL, - "send_code" int DEFAULT NULL, - "send_msg" varchar(255) DEFAULT NULL, - "api_send_code" varchar(63) DEFAULT NULL, - "api_send_msg" varchar(255) DEFAULT NULL, - "api_request_id" varchar(255) DEFAULT NULL, - "api_serial_no" varchar(255) DEFAULT NULL, - "receive_status" tinyint NOT NULL DEFAULT '0', - "receive_time" timestamp DEFAULT NULL, - "api_receive_code" varchar(63) DEFAULT NULL, - "api_receive_msg" varchar(255) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '短信日志'; - -CREATE TABLE IF NOT EXISTS "system_sms_code" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "mobile" varchar(11) NOT NULL, - "code" varchar(11) NOT NULL, - "scene" bigint NOT NULL, - "create_ip" varchar NOT NULL, - "today_index" int NOT NULL, - "used" bit NOT NULL DEFAULT FALSE, - "used_time" timestamp DEFAULT NULL, - "used_ip" varchar NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '短信日志'; - -CREATE TABLE IF NOT EXISTS "system_error_code" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "type" tinyint NOT NULL DEFAULT '0', - "application_name" varchar(50) NOT NULL, - "code" int NOT NULL DEFAULT '0', - "message" varchar(512) NOT NULL DEFAULT '', - "memo" varchar(512) DEFAULT '', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '错误码表'; - -CREATE TABLE IF NOT EXISTS "system_social_client" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(255) NOT NULL, - "social_type" int NOT NULL, - "user_type" int NOT NULL, - "client_id" varchar(255) NOT NULL, - "client_secret" varchar(255) NOT NULL, - "agent_id" varchar(255) NOT NULL, - "status" int NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '社交客户端表'; - -CREATE TABLE IF NOT EXISTS "system_social_user" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "type" tinyint NOT NULL, - "openid" varchar(64) NOT NULL, - "token" varchar(256) DEFAULT NULL, - "raw_token_info" varchar(1024) NOT NULL, - "nickname" varchar(32) NOT NULL, - "avatar" varchar(255) DEFAULT NULL, - "raw_user_info" varchar(1024) NOT NULL, - "code" varchar(64) NOT NULL, - "state" varchar(64), - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '社交用户'; - -CREATE TABLE IF NOT EXISTS "system_social_user_bind" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" tinyint NOT NULL, - "social_type" tinyint NOT NULL, - "social_user_id" number NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '社交用户的绑定'; - -CREATE TABLE IF NOT EXISTS "system_tenant" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "contact_user_id" bigint NOT NULL DEFAULT '0', - "contact_name" varchar(255) NOT NULL, - "contact_mobile" varchar(255), - "status" tinyint NOT NULL, - "website" varchar(63) DEFAULT '', - "package_id" bigint NOT NULL, - "expire_time" timestamp NOT NULL, - "account_count" int NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '租户'; - -CREATE TABLE IF NOT EXISTS "system_tenant_package" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(30) NOT NULL, - "status" tinyint NOT NULL, - "remark" varchar(256), - "menu_ids" varchar(2048) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '租户套餐表'; - -CREATE TABLE IF NOT EXISTS "system_sensitive_word" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(255) NOT NULL, - "tags" varchar(1024) NOT NULL, - "status" bit NOT NULL DEFAULT FALSE, - "description" varchar(512), - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '系统敏感词'; - -CREATE TABLE IF NOT EXISTS "system_oauth2_client" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "client_id" varchar NOT NULL, - "secret" varchar NOT NULL, - "name" varchar NOT NULL, - "logo" varchar NOT NULL, - "description" varchar, - "status" int NOT NULL, - "access_token_validity_seconds" int NOT NULL, - "refresh_token_validity_seconds" int NOT NULL, - "redirect_uris" varchar NOT NULL, - "authorized_grant_types" varchar NOT NULL, - "scopes" varchar NOT NULL DEFAULT '', - "auto_approve_scopes" varchar NOT NULL DEFAULT '', - "authorities" varchar NOT NULL DEFAULT '', - "resource_ids" varchar NOT NULL DEFAULT '', - "additional_information" varchar NOT NULL DEFAULT '', - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT 'OAuth2 客户端表'; - -CREATE TABLE IF NOT EXISTS "system_oauth2_approve" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" tinyint NOT NULL, - "client_id" varchar NOT NULL, - "scope" varchar NOT NULL, - "approved" bit NOT NULL DEFAULT FALSE, - "expires_time" datetime NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT 'OAuth2 批准表'; - -CREATE TABLE IF NOT EXISTS "system_oauth2_access_token" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" tinyint NOT NULL, - "access_token" varchar NOT NULL, - "refresh_token" varchar NOT NULL, - "client_id" varchar NOT NULL, - "scopes" varchar NOT NULL, - "approved" bit NOT NULL DEFAULT FALSE, - "expires_time" datetime NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT 'OAuth2 访问令牌'; - -CREATE TABLE IF NOT EXISTS "system_oauth2_refresh_token" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" tinyint NOT NULL, - "refresh_token" varchar NOT NULL, - "client_id" varchar NOT NULL, - "scopes" varchar NOT NULL, - "approved" bit NOT NULL DEFAULT FALSE, - "expires_time" datetime NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT 'OAuth2 刷新令牌'; - -CREATE TABLE IF NOT EXISTS "system_oauth2_code" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" tinyint NOT NULL, - "code" varchar NOT NULL, - "client_id" varchar NOT NULL, - "scopes" varchar NOT NULL, - "expires_time" datetime NOT NULL, - "redirect_uri" varchar NOT NULL, - "state" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT 'OAuth2 刷新令牌'; - -CREATE TABLE IF NOT EXISTS "system_mail_account" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "mail" varchar NOT NULL, - "username" varchar NOT NULL, - "password" varchar NOT NULL, - "host" varchar NOT NULL, - "port" int NOT NULL, - "ssl_enable" bit NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '邮箱账号表'; - -CREATE TABLE IF NOT EXISTS "system_mail_template" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "code" varchar NOT NULL, - "account_id" bigint NOT NULL, - "nickname" varchar, - "title" varchar NOT NULL, - "content" varchar NOT NULL, - "params" varchar NOT NULL, - "status" varchar NOT NULL, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '邮件模版表'; - -CREATE TABLE IF NOT EXISTS "system_mail_log" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint, - "user_type" varchar, - "to_mail" varchar NOT NULL, - "account_id" bigint NOT NULL, - "from_mail" varchar NOT NULL, - "template_id" bigint NOT NULL, - "template_code" varchar NOT NULL, - "template_nickname" varchar, - "template_title" varchar NOT NULL, - "template_content" varchar NOT NULL, - "template_params" varchar NOT NULL, - "send_status" varchar NOT NULL, - "send_time" datetime, - "send_message_id" varchar, - "send_exception" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '邮件日志表'; - --- 将该建表 SQL 语句,添加到 yudao-module-system-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "system_notify_template" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "code" varchar NOT NULL, - "nickname" varchar NOT NULL, - "content" varchar NOT NULL, - "type" varchar NOT NULL, - "params" varchar, - "status" varchar NOT NULL, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '站内信模板表'; - -CREATE TABLE IF NOT EXISTS "system_notify_message" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" varchar NOT NULL, - "template_id" bigint NOT NULL, - "template_code" varchar NOT NULL, - "template_nickname" varchar NOT NULL, - "template_content" varchar NOT NULL, - "template_type" int NOT NULL, - "template_params" varchar NOT NULL, - "read_status" bit NOT NULL, - "read_time" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '站内信消息表';