Compare commits
86
Commits
v1.0.3
..
9555474b0b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9555474b0b | ||
|
|
022185079c | ||
|
|
acc3f05f12 | ||
|
|
a150f9e017 | ||
|
|
a523df6a07 | ||
|
|
31c583eeb5 | ||
|
|
e3ef3e5275 | ||
|
|
84190b9773 | ||
|
|
7808d22775 | ||
|
|
fba559cd22 | ||
|
|
ecd2fa1c33 | ||
|
|
dcc75efa87 | ||
|
|
a9465299a9 | ||
|
|
42152c7b79 | ||
|
|
1a896ef457 | ||
|
|
9d8990a028 | ||
|
|
17d88fc338 | ||
|
|
bb40f347a3 | ||
|
|
e3236d262d | ||
|
|
3d4e32e5da | ||
|
|
c8e2e16ba5 | ||
|
|
bdc4cbb240 | ||
|
|
99b44faf09 | ||
|
|
7f6cebd4e2 | ||
|
|
75fd4bed18 | ||
|
|
b3e3cbf84b | ||
|
|
8db6f962c9 | ||
|
|
0aee11d824 | ||
|
|
e35cf3aa59 | ||
|
|
457e716b38 | ||
|
|
ab4a164680 | ||
|
|
9dfca25f8c | ||
|
|
e369a38e2e | ||
|
|
f1e10df6a7 | ||
|
|
fcf358a768 | ||
|
|
36e2a37af2 | ||
|
|
348f7396a1 | ||
|
|
619369104c | ||
|
|
c0b04fc554 | ||
|
|
5e5748b521 | ||
|
|
67d79f7527 | ||
|
|
ee530d2a8c | ||
|
|
5f36844279 | ||
|
|
5b9391a50a | ||
|
|
6bc73414d9 | ||
|
|
4f1408b9d0 | ||
|
|
d555aad9ac | ||
|
|
029eea70cc | ||
|
|
2f42204794 | ||
|
|
22b1e65385 | ||
|
|
72bdb8d49b | ||
|
|
5ec6bc472f | ||
|
|
81b7356d67 | ||
|
|
44af16f451 | ||
|
|
c6157db0de | ||
|
|
39ac73dc66 | ||
|
|
6e43ff349d | ||
|
|
ab79391cdc | ||
|
|
67bc9382c5 | ||
|
|
7e40e0202e | ||
|
|
7ffdd715ee | ||
|
|
1709316ce1 | ||
|
|
2170c48763 | ||
|
|
568563475e | ||
|
|
8a92e46eb1 | ||
|
|
1875cec8a5 | ||
|
|
c2d1c48aae | ||
|
|
4c162dad34 | ||
|
|
e14958c643 | ||
|
|
c49686c411 | ||
|
|
65161a7fad | ||
|
|
187f270866 | ||
|
|
50d4bba045 | ||
|
|
6eedc06a07 | ||
|
|
b55b43eba4 | ||
|
|
20289a3168 | ||
|
|
d45bf11477 | ||
|
|
7370b2fc98 | ||
|
|
da288338cd | ||
|
|
2f366fe219 | ||
|
|
ea430f2468 | ||
|
|
f1715a3e32 | ||
|
|
f76f79744a | ||
|
|
833a303bb6 | ||
|
|
19daaff907 | ||
|
|
1658be7d8d |
@@ -46,6 +46,11 @@ jobs:
|
||||
<username>${{ vars.TIMI_NEXUS_USERNAME }}</username>
|
||||
<password>${{ vars.TIMI_NEXUS_PASSWORD }}</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>e2ins_nexus</id>
|
||||
<username>${{ vars.E2INS_NEXUS_USERNAME }}</username>
|
||||
<password>${{ vars.E2INS_NEXUS_PASSWORD }}</password>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
||||
EOF
|
||||
|
||||
Generated
-7
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourcePerFileMappings">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java/com/imyeyu/api/modules/user/mapper/UserMapper.java" value="05742bdc-a11a-4147-9168-ef976a70258a" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources/mapper/timi-server/GaoCustomerMapper.xml" value="05742bdc-a11a-4147-9168-ef976a70258a" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+1
@@ -3,6 +3,7 @@
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources/db/migration/timiserver/V1__init_schema.sql" dialect="MariaDB" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources/db/migration/timiserver/V2__init_system_data.sql" dialect="GenericSQL" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources/mapper/timi-server/gao/GaoEventRecordMapper.xml" dialect="MariaDB" />
|
||||
<file url="PROJECT" dialect="MariaDB" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<groupId>com.imyeyu.timiserverapi</groupId>
|
||||
<artifactId>TimiServerAPI</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<version>1.0.19</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>TimiServerAPI</name>
|
||||
<description>imyeyu.com API</description>
|
||||
@@ -167,18 +167,28 @@
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>e2ins_nexus</id>
|
||||
<url>https://nexus.e2ins.com/repository/maven-public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.imyeyu.spring</groupId>
|
||||
<artifactId>timi-spring</artifactId>
|
||||
<version>0.0.17</version>
|
||||
<version>0.0.19</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.imyeyu.network</groupId>
|
||||
<artifactId>timi-network</artifactId>
|
||||
<version>0.0.13</version>
|
||||
<version>0.0.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.imyeyu.lang</groupId>
|
||||
@@ -188,12 +198,17 @@
|
||||
<dependency>
|
||||
<groupId>com.imyeyu.java</groupId>
|
||||
<artifactId>timi-java</artifactId>
|
||||
<version>0.0.6</version>
|
||||
<version>0.0.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.imyeyu.utils</groupId>
|
||||
<artifactId>timi-utils</artifactId>
|
||||
<version>0.0.12</version>
|
||||
<version>0.0.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.majiajie</groupId>
|
||||
<artifactId>tinypinyin</artifactId>
|
||||
<version>2.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.imyeyu.font.icon</groupId>
|
||||
@@ -225,11 +240,29 @@
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-mysql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.e2ins.ms.notify</groupId>
|
||||
<artifactId>e2ins-msg-notify-service-sdk</artifactId>
|
||||
<version>0.0.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java-sms</artifactId>
|
||||
<version>3.1.1281</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-freemarker</artifactId>
|
||||
<version>${springboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.imyeyu.api.annotation;
|
||||
|
||||
import com.imyeyu.api.bean.RoleMatchMode;
|
||||
import com.imyeyu.api.bean.CoreRoleCode;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
///
|
||||
/// 要求 CORE 模块角色
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-26
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface RequireCoreRole {
|
||||
|
||||
/// 所需角色
|
||||
///
|
||||
/// @return 角色列表
|
||||
CoreRoleCode[] value();
|
||||
|
||||
/// 匹配模式
|
||||
///
|
||||
/// @return 匹配模式
|
||||
RoleMatchMode mode() default RoleMatchMode.ALL;
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.imyeyu.api.annotation;
|
||||
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.bean.RoleMatchMode;
|
||||
import com.imyeyu.api.bean.CoreRoleCode;
|
||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
///
|
||||
/// CORE 角色注解处理器
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-27
|
||||
@Component
|
||||
public class RequireCoreRoleInterceptor implements HandlerInterceptor {
|
||||
|
||||
private final RoleChecker roleChecker;
|
||||
|
||||
public RequireCoreRoleInterceptor(RoleChecker roleChecker) {
|
||||
this.roleChecker = roleChecker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preHandle(@NonNull HttpServletRequest req, @NonNull HttpServletResponse resp, @NonNull Object handler) {
|
||||
if (!(handler instanceof HandlerMethod handlerMethod)) {
|
||||
return true;
|
||||
}
|
||||
RequireCoreRole annotation = handlerMethod.getMethodAnnotation(RequireCoreRole.class);
|
||||
if (annotation == null || TimiJava.isEmpty(annotation.value())) {
|
||||
return true;
|
||||
}
|
||||
String[] roleCodeList = java.util.Arrays.stream(annotation.value()).map(CoreRoleCode::name).toArray(String[]::new);
|
||||
if (annotation.mode() == RoleMatchMode.ANY) {
|
||||
roleChecker.checkAny(ModuleCode.CORE, roleCodeList);
|
||||
} else {
|
||||
roleChecker.checkAll(ModuleCode.CORE, roleCodeList);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,9 @@ public enum CorePermissionCode implements BuiltinPermissionCode {
|
||||
ROLE_PERMISSION_READ("ROLE_PERMISSION:READ", "角色权限读取", false, true),
|
||||
ROLE_PERMISSION_DELETE("ROLE_PERMISSION:DELETE", "角色权限删除", false, true),
|
||||
|
||||
ROLE_RELATION_CREATE("ROLE_RELATION:CREATE", "角色关联创建", false, true),
|
||||
ROLE_RELATION_READ("ROLE_RELATION:READ", "角色关联读取", false, true),
|
||||
ROLE_RELATION_DELETE("ROLE_RELATION:DELETE", "角色关联删除", false, true),
|
||||
ROLE_PERMISSION_INHERIT_CREATE("ROLE_PERMISSION_INHERIT:CREATE", "角色权限继承创建", false, true),
|
||||
ROLE_PERMISSION_INHERIT_READ("ROLE_PERMISSION_INHERIT:READ", "角色权限继承读取", false, true),
|
||||
ROLE_PERMISSION_INHERIT_DELETE("ROLE_PERMISSION_INHERIT:DELETE", "角色权限继承删除", false, true),
|
||||
|
||||
SETTING_CREATE("SETTING:CREATE", "设置创建", false, true),
|
||||
SETTING_READ("SETTING:READ", "设置读取", false, true),
|
||||
@@ -39,11 +39,27 @@ public enum CorePermissionCode implements BuiltinPermissionCode {
|
||||
MULTILINGUAL_UPDATE("MULTILINGUAL:UPDATE", "多语言修改", false, true),
|
||||
MULTILINGUAL_DELETE("MULTILINGUAL:DELETE", "多语言删除", false, true),
|
||||
|
||||
TAG_CREATE("TAG:CREATE", "标签创建", false, true),
|
||||
TAG_READ("TAG:READ", "标签读取", false, true),
|
||||
TAG_APPLY("TAG:APPLY", "标签应用", false, true),
|
||||
TAG_UPDATE("TAG:UPDATE", "标签修改", false, true),
|
||||
TAG_DELETE("TAG:DELETE", "标签删除", false, true),
|
||||
|
||||
USER_CREATE("USER:CREATE", "用户创建", false, true),
|
||||
USER_READ("USER:READ", "用户读取", false, true),
|
||||
USER_UPDATE("USER:UPDATE", "用户修改", false, true),
|
||||
USER_DELETE("USER:DELETE", "用户删除", false, true),
|
||||
|
||||
FEEDBACK_CREATE("FEEDBACK:CREATE", "反馈创建", false, true),
|
||||
FEEDBACK_READ("FEEDBACK:READ", "反馈读取", false, true),
|
||||
FEEDBACK_UPDATE("FEEDBACK:UPDATE", "反馈修改", false, true),
|
||||
FEEDBACK_DELETE("FEEDBACK:DELETE", "反馈删除", false, true),
|
||||
|
||||
NOTIFY_CREATE("NOTIFY:CREATE", "通知创建", false, true),
|
||||
NOTIFY_READ("NOTIFY:READ", "通知读取", false, true),
|
||||
NOTIFY_DELETE("NOTIFY:DELETE", "通知删除", false, true),
|
||||
NOTIFY_CANCEL("NOTIFY:CANCEL", "通知取消", false, true),
|
||||
|
||||
USER_ROLE_CREATE("USER_ROLE:CREATE", "用户角色创建", true, true),
|
||||
USER_ROLE_READ("USER_ROLE:READ", "用户角色读取", true, true),
|
||||
USER_ROLE_DELETE("USER_ROLE:DELETE", "用户角色删除", true, true);
|
||||
|
||||
@@ -13,9 +13,7 @@ public enum CoreRoleCode implements BuiltinRoleCode {
|
||||
|
||||
SYSTEM("系统", true, null),
|
||||
|
||||
ADMIN("管理员", false, SYSTEM.name()),
|
||||
|
||||
USER_ROLE_ADMIN("授权管理", false, ADMIN.name());
|
||||
ADMIN("管理员", false, SYSTEM.name());
|
||||
|
||||
final String defaultName;
|
||||
final boolean protectedRole;
|
||||
@@ -40,4 +38,5 @@ public enum CoreRoleCode implements BuiltinRoleCode {
|
||||
public String getParentCode() {
|
||||
return parentCode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.imyeyu.api.config;
|
||||
|
||||
import com.e2ins.ms.notify.SmsNotifyService;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
@@ -7,6 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.imyeyu.utils.Time;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -22,6 +24,7 @@ public class BeanConfig {
|
||||
@Bean
|
||||
public ObjectMapper jackson() {
|
||||
return JsonMapper.builder()
|
||||
.addModule(new JavaTimeModule())
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.defaultDateFormat(Time.dateTime)
|
||||
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
|
||||
@@ -29,6 +32,12 @@ public class BeanConfig {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SmsNotifyService smsNotifyService() {
|
||||
// TODO
|
||||
return new SmsNotifyService(null, null);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Yaml yaml() {
|
||||
return new Yaml();
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.imyeyu.api.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.imyeyu.api.modules.common.entity.Multilingual;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoUserInviteCache;
|
||||
import com.imyeyu.spring.bean.RedisConfigParams;
|
||||
import com.imyeyu.spring.config.AbstractRedisConfig;
|
||||
import com.imyeyu.spring.util.Redis;
|
||||
@@ -202,4 +203,10 @@ public class RedisConfig extends AbstractRedisConfig {
|
||||
public Redis<String, String> getClipboardRedisTemplate() {
|
||||
return getRedis(database, RedisSerializers.STRING, RedisSerializers.STRING);
|
||||
}
|
||||
|
||||
/// @return GAO 用户邀请,code: 邀请缓存
|
||||
@Bean("redisGaoUserInvite")
|
||||
public Redis<String, GaoUserInviteCache> getGaoUserInviteRedisTemplate() {
|
||||
return getRedis(database, RedisSerializers.STRING, RedisSerializers.jacksonSerializer(jackson, GaoUserInviteCache.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,11 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.imyeyu.api.annotation.EnableSettingInterceptor;
|
||||
import com.imyeyu.api.annotation.RequestRateLimitInterceptor;
|
||||
import com.imyeyu.api.annotation.RequireCorePermissionInterceptor;
|
||||
import com.imyeyu.api.annotation.RequireCoreRoleInterceptor;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermissionInterceptor;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoRoleInterceptor;
|
||||
import com.imyeyu.api.modules.journal.util.JournalAPIInterceptor;
|
||||
import com.imyeyu.api.modules.system.util.SystemAPIInterceptor;
|
||||
import com.imyeyu.spring.annotation.RequestBodyValueArgumentResolver;
|
||||
@@ -42,8 +41,6 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
private final SystemAPIInterceptor systemAPIInterceptor;
|
||||
private final JournalAPIInterceptor journalAPIInterceptor;
|
||||
private final EnableSettingInterceptor enableSettingInterceptor;
|
||||
private final RequireGaoRoleInterceptor requireGaoRoleInterceptor;
|
||||
private final RequireCoreRoleInterceptor requireCoreRoleInterceptor;
|
||||
private final RequestRateLimitInterceptor requestRateLimitInterceptor;
|
||||
private final RequireGaoPermissionInterceptor requireGaoPermissionInterceptor;
|
||||
private final RequireCorePermissionInterceptor requireCorePermissionInterceptor;
|
||||
@@ -58,9 +55,7 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
registry.addInterceptor(systemAPIInterceptor).addPathPatterns(SystemAPIInterceptor.PATH);
|
||||
registry.addInterceptor(journalAPIInterceptor).addPathPatterns(JournalAPIInterceptor.PATH);
|
||||
registry.addInterceptor(enableSettingInterceptor).addPathPatterns("/**");
|
||||
registry.addInterceptor(requireCoreRoleInterceptor).addPathPatterns("/**");
|
||||
registry.addInterceptor(requireCorePermissionInterceptor).addPathPatterns("/**");
|
||||
registry.addInterceptor(requireGaoRoleInterceptor).addPathPatterns("/**");
|
||||
registry.addInterceptor(requireGaoPermissionInterceptor).addPathPatterns("/**");
|
||||
registry.addInterceptor(requestRateLimitInterceptor).addPathPatterns("/**");
|
||||
}
|
||||
@@ -78,6 +73,7 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
JsonMapper jsonMapper = JsonMapper.builder()
|
||||
.addModule(new JavaTimeModule())
|
||||
// 设置默认属性包含规则:忽略 null 值
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
// 日期格式化
|
||||
|
||||
@@ -32,6 +32,8 @@ public enum SettingModule {
|
||||
|
||||
TEMP_FILE(Setting.Module.TempFile.class),
|
||||
|
||||
USER(Setting.Module.User.class),
|
||||
|
||||
SYSTEM(Setting.Module.System.class),
|
||||
|
||||
SYSTEM_STATUS(Setting.Module.SystemStatus.class);
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.imyeyu.api.modules.common.config;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/// 通知消息队列配置
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "notify.queue")
|
||||
public class NotifyQueueConfig {
|
||||
|
||||
private Mail mail = new Mail();
|
||||
|
||||
private Sms sms = new Sms();
|
||||
|
||||
private Wechat wechat = new Wechat();
|
||||
|
||||
private HTTP http = new HTTP();
|
||||
|
||||
/// 邮件队列配置
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class Mail extends Queue {
|
||||
|
||||
private String defaultFrom;
|
||||
}
|
||||
|
||||
/// 短信队列配置
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class Sms extends Queue {
|
||||
|
||||
private String appId;
|
||||
|
||||
private String sign;
|
||||
|
||||
private String secretId;
|
||||
|
||||
private String secretKey;
|
||||
}
|
||||
|
||||
/// 微信队列配置
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class Wechat extends Queue {
|
||||
}
|
||||
|
||||
/// HTTP 队列配置
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class HTTP extends Queue {
|
||||
}
|
||||
|
||||
/// 通用队列配置
|
||||
@Data
|
||||
public static class Queue {
|
||||
|
||||
/// true 为启用
|
||||
private boolean enable;
|
||||
|
||||
private String cron = "0/30 * * * * ?";
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package com.imyeyu.api.modules.common.controller;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.common.service.TempFileService;
|
||||
import com.imyeyu.api.modules.common.vo.attach.BizDeleteReq;
|
||||
import com.imyeyu.api.modules.common.vo.attach.BizUpdateReq;
|
||||
import com.imyeyu.api.modules.common.vo.attach.TempFileResp;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.network.Network;
|
||||
@@ -183,32 +181,7 @@ public class AttachmentController {
|
||||
return service.pageByBizId(bizType, bizId, attachTypeList, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按业务差分更新附件
|
||||
*
|
||||
* @param req 更新请求
|
||||
*/
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@PostMapping("/update/biz")
|
||||
public void updateByBiz(@RequestBody BizUpdateReq req) {
|
||||
service.updateByBiz(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按业务删除全部附件
|
||||
*
|
||||
* @param req 删除请求
|
||||
*/
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@PostMapping("/delete/biz")
|
||||
public void deleteByBiz(@RequestBody BizDeleteReq req) {
|
||||
service.deleteByBiz(req);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@IgnoreGlobalReturn
|
||||
@GetMapping({"/read/{id}", "/download/{id}"})
|
||||
public void readById(@PathVariable String id, @RequestParam(required = false) Integer thumbWidth, @RequestParam(required = false) Integer thumbHeight) throws UnsupportedEncodingException {
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.imyeyu.api.modules.common.controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.imyeyu.api.annotation.RequireCorePermission;
|
||||
import com.imyeyu.api.bean.CorePermissionCode;
|
||||
import com.imyeyu.api.modules.common.entity.Feedback;
|
||||
import com.imyeyu.api.modules.common.service.FeedbackService;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.CaptchaValid;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.CaptchaData;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.util.ResponseView;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/// 通用反馈接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-19
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/feedback")
|
||||
public class FeedbackController {
|
||||
|
||||
private final FeedbackService service;
|
||||
private final UserLoginService userLoginService;
|
||||
|
||||
/// 提交反馈。登录用户和匿名用户均需提交图形验证码,匿名用户按 IP 限流
|
||||
///
|
||||
/// @param captchaData 带图形验证码的反馈请求
|
||||
@AOPLog
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@CaptchaValid
|
||||
@RequestRateLimit(value = 3, inSeconds = 60)
|
||||
@PostMapping("/create")
|
||||
public void create(@RequestBody @Valid CaptchaData<Feedback> captchaData) {
|
||||
Feedback feedback = captchaData.getData();
|
||||
feedback.setIp(TimiSpring.getRequestIP());
|
||||
if (userLoginService.isLogged()) {
|
||||
feedback.setUserId(userLoginService.getRequireLoginUserId());
|
||||
}
|
||||
service.create(feedback);
|
||||
}
|
||||
|
||||
/// 查询反馈列表
|
||||
///
|
||||
/// @param page 分页参数
|
||||
/// @return 反馈分页
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_READ)
|
||||
@PostMapping("/list")
|
||||
public PageResult<Feedback> list(@RequestBody Page<Feedback> page) {
|
||||
return service.page(page);
|
||||
}
|
||||
|
||||
/// 查询反馈详情
|
||||
///
|
||||
/// @param id 反馈 ID
|
||||
/// @return 反馈详情
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_READ)
|
||||
@PostMapping("/detail")
|
||||
public Feedback detail(@RequestParam String id) {
|
||||
return service.get(id);
|
||||
}
|
||||
|
||||
/// 更新反馈
|
||||
///
|
||||
/// @param feedback 反馈
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_UPDATE)
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody Feedback feedback) {
|
||||
feedback.setRespondedBy(userLoginService.getRequireLoginUserId());
|
||||
service.update(feedback);
|
||||
}
|
||||
|
||||
/// 删除反馈
|
||||
///
|
||||
/// @param id 反馈 ID
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_DELETE)
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ package com.imyeyu.api.modules.common.controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.imyeyu.api.annotation.RequireCorePermission;
|
||||
import com.imyeyu.api.annotation.RequireCoreRole;
|
||||
import com.imyeyu.api.bean.CorePermissionCode;
|
||||
import com.imyeyu.api.bean.CoreRoleCode;
|
||||
import com.imyeyu.api.modules.common.entity.Multilingual;
|
||||
import com.imyeyu.api.modules.common.service.MultilingualService;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
@@ -40,7 +38,6 @@ public class MultilingualController {
|
||||
*/
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
@RequestRateLimit
|
||||
@RequireCoreRole(CoreRoleCode.ADMIN)
|
||||
@RequireCorePermission(CorePermissionCode.MULTILINGUAL_READ)
|
||||
@PostMapping("/detail")
|
||||
public Multilingual detail(@RequestParam String id) {
|
||||
@@ -56,7 +53,6 @@ public class MultilingualController {
|
||||
@AOPLog
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
@RequestRateLimit
|
||||
@RequireCoreRole(CoreRoleCode.ADMIN)
|
||||
@RequireCorePermission(CorePermissionCode.MULTILINGUAL_CREATE)
|
||||
@PostMapping("/create")
|
||||
public Multilingual create(@RequestBody Multilingual multilingual) {
|
||||
@@ -71,7 +67,6 @@ public class MultilingualController {
|
||||
*/
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireCoreRole(CoreRoleCode.ADMIN)
|
||||
@RequireCorePermission(CorePermissionCode.MULTILINGUAL_UPDATE)
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody Multilingual multilingual) {
|
||||
@@ -85,7 +80,6 @@ public class MultilingualController {
|
||||
*/
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireCoreRole(CoreRoleCode.ADMIN)
|
||||
@RequireCorePermission(CorePermissionCode.MULTILINGUAL_DELETE)
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
package com.imyeyu.api.modules.common.controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.imyeyu.api.annotation.RequireCorePermission;
|
||||
import com.imyeyu.api.bean.CorePermissionCode;
|
||||
import com.imyeyu.api.modules.common.entity.Notify;
|
||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||
import com.imyeyu.api.modules.common.service.NotifyDetailService;
|
||||
import com.imyeyu.api.modules.common.service.NotifyService;
|
||||
import com.imyeyu.api.modules.user.entity.User;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.api.modules.user.service.UserService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.spring.annotation.RequiredToken;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.util.ResponseView;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/// 通知接口
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/notify")
|
||||
public class NotifyController {
|
||||
|
||||
private final UserService userService;
|
||||
private final NotifyService service;
|
||||
private final UserLoginService userLoginService;
|
||||
private final NotifyDetailService detailService;
|
||||
|
||||
/// 创建通知,同时创建通知详情
|
||||
///
|
||||
/// @param notify 通知及通知详情
|
||||
/// @return 创建后的通知
|
||||
@RequireCorePermission(CorePermissionCode.NOTIFY_CREATE)
|
||||
@RequiredToken
|
||||
@PostMapping("/create")
|
||||
public Notify create(@RequestBody Notify notify) {
|
||||
service.create(notify);
|
||||
return notify;
|
||||
}
|
||||
|
||||
/// 查询通知详情
|
||||
///
|
||||
/// @param id 通知 ID
|
||||
/// @return 通知及通知详情
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
||||
@RequiredToken
|
||||
@RequestMapping("/detail")
|
||||
public Notify detail(@RequestParam String id) {
|
||||
Notify notify = service.get(id);
|
||||
{
|
||||
List<NotifyDetail> detailList = detailService.listByNotifyId(id);
|
||||
Set<String> userIdSet = detailList.stream()
|
||||
.filter(item -> item.getMsgType() == NotifyDetail.MsgType.INTERNAL)
|
||||
.flatMap(item -> Stream.of(item.getSendFrom(), item.getSendTo()))
|
||||
.collect(Collectors.toSet());
|
||||
Map<String, User> userMap = userService.mapByIdList(userIdSet);
|
||||
for (NotifyDetail detail : detailList) {
|
||||
if (TimiJava.isNotEmpty(detail.getSendFrom())) {
|
||||
detail.setFromUser(userMap.get(detail.getSendFrom()));
|
||||
}
|
||||
if (TimiJava.isNotEmpty(detail.getSendTo())) {
|
||||
detail.setToUser(userMap.get(detail.getSendTo()));
|
||||
}
|
||||
}
|
||||
notify.setDetailList(detailList);
|
||||
}
|
||||
return notify;
|
||||
}
|
||||
|
||||
/// 删除通知及其通知详情
|
||||
///
|
||||
/// @param id 通知 ID
|
||||
@RequireCorePermission(CorePermissionCode.NOTIFY_DELETE)
|
||||
@RequiredToken
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
|
||||
/// 取消尚未成功发送的通知详情
|
||||
///
|
||||
/// @param id 通知 ID
|
||||
@RequireCorePermission(CorePermissionCode.NOTIFY_CANCEL)
|
||||
@RequiredToken
|
||||
@PostMapping("/cancel")
|
||||
public void cancel(@RequestParam String id) {
|
||||
service.cancel(id);
|
||||
}
|
||||
|
||||
/// 查询当前用户的站内通知
|
||||
///
|
||||
/// @param page 分页参数
|
||||
/// @param unreadOnly true 为只查询未读通知
|
||||
/// @return 站内通知分页结果
|
||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
||||
@RequiredToken
|
||||
@PostMapping("/internal/internal")
|
||||
public PageResult<NotifyDetail> listInternal(
|
||||
@RequestBody(required = false) Page<NotifyDetail> page,
|
||||
@RequestParam(defaultValue = "false") boolean unreadOnly
|
||||
) {
|
||||
return detailService.pageInternalByUserId(page, userLoginService.getRequireLoginUserId(), unreadOnly);
|
||||
}
|
||||
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
||||
@RequiredToken
|
||||
@PostMapping("/internal/detail")
|
||||
public NotifyDetail internalDetail(@RequestParam String id) {
|
||||
NotifyDetail detail = detailService.getInternalByUserId(id, userLoginService.getRequireLoginUserId());
|
||||
if (TimiJava.isNotEmpty(detail.getSendFrom())) {
|
||||
detail.setFromUser(userService.get(detail.getSendFrom()));
|
||||
}
|
||||
if (TimiJava.isNotEmpty(detail.getSendTo())) {
|
||||
detail.setToUser(userService.get(detail.getSendTo()));
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
|
||||
/// 删除当前用户的一条站内通知
|
||||
///
|
||||
/// @param id 通知详情 ID
|
||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
||||
@RequiredToken
|
||||
@PostMapping("/internal/delete")
|
||||
public void deleteInternal(@RequestParam String id) {
|
||||
detailService.deleteInternalByUserId(id, userLoginService.getRequireLoginUserId());
|
||||
}
|
||||
|
||||
/// 查询当前用户未读通知数量
|
||||
///
|
||||
/// @return 未读通知数量
|
||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
||||
@RequiredToken
|
||||
@PostMapping("/internal/unread/count")
|
||||
public long countUnreadSite() {
|
||||
return detailService.countUnreadSiteByUserId(userLoginService.getRequireLoginUserId());
|
||||
}
|
||||
|
||||
/// 标记当前用户的一条站内通知已读
|
||||
///
|
||||
/// @param id 通知详情 ID
|
||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
||||
@RequiredToken
|
||||
@PostMapping("/internal/read")
|
||||
public void markSiteRead(@RequestParam String id) {
|
||||
detailService.markSiteRead(userLoginService.getRequireLoginUserId(), id);
|
||||
}
|
||||
|
||||
/// 标记当前用户全部站内通知已读
|
||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
||||
@RequiredToken
|
||||
@PostMapping("/internal/read/all")
|
||||
public void markAllSiteRead() {
|
||||
detailService.markAllSiteRead(userLoginService.getRequireLoginUserId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.imyeyu.api.modules.common.controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.imyeyu.api.modules.common.entity.Tag;
|
||||
import com.imyeyu.api.modules.common.entity.TagApply;
|
||||
import com.imyeyu.api.modules.common.service.TagService;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.util.ResponseView;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// 标签接口
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-12 15:09
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/tag")
|
||||
public class TagController {
|
||||
|
||||
private final TagService service;
|
||||
|
||||
/// 查询标签列表
|
||||
///
|
||||
/// @param page 分页参数
|
||||
/// @return 标签分页
|
||||
@RequestRateLimit
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@PostMapping("/list")
|
||||
public PageResult<Tag> list(@RequestBody Page<Tag> page) {
|
||||
return service.page(page);
|
||||
}
|
||||
|
||||
/// 查询标签详情
|
||||
///
|
||||
/// @param id 标签 ID
|
||||
/// @return 标签详情
|
||||
@RequestRateLimit
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@PostMapping("/detail")
|
||||
public Tag detail(@RequestParam String id) {
|
||||
return service.get(id);
|
||||
}
|
||||
|
||||
/// 创建标签
|
||||
///
|
||||
/// @param tag 标签
|
||||
/// @return 标签
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@PostMapping("/create")
|
||||
public Tag create(@RequestBody Tag tag) {
|
||||
service.create(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
/// 更新标签
|
||||
///
|
||||
/// @param tag 标签
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody Tag tag) {
|
||||
service.update(tag);
|
||||
}
|
||||
|
||||
/// 删除标签
|
||||
///
|
||||
/// @param id 标签 ID
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
|
||||
/// 按业务查询标签
|
||||
///
|
||||
/// @param bizType 业务类型
|
||||
/// @param bizId 业务 ID
|
||||
/// @return 标签列表
|
||||
@RequestRateLimit
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@GetMapping("/list/biz/id")
|
||||
public List<Tag> listByBizType(@RequestParam TagApply.BizType bizType, @RequestParam String bizId) {
|
||||
return service.listByBizType(bizType, bizId);
|
||||
}
|
||||
|
||||
/// 差分保存业务标签
|
||||
///
|
||||
/// @param apply 标签请求
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@PostMapping("/apply")
|
||||
public void apply(@RequestBody TagApply apply) {
|
||||
service.apply(apply.getBizType(), apply.getBizId(), apply.getTagIdList());
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,10 @@ public class Article extends UUIDEntity implements SettingSupport {
|
||||
public enum BizType {
|
||||
|
||||
/** 博客 */
|
||||
BLOG
|
||||
BLOG,
|
||||
|
||||
/// 反馈
|
||||
FEEDBACK
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,6 +52,19 @@ public class Article extends UUIDEntity implements SettingSupport {
|
||||
TIP_TAP
|
||||
}
|
||||
|
||||
/// 文章状态
|
||||
public enum Status {
|
||||
|
||||
/// 草稿
|
||||
DART,
|
||||
|
||||
/// 正常
|
||||
NORMAL,
|
||||
|
||||
/// 隐藏
|
||||
HIDDEN
|
||||
}
|
||||
|
||||
/** 业务类型 */
|
||||
protected BizType bizType;
|
||||
|
||||
@@ -58,8 +74,8 @@ public class Article extends UUIDEntity implements SettingSupport {
|
||||
/** 标题 */
|
||||
protected String title;
|
||||
|
||||
/** 摘要 */
|
||||
protected String digest;
|
||||
/** 描述 */
|
||||
protected String description;
|
||||
|
||||
/** 正文类型 */
|
||||
protected ContentType contentType;
|
||||
@@ -74,9 +90,15 @@ public class Article extends UUIDEntity implements SettingSupport {
|
||||
/** 喜欢数量 */
|
||||
protected Integer likes;
|
||||
|
||||
/** 文章状态 */
|
||||
protected Status status;
|
||||
|
||||
@Transient
|
||||
protected List<Setting> settingList;
|
||||
|
||||
@Transient
|
||||
protected List<Comment> commentList;
|
||||
|
||||
@Transient
|
||||
protected List<Attachment> attachmentList;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.imyeyu.api.TimiServerAPI;
|
||||
import com.imyeyu.api.modules.common.bean.attachment.AccessKey;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.ref.Ref;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
@@ -29,11 +30,13 @@ public class Attachment extends UUIDEntity {
|
||||
/// @since 2026-07-17 20:52
|
||||
public enum BizType {
|
||||
|
||||
ARTICLE,
|
||||
|
||||
USER,
|
||||
|
||||
GAO_CUSTOMER,
|
||||
|
||||
GAO_REGISTRATION_EVENT_RECORD,
|
||||
GAO_EVENT_RECORD,
|
||||
|
||||
TEMP_FILE,
|
||||
|
||||
@@ -54,7 +57,7 @@ public class Attachment extends UUIDEntity {
|
||||
|
||||
protected String mimeType;
|
||||
|
||||
protected JsonNode metadata;
|
||||
protected ObjectNode metadata;
|
||||
|
||||
protected Long size;
|
||||
|
||||
@@ -82,6 +85,14 @@ public class Attachment extends UUIDEntity {
|
||||
@Transient
|
||||
protected MultipartFile file;
|
||||
|
||||
public String buildMongoName() {
|
||||
StringBuilder result = new StringBuilder(bizType.name());
|
||||
if (TimiJava.isNotEmpty(attachType)) {
|
||||
result.append('_').append(attachType.toUpperCase());
|
||||
}
|
||||
return result.append('_').append(name).toString();
|
||||
}
|
||||
|
||||
public InputStream openInputStream() {
|
||||
AttachmentService service = TimiServerAPI.applicationContext.getBean(AttachmentService.class);
|
||||
return service.getInputStreamByMongoId(mongoId);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import com.imyeyu.spring.annotation.table.AutoUUID;
|
||||
import com.imyeyu.spring.annotation.table.Id;
|
||||
import com.imyeyu.spring.entity.Creatable;
|
||||
import com.imyeyu.spring.entity.Destroyable;
|
||||
import com.imyeyu.spring.entity.IDEntity;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/// 通知基础队列实体
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class BaseQueueEntity implements IDEntity<String>, Creatable, Destroyable {
|
||||
|
||||
/** 主键 */
|
||||
@Id
|
||||
@AutoUUID
|
||||
protected String id;
|
||||
|
||||
/** 所属通知详情 ID */
|
||||
protected String notifyDetailId;
|
||||
|
||||
/** 内容 */
|
||||
protected String data;
|
||||
|
||||
/** 参数 */
|
||||
protected String args;
|
||||
|
||||
/** 发送去向 */
|
||||
protected String sendTo;
|
||||
|
||||
/** 发送时间 */
|
||||
protected Long sendAt;
|
||||
|
||||
/** 剩余重试次数 */
|
||||
protected Integer retry;
|
||||
|
||||
/** 超时时间 */
|
||||
protected Long timeoutAt;
|
||||
|
||||
/** 创建时间 */
|
||||
protected Long createdAt;
|
||||
|
||||
/// 从通知详情创建队列实体
|
||||
///
|
||||
/// @param detail 通知详情
|
||||
public BaseQueueEntity(NotifyDetail detail) {
|
||||
notifyDetailId = detail.getId();
|
||||
data = detail.getData();
|
||||
args = detail.getArgs();
|
||||
sendTo = detail.getSendTo();
|
||||
sendAt = detail.getSendAt();
|
||||
retry = detail.getRetry();
|
||||
timeoutAt = detail.getTimeoutAt();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import com.imyeyu.spring.util.ResponseView;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/// 通用反馈
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-19
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Feedback extends UUIDEntity {
|
||||
|
||||
/// 反馈处理状态
|
||||
public enum Status {
|
||||
|
||||
/// 待处理
|
||||
PENDING,
|
||||
|
||||
/// 已回复
|
||||
REPLIED,
|
||||
|
||||
/// 已关闭
|
||||
CLOSED
|
||||
}
|
||||
|
||||
/// 所属模块
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private ModuleCode module;
|
||||
|
||||
/// 提交用户 ID,匿名反馈为 null
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
private String userId;
|
||||
|
||||
/// 反馈内容文章 ID
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private String contentId;
|
||||
|
||||
/// 联系方式
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private String contact;
|
||||
|
||||
/// 提交 IP
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
private String ip;
|
||||
|
||||
/// 处理状态
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private Status status;
|
||||
|
||||
/// 管理员回复文章 ID
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private String responseId;
|
||||
|
||||
/// 回复用户 ID
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
private String respondedBy;
|
||||
|
||||
/// 回复时间
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private Long respondedAt;
|
||||
|
||||
/// 管理员回复文章
|
||||
@Transient
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private Article content;
|
||||
|
||||
/// 管理员回复文章
|
||||
@Transient
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private Article response;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import com.imyeyu.spring.annotation.table.Table;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/// HTTP 回调队列
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("http_queue")
|
||||
public class HTTPQueue extends BaseQueueEntity {
|
||||
|
||||
/** HTTP 请求方法 */
|
||||
protected String method;
|
||||
|
||||
/// 从通知详情创建 HTTP 队列
|
||||
///
|
||||
/// @param detail 通知详情
|
||||
public HTTPQueue(NotifyDetail detail) {
|
||||
super(detail);
|
||||
method = "POST";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/// 邮件发送队列
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MailQueue extends BaseQueueEntity {
|
||||
|
||||
/** 邮件标题 */
|
||||
protected String subject;
|
||||
|
||||
/** 邮件附件 */
|
||||
protected String attachments;
|
||||
|
||||
/** 发送来源 */
|
||||
protected String sendFrom;
|
||||
|
||||
/// 从通知详情创建邮件队列
|
||||
///
|
||||
/// @param detail 通知详情
|
||||
public MailQueue(NotifyDetail detail) {
|
||||
super(detail);
|
||||
subject = detail.getSubject();
|
||||
sendFrom = detail.getSendFrom();
|
||||
}
|
||||
|
||||
/// 邮件附件
|
||||
@Data
|
||||
public static class Attachment {
|
||||
|
||||
/** 附件类型 */
|
||||
private Type type;
|
||||
|
||||
/** 附件值 */
|
||||
private String value;
|
||||
|
||||
/// 附件来源类型
|
||||
public enum Type {
|
||||
|
||||
/** 系统附件 */
|
||||
E2INS_ATTACH,
|
||||
|
||||
/** URL 附件 */
|
||||
URL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.imyeyu.java.bean.Language;
|
||||
import com.imyeyu.spring.annotation.table.Column;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -15,6 +17,18 @@ public class Multilingual extends UUIDEntity {
|
||||
|
||||
protected String zhCN;
|
||||
|
||||
@Column("zh_cn_pinyin_full")
|
||||
@JsonIgnore
|
||||
protected String zhCNPinyinFull;
|
||||
|
||||
@Column("zh_cn_pinyin_initial")
|
||||
@JsonIgnore
|
||||
protected String zhCNPinyinInitial;
|
||||
|
||||
@Column("zh_cn_pinyin_mixed")
|
||||
@JsonIgnore
|
||||
protected String zhCNPinyinMixed;
|
||||
|
||||
protected String zhTW;
|
||||
|
||||
protected String enUS;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import com.imyeyu.spring.annotation.table.AutoUUID;
|
||||
import com.imyeyu.spring.annotation.table.Id;
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import lombok.Data;
|
||||
@@ -19,11 +17,6 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Notify extends UUIDEntity {
|
||||
|
||||
/** 主键 */
|
||||
@Id
|
||||
@AutoUUID
|
||||
private String id;
|
||||
|
||||
/** 业务类型 */
|
||||
private String bizType;
|
||||
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.imyeyu.api.TimiServerAPI;
|
||||
import com.imyeyu.api.modules.common.service.BaseQueueService;
|
||||
import com.imyeyu.api.modules.common.service.HTTPQueueService;
|
||||
import com.imyeyu.api.modules.common.service.MailQueueService;
|
||||
import com.imyeyu.api.modules.common.service.SmsQueueService;
|
||||
import com.imyeyu.api.modules.common.service.WechatQueueService;
|
||||
import com.imyeyu.api.modules.user.entity.User;
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import com.imyeyu.spring.util.ResponseView;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -25,13 +34,32 @@ public class NotifyDetail extends UUIDEntity {
|
||||
@AllArgsConstructor
|
||||
public enum MsgType {
|
||||
|
||||
SMS,
|
||||
/** 站内通知,不进入外部消息队列 */
|
||||
INTERNAL(null),
|
||||
|
||||
MAIL,
|
||||
SMS(SmsQueueService.class),
|
||||
|
||||
HTTP,
|
||||
MAIL(MailQueueService.class),
|
||||
|
||||
WECHAT;
|
||||
HTTP(HTTPQueueService.class),
|
||||
|
||||
WECHAT(WechatQueueService.class);
|
||||
|
||||
private final Class<? extends BaseQueueService<?>> queueServiceClass;
|
||||
|
||||
/// 获取消息队列服务
|
||||
///
|
||||
/// @return 消息队列服务
|
||||
public BaseQueueService<?> getService() {
|
||||
return TimiServerAPI.applicationContext.getBean(queueServiceClass);
|
||||
}
|
||||
|
||||
/// 判断是否需要外部消息队列
|
||||
///
|
||||
/// @return true 为需要外部消息队列
|
||||
public boolean isQueue() {
|
||||
return queueServiceClass != null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,44 +82,67 @@ public class NotifyDetail extends UUIDEntity {
|
||||
}
|
||||
|
||||
/** 所属通知 ID */
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private String notifyId;
|
||||
|
||||
/** 消息类型 */
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private MsgType msgType;
|
||||
|
||||
/** 模板 ID */
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
private String templateId;
|
||||
|
||||
/** 标题 */
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private String subject;
|
||||
|
||||
/** 内容 */
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private String data;
|
||||
|
||||
/** 参数 */
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private String args;
|
||||
|
||||
/** 发送来源 */
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private String sendFrom;
|
||||
|
||||
/** 发送去向 */
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private String sendTo;
|
||||
|
||||
/** 发送时间 */
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private Long sendAt;
|
||||
|
||||
/** 重试计数 */
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
private Integer retry;
|
||||
|
||||
/** 超时时间 */
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
private Long timeoutAt;
|
||||
|
||||
/** 结果描述 */
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
private String resultDesc;
|
||||
|
||||
/** 状态 */
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private Status status;
|
||||
|
||||
/** 已读时间,站内通知未读时为空 */
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private Long readAt;
|
||||
|
||||
@Transient
|
||||
protected Notify notify;
|
||||
|
||||
@Transient
|
||||
protected User fromUser;
|
||||
|
||||
@Transient
|
||||
protected User toUser;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/// 短信发送队列
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SmsQueue extends BaseQueueEntity {
|
||||
|
||||
/** 短信模板 ID */
|
||||
protected String templateId;
|
||||
|
||||
/// 从通知详情创建短信队列
|
||||
///
|
||||
/// @param detail 通知详情
|
||||
public SmsQueue(NotifyDetail detail) {
|
||||
super(detail);
|
||||
templateId = detail.getTemplateId();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,43 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import com.imyeyu.api.annotation.MultilingualField;
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2024-08-28 14:26
|
||||
*/
|
||||
/// 标签
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2024-08-28 14:26
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Tag extends UUIDEntity {
|
||||
|
||||
protected String langKey;
|
||||
///
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-12 16:49
|
||||
public enum OwnerType {
|
||||
|
||||
GAO_STORE
|
||||
}
|
||||
|
||||
/// 归属类型
|
||||
protected OwnerType ownerType;
|
||||
|
||||
/// 归属 ID
|
||||
protected String ownerId;
|
||||
|
||||
/// 名称多语言 ID
|
||||
protected String nameLangId;
|
||||
|
||||
/// 当前语言名称
|
||||
@Transient
|
||||
protected String value;
|
||||
@MultilingualField("nameLangId")
|
||||
protected String name;
|
||||
|
||||
/// 中文名称
|
||||
@Transient
|
||||
protected String zhCN;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 标签应用
|
||||
*
|
||||
@@ -14,12 +17,25 @@ import lombok.EqualsAndHashCode;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TagApply extends UUIDEntity {
|
||||
|
||||
///
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-12 14:27
|
||||
public enum BizType {
|
||||
|
||||
GAO_CUSTOMER
|
||||
}
|
||||
|
||||
/** 业务类型 */
|
||||
protected String bizType;
|
||||
protected BizType bizType;
|
||||
|
||||
/** 业务 ID */
|
||||
protected String bizId;
|
||||
|
||||
/** 标签 ID */
|
||||
protected String tagId;
|
||||
|
||||
/// 标签 ID 列表
|
||||
@Transient
|
||||
private List<String> tagIdList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/// 微信消息发送队列
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WechatQueue extends BaseQueueEntity {
|
||||
|
||||
/// 从通知详情创建微信队列
|
||||
///
|
||||
/// @param detail 通知详情
|
||||
public WechatQueue(NotifyDetail detail) {
|
||||
super(detail);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.mapper.RawMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -31,6 +32,8 @@ public interface AttachmentMapper extends BaseMapper<Attachment, String>, RawMap
|
||||
|
||||
List<Attachment> selectByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes, Page<Attachment> page);
|
||||
|
||||
List<Attachment> selectAllByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, List<String> attachTypes);
|
||||
|
||||
long countByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes);
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.imyeyu.api.modules.common.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.BaseQueueEntity;
|
||||
import com.imyeyu.api.modules.common.util.QueueSQLProvider;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.DeleteProvider;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.SelectProvider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// 通知队列基础 Mapper
|
||||
///
|
||||
/// @param <T> 队列实体类型
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
public interface BaseQueueMapper<T extends BaseQueueEntity> extends BaseMapper<T, String> {
|
||||
|
||||
/** 查询已到发送时间的队列 */
|
||||
@SelectProvider(type = QueueSQLProvider.class, method = "listReadyQueue")
|
||||
List<T> listReadyQueue();
|
||||
|
||||
/** 根据通知详情 ID 物理删除队列 */
|
||||
@DeleteProvider(type = QueueSQLProvider.class, method = "destroyByNotifyDetailId")
|
||||
void destroyByNotifyDetailId(@Param("notifyDetailId") String notifyDetailId);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.imyeyu.api.modules.common.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Feedback;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
|
||||
/// 通用反馈 Mapper
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-19
|
||||
public interface FeedbackMapper extends BaseMapper<Feedback, String> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.imyeyu.api.modules.common.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.HTTPQueue;
|
||||
|
||||
/// HTTP 队列 Mapper
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
public interface HTTPQueueMapper extends BaseQueueMapper<HTTPQueue> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.imyeyu.api.modules.common.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.MailQueue;
|
||||
|
||||
/// 邮件队列 Mapper
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
public interface MailQueueMapper extends BaseQueueMapper<MailQueue> {
|
||||
}
|
||||
@@ -2,6 +2,11 @@ package com.imyeyu.api.modules.common.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通知详情 Mapper
|
||||
@@ -10,4 +15,36 @@ import com.imyeyu.spring.mapper.BaseMapper;
|
||||
* @since 2026-05-13 14:46
|
||||
*/
|
||||
public interface NotifyDetailMapper extends BaseMapper<NotifyDetail, String> {
|
||||
|
||||
/** 查询用户的站内通知 */
|
||||
@Select("SELECT * FROM `notify_detail` WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} " + NOT_DELETE + " ORDER BY `created_at` DESC LIMIT #{offset}, #{limit}")
|
||||
List<NotifyDetail> selectSiteByUserId(@Param("userId") String userId, @Param("offset") long offset, @Param("limit") long limit);
|
||||
|
||||
/** 查询用户的未读站内通知 */
|
||||
@Select("SELECT * FROM `notify_detail` WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `read_at` IS NULL " + NOT_DELETE + " ORDER BY `created_at` DESC LIMIT #{offset}, #{limit}")
|
||||
List<NotifyDetail> selectUnreadSiteByUserId(@Param("userId") String userId, @Param("offset") long offset, @Param("limit") long limit);
|
||||
|
||||
/** 统计用户的站内通知数量 */
|
||||
@Select("SELECT COUNT(*) FROM `notify_detail` WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} " + NOT_DELETE)
|
||||
long countSiteByUserId(@Param("userId") String userId);
|
||||
|
||||
/** 统计用户的未读站内通知数量 */
|
||||
@Select("SELECT COUNT(*) FROM `notify_detail` WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `read_at` IS NULL " + NOT_DELETE)
|
||||
long countUnreadSiteByUserId(@Param("userId") String userId);
|
||||
|
||||
/** 查询用户拥有的站内通知 */
|
||||
@Select("SELECT * FROM `notify_detail` WHERE `id` = #{detailId} AND `msg_type` = 'INTERNAL' AND `send_to` = #{userId} " + NOT_DELETE + " LIMIT 1")
|
||||
NotifyDetail selectSiteByIdAndUserId(@Param("detailId") String detailId, @Param("userId") String userId);
|
||||
|
||||
/** 删除用户的站内通知 */
|
||||
@Update("UPDATE `notify_detail` SET `deleted_at` = " + UNIX_TIME + ", `updated_at` = " + UNIX_TIME + " WHERE `id` = #{detailId} AND `msg_type` = 'INTERNAL' AND `send_to` = #{userId} " + NOT_DELETE)
|
||||
int deleteSiteByIdAndUserId(@Param("detailId") String detailId, @Param("userId") String userId);
|
||||
|
||||
/** 标记站内通知已读 */
|
||||
@Update("UPDATE `notify_detail` SET `read_at` = #{readAt}, `updated_at` = " + UNIX_TIME + " WHERE `id` = #{detailId} AND `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `read_at` IS NULL " + NOT_DELETE)
|
||||
int markSiteRead(@Param("detailId") String detailId, @Param("userId") String userId, @Param("readAt") long readAt);
|
||||
|
||||
/** 标记用户全部站内通知已读 */
|
||||
@Update("UPDATE `notify_detail` SET `read_at` = #{readAt}, `updated_at` = " + UNIX_TIME + " WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `read_at` IS NULL " + NOT_DELETE)
|
||||
int markAllSiteRead(@Param("userId") String userId, @Param("readAt") long readAt);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.imyeyu.api.modules.common.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.SmsQueue;
|
||||
|
||||
/// 短信队列 Mapper
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
public interface SmsQueueMapper extends BaseQueueMapper<SmsQueue> {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.imyeyu.api.modules.common.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.TagApply;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
|
||||
/// 标签应用 Mapper
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-12 15:05
|
||||
public interface TagApplyMapper extends BaseMapper<TagApply, String> {
|
||||
}
|
||||
@@ -2,10 +2,36 @@ package com.imyeyu.api.modules.common.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Tag;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2025-05-30 22:48
|
||||
*/
|
||||
public interface TagMapper extends BaseMapper<Tag, String> {
|
||||
|
||||
List<Tag> selectByIdList(Collection<String> idList);
|
||||
|
||||
/// 按归属和名称关键词查询标签总数
|
||||
///
|
||||
/// @param ownerType 归属类型
|
||||
/// @param ownerId 归属 ID
|
||||
/// @param keyword 名称关键词
|
||||
/// @return 标签总数
|
||||
long countByOwnerAndKeyword(@Param("ownerType") Tag.OwnerType ownerType, @Param("ownerId") String ownerId, @Param("keyword") String keyword);
|
||||
|
||||
/// 按归属和名称关键词分页查询标签
|
||||
///
|
||||
/// @param ownerType 归属类型
|
||||
/// @param ownerId 归属 ID
|
||||
/// @param keyword 名称关键词
|
||||
/// @param offset 分页偏移量
|
||||
/// @param limit 分页数量
|
||||
/// @return 标签列表
|
||||
List<Tag> selectByOwnerAndKeyword(@Param("ownerType") Tag.OwnerType ownerType, @Param("ownerId") String ownerId, @Param("keyword") String keyword, @Param("offset") long offset, @Param("limit") long limit);
|
||||
|
||||
Tag selectByOwnerAndZhCN(@Param("ownerType") Tag.OwnerType ownerType, @Param("ownerId") String ownerId, @Param("zhCN") String zhCN);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.imyeyu.api.modules.common.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.WechatQueue;
|
||||
|
||||
/// 微信队列 Mapper
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
public interface WechatQueueMapper extends BaseQueueMapper<WechatQueue> {
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.imyeyu.api.modules.common.service;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.vo.attach.BizDeleteReq;
|
||||
import com.imyeyu.api.modules.common.vo.attach.BizUpdateReq;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.service.BaseService;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 附件服务
|
||||
@@ -18,6 +18,13 @@ import java.util.List;
|
||||
*/
|
||||
public interface AttachmentService extends BaseService<Attachment, String> {
|
||||
|
||||
///
|
||||
/// 克隆附件,复制业务属性和文件内容并生成新的附件记录
|
||||
///
|
||||
/// @param id 源附件 ID
|
||||
/// @return 克隆后的附件
|
||||
Attachment clone(String id);
|
||||
|
||||
/**
|
||||
* 按需获取或创建缩略图附件。
|
||||
* <p>当附件为图片或视频时,若指定尺寸的缩略图已存在则直接返回缓存,
|
||||
@@ -50,6 +57,16 @@ public interface AttachmentService extends BaseService<Attachment, String> {
|
||||
*/
|
||||
List<Attachment> listByBizId(Attachment.BizType bizType, String bizId, String... attachTypes);
|
||||
|
||||
/**
|
||||
* 根据多个业务 ID 批量获取附件
|
||||
*
|
||||
* @param bizType 业务类型
|
||||
* @param bizIdList 业务 ID 列表
|
||||
* @param attachTypes 附件类型,可为 null
|
||||
* @return 按业务 ID 分组的附件列表
|
||||
*/
|
||||
Map<String, List<Attachment>> mapByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, String... attachTypes);
|
||||
|
||||
/**
|
||||
* 根据业务获取所有附件
|
||||
*
|
||||
@@ -73,10 +90,8 @@ public interface AttachmentService extends BaseService<Attachment, String> {
|
||||
* <li>请求有、数据库有、无 tempFileId → 仅更新元数据</li>
|
||||
* <li>请求有、数据库有、有 tempFileId → 更新文件与元数据</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param req 差分更新请求
|
||||
*/
|
||||
void updateByBiz(BizUpdateReq req);
|
||||
void updateByBizId(Attachment.BizType bizType, String bizId, List<Attachment> list);
|
||||
|
||||
void deleteByBiz(BizDeleteReq req);
|
||||
void deleteByBizId(Attachment.BizType bizType, String bizId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.imyeyu.api.modules.common.service;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.BaseQueueEntity;
|
||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||
|
||||
/// 通知队列基础服务
|
||||
///
|
||||
/// @param <T> 队列实体类型
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
public interface BaseQueueService<T extends BaseQueueEntity> {
|
||||
|
||||
/// 创建队列
|
||||
///
|
||||
/// @param detail 通知详情
|
||||
void createQueue(NotifyDetail detail);
|
||||
|
||||
/// 删除队列
|
||||
///
|
||||
/// @param detail 通知详情
|
||||
void destroyQueue(NotifyDetail detail);
|
||||
|
||||
/// 执行已到期队列
|
||||
void invokeQueue();
|
||||
|
||||
/// 发送队列消息
|
||||
///
|
||||
/// @param queue 队列
|
||||
void send(T queue);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.imyeyu.api.modules.common.service;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Feedback;
|
||||
import com.imyeyu.spring.service.BaseService;
|
||||
|
||||
/// 通用反馈服务
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-19
|
||||
public interface FeedbackService extends BaseService<Feedback, String> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.imyeyu.api.modules.common.service;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.HTTPQueue;
|
||||
|
||||
/// HTTP 队列服务
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
public interface HTTPQueueService extends BaseQueueService<HTTPQueue> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.imyeyu.api.modules.common.service;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.MailQueue;
|
||||
|
||||
/// 邮件队列服务
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
public interface MailQueueService extends BaseQueueService<MailQueue> {
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.imyeyu.api.modules.common.service;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.service.BaseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通知详情服务
|
||||
*
|
||||
@@ -10,4 +14,53 @@ import com.imyeyu.spring.service.BaseService;
|
||||
* @since 2026-05-13 14:46
|
||||
*/
|
||||
public interface NotifyDetailService extends BaseService<NotifyDetail, String> {
|
||||
|
||||
/// 查询通知下的全部详情
|
||||
///
|
||||
/// @param notifyId 通知 ID
|
||||
/// @return 通知详情列表
|
||||
List<NotifyDetail> listByNotifyId(String notifyId);
|
||||
|
||||
/// 重新将通知详情放入消息队列
|
||||
///
|
||||
/// @param detailId 通知详情 ID
|
||||
void requeue(String detailId);
|
||||
|
||||
/// 分页查询用户的站内通知
|
||||
///
|
||||
/// @param page 分页参数
|
||||
/// @param userId 用户 ID
|
||||
/// @param unreadOnly true 为只查询未读通知
|
||||
/// @return 站内通知分页结果
|
||||
PageResult<NotifyDetail> pageInternalByUserId(Page<NotifyDetail> page, String userId, boolean unreadOnly);
|
||||
|
||||
/// 查询当前用户拥有的站内通知详情
|
||||
///
|
||||
/// @param detailId 通知详情 ID
|
||||
/// @param userId 用户 ID
|
||||
/// @return 通知详情
|
||||
NotifyDetail getInternalByUserId(String detailId, String userId);
|
||||
|
||||
/// 删除当前用户拥有的站内通知详情
|
||||
///
|
||||
/// @param detailId 通知详情 ID
|
||||
/// @param userId 用户 ID
|
||||
void deleteInternalByUserId(String detailId, String userId);
|
||||
|
||||
/// 查询用户未读站内通知数量
|
||||
///
|
||||
/// @param userId 用户 ID
|
||||
/// @return 未读数量
|
||||
long countUnreadSiteByUserId(String userId);
|
||||
|
||||
/// 标记站内通知已读
|
||||
///
|
||||
/// @param userId 用户 ID
|
||||
/// @param detailId 通知详情 ID
|
||||
void markSiteRead(String userId, String detailId);
|
||||
|
||||
/// 标记用户全部站内通知已读
|
||||
///
|
||||
/// @param userId 用户 ID
|
||||
void markAllSiteRead(String userId);
|
||||
}
|
||||
|
||||
@@ -10,4 +10,9 @@ import com.imyeyu.spring.service.BaseService;
|
||||
* @since 2026-05-13 14:46
|
||||
*/
|
||||
public interface NotifyService extends BaseService<Notify, String> {
|
||||
|
||||
/// 取消通知中尚未成功发送的通知详情
|
||||
///
|
||||
/// @param notifyId 通知 ID
|
||||
void cancel(String notifyId);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.imyeyu.api.modules.common.service;
|
||||
|
||||
import com.imyeyu.api.modules.common.bean.SettingModule;
|
||||
import com.imyeyu.api.modules.common.bean.attachment.SettingSupport;
|
||||
import com.imyeyu.api.modules.common.entity.Setting;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.spring.service.BaseService;
|
||||
import com.imyeyu.utils.Text;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface SettingService extends BaseService<Setting, String> {
|
||||
Setting getByCode(String bizType, String bizId, String code);
|
||||
|
||||
default Setting getSystem(Enum<?> bizType) {
|
||||
return getByCode(Text.bizClassName(bizType.getClass()), TimiJava.ZERO_UUID, bizType.toString());
|
||||
return getByCode(SettingModule.fromClass(bizType.getClass()).name(), TimiJava.ZERO_UUID, bizType.toString());
|
||||
}
|
||||
|
||||
List<Setting> listByBizId(String bizType, String bizId);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.imyeyu.api.modules.common.service;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.SmsQueue;
|
||||
|
||||
/// 短信队列服务
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
public interface SmsQueueService extends BaseQueueService<SmsQueue> {
|
||||
}
|
||||
@@ -1,11 +1,42 @@
|
||||
package com.imyeyu.api.modules.common.service;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Tag;
|
||||
import com.imyeyu.api.modules.common.entity.TagApply;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.service.BaseService;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2025-05-30 22:46
|
||||
*/
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/// 标签服务
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2025-05-30 22:46
|
||||
public interface TagService extends BaseService<Tag, String> {
|
||||
|
||||
List<Tag> listByIdList(Collection<String> idList);
|
||||
|
||||
/// 按归属和名称关键词分页查询标签
|
||||
///
|
||||
/// @param page 分页参数
|
||||
/// @param ownerType 归属类型
|
||||
/// @param ownerId 归属 ID
|
||||
/// @param keyword 名称关键词
|
||||
/// @return 标签分页
|
||||
PageResult<Tag> pageByOwnerAndKeyword(Page<Tag> page, Tag.OwnerType ownerType, String ownerId, String keyword);
|
||||
|
||||
/// 按业务查询标签列表
|
||||
///
|
||||
/// @param bizType 业务类型
|
||||
/// @param bizId 业务 ID
|
||||
/// @return 标签列表
|
||||
List<Tag> listByBizType(TagApply.BizType bizType, String bizId);
|
||||
|
||||
/// 差分保存业务标签
|
||||
///
|
||||
/// @param bizType 业务类型
|
||||
/// @param bizId 业务 ID
|
||||
/// @param tagIdList 标签 ID 列表
|
||||
void apply(TagApply.BizType bizType, String bizId, List<String> tagIdList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.imyeyu.api.modules.common.service;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.WechatQueue;
|
||||
|
||||
/// 微信队列服务
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
public interface WechatQueueService extends BaseQueueService<WechatQueue> {
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.imyeyu.api.modules.common.config.NotifyQueueConfig;
|
||||
import com.imyeyu.api.modules.common.entity.BaseQueueEntity;
|
||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||
import com.imyeyu.api.modules.common.mapper.BaseQueueMapper;
|
||||
import com.imyeyu.api.modules.common.service.BaseQueueService;
|
||||
import com.imyeyu.api.modules.common.service.NotifyDetailService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.utils.Time;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/// 通知队列抽象服务
|
||||
///
|
||||
/// @param <T> 队列实体类型
|
||||
/// @param <C> 队列配置类型
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Slf4j
|
||||
public abstract class AbstractQueueService<T extends BaseQueueEntity, C extends NotifyQueueConfig.Queue> implements BaseQueueService<T> {
|
||||
|
||||
private NotifyDetailService notifyDetailService;
|
||||
|
||||
/// 注入通知详情服务
|
||||
@Autowired
|
||||
private void setNotifyDetailService(NotifyDetailService notifyDetailService) {
|
||||
this.notifyDetailService = notifyDetailService;
|
||||
}
|
||||
|
||||
/// 获取队列 Mapper
|
||||
///
|
||||
/// @return 队列 Mapper
|
||||
protected abstract BaseQueueMapper<T> mapper();
|
||||
|
||||
/// 获取队列配置
|
||||
///
|
||||
/// @return 队列配置
|
||||
protected abstract C config();
|
||||
|
||||
/// 校验发送目标
|
||||
///
|
||||
/// @param sendTo 发送目标
|
||||
protected abstract void validateSendTo(String sendTo);
|
||||
|
||||
@Override
|
||||
public void destroyQueue(NotifyDetail detail) {
|
||||
TimiException.required(detail, "未找到通知详情");
|
||||
TimiException.required(detail.getId(), "未找到通知详情 ID");
|
||||
mapper().destroyByNotifyDetailId(detail.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokeQueue() {
|
||||
for (T queue : mapper().listReadyQueue()) {
|
||||
send(queue);
|
||||
}
|
||||
}
|
||||
|
||||
/// 处理单个队列消息
|
||||
///
|
||||
/// @param queue 队列
|
||||
@Override
|
||||
public final void send(T queue) {
|
||||
TimiException.required(queue, "未找到通知队列");
|
||||
NotifyDetail detail = notifyDetailService.get(queue.getNotifyDetailId());
|
||||
if (detail == null) {
|
||||
mapper().destroy(queue.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
long now = Time.now();
|
||||
queue.setSendAt(now);
|
||||
if (queue.getTimeoutAt() < now) {
|
||||
throw new TimiException(TimiCode.RESULT_TIMEOUT, "通知队列已超时");
|
||||
}
|
||||
validateSendTo(queue.getSendTo());
|
||||
if (!config().isEnable()) {
|
||||
throw new TimiException(TimiCode.IGNORE, "通知队列未启用");
|
||||
}
|
||||
doSend(queue);
|
||||
detail.setStatus(NotifyDetail.Status.REMINDED);
|
||||
} catch (TimiException e) {
|
||||
if (e.getCode() == TimiCode.IGNORE) {
|
||||
detail.setStatus(NotifyDetail.Status.CANCEL);
|
||||
detail.setResultDesc(e.getMessage());
|
||||
} else if (e.getCode() == TimiCode.RESULT_TIMEOUT) {
|
||||
detail.setStatus(NotifyDetail.Status.TIMEOUT);
|
||||
detail.setResultDesc(e.getMessage());
|
||||
} else {
|
||||
log.error("处理通知队列失败", e);
|
||||
detail.setStatus(NotifyDetail.Status.FAIL);
|
||||
detail.setResultDesc(TimiJava.serializeThrowable(e));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("处理通知队列失败", e);
|
||||
detail.setStatus(NotifyDetail.Status.FAIL);
|
||||
detail.setResultDesc(TimiJava.serializeThrowable(e));
|
||||
} finally {
|
||||
try {
|
||||
notifyDetailService.update(detail);
|
||||
if (detail.getStatus() == NotifyDetail.Status.REMINDED
|
||||
|| detail.getStatus() == NotifyDetail.Status.CANCEL
|
||||
|| queue.getRetry() < 0
|
||||
) {
|
||||
mapper().destroy(queue.getId());
|
||||
} else {
|
||||
queue.setRetry(queue.getRetry() - 1);
|
||||
mapper().update(queue);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("通知队列收尾处理失败", e);
|
||||
mapper().destroy(queue.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 执行实际发送动作
|
||||
///
|
||||
/// @param queue 队列
|
||||
/// @throws Exception 发送异常
|
||||
protected abstract void doSend(T queue) throws Exception;
|
||||
}
|
||||
+54
@@ -1,8 +1,15 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Article;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.mapper.ArticleMapper;
|
||||
import com.imyeyu.api.modules.common.service.ArticleService;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.system.entity.Logger;
|
||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -20,10 +27,57 @@ import org.springframework.stereotype.Service;
|
||||
@RequiredArgsConstructor
|
||||
public class ArticleServiceImplement extends AbstractEntityService<Article, String> implements ArticleService {
|
||||
|
||||
private final LoggerService loggerService;
|
||||
private final AttachmentService attachmentService;
|
||||
|
||||
private final ArticleMapper mapper;
|
||||
|
||||
@Override
|
||||
protected BaseMapper<Article, String> mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(Article article) {
|
||||
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_ARTICLE_CREATE");
|
||||
try {
|
||||
super.create(article);
|
||||
attachmentService.updateByBizId(Attachment.BizType.ARTICLE, article.getId(), article.getAttachmentList());
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(article.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("create article error", e);
|
||||
throw new TimiException(TimiCode.ERROR, "create article error", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Article article) {
|
||||
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_ARTICLE_UPDATE");
|
||||
try {
|
||||
super.update(article);
|
||||
attachmentService.updateByBizId(Attachment.BizType.ARTICLE, article.getId(), article.getAttachmentList());
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(article.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("update article error", e);
|
||||
throw new TimiException(TimiCode.ERROR, "update article error", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+120
-105
@@ -8,8 +8,6 @@ import com.imyeyu.api.modules.common.bean.attachment.Metadata;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.mapper.AttachmentMapper;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.common.vo.attach.BizDeleteReq;
|
||||
import com.imyeyu.api.modules.common.vo.attach.BizUpdateReq;
|
||||
import com.imyeyu.api.util.JavaCV;
|
||||
import com.imyeyu.io.IO;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
@@ -43,7 +41,10 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -69,6 +70,88 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void create(Attachment attachment) {
|
||||
TimiException.required(attachment.getBizType(), "not found String");
|
||||
TimiException.required(attachment.getName(), "not found attachment.name");
|
||||
String mongoId = null;
|
||||
try {
|
||||
if (attachment.getFile() != null) {
|
||||
attachment.setInputStream(attachment.getFile().getInputStream());
|
||||
}
|
||||
InputStream is = attachment.getInputStream();
|
||||
TimiException.required(is, "not found attachment.inputStream");
|
||||
|
||||
mongoId = gridFsTemplate.store(attachment.getInputStream(), attachment.buildMongoName()).toString();
|
||||
GridFSFile gridFSFile = gridFsTemplate.findOne(new Query(Criteria.where("_id").is(mongoId)));
|
||||
attachment.setMongoId(mongoId);
|
||||
attachment.setSize(gridFSFile.getLength());
|
||||
attachment.setMd5(IO.md5(gridFSBucket.openDownloadStream(gridFSFile.getObjectId())));
|
||||
attachment.setMimeType(new Tika().detect(gridFSBucket.openDownloadStream(gridFSFile.getObjectId())));
|
||||
attachment.setUploaderIp(TimiSpring.getRequestIP());
|
||||
attachment.setIsDestroyed(false);
|
||||
if (attachment.getMimeType().startsWith("image")) {
|
||||
BufferedImage image = ImageIO.read(gridFSBucket.openDownloadStream(gridFSFile.getObjectId()));
|
||||
ObjectNode metadata = TimiJava.defaultIfNull(attachment.getMetadata(), jackson.createObjectNode());
|
||||
metadata.put("width", image.getWidth());
|
||||
metadata.put("height", image.getHeight());
|
||||
attachment.setMetadata(metadata);
|
||||
}
|
||||
mapper.insert(attachment);
|
||||
} catch (Exception e) {
|
||||
if (mongoId != null) {
|
||||
gridFsTemplate.delete(Query.query(Criteria.where("_id").is(mongoId)));
|
||||
}
|
||||
log.error("create error", e);
|
||||
throw new TimiException(TimiCode.ARG_BAD, "TODO read attachment input stream error");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void update(Attachment attachment) {
|
||||
String newMongoId = null;
|
||||
try {
|
||||
if (attachment.getFile() != null) {
|
||||
attachment.setInputStream(attachment.getFile().getInputStream());
|
||||
}
|
||||
InputStream stream = attachment.getInputStream();
|
||||
if (stream == null) {
|
||||
// 无新文件,仅更新元数据字段
|
||||
super.update(attachment);
|
||||
return;
|
||||
}
|
||||
// 有新文件时,先查旧记录获取旧 mongoId 和兜底字段
|
||||
Attachment old = mapper.selectRaw(attachment.getId());
|
||||
// 存储新文件
|
||||
newMongoId = gridFsTemplate.store(stream, attachment.buildMongoName()).toString();
|
||||
GridFSFile gridFSFile = gridFsTemplate.findOne(new Query(Criteria.where("_id").is(newMongoId)));
|
||||
attachment.setMongoId(newMongoId);
|
||||
attachment.setSize(gridFSFile.getLength());
|
||||
attachment.setMd5(IO.md5(gridFSBucket.openDownloadStream(gridFSFile.getObjectId())));
|
||||
attachment.setMimeType(new Tika().detect(gridFSBucket.openDownloadStream(gridFSFile.getObjectId())));
|
||||
if (attachment.getMimeType().startsWith("image")) {
|
||||
BufferedImage image = ImageIO.read(gridFSBucket.openDownloadStream(gridFSFile.getObjectId()));
|
||||
ObjectNode metadata = TimiJava.defaultIfNull(attachment.getMetadata(), jackson.createObjectNode());
|
||||
metadata.put("width", image.getWidth());
|
||||
metadata.put("height", image.getHeight());
|
||||
attachment.setMetadata(metadata);
|
||||
}
|
||||
|
||||
// 更新数据库后删除旧 GridFS 文件
|
||||
super.update(attachment);
|
||||
gridFsTemplate.delete(Query.query(Criteria.where("_id").is(old.getMongoId())));
|
||||
} catch (Exception e) {
|
||||
// 新文件已上传但后续操作失败,清理新文件防止孤儿数据
|
||||
if (TimiJava.isNotEmpty(newMongoId)) {
|
||||
gridFsTemplate.delete(Query.query(Criteria.where("_id").is(newMongoId)));
|
||||
}
|
||||
log.error("update error", e);
|
||||
throw new TimiException(TimiCode.ERROR, "TODO update file error");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
@@ -106,101 +189,30 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void create(Attachment attachment) {
|
||||
TimiException.required(attachment.getBizType(), "not found String");
|
||||
TimiException.required(attachment.getName(), "not found attachment.name");
|
||||
String mongoId = null;
|
||||
try {
|
||||
if (attachment.getFile() != null) {
|
||||
attachment.setInputStream(attachment.getFile().getInputStream());
|
||||
}
|
||||
InputStream is = attachment.getInputStream();
|
||||
TimiException.required(is, "not found attachment.inputStream");
|
||||
public Attachment clone(String id) {
|
||||
TimiException.required(id, "not found id");
|
||||
Attachment source = mapper.selectRaw(id);
|
||||
TimiException.required(source, "not found attachment");
|
||||
TimiException.required(source.getMongoId(), "not found mongoId");
|
||||
|
||||
StringBuilder mongoName = new StringBuilder(attachment.getBizType().name());
|
||||
if (TimiJava.isNotEmpty(attachment.getAttachType())) {
|
||||
mongoName.append("_").append(attachment.getAttachType().toUpperCase()).append("_");
|
||||
Attachment target = new Attachment();
|
||||
target.setBizType(source.getBizType());
|
||||
target.setBizId(source.getBizId());
|
||||
target.setAttachType(source.getAttachType());
|
||||
target.setTitle(source.getTitle());
|
||||
target.setName(source.getName());
|
||||
target.setMetadata(source.getMetadata() == null ? null : source.getMetadata().deepCopy());
|
||||
target.setDestroyAt(source.getDestroyAt());
|
||||
try (InputStream inputStream = getInputStreamByMongoId(source.getMongoId())) {
|
||||
target.setInputStream(inputStream);
|
||||
create(target);
|
||||
return target;
|
||||
} catch (IOException e) {
|
||||
if (target.getMongoId() != null) {
|
||||
gridFsTemplate.delete(Query.query(Criteria.where("_id").is(target.getMongoId())));
|
||||
}
|
||||
mongoName.append(attachment.getName());
|
||||
|
||||
mongoId = gridFsTemplate.store(attachment.getInputStream(), mongoName.toString()).toString();
|
||||
GridFSFile gridFSFile = gridFsTemplate.findOne(new Query(Criteria.where("_id").is(mongoId)));
|
||||
attachment.setMongoId(mongoId);
|
||||
attachment.setSize(gridFSFile.getLength());
|
||||
attachment.setMd5(IO.md5(gridFSBucket.openDownloadStream(gridFSFile.getObjectId())));
|
||||
attachment.setMimeType(new Tika().detect(gridFSBucket.openDownloadStream(gridFSFile.getObjectId())));
|
||||
attachment.setUploaderIp(TimiSpring.getRequestIP());
|
||||
attachment.setIsDestroyed(false);
|
||||
if (attachment.getMimeType().startsWith("image")) {
|
||||
BufferedImage image = ImageIO.read(gridFSBucket.openDownloadStream(gridFSFile.getObjectId()));
|
||||
attachment.setMetadata(TimiJava.defaultIfNull(attachment.getMetadata(), jackson.createObjectNode()));
|
||||
if (attachment.getMetadata() instanceof ObjectNode obj) {
|
||||
obj.put("width", image.getWidth());
|
||||
obj.put("height", image.getHeight());
|
||||
}
|
||||
}
|
||||
mapper.insert(attachment);
|
||||
} catch (Exception e) {
|
||||
if (mongoId != null) {
|
||||
gridFsTemplate.delete(Query.query(Criteria.where("_id").is(mongoId)));
|
||||
}
|
||||
log.error("create error", e);
|
||||
throw new TimiException(TimiCode.ARG_BAD, "TODO read attachment input stream error");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void update(Attachment attachment) {
|
||||
String newMongoId = null;
|
||||
try {
|
||||
if (attachment.getFile() != null) {
|
||||
attachment.setInputStream(attachment.getFile().getInputStream());
|
||||
}
|
||||
InputStream stream = attachment.getInputStream();
|
||||
if (stream == null) {
|
||||
// 无新文件,仅更新元数据字段
|
||||
super.update(attachment);
|
||||
return;
|
||||
}
|
||||
// 有新文件时,先查旧记录获取旧 mongoId 和兜底字段
|
||||
Attachment old = mapper.selectRaw(attachment.getId());
|
||||
// 构建存储名,优先取调用方设置的字段,否则沿用旧值
|
||||
Attachment.BizType bizType = TimiJava.defaultIfNull(attachment.getBizType(), old.getBizType());
|
||||
String attachType = TimiJava.defaultIfEmpty(attachment.getAttachType(), old.getAttachType());
|
||||
String name = TimiJava.defaultIfEmpty(attachment.getName(), old.getName());
|
||||
StringBuilder mongoName = new StringBuilder(bizType.name());
|
||||
if (TimiJava.isNotEmpty(attachType)) {
|
||||
mongoName.append("_").append(attachType.toUpperCase()).append("_");
|
||||
}
|
||||
mongoName.append(name);
|
||||
|
||||
// 存储新文件
|
||||
newMongoId = gridFsTemplate.store(stream, mongoName.toString()).toString();
|
||||
GridFSFile gridFSFile = gridFsTemplate.findOne(new Query(Criteria.where("_id").is(newMongoId)));
|
||||
attachment.setMongoId(newMongoId);
|
||||
attachment.setSize(gridFSFile.getLength());
|
||||
attachment.setMd5(IO.md5(gridFSBucket.openDownloadStream(gridFSFile.getObjectId())));
|
||||
attachment.setMimeType(new Tika().detect(gridFSBucket.openDownloadStream(gridFSFile.getObjectId())));
|
||||
if (attachment.getMimeType().startsWith("image")) {
|
||||
BufferedImage image = ImageIO.read(gridFSBucket.openDownloadStream(gridFSFile.getObjectId()));
|
||||
attachment.setMetadata(TimiJava.defaultIfNull(attachment.getMetadata(), jackson.createObjectNode()));
|
||||
if (attachment.getMetadata() instanceof ObjectNode obj) {
|
||||
obj.put("width", image.getWidth());
|
||||
obj.put("height", image.getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
// 更新数据库后删除旧 GridFS 文件
|
||||
super.update(attachment);
|
||||
gridFsTemplate.delete(Query.query(Criteria.where("_id").is(old.getMongoId())));
|
||||
} catch (Exception e) {
|
||||
// 新文件已上传但后续操作失败,清理新文件防止孤儿数据
|
||||
if (newMongoId != null) {
|
||||
gridFsTemplate.delete(Query.query(Criteria.where("_id").is(newMongoId)));
|
||||
}
|
||||
log.error("update error", e);
|
||||
throw new TimiException(TimiCode.ERROR, "TODO update file error");
|
||||
log.error("clone attachment error, id={}", id, e);
|
||||
throw new TimiException(TimiCode.ERROR, "clone attachment error", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,9 +226,9 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
||||
if (!isImage && !isVideo) {
|
||||
return null;
|
||||
}
|
||||
// 命中缓存直接返回
|
||||
Attachment cached = mapper.selectThumb(source.getBizType(), source.getId(), requestWidth, requestHeight);
|
||||
if (cached != null) {
|
||||
// 命中缓存直接返回
|
||||
return cached;
|
||||
}
|
||||
try {
|
||||
@@ -307,7 +319,12 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
||||
|
||||
@Override
|
||||
public List<Attachment> listByBizId(Attachment.BizType bizType, String bizId, String... attachTypes) {
|
||||
return mapper.selectByBizId(bizType, bizId, List.of(attachTypes), null);
|
||||
return mapper.selectAllByBizIdList(bizType, List.of(bizId), List.of(attachTypes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<Attachment>> mapByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, String... attachTypes) {
|
||||
return mapper.selectAllByBizIdList(bizType, bizIdList, List.of(attachTypes)).stream().collect(Collectors.groupingBy(Attachment::getBizId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -330,16 +347,14 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void updateByBiz(BizUpdateReq req) {
|
||||
Attachment.BizType bizType = req.getBizType();
|
||||
String bizId = req.getBizId();
|
||||
List<Attachment> items = req.getItems();
|
||||
public void updateByBizId(Attachment.BizType bizType, String bizId, List<Attachment> list) {
|
||||
list = TimiJava.defaultIfNull(list, new ArrayList<>());
|
||||
|
||||
// 数据库现有附件
|
||||
List<Attachment> dbList = mapper.selectAllByBizId(bizType, bizId);
|
||||
Set<String> dbIds = dbList.stream().map(Attachment::getId).collect(Collectors.toSet());
|
||||
// 请求附件 ID
|
||||
Set<String> reqIds = items.stream().map(Attachment::getId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
Set<String> reqIds = list.stream().map(Attachment::getId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
// 数据库有、请求无:删除
|
||||
for (Attachment attach : dbList) {
|
||||
if (!reqIds.contains(attach.getId())) {
|
||||
@@ -347,7 +362,7 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
||||
}
|
||||
}
|
||||
|
||||
for (Attachment item : items) {
|
||||
for (Attachment item : list) {
|
||||
boolean isNew = item.getId() == null || !dbIds.contains(item.getId());
|
||||
String tempFileId = item.getTempFileId();
|
||||
|
||||
@@ -414,8 +429,8 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void deleteByBiz(BizDeleteReq req) {
|
||||
List<Attachment> attachmentList = mapper.selectAllByBizId(req.getBizType(), req.getBizId());
|
||||
public void deleteByBizId(Attachment.BizType bizType, String bizId) {
|
||||
List<Attachment> attachmentList = mapper.selectAllByBizId(bizType, bizId);
|
||||
for (Attachment attachment : attachmentList) {
|
||||
delete(attachment.getId());
|
||||
}
|
||||
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.modules.common.entity.Feedback;
|
||||
import com.imyeyu.api.modules.common.mapper.FeedbackMapper;
|
||||
import com.imyeyu.api.modules.common.service.ArticleService;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.common.service.FeedbackService;
|
||||
import com.imyeyu.api.modules.system.entity.Logger;
|
||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import com.imyeyu.utils.Time;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/// 通用反馈服务实现
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-19
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class FeedbackServiceImplement extends AbstractEntityService<Feedback, String> implements FeedbackService {
|
||||
|
||||
private static final long ANONYMOUS_ATTACHMENT_MAX_SIZE = 500L * 1024;
|
||||
|
||||
private final LoggerService loggerService;
|
||||
private final ArticleService articleService;
|
||||
private final UserLoginService userLoginService;
|
||||
private final AttachmentService attachmentService;
|
||||
|
||||
private final FeedbackMapper mapper;
|
||||
|
||||
@Override
|
||||
protected BaseMapper<Feedback, String> mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void create(Feedback feedback) {
|
||||
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_FEEDBACK_CREATE");
|
||||
try {
|
||||
TimiException.required(feedback, "未找到反馈");
|
||||
articleService.create(feedback.getContent());
|
||||
feedback.setContentId(feedback.getContent().getId());
|
||||
feedback.setStatus(TimiJava.defaultIfNull(feedback.getStatus(), Feedback.Status.PENDING));
|
||||
super.create(feedback);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(feedback.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("create feedback error", e);
|
||||
throw new TimiException(TimiCode.ERROR, "create feedback error", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void update(Feedback feedback) {
|
||||
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_FEEDBACK_UPDATE");
|
||||
try {
|
||||
TimiException.required(feedback, "未找到反馈");
|
||||
TimiException.required(feedback.getId(), "未找到反馈 ID");
|
||||
Feedback dbFeedback = get(feedback.getId());
|
||||
TimiException.required(dbFeedback, "未找到反馈");
|
||||
|
||||
feedback.getContent().setId(dbFeedback.getContentId());
|
||||
articleService.update(feedback.getContent());
|
||||
|
||||
dbFeedback.setModule(TimiJava.defaultIfNull(feedback.getModule(), dbFeedback.getModule()));
|
||||
if (TimiJava.isNotEmpty(feedback.getResponse())) {
|
||||
if (TimiJava.isEmpty(feedback.getResponseId())) {
|
||||
articleService.create(feedback.getResponse());
|
||||
dbFeedback.setResponseId(feedback.getResponse().getId());
|
||||
dbFeedback.setRespondedAt(Time.now());
|
||||
} else {
|
||||
feedback.getResponse().setId(dbFeedback.getResponseId());
|
||||
articleService.update(feedback.getResponse());
|
||||
}
|
||||
dbFeedback.setStatus(Feedback.Status.REPLIED);
|
||||
dbFeedback.setRespondedBy(userLoginService.getRequireLoginUserId());
|
||||
}
|
||||
super.update(dbFeedback);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(feedback.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("修改反馈失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "修改反馈失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_FEEDBACK_DELETE");
|
||||
try {
|
||||
Feedback feedback = get(id);
|
||||
articleService.delete(feedback.getContentId());
|
||||
if (TimiJava.isNotEmpty(feedback.getResponseId())) {
|
||||
articleService.delete(feedback.getResponseId());
|
||||
}
|
||||
super.delete(id);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(id);
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("delete feedback error", e);
|
||||
throw new TimiException(TimiCode.ERROR, "delete feedback error", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.imyeyu.api.modules.common.config.NotifyQueueConfig;
|
||||
import com.imyeyu.api.modules.common.entity.HTTPQueue;
|
||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||
import com.imyeyu.api.modules.common.mapper.BaseQueueMapper;
|
||||
import com.imyeyu.api.modules.common.mapper.HTTPQueueMapper;
|
||||
import com.imyeyu.api.modules.common.service.HTTPQueueService;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/// HTTP 队列服务实现
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class HTTPQueueServiceImplement extends AbstractQueueService<HTTPQueue, NotifyQueueConfig.HTTP> implements HTTPQueueService {
|
||||
|
||||
private final NotifyQueueConfig config;
|
||||
|
||||
private final HTTPQueueMapper mapper;
|
||||
|
||||
@Override
|
||||
protected NotifyQueueConfig.HTTP config() {
|
||||
return config.getHttp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseQueueMapper<HTTPQueue> mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateSendTo(String sendTo) {
|
||||
try {
|
||||
URI uri = URI.create(sendTo);
|
||||
TimiException.requiredTrue(uri.isAbsolute(), "发送目标不是有效 URI");
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new TimiException(TimiCode.ARG_BAD, "发送目标不是有效 URI", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createQueue(NotifyDetail detail) {
|
||||
mapper.insert(new HTTPQueue(detail));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doSend(HTTPQueue queue) {
|
||||
throw new TimiException(TimiCode.ERROR_NOT_SUPPORT, "HTTP 推送暂未实现");
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.imyeyu.api.modules.common.config.NotifyQueueConfig;
|
||||
import com.imyeyu.api.modules.common.entity.MailQueue;
|
||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||
import com.imyeyu.api.modules.common.mapper.BaseQueueMapper;
|
||||
import com.imyeyu.api.modules.common.mapper.MailQueueMapper;
|
||||
import com.imyeyu.api.modules.common.service.MailQueueService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.utils.Regex;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/// 邮件队列服务实现
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MailQueueServiceImplement extends AbstractQueueService<MailQueue, NotifyQueueConfig.Mail> implements MailQueueService {
|
||||
|
||||
private final NotifyQueueConfig config;
|
||||
private final JavaMailSender mailSender;
|
||||
|
||||
private final MailQueueMapper mapper;
|
||||
|
||||
@Override
|
||||
protected NotifyQueueConfig.Mail config() {
|
||||
return config.getMail();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseQueueMapper<MailQueue> mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateSendTo(String sendTo) {
|
||||
TimiException.requiredTrue(Regex.isMatch(Regex.EMAIL, sendTo), "发送目标不是有效邮箱");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createQueue(NotifyDetail detail) {
|
||||
MailQueue queue = new MailQueue(detail);
|
||||
queue.setSendFrom(TimiJava.defaultIfEmpty(queue.getSendFrom(), config.getMail().getDefaultFrom()));
|
||||
mapper.insert(queue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doSend(MailQueue queue) {
|
||||
TimiException.required(queue.getSendFrom(), "邮件发送来源不能为空");
|
||||
TimiException.required(queue.getSubject(), "邮件标题不能为空");
|
||||
|
||||
SimpleMailMessage message = new SimpleMailMessage();
|
||||
message.setFrom(queue.getSendFrom());
|
||||
message.setTo(queue.getSendTo());
|
||||
message.setSubject(queue.getSubject());
|
||||
message.setText(queue.getData());
|
||||
mailSender.send(message);
|
||||
log.info("邮件发送成功,目标:{}", queue.getSendTo());
|
||||
}
|
||||
}
|
||||
+23
@@ -3,6 +3,7 @@ package com.imyeyu.api.modules.common.service.implement;
|
||||
import com.imyeyu.api.modules.common.entity.Multilingual;
|
||||
import com.imyeyu.api.modules.common.mapper.MultilingualMapper;
|
||||
import com.imyeyu.api.modules.common.service.MultilingualService;
|
||||
import com.imyeyu.api.util.PinyinUtil;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import com.imyeyu.spring.util.Redis;
|
||||
@@ -34,6 +35,18 @@ public class MultilingualServiceImplement extends AbstractEntityService<Multilin
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(Multilingual multilingual) {
|
||||
fillPinyin(multilingual);
|
||||
super.create(multilingual);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Multilingual multilingual) {
|
||||
fillPinyin(multilingual);
|
||||
super.update(multilingual);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multilingual get(String id) {
|
||||
Multilingual result = redisLanguage.get(getKey(id));
|
||||
@@ -81,4 +94,14 @@ public class MultilingualServiceImplement extends AbstractEntityService<Multilin
|
||||
private String getKey(String id) {
|
||||
return "%s%s".formatted(KEY_PREFIX, id);
|
||||
}
|
||||
|
||||
private void fillPinyin(Multilingual multilingual) {
|
||||
if (multilingual == null) {
|
||||
return;
|
||||
}
|
||||
String zhCN = multilingual.getZhCN();
|
||||
multilingual.setZhCNPinyinFull(PinyinUtil.full(zhCN));
|
||||
multilingual.setZhCNPinyinInitial(PinyinUtil.initial(zhCN));
|
||||
multilingual.setZhCNPinyinMixed(PinyinUtil.mixed(zhCN));
|
||||
}
|
||||
}
|
||||
|
||||
+176
@@ -1,12 +1,24 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||
import com.imyeyu.api.modules.common.entity.Notify;
|
||||
import com.imyeyu.api.modules.common.mapper.NotifyDetailMapper;
|
||||
import com.imyeyu.api.modules.common.mapper.NotifyMapper;
|
||||
import com.imyeyu.api.modules.common.service.NotifyDetailService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import com.imyeyu.utils.Time;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通知详情服务实现
|
||||
@@ -18,10 +30,174 @@ import org.springframework.stereotype.Service;
|
||||
@RequiredArgsConstructor
|
||||
public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDetail, String> implements NotifyDetailService {
|
||||
|
||||
private final NotifyMapper notifyMapper;
|
||||
|
||||
private final NotifyDetailMapper mapper;
|
||||
|
||||
@Override
|
||||
protected BaseMapper<NotifyDetail, String> mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
/// 创建通知详情,同时初始化投递状态和时间参数
|
||||
///
|
||||
/// @param detail 通知详情
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void create(NotifyDetail detail) {
|
||||
TimiException.required(detail, "未找到通知详情");
|
||||
TimiException.required(detail.getNotifyId(), "未找到通知 ID");
|
||||
TimiException.required(detail.getMsgType(), "未找到消息类型");
|
||||
Notify notify = notifyMapper.select(detail.getNotifyId());
|
||||
TimiException.required(notify, "未找到通知");
|
||||
if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) {
|
||||
TimiException.required(detail.getSendTo(), "未找到站内通知接收用户 ID");
|
||||
}
|
||||
|
||||
detail.setRetry(TimiJava.defaultIfNull(detail.getRetry(), 1));
|
||||
detail.setSendAt(TimiJava.defaultIfNull(detail.getSendAt(), Time.now()));
|
||||
detail.setTimeoutAt(TimiJava.defaultIfNull(detail.getTimeoutAt(), detail.getSendAt() + Time.D));
|
||||
detail.setStatus(detail.getMsgType() == NotifyDetail.MsgType.INTERNAL
|
||||
? NotifyDetail.Status.REMINDED
|
||||
: NotifyDetail.Status.WAITING);
|
||||
detail.setReadAt(null);
|
||||
super.create(detail);
|
||||
|
||||
if (detail.getMsgType().isQueue()) {
|
||||
// 加入外部消息队列
|
||||
detail.getMsgType().getService().createQueue(detail);
|
||||
}
|
||||
}
|
||||
|
||||
/// 查询通知下的全部详情
|
||||
///
|
||||
/// @param notifyId 通知 ID
|
||||
/// @return 通知详情列表
|
||||
@Override
|
||||
public List<NotifyDetail> listByNotifyId(String notifyId) {
|
||||
NotifyDetail example = new NotifyDetail();
|
||||
example.setNotifyId(notifyId);
|
||||
return mapper.selectAllByExample(example);
|
||||
}
|
||||
|
||||
/// 删除通知详情
|
||||
///
|
||||
/// @param detailId 通知详情 ID
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void delete(String detailId) {
|
||||
TimiException.required(detailId, "未找到通知详情 ID");
|
||||
NotifyDetail detail = get(detailId);
|
||||
TimiException.required(detail, "未找到通知详情");
|
||||
if (detail.getMsgType().isQueue()) {
|
||||
detail.getMsgType().getService().destroyQueue(detail);
|
||||
}
|
||||
super.delete(detailId);
|
||||
}
|
||||
|
||||
/// 重新将通知详情放入消息队列
|
||||
///
|
||||
/// @param detailId 通知详情 ID
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void requeue(String detailId) {
|
||||
NotifyDetail detail = get(detailId);
|
||||
TimiException.required(detail, "未找到通知详情");
|
||||
TimiException.required(detail.getMsgType(), "未找到消息类型");
|
||||
TimiException.requiredTrue(detail.getMsgType().isQueue(), "站内通知不支持重新入队");
|
||||
if (detail.getStatus() == NotifyDetail.Status.WAITING) {
|
||||
throw new TimiException(TimiCode.RESULT_BAD, "通知详情已经在等待队列中");
|
||||
}
|
||||
|
||||
detail.getMsgType().getService().destroyQueue(detail);
|
||||
detail.setStatus(NotifyDetail.Status.WAITING);
|
||||
detail.setResultDesc(null);
|
||||
detail.setRetry(1);
|
||||
detail.setSendAt(Time.now());
|
||||
detail.setTimeoutAt(detail.getSendAt() + Time.D);
|
||||
update(detail);
|
||||
|
||||
// 加入消息队列
|
||||
detail.getMsgType().getService().createQueue(detail);
|
||||
}
|
||||
|
||||
/// 分页查询用户的站内通知
|
||||
///
|
||||
/// @param page 分页参数
|
||||
/// @param userId 用户 ID
|
||||
/// @param unreadOnly true 为只查询未读通知
|
||||
/// @return 站内通知分页结果
|
||||
@Override
|
||||
public PageResult<NotifyDetail> pageInternalByUserId(Page<NotifyDetail> page, String userId, boolean unreadOnly) {
|
||||
TimiException.required(userId, "未找到用户 ID");
|
||||
Page<NotifyDetail> validPage = TimiJava.defaultIfNull(page, new Page<>());
|
||||
PageResult<NotifyDetail> result = new PageResult<>();
|
||||
result.setTotal(unreadOnly
|
||||
? mapper.countUnreadSiteByUserId(userId)
|
||||
: mapper.countSiteByUserId(userId));
|
||||
result.setList(unreadOnly
|
||||
? mapper.selectUnreadSiteByUserId(userId, validPage.getOffset(), validPage.getLimit())
|
||||
: mapper.selectSiteByUserId(userId, validPage.getOffset(), validPage.getLimit()));
|
||||
return result;
|
||||
}
|
||||
|
||||
/// 查询当前用户拥有的站内通知详情
|
||||
///
|
||||
/// @param detailId 通知详情 ID
|
||||
/// @param userId 用户 ID
|
||||
/// @return 通知详情
|
||||
@Override
|
||||
public NotifyDetail getInternalByUserId(String detailId, String userId) {
|
||||
TimiException.required(detailId, "未找到通知详情 ID");
|
||||
TimiException.required(userId, "未找到用户 ID");
|
||||
NotifyDetail detail = mapper.selectSiteByIdAndUserId(detailId, userId);
|
||||
TimiException.required(detail, "未找到站内通知");
|
||||
return detail;
|
||||
}
|
||||
|
||||
/// 删除当前用户拥有的站内通知详情
|
||||
///
|
||||
/// @param detailId 通知详情 ID
|
||||
/// @param userId 用户 ID
|
||||
@Override
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
public void deleteInternalByUserId(String detailId, String userId) {
|
||||
TimiException.required(detailId, "未找到通知详情 ID");
|
||||
TimiException.required(userId, "未找到用户 ID");
|
||||
int affected = mapper.deleteSiteByIdAndUserId(detailId, userId);
|
||||
TimiException.requiredTrue(0 < affected, "未找到站内通知");
|
||||
}
|
||||
|
||||
/// 查询用户未读站内通知数量
|
||||
///
|
||||
/// @param userId 用户 ID
|
||||
/// @return 未读数量
|
||||
@Override
|
||||
public long countUnreadSiteByUserId(String userId) {
|
||||
TimiException.required(userId, "未找到用户 ID");
|
||||
return mapper.countUnreadSiteByUserId(userId);
|
||||
}
|
||||
|
||||
/// 标记站内通知已读
|
||||
///
|
||||
/// @param userId 用户 ID
|
||||
/// @param detailId 通知详情 ID
|
||||
@Override
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
public void markSiteRead(String userId, String detailId) {
|
||||
TimiException.required(userId, "未找到用户 ID");
|
||||
TimiException.required(detailId, "未找到通知详情 ID");
|
||||
TimiException.required(mapper.selectSiteByIdAndUserId(detailId, userId), "未找到站内通知");
|
||||
mapper.markSiteRead(detailId, userId, Time.now());
|
||||
}
|
||||
|
||||
/// 标记用户全部站内通知已读
|
||||
///
|
||||
/// @param userId 用户 ID
|
||||
@Override
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
public void markAllSiteRead(String userId) {
|
||||
TimiException.required(userId, "未找到用户 ID");
|
||||
mapper.markAllSiteRead(userId, Time.now());
|
||||
}
|
||||
}
|
||||
|
||||
+117
@@ -1,12 +1,25 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.modules.common.entity.Notify;
|
||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||
import com.imyeyu.api.modules.common.mapper.NotifyMapper;
|
||||
import com.imyeyu.api.modules.common.service.NotifyDetailService;
|
||||
import com.imyeyu.api.modules.common.service.NotifyService;
|
||||
import com.imyeyu.api.modules.system.entity.Logger;
|
||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通知服务实现
|
||||
@@ -14,14 +27,118 @@ import org.springframework.stereotype.Service;
|
||||
* @author 夜雨
|
||||
* @since 2026-05-13 14:46
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class NotifyServiceImplement extends AbstractEntityService<Notify, String> implements NotifyService {
|
||||
|
||||
private final LoggerService loggerService;
|
||||
private final UserLoginService userLoginService;
|
||||
private final NotifyDetailService detailService;
|
||||
|
||||
private final NotifyMapper mapper;
|
||||
|
||||
@Override
|
||||
protected BaseMapper<Notify, String> mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
/// 创建通知并级联创建通知详情
|
||||
///
|
||||
/// @param notify 通知
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void create(Notify notify) {
|
||||
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_NOTIFY_CREATE");
|
||||
try {
|
||||
TimiException.required(notify, "未找到通知");
|
||||
TimiException.required(notify.getDetailList(), "未找到通知详情列表");
|
||||
super.create(notify);
|
||||
|
||||
String sendFrom = null;
|
||||
if (userLoginService.isLogged()) {
|
||||
sendFrom = userLoginService.getRequireLoginUserId();
|
||||
}
|
||||
for (NotifyDetail detail : notify.getDetailList()) {
|
||||
detail.setNotifyId(notify.getId());
|
||||
if (TimiJava.isNotEmpty(sendFrom)) {
|
||||
detail.setSendFrom(sendFrom);
|
||||
}
|
||||
detailService.create(detail);
|
||||
}
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(notify.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("创建通知失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "创建通知失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
/// 删除通知并级联软删除通知详情
|
||||
///
|
||||
/// @param notifyId 通知 ID
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void delete(String notifyId) {
|
||||
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_NOTIFY_DELETE");
|
||||
try {
|
||||
TimiException.required(notifyId, "未找到通知 ID");
|
||||
TimiException.required(get(notifyId), "未找到通知");
|
||||
List<NotifyDetail> detailList = detailService.listByNotifyId(notifyId);
|
||||
for (NotifyDetail detail : detailList) {
|
||||
detailService.delete(detail.getId());
|
||||
}
|
||||
super.delete(notifyId);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(notifyId);
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("删除通知失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "删除通知失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
/// 取消通知中尚未成功发送的通知详情
|
||||
///
|
||||
/// @param notifyId 通知 ID
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void cancel(String notifyId) {
|
||||
TimiException.required(notifyId, "未找到通知 ID");
|
||||
TimiException.required(get(notifyId), "未找到通知");
|
||||
|
||||
boolean canceled = false;
|
||||
for (NotifyDetail detail : detailService.listByNotifyId(notifyId)) {
|
||||
if (detail.getStatus() == NotifyDetail.Status.REMINDED
|
||||
|| detail.getStatus() == NotifyDetail.Status.CANCEL
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (detail.getMsgType() != null && detail.getMsgType().isQueue()) {
|
||||
detail.getMsgType().getService().destroyQueue(detail);
|
||||
}
|
||||
detail.setStatus(NotifyDetail.Status.CANCEL);
|
||||
detail.setResultDesc("通知已取消");
|
||||
detailService.update(detail);
|
||||
canceled = true;
|
||||
}
|
||||
if (!canceled) {
|
||||
throw new TimiException(TimiCode.RESULT_BAD, "通知没有可取消的通知详情");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.imyeyu.api.modules.common.config.NotifyQueueConfig;
|
||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||
import com.imyeyu.api.modules.common.entity.SmsQueue;
|
||||
import com.imyeyu.api.modules.common.mapper.BaseQueueMapper;
|
||||
import com.imyeyu.api.modules.common.mapper.SmsQueueMapper;
|
||||
import com.imyeyu.api.modules.common.service.SmsQueueService;
|
||||
import com.imyeyu.api.modules.common.util.QCloudSmsProxy;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
|
||||
import com.tencentcloudapi.sms.v20210111.models.SendStatus;
|
||||
import com.imyeyu.utils.Regex;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/// 短信队列服务实现
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SmsQueueServiceImplement extends AbstractQueueService<SmsQueue, NotifyQueueConfig.Sms> implements SmsQueueService {
|
||||
|
||||
private final NotifyQueueConfig config;
|
||||
private final ObjectMapper jackson;
|
||||
private final QCloudSmsProxy smsProxy;
|
||||
|
||||
private final SmsQueueMapper mapper;
|
||||
|
||||
@Override
|
||||
protected NotifyQueueConfig.Sms config() {
|
||||
return config.getSms();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseQueueMapper<SmsQueue> mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateSendTo(String sendTo) {
|
||||
TimiException.requiredTrue(Regex.isMatch(Regex.MOBILE_PHONE, sendTo), "发送目标不是手机号");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createQueue(NotifyDetail detail) {
|
||||
mapper.insert(new SmsQueue(detail));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doSend(SmsQueue queue) {
|
||||
try {
|
||||
String[] args = new String[0];
|
||||
if (queue.getArgs() != null && !queue.getArgs().isBlank()) {
|
||||
JsonNode argsNode = jackson.readTree(queue.getArgs());
|
||||
TimiException.requiredTrue(argsNode != null && argsNode.isArray(), "短信参数必须是数组");
|
||||
args = jackson.treeToValue(argsNode, String[].class);
|
||||
}
|
||||
SendSmsResponse response = smsProxy.send(queue.getSendTo(), queue.getTemplateId(), args);
|
||||
TimiException.required(response, "未找到短信响应");
|
||||
SendStatus[] statusSet = response.getSendStatusSet();
|
||||
TimiException.requiredTrue(statusSet != null && 0 < statusSet.length, "短信响应为空");
|
||||
if (!"ok".equalsIgnoreCase(statusSet[0].getCode())) {
|
||||
throw new TimiException(TimiCode.ERROR, jackson.writeValueAsString(response));
|
||||
}
|
||||
} catch (TimiException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new TimiException(TimiCode.ERROR, "短信发送失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+98
-4
@@ -1,27 +1,121 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Tag;
|
||||
import com.imyeyu.api.modules.common.entity.TagApply;
|
||||
import com.imyeyu.api.modules.common.mapper.TagApplyMapper;
|
||||
import com.imyeyu.api.modules.common.mapper.TagMapper;
|
||||
import com.imyeyu.api.modules.common.service.MultilingualService;
|
||||
import com.imyeyu.api.modules.common.service.TagService;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2025-05-30 22:47
|
||||
*/
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
/// 标签服务实现
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2025-05-30 22:47
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TagServiceImplement extends AbstractEntityService<Tag, String> implements TagService {
|
||||
|
||||
private final TagMapper mapper;
|
||||
private final TagApplyMapper applyMapper;
|
||||
private final MultilingualService multilingualService;
|
||||
|
||||
@Override
|
||||
protected BaseMapper<Tag, String> mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(Tag tag) {
|
||||
TimiException.required(tag, "not found tag");
|
||||
TimiException.required(tag.getZhCN(), "not found tag.zhCN");
|
||||
TimiException.required(tag.getOwnerType(), "not found ownerType");
|
||||
TimiException.required(tag.getOwnerId(), "not found ownerId");
|
||||
checkZhCNUniqueInOwner(tag, null);
|
||||
tag.setNameLangId(multilingualService.create(tag.getZhCN()));
|
||||
super.create(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tag tag) {
|
||||
TimiException.required(tag, "not found tag");
|
||||
TimiException.required(tag.getId(), "not found tag.id");
|
||||
Tag dbTag = get(tag.getId());
|
||||
TimiException.required(dbTag, "not found tag");
|
||||
tag.setOwnerType(dbTag.getOwnerType());
|
||||
tag.setOwnerId(dbTag.getOwnerId());
|
||||
if (tag.getZhCN() != null) {
|
||||
if (tag.getNameLangId() == null) {
|
||||
tag.setNameLangId(dbTag.getNameLangId());
|
||||
}
|
||||
checkZhCNUniqueInOwner(tag, tag.getId());
|
||||
tag.setNameLangId(multilingualService.createIfDifferent(tag.getNameLangId(), tag.getZhCN()));
|
||||
}
|
||||
super.update(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tag> listByIdList(Collection<String> idList) {
|
||||
return mapper.selectByIdList(new HashSet<>(idList));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Tag> pageByOwnerAndKeyword(Page<Tag> page, Tag.OwnerType ownerType, String ownerId, String keyword) {
|
||||
PageResult<Tag> result = new PageResult<>();
|
||||
result.setTotal(mapper.countByOwnerAndKeyword(ownerType, ownerId, keyword));
|
||||
result.setList(mapper.selectByOwnerAndKeyword(ownerType, ownerId, keyword, page.getOffset(), page.getLimit()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tag> listByBizType(TagApply.BizType bizType, String bizId) {
|
||||
return listByIdList(listApply(bizType, bizId).stream().map(TagApply::getTagId).toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(TagApply.BizType bizType, String bizId, List<String> tagIdList) {
|
||||
LinkedHashSet<String> tagIdSet = new LinkedHashSet<>(tagIdList == null ? List.of() : tagIdList);
|
||||
for (TagApply apply : listApply(bizType, bizId)) {
|
||||
if (tagIdSet.remove(apply.getTagId())) {
|
||||
continue;
|
||||
}
|
||||
applyMapper.delete(apply.getId());
|
||||
}
|
||||
List<Tag> tagList = listByIdList(tagIdSet);
|
||||
for (Tag tag : tagList) {
|
||||
TagApply apply = new TagApply();
|
||||
apply.setBizType(bizType);
|
||||
apply.setBizId(bizId);
|
||||
apply.setTagId(tag.getId());
|
||||
applyMapper.insert(apply);
|
||||
}
|
||||
}
|
||||
|
||||
private List<TagApply> listApply(TagApply.BizType bizType, String bizId) {
|
||||
TimiException.required(bizType, "not found bizType");
|
||||
TimiException.required(bizId, "not found bizId");
|
||||
|
||||
TagApply example = new TagApply();
|
||||
example.setBizType(bizType);
|
||||
example.setBizId(bizId);
|
||||
return applyMapper.selectAllByExample(example);
|
||||
}
|
||||
|
||||
private void checkZhCNUniqueInOwner(Tag tag, String allowedId) {
|
||||
Tag existed = mapper.selectByOwnerAndZhCN(tag.getOwnerType(), tag.getOwnerId(), tag.getZhCN());
|
||||
TimiException.requiredTrue(existed == null || existed.getId().equals(allowedId), "该标签名称已存在");
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -46,8 +46,8 @@ public class TempFileServiceImplement implements TempFileService {
|
||||
|
||||
public List<TempFileResp> create(List<MultipartFile> files, Long ttl) throws TimiException {
|
||||
Logger logger = new Logger();
|
||||
logger.setModule("TEMP_FILE");
|
||||
logger.setOperation("STORE");
|
||||
logger.setModule(Logger.Module.COMMON);
|
||||
logger.setOperation("TEMP_FILE_STORE");
|
||||
logger.setIp(TimiSpring.getRequestIP());
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(logRequestArgs(files, ttl)));
|
||||
@@ -116,8 +116,8 @@ public class TempFileServiceImplement implements TempFileService {
|
||||
@Override
|
||||
public void save(TempFileSaveReq request) {
|
||||
Logger logger = new Logger();
|
||||
logger.setModule("TEMP_FILE");
|
||||
logger.setOperation("SAVE");
|
||||
logger.setModule(Logger.Module.COMMON);
|
||||
logger.setOperation("TEMP_FILE_SAVE");
|
||||
logger.setIp(TimiSpring.getRequestIP());
|
||||
try {
|
||||
logger.setContent(jackson.writeValueAsString(request));
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.imyeyu.api.modules.common.config.NotifyQueueConfig;
|
||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||
import com.imyeyu.api.modules.common.entity.WechatQueue;
|
||||
import com.imyeyu.api.modules.common.mapper.BaseQueueMapper;
|
||||
import com.imyeyu.api.modules.common.mapper.WechatQueueMapper;
|
||||
import com.imyeyu.api.modules.common.service.WechatQueueService;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/// 微信队列服务实现
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class WechatQueueServiceImplement extends AbstractQueueService<WechatQueue, NotifyQueueConfig.Wechat> implements WechatQueueService {
|
||||
|
||||
private final NotifyQueueConfig config;
|
||||
|
||||
private final WechatQueueMapper mapper;
|
||||
|
||||
@Override
|
||||
protected NotifyQueueConfig.Wechat config() {
|
||||
return config.getWechat();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseQueueMapper<WechatQueue> mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateSendTo(String sendTo) {
|
||||
TimiException.required(sendTo, "发送目标不能为空");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createQueue(NotifyDetail detail) {
|
||||
mapper.insert(new WechatQueue(detail));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doSend(WechatQueue queue) {
|
||||
throw new TimiException(TimiCode.ERROR_NOT_SUPPORT, "微信推送暂未实现");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.imyeyu.api.modules.common.task;
|
||||
|
||||
import com.imyeyu.api.modules.common.config.NotifyQueueConfig;
|
||||
import com.imyeyu.api.modules.common.service.MailQueueService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
import org.springframework.scheduling.support.CronTrigger;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/// 邮件队列定时任务
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MailQueueTask implements SchedulingConfigurer {
|
||||
|
||||
private final NotifyQueueConfig config;
|
||||
|
||||
private final MailQueueService service;
|
||||
|
||||
private boolean running;
|
||||
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
if (!config.getMail().isEnable()) {
|
||||
log.warn("邮件队列任务已禁用");
|
||||
return;
|
||||
}
|
||||
taskRegistrar.addTriggerTask(() -> {
|
||||
if (running) {
|
||||
log.info("邮件队列任务正在运行,跳过本次执行");
|
||||
return;
|
||||
}
|
||||
running = true;
|
||||
try {
|
||||
service.invokeQueue();
|
||||
} finally {
|
||||
running = false;
|
||||
}
|
||||
}, triggerContext -> new CronTrigger(config.getMail().getCron()).nextExecution(triggerContext));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.imyeyu.api.modules.common.task;
|
||||
|
||||
import com.imyeyu.api.modules.common.config.NotifyQueueConfig;
|
||||
import com.imyeyu.api.modules.common.service.SmsQueueService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
import org.springframework.scheduling.support.CronTrigger;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/// 短信队列定时任务
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SmsQueueTask implements SchedulingConfigurer {
|
||||
|
||||
private final NotifyQueueConfig config;
|
||||
|
||||
private final SmsQueueService service;
|
||||
|
||||
private boolean running;
|
||||
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
if (!config.getSms().isEnable()) {
|
||||
log.warn("短信队列任务已禁用");
|
||||
return;
|
||||
}
|
||||
taskRegistrar.addTriggerTask(() -> {
|
||||
if (running) {
|
||||
log.info("短信队列任务正在运行,跳过本次执行");
|
||||
return;
|
||||
}
|
||||
running = true;
|
||||
try {
|
||||
service.invokeQueue();
|
||||
} finally {
|
||||
running = false;
|
||||
}
|
||||
}, triggerContext -> new CronTrigger(config.getSms().getCron()).nextExecution(triggerContext));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.imyeyu.api.modules.common.task;
|
||||
|
||||
/// 微信队列定时任务占位
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
public class WechatQueueTask {
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.imyeyu.api.modules.common.util;
|
||||
|
||||
import com.imyeyu.api.modules.common.config.NotifyQueueConfig;
|
||||
import com.tencentcloudapi.common.Credential;
|
||||
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||
import com.tencentcloudapi.common.profile.HttpProfile;
|
||||
import com.tencentcloudapi.sms.v20210111.SmsClient;
|
||||
import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
|
||||
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// 腾讯云短信服务代理
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class QCloudSmsProxy {
|
||||
|
||||
private final NotifyQueueConfig config;
|
||||
|
||||
/// 发送短信
|
||||
///
|
||||
/// @param mobilePhone 手机号
|
||||
/// @param templateId 模板 ID
|
||||
/// @param args 模板参数
|
||||
/// @return 腾讯云短信响应
|
||||
/// @throws TencentCloudSDKException 腾讯云 SDK 调用异常
|
||||
public SendSmsResponse send(String mobilePhone, String templateId, String[] args) throws TencentCloudSDKException {
|
||||
return send(List.of(mobilePhone), templateId, args);
|
||||
}
|
||||
|
||||
/// 批量发送短信
|
||||
///
|
||||
/// @param mobilePhoneList 手机号列表
|
||||
/// @param templateId 模板 ID
|
||||
/// @param args 模板参数
|
||||
/// @return 腾讯云短信响应
|
||||
/// @throws TencentCloudSDKException 腾讯云 SDK 调用异常
|
||||
public SendSmsResponse send(List<String> mobilePhoneList, String templateId, String[] args) throws TencentCloudSDKException {
|
||||
SmsClient client = createSmsClient();
|
||||
NotifyQueueConfig.Sms sms = config.getSms();
|
||||
|
||||
SendSmsRequest request = new SendSmsRequest();
|
||||
request.setSmsSdkAppId(sms.getAppId().trim());
|
||||
request.setSignName(sms.getSign().trim());
|
||||
request.setTemplateId(templateId);
|
||||
request.setTemplateParamSet(args);
|
||||
request.setPhoneNumberSet(mobilePhoneList.toArray(new String[0]));
|
||||
return client.SendSms(request);
|
||||
}
|
||||
|
||||
private SmsClient createSmsClient() {
|
||||
NotifyQueueConfig.Sms sms = config.getSms();
|
||||
Credential credential = new Credential(sms.getSecretId().trim(), sms.getSecretKey().trim());
|
||||
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setReqMethod("GET");
|
||||
httpProfile.setConnTimeout(10);
|
||||
httpProfile.setWriteTimeout(10);
|
||||
httpProfile.setReadTimeout(10);
|
||||
httpProfile.setEndpoint("sms.tencentcloudapi.com");
|
||||
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setSignMethod("HmacSHA256");
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
return new SmsClient(credential, "ap-guangzhou", clientProfile);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.imyeyu.api.modules.common.util;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.BaseQueueEntity;
|
||||
import com.imyeyu.spring.util.SQLProvider;
|
||||
import com.imyeyu.utils.Time;
|
||||
import org.apache.ibatis.builder.annotation.ProviderContext;
|
||||
|
||||
/// 通知队列 SQL 提供器
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-20
|
||||
public class QueueSQLProvider extends SQLProvider {
|
||||
|
||||
/// 查询已到发送时间的队列
|
||||
///
|
||||
/// @param context Mapper 上下文
|
||||
/// @return 查询 SQL
|
||||
public String listReadyQueue(ProviderContext context) {
|
||||
EntityMeta meta = getEntityMeta(context);
|
||||
StringBuilder sql = new StringBuilder("SELECT * FROM %s WHERE 1 = 1".formatted(meta.getTable()));
|
||||
if (BaseQueueEntity.class.isAssignableFrom(meta.getEntityClass())) {
|
||||
sql.append(" AND `send_at` < %d".formatted(Time.now()));
|
||||
}
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
/// 根据通知详情 ID 物理删除队列
|
||||
///
|
||||
/// @param context Mapper 上下文
|
||||
/// @return 删除 SQL
|
||||
public String destroyByNotifyDetailId(ProviderContext context) {
|
||||
EntityMeta meta = getEntityMeta(context);
|
||||
return "DELETE FROM %s WHERE `notify_detail_id` = #{notifyDetailId}".formatted(meta.getTable());
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.imyeyu.api.modules.common.vo.attach;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 业务附件差分更新请求
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2026-03-11 00:00
|
||||
*/
|
||||
@Data
|
||||
public class BizDeleteReq {
|
||||
|
||||
/** 业务类型 */
|
||||
private Attachment.BizType bizType;
|
||||
|
||||
/** 业务 ID */
|
||||
private String bizId;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.imyeyu.api.modules.common.vo.attach;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务附件差分更新请求
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2026-03-11 00:00
|
||||
*/
|
||||
@Data
|
||||
public class BizUpdateReq {
|
||||
|
||||
/** 业务类型 */
|
||||
private Attachment.BizType bizType;
|
||||
|
||||
/** 业务 ID */
|
||||
private String bizId;
|
||||
|
||||
/** 附件项列表 */
|
||||
private List<Attachment> items = new ArrayList<>();
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.imyeyu.api.modules.common.vo.tag;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2025-05-30 22:58
|
||||
*/
|
||||
@Data
|
||||
public class TagRequest {
|
||||
|
||||
private String bizId;
|
||||
|
||||
private String zhCN;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.imyeyu.api.modules.forevermc.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 服务器接口
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2024-08-06 17:20
|
||||
*/
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/fmc/server")
|
||||
public class ServerController {
|
||||
|
||||
/**
|
||||
* 服务器状态报告,由 FMCServer 服务端插件发送
|
||||
*/
|
||||
@PostMapping("/report")
|
||||
public void report() {
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.imyeyu.api.modules.gao.annotation;
|
||||
|
||||
import com.imyeyu.api.bean.RoleMatchMode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
///
|
||||
/// 要求 GAO 模块角色
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-26
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface RequireGaoRole {
|
||||
|
||||
/// 所需角色
|
||||
///
|
||||
/// @return 角色列表
|
||||
GaoRoleCode[] value();
|
||||
|
||||
/// 匹配模式
|
||||
///
|
||||
/// @return 匹配模式
|
||||
RoleMatchMode mode() default RoleMatchMode.ALL;
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.imyeyu.api.modules.gao.annotation;
|
||||
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.bean.RoleMatchMode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
///
|
||||
/// GAO 角色注解处理器
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-27
|
||||
@Component
|
||||
public class RequireGaoRoleInterceptor implements HandlerInterceptor {
|
||||
|
||||
private final RoleChecker roleChecker;
|
||||
|
||||
public RequireGaoRoleInterceptor(RoleChecker roleChecker) {
|
||||
this.roleChecker = roleChecker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preHandle(@NonNull HttpServletRequest req, @NonNull HttpServletResponse resp, @NonNull Object handler) {
|
||||
if (!(handler instanceof HandlerMethod handlerMethod)) {
|
||||
return true;
|
||||
}
|
||||
RequireGaoRole annotation = handlerMethod.getMethodAnnotation(RequireGaoRole.class);
|
||||
if (annotation == null || TimiJava.isEmpty(annotation.value())) {
|
||||
return true;
|
||||
}
|
||||
String[] roleCodeList = java.util.Arrays.stream(annotation.value()).map(GaoRoleCode::name).toArray(String[]::new);
|
||||
if (annotation.mode() == RoleMatchMode.ANY) {
|
||||
roleChecker.checkAny(ModuleCode.GAO, roleCodeList);
|
||||
} else {
|
||||
roleChecker.checkAll(ModuleCode.GAO, roleCodeList);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.imyeyu.api.modules.gao.bean;
|
||||
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.user.bean.BuiltinPermissionCode;
|
||||
import lombok.Getter;
|
||||
|
||||
///
|
||||
/// GAO 模块权限枚举
|
||||
@@ -10,54 +11,88 @@ import com.imyeyu.api.modules.user.bean.BuiltinPermissionCode;
|
||||
/// @since 2026-07-26
|
||||
public enum GaoPermissionCode implements BuiltinPermissionCode {
|
||||
|
||||
CUSTOMER_CREATE("CUSTOMER:CREATE", "客户创建"),
|
||||
STORE_CREATE("STORE:CREATE", "门店创建", false, true),
|
||||
|
||||
CUSTOMER_READ("CUSTOMER:READ", "客户读取"),
|
||||
STORE_READ("STORE:READ", "门店读取", true, true),
|
||||
|
||||
CUSTOMER_UPDATE("CUSTOMER:UPDATE", "客户修改"),
|
||||
STORE_EXPORT("STORE:EXPORT", "门店导出", false, true),
|
||||
|
||||
CUSTOMER_DELETE("CUSTOMER:DELETE", "客户删除"),
|
||||
STORE_UPDATE("STORE:UPDATE", "门店修改", true, true),
|
||||
|
||||
REGISTRATION_EVENT_CREATE("REGISTRATION_EVENT:CREATE", "登记事件创建"),
|
||||
STORE_DELETE("STORE:DELETE", "门店删除", false, true),
|
||||
|
||||
REGISTRATION_EVENT_READ("REGISTRATION_EVENT:READ", "登记事件读取"),
|
||||
CUSTOMER_CREATE("CUSTOMER:CREATE", "客户创建", false, false),
|
||||
|
||||
REGISTRATION_EVENT_UPDATE("REGISTRATION_EVENT:UPDATE", "登记事件修改"),
|
||||
CUSTOMER_READ("CUSTOMER:READ", "客户读取", false, false),
|
||||
|
||||
REGISTRATION_EVENT_DELETE("REGISTRATION_EVENT:DELETE", "登记事件删除"),
|
||||
CUSTOMER_EXPORT("CUSTOMER:EXPORT", "客户导出", true, false),
|
||||
|
||||
REGISTRATION_EVENT_RECORD_CREATE("REGISTRATION_EVENT_RECORD:CREATE", "登记事件记录创建"),
|
||||
CUSTOMER_UPDATE("CUSTOMER:UPDATE", "客户修改", false, false),
|
||||
|
||||
REGISTRATION_EVENT_RECORD_READ("REGISTRATION_EVENT_RECORD:READ", "登记事件记录读取"),
|
||||
CUSTOMER_DELETE("CUSTOMER:DELETE", "客户删除", false, false),
|
||||
|
||||
REGISTRATION_EVENT_RECORD_UPDATE("REGISTRATION_EVENT_RECORD:UPDATE", "登记事件记录修改"),
|
||||
EVENT_CREATE("EVENT:CREATE", "登记事件创建", false, false),
|
||||
|
||||
REGISTRATION_EVENT_RECORD_DELETE("REGISTRATION_EVENT_RECORD:DELETE", "登记事件记录删除"),
|
||||
EVENT_READ("EVENT:READ", "登记事件读取", false, false),
|
||||
|
||||
STAT_READ("STAT:READ", "统计读取"),
|
||||
EVENT_UPDATE("EVENT:UPDATE", "登记事件修改", false, false),
|
||||
|
||||
QR_CODE_CREATE("QR_CODE:CREATE", "二维码创建"),
|
||||
EVENT_DELETE("EVENT:DELETE", "登记事件删除", false, false),
|
||||
|
||||
USER_CREATE("USER:CREATE", "用户创建", true),
|
||||
EVENT_RECORD_CREATE("EVENT_RECORD:CREATE", "登记事件记录创建", false, false),
|
||||
|
||||
USER_READ("USER:READ", "用户读取", true),
|
||||
EVENT_RECORD_READ("EVENT_RECORD:READ", "登记事件记录读取", false, false),
|
||||
|
||||
USER_UPDATE("USER:UPDATE", "用户修改", true),
|
||||
EVENT_RECORD_EXPORT("EVENT_RECORD:EXPORT", "登记事件记录导出", true, false),
|
||||
|
||||
USER_DELETE("USER:DELETE", "用户删除", true);
|
||||
EVENT_RECORD_UPDATE("EVENT_RECORD:UPDATE", "登记事件记录修改", false, false),
|
||||
|
||||
EVENT_RECORD_DELETE("EVENT_RECORD:DELETE", "登记事件记录删除", false, false),
|
||||
|
||||
POINT_ACCOUNT_READ("POINT_ACCOUNT:READ", "客户积分账户读取", true, true),
|
||||
|
||||
POINT_LEDGER_READ("POINT_LEDGER:READ", "客户积分流水读取", true, true),
|
||||
|
||||
POINT_RULE_CREATE("POINT_RULE:CREATE", "客户积分规则创建", true, true),
|
||||
|
||||
POINT_RULE_READ("POINT_RULE:READ", "客户积分规则读取", true, true),
|
||||
|
||||
POINT_RULE_UPDATE("POINT_RULE:UPDATE", "客户积分规则修改", true, true),
|
||||
|
||||
POINT_RULE_DELETE("POINT_RULE:DELETE", "客户积分规则删除", true, true),
|
||||
|
||||
POINT_ADJUST("POINT:ADJUST", "客户积分人工调整", true, true),
|
||||
|
||||
POINT_SOURCE_VALUE("POINT:SOURCE_VALUE", "登记提交自定义积分值", true, true),
|
||||
|
||||
STAT_READ("STAT:READ", "统计读取", false, false),
|
||||
|
||||
QR_CODE_CREATE("QR_CODE:CREATE", "二维码创建", false, false),
|
||||
|
||||
USER_CREATE("USER:CREATE", "用户创建", true, false),
|
||||
|
||||
USER_READ("USER:READ", "用户读取", true, false),
|
||||
|
||||
USER_UPDATE("USER:UPDATE", "用户修改", true, false),
|
||||
|
||||
USER_DELETE("USER:DELETE", "用户删除", true, false);
|
||||
|
||||
final String value;
|
||||
final String defaultName;
|
||||
|
||||
/// `true` 为初始化时授权给店长角色
|
||||
@Getter
|
||||
final boolean grantToStoreManager;
|
||||
|
||||
GaoPermissionCode(String value, String defaultName) {
|
||||
this(value, defaultName, false);
|
||||
}
|
||||
/// `true` 为初始化时授权给门店管理角色
|
||||
@Getter
|
||||
final boolean grantToGlobalManager;
|
||||
|
||||
GaoPermissionCode(String value, String defaultName, boolean grantToStoreManager) {
|
||||
GaoPermissionCode(String value, String defaultName, boolean grantToStoreManager, boolean grantToGlobalManager) {
|
||||
this.value = value;
|
||||
this.defaultName = defaultName;
|
||||
this.grantToStoreManager = grantToStoreManager;
|
||||
this.grantToGlobalManager = grantToGlobalManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,11 +119,4 @@ public enum GaoPermissionCode implements BuiltinPermissionCode {
|
||||
public boolean isGrantToAdmin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// true 为初始化时授权给店长角色
|
||||
///
|
||||
/// @return 是否授权给店长角色
|
||||
public boolean isGrantToStoreManager() {
|
||||
return grantToStoreManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,14 @@ import lombok.AllArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public enum GaoRoleCode implements BuiltinRoleCode {
|
||||
|
||||
/// 店长
|
||||
STORE_MANAGER("店长"),
|
||||
/// 门店管理
|
||||
GLOBAL_MANAGER("门店管理", null),
|
||||
|
||||
EMPLOYEE("员工");
|
||||
/// 店长
|
||||
STORE_MANAGER("店长", GLOBAL_MANAGER.name());
|
||||
|
||||
final String defaultName;
|
||||
final String parentCode;
|
||||
|
||||
@Override
|
||||
public ModuleCode getModuleCode() {
|
||||
@@ -36,6 +38,7 @@ public enum GaoRoleCode implements BuiltinRoleCode {
|
||||
|
||||
@Override
|
||||
public String getParentCode() {
|
||||
return null;
|
||||
return parentCode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.imyeyu.api.modules.gao.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/// GAO 用户邀请缓存
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-13
|
||||
@Data
|
||||
public class GaoUserInviteCache {
|
||||
|
||||
/// 发起邀请的用户 ID
|
||||
private String inviterUserId;
|
||||
|
||||
/// 门店 ID,GLOBAL_MANAGER 可为空
|
||||
private String storeId;
|
||||
|
||||
/// 角色 ID
|
||||
private String roleId;
|
||||
|
||||
/// 邀请来源或场景
|
||||
private String scene;
|
||||
|
||||
/// 邀请创建时间,毫秒时间戳
|
||||
private Long createdAt;
|
||||
|
||||
/// 邀请过期时间,毫秒时间戳
|
||||
private Long expireAt;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.service.GaoCustomerChartService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerChartReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 客户报表接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-11
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/customer/chart")
|
||||
public class GaoCustomerChartController {
|
||||
|
||||
private final GaoCustomerChartService service;
|
||||
|
||||
/// 查询客户登记每日统计,可同时支撑登记趋势和登记事件结构图表
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/event/record/daily")
|
||||
public List<GaoEventRecordDailyStatView> eventRecordDaily(@RequestBody GaoCustomerChartReq req) {
|
||||
return service.eventRecordDailyStat(req);
|
||||
}
|
||||
|
||||
/// 查询客户登记日历记录
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/event/record/calendar")
|
||||
public List<GaoEventRecordCalendarView> eventRecordCalendar(@RequestBody GaoCustomerChartReq req) {
|
||||
return service.eventRecordCalendar(req);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,33 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.bean.RoleMatchMode;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoRole;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoRegistrationEvent;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoRegistrationEventRecord;
|
||||
import com.imyeyu.api.modules.gao.service.GaoRegistrationEventService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoRegistrationEventRecordService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerInviteUpdateReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerSearchReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStatReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoQuickRegistrationEventRecordReq;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerPage;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStateReq;
|
||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.api.modules.user.service.UserService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.network.Network;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.util.ResponseView;
|
||||
import com.imyeyu.utils.Time;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -30,113 +37,71 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
///
|
||||
/// GAO 客户接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-27
|
||||
/// @author 夜雨
|
||||
/// @since 2026-07-27 14:12
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/customer")
|
||||
@RequireGaoRole(value = {GaoRoleCode.STORE_MANAGER, GaoRoleCode.EMPLOYEE}, mode = RoleMatchMode.ANY)
|
||||
public class GaoCustomerController {
|
||||
|
||||
private static final String SIGN_IN_REGISTRATION_EVENT_NAME = "签到";
|
||||
|
||||
private final UserService userService;
|
||||
private final RoleChecker roleChecker;
|
||||
private final AttachmentService attachmentService;
|
||||
private final GaoCustomerService service;
|
||||
private final GaoRegistrationEventRecordService registrationEventRecordService;
|
||||
private final GaoRegistrationEventService registrationEventService;
|
||||
private final GaoStoreService gaoStoreService;
|
||||
private final UserLoginService userLoginService;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/list")
|
||||
public PageResult<GaoCustomer> list(@RequestBody Page<GaoCustomer> page) {
|
||||
PageResult<GaoCustomer> result = service.page(page);
|
||||
fillLastSignInAt(result.getList());
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public PageResult<GaoCustomer> list(@RequestBody GaoCustomerPage page) {
|
||||
PageResult<GaoCustomer> result = service.pageByQuery(page);
|
||||
|
||||
List<String> idList = result.getList().stream().map(GaoCustomer::getId).distinct().toList();
|
||||
Map<String, List<Attachment>> attachmentMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, idList);
|
||||
for (GaoCustomer customer : result.getList()) {
|
||||
customer.setAttachmentList(attachmentMap.get(customer.getId()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/search")
|
||||
public List<GaoCustomer> search(@RequestBody GaoCustomerSearchReq req) {
|
||||
return service.search(req);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/search/page")
|
||||
public PageResult<GaoCustomer> searchPage(@RequestBody Page<GaoCustomerSearchReq> page) {
|
||||
return service.searchPage(page);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@IgnoreGlobalReturn
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/export")
|
||||
public void export(@RequestBody GaoCustomerSearchReq req, HttpServletResponse resp) throws IOException {
|
||||
String fileName = URLEncoder.encode("客户列表.xlsx", "UTF-8").replace("+", "%20");
|
||||
resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
resp.setHeader("Content-Disposition", "attachment; filename=\"gao-customer.xlsx\"; filename*=UTF-8''" + fileName);
|
||||
resp.getOutputStream().write(service.exportSearchExcel(req));
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/detail")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public GaoCustomer detail(@RequestParam String id) {
|
||||
return service.get(id);
|
||||
GaoCustomer customer = service.get(id);
|
||||
if (TimiJava.isNotEmpty(customer.getIntroducerCustomerId())) {
|
||||
GaoCustomer introducerCustomer = service.get(customer.getIntroducerCustomerId());
|
||||
introducerCustomer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, introducerCustomer.getId()));
|
||||
customer.setIntroducerCustomer(introducerCustomer);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/detail/code")
|
||||
public GaoCustomer detailByCode(@RequestParam String code) {
|
||||
return service.getByCode(code);
|
||||
if (TimiJava.isNotEmpty(customer.getCreatorUserId())) {
|
||||
customer.setCreatorUser(userService.get(customer.getCreatorUserId()));
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/detail/code/nullable")
|
||||
public GaoCustomer nullableDetailByCode(@RequestParam String code) {
|
||||
return service.getNullableByCode(code);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/invited/list")
|
||||
public List<GaoCustomer> invitedList(@RequestParam String introducerCustomerId) {
|
||||
return service.listInvited(introducerCustomerId);
|
||||
customer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, customer.getId()));
|
||||
return customer;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_CREATE)
|
||||
@PostMapping("/create")
|
||||
public GaoCustomer create(@RequestBody GaoCustomer customer) {
|
||||
service.create(customer);
|
||||
return customer;
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public String create(@RequestBody GaoCustomer customer) {
|
||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
customer.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@PostMapping("/quick/register")
|
||||
public GaoRegistrationEventRecord quickRegister(@RequestBody GaoQuickRegistrationEventRecordReq req) {
|
||||
return registrationEventRecordService.quickRegister(req);
|
||||
service.create(customer);
|
||||
return customer.getId();
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@@ -144,7 +109,10 @@ public class GaoCustomerController {
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE)
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody GaoCustomer customer) {
|
||||
service.update(customer);
|
||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
customer.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
||||
}
|
||||
service.updateWithAttachment(customer);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@@ -157,26 +125,78 @@ public class GaoCustomerController {
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE)
|
||||
@PostMapping("/invite/create")
|
||||
public void createInvite(@RequestBody GaoCustomerInviteUpdateReq req) {
|
||||
service.saveInviteRelation(req);
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/find/id")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public GaoCustomer findById(@RequestParam String id) {
|
||||
GaoCustomer customer = service.get(id);
|
||||
TimiException.required(customer, "not found customer");
|
||||
customer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, customer.getId()));
|
||||
return customer;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/invite/detail")
|
||||
public GaoCustomer inviteDetail(@RequestParam String customerId) {
|
||||
return service.get(customerId);
|
||||
@PostMapping("/find/code")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public GaoCustomer findByCode(@RequestParam String storeId, @RequestParam String code) {
|
||||
GaoCustomer customer = service.getByCode(storeId, code);
|
||||
if (customer == null) {
|
||||
return null;
|
||||
}
|
||||
customer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, customer.getId()));
|
||||
return customer;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/find/name")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public GaoCustomer findByName(@RequestParam String storeId, @RequestParam String name) {
|
||||
GaoCustomer customer = service.getByName(storeId, name);
|
||||
if (customer == null) {
|
||||
return null;
|
||||
}
|
||||
customer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, customer.getId()));
|
||||
return customer;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@IgnoreGlobalReturn
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(@RequestBody Page<GaoCustomer> page) throws IOException {
|
||||
HttpServletResponse resp = TimiSpring.getResponse();
|
||||
String contentDisposition = Network.getFileDownloadHeader("客户列表-%s.xlsx".formatted(Time.serialize.format(Time.now())));
|
||||
resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
resp.setHeader("Content-Disposition", contentDisposition);
|
||||
resp.getOutputStream().write(service.export(page));
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/invited/list")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public List<GaoCustomer> listInvited(@RequestParam String introducerCustomerId) {
|
||||
List<GaoCustomer> result = service.listInvited(introducerCustomerId);
|
||||
List<String> idList = result.stream().map(GaoCustomer::getId).distinct().toList();
|
||||
Map<String, List<Attachment>> attachMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, idList);
|
||||
for (GaoCustomer customer : result) {
|
||||
customer.setAttachmentList(attachMap.get(customer.getId()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE)
|
||||
@PostMapping("/invite/update")
|
||||
public void updateInvite(@RequestBody GaoCustomerInviteUpdateReq req) {
|
||||
service.saveInviteRelation(req);
|
||||
@PostMapping("/invite/save")
|
||||
public void saveInvite(@RequestParam String introducerCustomerId, @RequestParam String customerId) {
|
||||
service.saveInviteRelation(introducerCustomerId, customerId);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@@ -187,37 +207,21 @@ public class GaoCustomerController {
|
||||
service.deleteInviteRelation(customerId);
|
||||
}
|
||||
|
||||
/// 按天统计客户新增数和累计总数
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/stat/daily")
|
||||
/// 按天统计客户新增数和累计总数
|
||||
public List<GaoCustomerDailyStatView> dailyStat(@RequestBody GaoCustomerTrendStatReq req) {
|
||||
return service.statDailyTrend(req);
|
||||
@PostMapping("/state/daily")
|
||||
public List<GaoCustomerDailyStateView> dailyStat(@RequestBody GaoCustomerTrendStateReq req) {
|
||||
return service.stateDailyTrend(req);
|
||||
}
|
||||
|
||||
private void fillLastSignInAt(List<GaoCustomer> customerList) {
|
||||
if (customerList == null || customerList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String signInRegistrationEventId = null;
|
||||
for (GaoRegistrationEvent registrationEvent : registrationEventService.listEnabled()) {
|
||||
if (SIGN_IN_REGISTRATION_EVENT_NAME.equals(registrationEvent.getName())) {
|
||||
signInRegistrationEventId = registrationEvent.getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (signInRegistrationEventId == null) {
|
||||
return;
|
||||
}
|
||||
List<String> customerIdList = customerList.stream().map(GaoCustomer::getId).toList();
|
||||
Map<String, GaoRegistrationEventRecord> recordMap = registrationEventRecordService.listLatestByCustomerIdListAndRegistrationEventId(customerIdList, signInRegistrationEventId).stream()
|
||||
.collect(Collectors.toMap(GaoRegistrationEventRecord::getCustomerId, Function.identity(), (left, right) -> left));
|
||||
for (GaoCustomer customer : customerList) {
|
||||
GaoRegistrationEventRecord record = recordMap.get(customer.getId());
|
||||
if (record != null) {
|
||||
customer.setLastSignInAt(record.getRegisteredAt());
|
||||
}
|
||||
}
|
||||
/// 统计客户性别分布
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/state/gender")
|
||||
public List<GaoCustomerGenderStatView> genderStat(@RequestParam String storeId) {
|
||||
return service.stateGender(storeId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoEvent;
|
||||
import com.imyeyu.api.modules.gao.service.GaoEventService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/// GAO 登记事件接口
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-07-27 14:13
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/event")
|
||||
public class GaoEventController {
|
||||
|
||||
private final GaoEventService service;
|
||||
private final RoleChecker roleChecker;
|
||||
private final GaoStoreService gaoStoreService;
|
||||
private final UserLoginService userLoginService;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_READ)
|
||||
@PostMapping("/list")
|
||||
public PageResult<GaoEvent> list(@RequestBody Page<GaoEvent> page) {
|
||||
PageResult<GaoEvent> result = service.page(page);
|
||||
Map<String, List<String>> roleMap = service.mapRoleCodeListByEventIdList(result.getList().stream().map(GaoEvent::getId).toList());
|
||||
for (GaoEvent event : result.getList()) {
|
||||
event.setRoleCodeList(roleMap.get(event.getId()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@PostMapping("/list/valid")
|
||||
public List<GaoEvent> listValid(@RequestParam String storeId) {
|
||||
return service.listValid(storeId);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_READ)
|
||||
@PostMapping("/detail")
|
||||
public GaoEvent detail(@RequestParam String id) {
|
||||
GaoEvent event = service.get(id);
|
||||
event.setRoleCodeList(service.listRoleCode(event.getId()));
|
||||
return event;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_CREATE)
|
||||
@PostMapping("/create")
|
||||
public void create(@RequestBody GaoEvent event) {
|
||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
event.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
||||
}
|
||||
service.create(event);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_UPDATE)
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody GaoEvent event) {
|
||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
event.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
||||
}
|
||||
service.update(event);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_UPDATE)
|
||||
@PostMapping("/sort")
|
||||
public void sort(@RequestBody List<String> idList) {
|
||||
service.sort(idList);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_DELETE)
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoEvent;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
|
||||
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoEventRecordService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoEventService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordPage;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordPageResult;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordRankPage;
|
||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.api.modules.user.service.UserService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.network.Network;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.util.ResponseView;
|
||||
import com.imyeyu.utils.Time;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/// GAO 登记事件记录接口
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-07-27 14:11
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/event/record")
|
||||
public class GaoEventRecordController {
|
||||
|
||||
private final UserService userService;
|
||||
private final RoleChecker roleChecker;
|
||||
private final GaoEventService eventService;
|
||||
private final AttachmentService attachmentService;
|
||||
private final GaoCustomerService customerService;
|
||||
private final GaoStoreService gaoStoreService;
|
||||
private final GaoEventRecordService service;
|
||||
private final UserLoginService userLoginService;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_READ)
|
||||
@PostMapping("/list")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public GaoEventRecordPageResult list(@RequestBody GaoEventRecordPage page) {
|
||||
PageResult<GaoEventRecord> pageResult = service.pageByRange(page);
|
||||
GaoEventRecordPageResult result = new GaoEventRecordPageResult();
|
||||
result.setTotal(pageResult.getTotal());
|
||||
result.setList(pageResult.getList());
|
||||
result.setNumberValueTotal(resolveNumberValueTotal(page));
|
||||
{
|
||||
List<String> customerIdList = result.getList().stream().map(GaoEventRecord::getCustomerId).toList();
|
||||
Map<String, GaoEvent> eventMap = eventService.mapByIdList(result.getList().stream().map(GaoEventRecord::getEventId).toList());
|
||||
Map<String, GaoCustomer> customerMap = customerService.mapByIdList(customerIdList);
|
||||
Map<String, List<Attachment>> attachMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, customerIdList);
|
||||
for (GaoEventRecord record : result.getList()) {
|
||||
record.setEvent(eventMap.get(record.getEventId()));
|
||||
record.setCustomer(customerMap.get(record.getCustomerId()));
|
||||
record.getCustomer().setAttachmentList(attachMap.get(record.getCustomerId()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// 根据列表筛选条件返回单个 NUMBER 事件的数值合计
|
||||
///
|
||||
/// @param page 登记记录范围查询请求
|
||||
/// @return 数值合计,不满足单个 NUMBER 事件条件时为空
|
||||
private Long resolveNumberValueTotal(GaoEventRecordPage page) {
|
||||
List<String> eventIdList = page.getEventIdList();
|
||||
if (eventIdList == null || eventIdList.size() != 1) {
|
||||
return null;
|
||||
}
|
||||
GaoEvent event = eventService.mapByIdList(eventIdList).get(eventIdList.get(0));
|
||||
if (event == null || event.getValueType() != GaoEvent.ValueType.NUMBER) {
|
||||
return null;
|
||||
}
|
||||
return service.sumNumberValueByRange(page);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_READ)
|
||||
@PostMapping("/detail")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public GaoEventRecord detail(@RequestParam String id) {
|
||||
GaoEventRecord record = service.get(id);
|
||||
record.setCustomer(customerService.get(record.getCustomerId()));
|
||||
record.getCustomer().setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, record.getCustomerId()));
|
||||
record.setEvent(eventService.get(record.getEventId()));
|
||||
record.setOperator(userService.get(record.getOperatorUserId()));
|
||||
record.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_EVENT_RECORD, record.getId()));
|
||||
return record;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_CREATE)
|
||||
@PostMapping("/create")
|
||||
public void create(@RequestBody GaoEventRecord record) {
|
||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
record.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
||||
}
|
||||
service.create(record);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_CREATE)
|
||||
@PostMapping("/create/batch")
|
||||
public void createBatch(@RequestBody List<GaoEventRecord> recordList) {
|
||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
String storeId = gaoStoreService.getBelongIdByRequiredLoginUserId();
|
||||
for (GaoEventRecord record : recordList) {
|
||||
record.setStoreId(storeId);
|
||||
}
|
||||
}
|
||||
service.createBatch(recordList);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_CREATE)
|
||||
@PostMapping("/create/customer")
|
||||
public void createWithCustomer(@RequestBody GaoCustomer customer) {
|
||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
String storeId = gaoStoreService.getBelongIdByRequiredLoginUserId();
|
||||
for (GaoEventRecord record : TimiJava.safeIterable(customer.getEventRecordList())) {
|
||||
record.setStoreId(storeId);
|
||||
}
|
||||
}
|
||||
service.createWithCustomer(customer);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_UPDATE)
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody GaoEventRecord record) {
|
||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
record.setStoreId(gaoStoreService.getBelongIdByRequiredLoginUserId());
|
||||
}
|
||||
service.update(record);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_DELETE)
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@IgnoreGlobalReturn
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(@RequestBody GaoEventRecordPage page) throws IOException {
|
||||
HttpServletResponse resp = TimiSpring.getResponse();
|
||||
String contentDisposition = Network.getFileDownloadHeader("登记事件记录-%s.xlsx".formatted(Time.serialize.format(Time.now())));
|
||||
resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
resp.setHeader("Content-Disposition", contentDisposition);
|
||||
resp.getOutputStream().write(service.export(page));
|
||||
}
|
||||
|
||||
/// 按时间范围查询客户登记排行榜
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/rank")
|
||||
public PageResult<GaoCustomerEventRankView> eventRank(@RequestBody GaoEventRecordRankPage page) {
|
||||
PageResult<GaoCustomerEventRankView> result = service.pageRankByRange(page);
|
||||
List<String> customerIdList = result.getList().stream().map(GaoCustomerEventRankView::getCustomerId).distinct().toList();
|
||||
if (customerIdList.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
Map<String, GaoCustomer> customerMap = customerService.mapByIdList(customerIdList);
|
||||
Map<String, List<Attachment>> attachmentMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, customerIdList);
|
||||
for (GaoCustomerEventRankView view : result.getList()) {
|
||||
GaoCustomer customer = customerMap.get(view.getCustomerId());
|
||||
if (customer != null) {
|
||||
customer.setAttachmentList(attachmentMap.get(view.getCustomerId()));
|
||||
}
|
||||
view.setCustomer(customer);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoPointAccount;
|
||||
import com.imyeyu.api.modules.gao.service.GaoPointAccountService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
|
||||
/// GAO 客户积分账户接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-11
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/customer/point")
|
||||
public class GaoPointAccountController {
|
||||
|
||||
private final RoleChecker roleChecker;
|
||||
private final GaoStoreService storeService;
|
||||
private final GaoPointAccountService accountService;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_ACCOUNT_READ)
|
||||
@PostMapping("/account/detail")
|
||||
public GaoPointAccount detail(@RequestParam String customerId, @RequestParam(required = false) String storeId) {
|
||||
storeId = resolveStoreId(storeId);
|
||||
return accountService.getByCustomerId(storeId, customerId);
|
||||
}
|
||||
|
||||
private String resolveStoreId(String requestedStoreId) {
|
||||
if (roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
return requestedStoreId;
|
||||
}
|
||||
return storeService.getBelongIdByRequiredLoginUserId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoPointLedger;
|
||||
import com.imyeyu.api.modules.gao.service.GaoPointLedgerService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoPointTriggerService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoPointAdjustRequest;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoPointLedgerPage;
|
||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/// GAO 客户积分流水接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-11
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/customer/point")
|
||||
public class GaoPointLedgerController {
|
||||
|
||||
private final RoleChecker roleChecker;
|
||||
private final GaoStoreService storeService;
|
||||
private final GaoPointLedgerService ledgerService;
|
||||
private final GaoPointTriggerService triggerService;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_LEDGER_READ)
|
||||
@PostMapping("/ledger/list")
|
||||
public PageResult<GaoPointLedger> list(@RequestBody GaoPointLedgerPage page) {
|
||||
TimiException.required(page, "not found page");
|
||||
page.setStoreId(resolveStoreId(page.getStoreId()));
|
||||
return ledgerService.pageByQuery(page);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_ADJUST)
|
||||
@PostMapping("/adjust")
|
||||
public void adjust(@RequestBody GaoPointAdjustRequest request) {
|
||||
request.setStoreId(resolveStoreId(request.getStoreId()));
|
||||
triggerService.adjust(request);
|
||||
}
|
||||
|
||||
private String resolveStoreId(String requestedStoreId) {
|
||||
if (roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
return requestedStoreId;
|
||||
}
|
||||
return storeService.getBelongIdByRequiredLoginUserId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoPointRule;
|
||||
import com.imyeyu.api.modules.gao.service.GaoPointRuleService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 客户积分规则接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-11
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/customer/point")
|
||||
public class GaoPointRuleController {
|
||||
|
||||
private final RoleChecker roleChecker;
|
||||
private final GaoStoreService storeService;
|
||||
private final GaoPointRuleService ruleService;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_READ)
|
||||
@PostMapping("/rule/list")
|
||||
public PageResult<GaoPointRule> list(@RequestBody Page<GaoPointRule> page) {
|
||||
TimiException.required(page, "not found page");
|
||||
if (!isGlobalManager()) {
|
||||
GaoPointRule example = TimiJava.defaultIfNull(page.getEqualsExample(), new GaoPointRule());
|
||||
example.setStoreId(resolveStoreId(null));
|
||||
page.setEqualsExample(example);
|
||||
}
|
||||
return ruleService.page(page);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_READ)
|
||||
@PostMapping("/rule/detail")
|
||||
public GaoPointRule detail(@RequestParam String id) {
|
||||
GaoPointRule rule = ruleService.get(id);
|
||||
TimiException.required(rule, "not found point rule");
|
||||
checkStore(rule.getStoreId());
|
||||
return rule;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_CREATE)
|
||||
@PostMapping("/rule/create")
|
||||
public String create(@RequestBody GaoPointRule rule) {
|
||||
rule.setStoreId(resolveStoreId(rule.getStoreId()));
|
||||
ruleService.create(rule);
|
||||
return rule.getId();
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_UPDATE)
|
||||
@PostMapping("/rule/update")
|
||||
public void update(@RequestBody GaoPointRule rule) {
|
||||
rule.setStoreId(resolveStoreId(rule.getStoreId()));
|
||||
ruleService.update(rule);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_UPDATE)
|
||||
@PostMapping("/rule/sort")
|
||||
public void sort(@RequestBody List<String> idList) {
|
||||
if (idList != null) {
|
||||
for (GaoPointRule rule : ruleService.listByIdList(idList)) {
|
||||
checkStore(rule.getStoreId());
|
||||
}
|
||||
}
|
||||
ruleService.sort(idList);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_DELETE)
|
||||
@PostMapping("/rule/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
GaoPointRule rule = ruleService.get(id);
|
||||
TimiException.required(rule, "not found point rule");
|
||||
checkStore(rule.getStoreId());
|
||||
ruleService.delete(id);
|
||||
}
|
||||
|
||||
private String resolveStoreId(String requestedStoreId) {
|
||||
if (isGlobalManager()) {
|
||||
return requestedStoreId;
|
||||
}
|
||||
return storeService.getBelongIdByRequiredLoginUserId();
|
||||
}
|
||||
|
||||
private void checkStore(String storeId) {
|
||||
if (!isGlobalManager()) {
|
||||
TimiException.requiredTrue(resolveStoreId(null).equals(storeId), "无权操作其他门店数据");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isGlobalManager() {
|
||||
return roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name());
|
||||
}
|
||||
}
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoRole;
|
||||
import com.imyeyu.api.bean.RoleMatchMode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoRegistrationEvent;
|
||||
import com.imyeyu.api.modules.gao.service.GaoRegistrationEventService;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
///
|
||||
/// GAO 登记事件接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-27
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/registration-event")
|
||||
@RequireGaoRole(value = {GaoRoleCode.STORE_MANAGER, GaoRoleCode.EMPLOYEE}, mode = RoleMatchMode.ANY)
|
||||
public class GaoRegistrationEventController {
|
||||
|
||||
private final GaoRegistrationEventService service;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_READ)
|
||||
@PostMapping("/list")
|
||||
public PageResult<GaoRegistrationEvent> list(@RequestBody Page<GaoRegistrationEvent> page) {
|
||||
return service.pageWithRegistrationEventLimit(page);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@PostMapping("/enabled/list")
|
||||
public List<GaoRegistrationEvent> enabledList() {
|
||||
return service.listEnabled();
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_READ)
|
||||
@PostMapping("/detail")
|
||||
public GaoRegistrationEvent detail(@RequestParam String id) {
|
||||
return service.get(id);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_CREATE)
|
||||
@PostMapping("/create")
|
||||
public void create(@RequestBody GaoRegistrationEvent registrationEvent) {
|
||||
service.create(registrationEvent);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_UPDATE)
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody GaoRegistrationEvent registrationEvent) {
|
||||
service.update(registrationEvent);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_DELETE)
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
}
|
||||
-174
@@ -1,174 +0,0 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.bean.RoleMatchMode;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoRole;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoRegistrationEventRecord;
|
||||
import com.imyeyu.api.modules.gao.service.GaoRegistrationEventRecordService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoRegistrationEventPeriodStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerRegisterStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoRegistrationEventRecordCreateReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoRegistrationEventRecordDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoRegistrationEventRecordPeriodReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoRegistrationEventRecordRangeReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoRegistrationEventRecordStatReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoRegistrationEventRecordTrendStatReq;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
///
|
||||
/// GAO 登记事件记录接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-27
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/registration-event-record")
|
||||
@RequireGaoRole(value = {GaoRoleCode.STORE_MANAGER, GaoRoleCode.EMPLOYEE}, mode = RoleMatchMode.ANY)
|
||||
public class GaoRegistrationEventRecordController {
|
||||
|
||||
private final GaoRegistrationEventRecordService service;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_RECORD_READ)
|
||||
@PostMapping("/list")
|
||||
public PageResult<GaoRegistrationEventRecord> list(@RequestBody Page<GaoRegistrationEventRecord> page) {
|
||||
return service.page(page);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_RECORD_READ)
|
||||
@PostMapping("/range/page")
|
||||
public PageResult<GaoRegistrationEventRecord> rangePage(@RequestBody Page<GaoRegistrationEventRecordRangeReq> page) {
|
||||
return service.pageByRange(page);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_RECORD_READ)
|
||||
@PostMapping("/detail")
|
||||
public GaoRegistrationEventRecord detail(@RequestParam String id) {
|
||||
return service.get(id);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@PostMapping("/create")
|
||||
public GaoRegistrationEventRecord create(@RequestBody GaoRegistrationEventRecordCreateReq req) {
|
||||
return service.createRecord(req);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_RECORD_UPDATE)
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody GaoRegistrationEventRecord record) {
|
||||
service.update(record);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_RECORD_DELETE)
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_RECORD_READ)
|
||||
@PostMapping("/period/list")
|
||||
public List<GaoRegistrationEventRecord> periodList(@RequestBody GaoRegistrationEventRecordPeriodReq req) {
|
||||
return service.listByRegistrationEventAndPeriod(req);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_RECORD_READ)
|
||||
@PostMapping("/range/list")
|
||||
public List<GaoRegistrationEventRecord> rangeList(@RequestBody GaoRegistrationEventRecordRangeReq req) {
|
||||
return service.listByRange(req);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@IgnoreGlobalReturn
|
||||
@RequireGaoPermission(GaoPermissionCode.REGISTRATION_EVENT_RECORD_READ)
|
||||
@PostMapping("/range/export")
|
||||
public void rangeExport(@RequestBody GaoRegistrationEventRecordRangeReq req, HttpServletResponse resp) throws IOException {
|
||||
String fileName = URLEncoder.encode("登记事件记录.xlsx", "UTF-8").replace("+", "%20");
|
||||
resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
resp.setHeader("Content-Disposition", "attachment; filename=\"gao-registration-event-record.xlsx\"; filename*=UTF-8''" + fileName);
|
||||
resp.getOutputStream().write(service.exportRangeExcel(req));
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/period/stat")
|
||||
public List<GaoRegistrationEventPeriodStatView> periodStat(@RequestBody GaoRegistrationEventRecordPeriodReq req) {
|
||||
return service.statByRegistrationEventAndPeriodType(req.getRegistrationEventId(), req.getPeriodType());
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/customer/stat")
|
||||
public List<GaoCustomerRegisterStatView> customerStat(@RequestParam String customerId) {
|
||||
return service.statByCustomerId(customerId);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/customer/range/stat")
|
||||
/// 按时间段统计单个客户各登记事件记录数
|
||||
public List<GaoCustomerRegisterStatView> customerRangeStat(@RequestBody GaoRegistrationEventRecordStatReq req) {
|
||||
return service.statByCustomerAndRange(req);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/all-customer/range/stat")
|
||||
/// 按时间段统计全部客户各登记事件记录数
|
||||
public List<GaoCustomerRegisterStatView> allCustomerRangeStat(@RequestBody GaoRegistrationEventRecordStatReq req) {
|
||||
return service.statAllCustomerByRange(req);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/customer/registration-event/daily/stat")
|
||||
/// 按天统计单个客户单个登记事件记录趋势
|
||||
public List<GaoRegistrationEventRecordDailyStatView> customerRegistrationEventDailyStat(@RequestBody GaoRegistrationEventRecordTrendStatReq req) {
|
||||
return service.statDailyByCustomerAndRegistrationEvent(req);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/all-customer/registration-event/daily/stat")
|
||||
/// 按天统计全部客户单个登记事件记录趋势
|
||||
public List<GaoRegistrationEventRecordDailyStatView> allCustomerRegistrationEventDailyStat(@RequestBody GaoRegistrationEventRecordTrendStatReq req) {
|
||||
return service.statDailyByRegistrationEvent(req);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.annotation.RequireCorePermission;
|
||||
import com.imyeyu.api.bean.CorePermissionCode;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoRole;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.modules.user.entity.Role;
|
||||
import com.imyeyu.api.modules.user.service.RoleService;
|
||||
import com.imyeyu.api.modules.user.service.AuthorizationScopeService;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -14,23 +15,23 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
///
|
||||
/// GAO 角色接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-28
|
||||
/// @author 夜雨
|
||||
/// @since 2026-07-28 14:15
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/role")
|
||||
@RequireGaoRole(GaoRoleCode.STORE_MANAGER)
|
||||
public class GaoRoleController {
|
||||
|
||||
private final RoleService roleService;
|
||||
private final UserLoginService userLoginService;
|
||||
private final AuthorizationScopeService authorizationScopeService;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.ROLE_READ)
|
||||
@PostMapping("/available/list")
|
||||
public List<Role> availableList() {
|
||||
return roleService.listByModuleCode(ModuleCode.GAO);
|
||||
return authorizationScopeService.listGrantableRole(userLoginService.getRequireLoginUserId(), ModuleCode.GAO);
|
||||
}
|
||||
}
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoStoreBusinessDay;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreBusinessDayService;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 门店营业日接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-06
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/store/business/day")
|
||||
public class GaoStoreBusinessDayController {
|
||||
|
||||
private final GaoStoreBusinessDayService service;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
||||
@PostMapping("/list")
|
||||
public PageResult<GaoStoreBusinessDay> list(@RequestBody Page<GaoStoreBusinessDay> page) {
|
||||
return service.page(page);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
||||
@PostMapping("/calendar")
|
||||
public List<GaoStoreBusinessDay> calendar(@RequestParam String storeId, @RequestParam Integer beginDateValue, @RequestParam Integer endDateValue) {
|
||||
return service.listByDateRange(storeId, beginDateValue, endDateValue);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
||||
@PostMapping("/detail")
|
||||
public GaoStoreBusinessDay detail(@RequestParam String id) {
|
||||
return service.get(id);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
||||
@PostMapping("/create")
|
||||
public String create(@RequestBody GaoStoreBusinessDay businessDay) {
|
||||
service.create(businessDay);
|
||||
return businessDay.getId();
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody GaoStoreBusinessDay businessDay) {
|
||||
service.update(businessDay);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_DELETE)
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreChartService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 门店报表接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-11
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/store/chart")
|
||||
public class GaoStoreChartController {
|
||||
|
||||
private final GaoStoreChartService service;
|
||||
|
||||
/// 查询客户增长趋势
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/customer/daily")
|
||||
public List<GaoCustomerDailyStateView> customerDaily(@RequestBody GaoStoreChartReq req) {
|
||||
return service.customerDailyTrend(req);
|
||||
}
|
||||
|
||||
/// 查询客户性别统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/customer/gender")
|
||||
public List<GaoCustomerGenderStatView> customerGender(@RequestParam String storeId) {
|
||||
return service.customerGender(storeId);
|
||||
}
|
||||
|
||||
/// 查询登记事件每日统计,可同时支撑登记趋势和事件结构图表
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/event/record/daily")
|
||||
public List<GaoEventRecordDailyStatView> eventRecordDaily(@RequestBody GaoStoreChartReq req) {
|
||||
return service.eventRecordDailyStat(req);
|
||||
}
|
||||
|
||||
/// 查询登记事件每日数值合计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/event/record/number-value/daily")
|
||||
public List<GaoEventRecordNumberValueDailyStatView> eventRecordNumberValueDaily(@RequestBody GaoStoreChartReq req) {
|
||||
return service.eventRecordNumberValueDailyStat(req);
|
||||
}
|
||||
|
||||
/// 查询登记事件日历记录
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/event/record/calendar")
|
||||
public List<GaoEventRecordCalendarView> eventRecordCalendar(@RequestBody GaoStoreChartReq req) {
|
||||
return service.eventRecordCalendar(req);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoStore;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||
import com.imyeyu.api.modules.user.service.PermissionChecker;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.network.Network;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.utils.Time;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 门店接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-06
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/store")
|
||||
public class GaoStoreController {
|
||||
|
||||
private final GaoStoreService service;
|
||||
private final UserLoginService userLoginService;
|
||||
private final PermissionChecker permissionChecker;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
||||
@PostMapping("/list")
|
||||
public PageResult<GaoStore> list(@RequestBody Page<GaoStore> page) {
|
||||
return service.page(page);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
||||
@PostMapping("/detail")
|
||||
public GaoStore detail(@RequestParam String id) {
|
||||
return service.get(id);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_CREATE)
|
||||
@PostMapping("/create")
|
||||
public String create(@RequestBody GaoStore store) {
|
||||
service.create(store);
|
||||
return store.getId();
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody GaoStore store) {
|
||||
if (permissionChecker.hasAny(ModuleCode.GAO, GaoPermissionCode.STORE_CREATE.getValue())) {
|
||||
// 门店管理
|
||||
service.update(store);
|
||||
} else {
|
||||
// 店长
|
||||
GaoStore dbStore = service.get(store.getId());
|
||||
dbStore.setName(store.getName());
|
||||
dbStore.setTelephone(store.getTelephone());
|
||||
dbStore.setAddress(store.getAddress());
|
||||
dbStore.setRemark(store.getRemark());
|
||||
dbStore.setAutoClosedDay(TimiJava.defaultIfNull(store.getAutoClosedDay(), false));
|
||||
service.update(dbStore);
|
||||
}
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_DELETE)
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
||||
@PostMapping("/sort")
|
||||
public void sort(@RequestBody List<String> idList) {
|
||||
service.sort(idList);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@IgnoreGlobalReturn
|
||||
@RequireGaoPermission(GaoPermissionCode.STORE_EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(@RequestBody Page<GaoStore> page) throws IOException {
|
||||
HttpServletResponse resp = TimiSpring.getResponse();
|
||||
String contentDisposition = Network.getFileDownloadHeader("门店列表-%s.xlsx".formatted(Time.serialize.format(Time.now())));
|
||||
resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
resp.setHeader("Content-Disposition", contentDisposition);
|
||||
resp.getOutputStream().write(service.export(page));
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@PostMapping("/user")
|
||||
public GaoStore getLoginStore() {
|
||||
return service.getByUserId(userLoginService.getRequireLoginUserId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.imyeyu.api.annotation.RequireCorePermission;
|
||||
import com.imyeyu.api.bean.CorePermissionCode;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.common.entity.Tag;
|
||||
import com.imyeyu.api.modules.common.entity.TagApply;
|
||||
import com.imyeyu.api.modules.common.service.TagService;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.util.ResponseView;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 标签接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-13
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/tag")
|
||||
public class GaoTagController {
|
||||
|
||||
private final TagService service;
|
||||
private final RoleChecker roleChecker;
|
||||
private final GaoStoreService storeService;
|
||||
|
||||
/// 查询标签列表
|
||||
///
|
||||
/// @param page 分页参数
|
||||
/// @return 标签分页
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.TAG_READ)
|
||||
@PostMapping("/list")
|
||||
public PageResult<Tag> list(@RequestBody Page<Tag> page) {
|
||||
TimiException.required(page, "未找到分页参数");
|
||||
String ownerId = null;
|
||||
page.setEqualsExample(TimiJava.defaultIfNull(page.getEqualsExample(), new Tag()));
|
||||
page.getEqualsExample().setOwnerType(Tag.OwnerType.GAO_STORE);
|
||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
ownerId = storeService.getBelongIdByRequiredLoginUserId();
|
||||
page.getEqualsExample().setOwnerId(ownerId);
|
||||
}
|
||||
String keyword = page.getLikesExample() == null ? null : page.getLikesExample().getName();
|
||||
if (TimiJava.isNotEmpty(keyword)) {
|
||||
return service.pageByOwnerAndKeyword(page, Tag.OwnerType.GAO_STORE, ownerId, keyword.trim());
|
||||
}
|
||||
return service.page(page);
|
||||
}
|
||||
|
||||
/// 查询标签详情
|
||||
///
|
||||
/// @param id 标签 ID
|
||||
/// @return 标签详情
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.TAG_READ)
|
||||
@PostMapping("/detail")
|
||||
public Tag detail(@RequestParam String id) {
|
||||
return service.get(id);
|
||||
}
|
||||
|
||||
/// 创建标签
|
||||
///
|
||||
/// @param tag 标签
|
||||
/// @return 标签
|
||||
@AOPLog
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.TAG_CREATE)
|
||||
@PostMapping("/create")
|
||||
public Tag create(@RequestBody Tag tag) {
|
||||
tag.setOwnerType(Tag.OwnerType.GAO_STORE);
|
||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
tag.setOwnerId(storeService.getBelongIdByRequiredLoginUserId());
|
||||
}
|
||||
service.create(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
/// 更新标签
|
||||
///
|
||||
/// @param tag 标签
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.TAG_UPDATE)
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody Tag tag) {
|
||||
Tag dbTag = service.get(tag.getId());
|
||||
tag.setOwnerType(dbTag.getOwnerType());
|
||||
tag.setOwnerId(dbTag.getOwnerId());
|
||||
service.update(tag);
|
||||
}
|
||||
|
||||
/// 删除标签
|
||||
///
|
||||
/// @param id 标签 ID
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.TAG_DELETE)
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
|
||||
/// 按业务查询标签
|
||||
///
|
||||
/// @param bizType 业务类型
|
||||
/// @param bizId 业务 ID
|
||||
/// @return 标签列表
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.TAG_READ)
|
||||
@GetMapping("/list/biz/id")
|
||||
public List<Tag> listByBizType(@RequestParam TagApply.BizType bizType, @RequestParam String bizId) {
|
||||
return service.listByBizType(bizType, bizId);
|
||||
}
|
||||
|
||||
/// 差分保存业务标签
|
||||
///
|
||||
/// @param apply 标签请求
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.TAG_APPLY)
|
||||
@PostMapping("/apply")
|
||||
public void apply(@RequestBody TagApply apply) {
|
||||
service.apply(apply.getBizType(), apply.getBizId(), apply.getTagIdList());
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,38 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoRole;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoUser;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoUserInviteService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoUserService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoUserInviteCreateRequest;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoUserInviteCreateResponse;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoUserInviteRegisterData;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoUserInviteRegisterRequest;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoUserInviteValidateRequest;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoUserInviteValidateResponse;
|
||||
import com.imyeyu.api.modules.user.entity.Role;
|
||||
import com.imyeyu.api.modules.user.entity.User;
|
||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||
import com.imyeyu.api.modules.user.service.RoleService;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.api.modules.user.service.UserRoleService;
|
||||
import com.imyeyu.api.modules.user.service.UserService;
|
||||
import com.imyeyu.api.modules.user.vo.LoginResponse;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.CaptchaValid;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.util.ResponseView;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -21,50 +41,105 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
///
|
||||
/// GAO 用户接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-30
|
||||
/// @author 夜雨
|
||||
/// @since 2026-07-30 14:15
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/user")
|
||||
@RequireGaoRole(GaoRoleCode.STORE_MANAGER)
|
||||
public class GaoUserController {
|
||||
|
||||
private final GaoUserService service;
|
||||
private final UserService userService;
|
||||
private final RoleService roleService;
|
||||
private final RoleChecker roleChecker;
|
||||
private final GaoUserService service;
|
||||
private final GaoUserInviteService inviteService;
|
||||
private final UserRoleService userRoleService;
|
||||
private final GaoStoreService gaoStoreService;
|
||||
private final UserLoginService userLoginService;
|
||||
private final AttachmentService attachmentService;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.USER_CREATE)
|
||||
@PostMapping("/invite")
|
||||
public GaoUserInviteCreateResponse invite(@RequestBody @Valid GaoUserInviteCreateRequest req) {
|
||||
return inviteService.create(req);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit(20)
|
||||
@PostMapping("/invite/validate")
|
||||
public GaoUserInviteValidateResponse validateInvite(@RequestBody @Valid GaoUserInviteValidateRequest req) {
|
||||
return inviteService.validate(req.getCode());
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@CaptchaValid
|
||||
@RequestRateLimit(value = 5, inSeconds = 60)
|
||||
@PostMapping("/invite/register")
|
||||
public LoginResponse registerByInvite(@RequestBody @Valid GaoUserInviteRegisterRequest req) {
|
||||
GaoUserInviteRegisterData data = req.getData();
|
||||
String userId = inviteService.register(data);
|
||||
return userLoginService.login(UUID.randomUUID().toString(), userId);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.USER_READ)
|
||||
@PostMapping("/list")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public PageResult<GaoUser> list(@RequestBody Page<GaoUser> page) {
|
||||
return service.pageWithUser(page);
|
||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
// 非全局管理只能看所在店用户
|
||||
page.setEqualsExample(TimiJava.defaultIfNull(page.getEqualsExample(), new GaoUser()));
|
||||
page.getEqualsExample().setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
||||
}
|
||||
PageResult<GaoUser> result = service.page(page);
|
||||
{
|
||||
List<String> userIdList = result.getList().stream().map(GaoUser::getUserId).toList();
|
||||
Map<String, User> userMap = userService.mapByIdList(userIdList);
|
||||
Map<String, List<Role>> roleMap = userRoleService.mapRoleListByUserIdList(userIdList);
|
||||
for (GaoUser gaoUser : result.getList()) {
|
||||
gaoUser.setUser(userMap.get(gaoUser.getUserId()));
|
||||
gaoUser.getUser().setRoleEntityList(roleMap.get(gaoUser.getUserId()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.USER_READ)
|
||||
@PostMapping("/detail")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public GaoUser detail(@RequestParam String id) {
|
||||
return service.get(id);
|
||||
GaoUser result = service.get(id);
|
||||
{
|
||||
User user = userService.get(result.getUserId());
|
||||
user.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.USER, user.getId()));
|
||||
user.setRoleList(userRoleService.listAllRoleCodeByUserId(user.getId()));
|
||||
user.setRoleEntityList(userRoleService.listRoleByUserId(user.getId()));
|
||||
user.setPermissionList(userRoleService.listAllPermissionCodeByUserId(user.getId()));
|
||||
result.setUser(user);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.USER_READ)
|
||||
@PostMapping("/detail/user")
|
||||
public GaoUser detailByUserId(@RequestParam String userId) {
|
||||
return service.getByUserId(userId);
|
||||
return result;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.USER_CREATE)
|
||||
@PostMapping("/create")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public GaoUser create(@RequestBody GaoUser gaoUser) {
|
||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||
gaoUser.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
||||
}
|
||||
service.create(gaoUser);
|
||||
return service.get(gaoUser.getId());
|
||||
}
|
||||
@@ -73,11 +148,22 @@ public class GaoUserController {
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.USER_UPDATE)
|
||||
@PostMapping("/update")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public GaoUser update(@RequestBody GaoUser gaoUser) {
|
||||
service.update(gaoUser);
|
||||
return service.get(gaoUser.getId());
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.USER_UPDATE)
|
||||
@PostMapping("/transfer/store")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public GaoUser transferStore(@RequestBody GaoUser gaoUser) {
|
||||
service.transferStore(gaoUser);
|
||||
return service.get(gaoUser.getId());
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.USER_DELETE)
|
||||
@@ -91,6 +177,7 @@ public class GaoUserController {
|
||||
@RequireGaoPermission(GaoPermissionCode.USER_READ)
|
||||
@PostMapping("/role/list")
|
||||
public List<Role> roleList() {
|
||||
// TODO 此接口获取本模块所有角色,需要限制角色
|
||||
return roleService.listByModuleCode(ModuleCode.GAO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
package com.imyeyu.api.modules.gao.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.entity.TagApply;
|
||||
import com.imyeyu.api.modules.user.bean.Gender;
|
||||
import com.imyeyu.api.modules.user.entity.User;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.spring.annotation.table.Column;
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
///
|
||||
@@ -26,20 +33,58 @@ public class GaoCustomer extends UUIDEntity {
|
||||
/// @since 2026-07-27
|
||||
public enum AttachType {
|
||||
|
||||
PHOTO
|
||||
PHOTO,
|
||||
|
||||
POINT_CARD,
|
||||
|
||||
OTHER
|
||||
}
|
||||
|
||||
///
|
||||
/// 出生日期使用的历法
|
||||
///
|
||||
public enum BirthdateCalendar {
|
||||
|
||||
/// 公历
|
||||
SOLAR,
|
||||
|
||||
/// 农历
|
||||
LUNAR
|
||||
}
|
||||
|
||||
/// 客户编码
|
||||
private String code;
|
||||
|
||||
/// 门店 ID
|
||||
private String storeId;
|
||||
|
||||
/// 姓名
|
||||
private String name;
|
||||
|
||||
@Column("zh_cn_pinyin_full")
|
||||
@JsonIgnore
|
||||
private String namePinyinFull;
|
||||
|
||||
@Column("zh_cn_pinyin_initial")
|
||||
@JsonIgnore
|
||||
private String namePinyinInitial;
|
||||
|
||||
@Column("zh_cn_pinyin_mixed")
|
||||
@JsonIgnore
|
||||
private String namePinyinMixed;
|
||||
|
||||
/// 性别
|
||||
private Gender gender;
|
||||
|
||||
/// 年龄
|
||||
private Integer age;
|
||||
private Long age;
|
||||
|
||||
/// 出生日期,数据库只保存公历日期
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate birthdate;
|
||||
|
||||
/// 出生日期录入时使用的历法
|
||||
private BirthdateCalendar birthdateCalendar;
|
||||
|
||||
/// 电话
|
||||
private String telephone;
|
||||
@@ -59,19 +104,30 @@ public class GaoCustomer extends UUIDEntity {
|
||||
/// 介绍人客户 ID
|
||||
private String introducerCustomerId;
|
||||
|
||||
@Transient
|
||||
private Long lastSignInAt;
|
||||
private Long invitedCount;
|
||||
|
||||
/// 录入用户 ID
|
||||
private String creatorUserId;
|
||||
|
||||
@Transient
|
||||
private GaoCustomer introducerCustomer;
|
||||
|
||||
@Transient
|
||||
private Long invitedCount;
|
||||
private User creatorUser;
|
||||
|
||||
@Transient
|
||||
private List<Attachment> attachmentList;
|
||||
|
||||
/// 临时照片附件 ID 列表
|
||||
@Transient
|
||||
private List<String> attachmentIdList;
|
||||
private GaoEventRecord eventRecord;
|
||||
|
||||
@Transient
|
||||
private List<GaoEventRecord> eventRecordList;
|
||||
|
||||
@Transient
|
||||
private TagApply tagApply;
|
||||
|
||||
public boolean hasIntroducer() {
|
||||
return TimiJava.isNotEmpty(introducerCustomerId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.imyeyu.api.modules.gao.entity;
|
||||
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
///
|
||||
/// 登记事件
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-27
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class GaoEvent extends UUIDEntity {
|
||||
|
||||
///
|
||||
/// 登记事件状态
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-01
|
||||
public enum Status {
|
||||
|
||||
/// 草稿,未发布不可登记
|
||||
DRAFT,
|
||||
|
||||
/// 可登记
|
||||
ACTIVE,
|
||||
|
||||
/// 无效,不可登记但保留统计
|
||||
INACTIVE,
|
||||
|
||||
/// 已删除,不可登记但保留统计
|
||||
DELETED
|
||||
}
|
||||
|
||||
/// 事件数值类型
|
||||
public enum ValueType {
|
||||
|
||||
/// 不携带数值
|
||||
NONE,
|
||||
|
||||
/// 携带整数数值
|
||||
NUMBER
|
||||
}
|
||||
|
||||
/// 事件数值单位
|
||||
public enum ValueUnit {
|
||||
|
||||
/// 金额分
|
||||
CENT,
|
||||
|
||||
/// 次数
|
||||
COUNT
|
||||
}
|
||||
|
||||
/// 登记限制类型
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-08-01 14:37
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum LimitType {
|
||||
|
||||
/// 不限制
|
||||
NONE(null),
|
||||
|
||||
/// 每天上午、下午各 N 次
|
||||
DAILY_HALF_DAY(1L),
|
||||
|
||||
/// 每个自然日 N 次
|
||||
NATURAL_DAY(1L),
|
||||
|
||||
/// 每隔 N 小时一次
|
||||
INTERVAL_HOUR(1L),
|
||||
|
||||
/// 每个自然月 N 次
|
||||
NATURAL_MONTH(1L),
|
||||
|
||||
/// 事件总登记次数上限
|
||||
TOTAL_LIMIT(1L),
|
||||
|
||||
/// 单个客户总登记次数上限
|
||||
CUSTOMER_TOTAL_LIMIT(1L);
|
||||
|
||||
final Long min;
|
||||
}
|
||||
|
||||
/// 统计图表颜色
|
||||
private String color;
|
||||
|
||||
/// 登记事件名称
|
||||
private String name;
|
||||
|
||||
/// 门店 ID
|
||||
private String storeId;
|
||||
|
||||
/// 说明
|
||||
private String description;
|
||||
|
||||
/// 数值类型
|
||||
private ValueType valueType;
|
||||
|
||||
/// 数值单位
|
||||
private ValueUnit valueUnit;
|
||||
|
||||
/// true 为登记时必须提交 numberValue
|
||||
private Boolean requireValue;
|
||||
|
||||
/// 状态
|
||||
private Status status;
|
||||
|
||||
/// true 为登记时要求拍照
|
||||
private Boolean requirePhoto;
|
||||
|
||||
/// 登记限制类型
|
||||
private LimitType limitType;
|
||||
|
||||
/// 登记限制数值,按限制类型表示小时数或次数
|
||||
private Integer limitValue;
|
||||
|
||||
/// 可登记起始时间戳,毫秒,空为不限制
|
||||
private Long beginAt;
|
||||
|
||||
/// 可登记终止时间戳,毫秒,空为不限制
|
||||
private Long endAt;
|
||||
|
||||
/// 排序值
|
||||
private Integer sort;
|
||||
|
||||
/// 可登记角色代码列表
|
||||
@Transient
|
||||
private List<String> roleCodeList;
|
||||
}
|
||||
+23
-5
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
/// @since 2026-07-27
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class GaoRegistrationEventRecord extends UUIDEntity {
|
||||
public class GaoEventRecord extends UUIDEntity {
|
||||
|
||||
///
|
||||
/// 登记事件记录附件类型
|
||||
@@ -31,23 +31,41 @@ public class GaoRegistrationEventRecord extends UUIDEntity {
|
||||
/// 客户 ID
|
||||
private String customerId;
|
||||
|
||||
/// 门店 ID
|
||||
private String storeId;
|
||||
|
||||
/// 登记登记事件 ID
|
||||
private String registrationEventId;
|
||||
private String eventId;
|
||||
|
||||
/// 操作管理员用户 ID
|
||||
private String operatorUserId;
|
||||
|
||||
/// 本次登记提交的积分值
|
||||
private Long pointValue;
|
||||
|
||||
/// 本次登记通过积分规则获得的积分总和
|
||||
private Long earnedPointValue;
|
||||
|
||||
/// 本次登记提交的整数业务数值
|
||||
private Long numberValue;
|
||||
|
||||
/// 备注
|
||||
private String remark;
|
||||
|
||||
/// 登记时间
|
||||
private Long registeredAt;
|
||||
|
||||
/// 登记日期值,格式为 yyyyMMdd
|
||||
private Integer registeredDateValue;
|
||||
|
||||
/// 营业日递增序号
|
||||
private Long businessDayNo;
|
||||
|
||||
@Transient
|
||||
private GaoCustomer customer;
|
||||
|
||||
@Transient
|
||||
private GaoRegistrationEvent registrationEvent;
|
||||
private GaoEvent event;
|
||||
|
||||
@Transient
|
||||
private User operator;
|
||||
@@ -55,7 +73,7 @@ public class GaoRegistrationEventRecord extends UUIDEntity {
|
||||
@Transient
|
||||
private List<Attachment> attachmentList;
|
||||
|
||||
/// 临时照片附件 ID 列表
|
||||
/// 客户 ID 列表,批量登记时使用
|
||||
@Transient
|
||||
private List<String> attachmentIdList;
|
||||
private List<String> customerIdList;
|
||||
}
|
||||
+2
-2
@@ -11,10 +11,10 @@ import lombok.EqualsAndHashCode;
|
||||
/// @since 2026-07-28
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class GaoRegistrationEventRoleRelation extends UUIDEntity {
|
||||
public class GaoEventRoleRelation extends UUIDEntity {
|
||||
|
||||
/// 登记事件 ID
|
||||
private String registrationEventId;
|
||||
private String eventId;
|
||||
|
||||
/// 角色代码
|
||||
private String roleCode;
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.imyeyu.api.modules.gao.entity;
|
||||
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/// GAO 客户积分账户
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-11
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class GaoPointAccount extends UUIDEntity {
|
||||
|
||||
/// 门店 ID
|
||||
private String storeId;
|
||||
|
||||
/// 客户 ID
|
||||
private String customerId;
|
||||
|
||||
/// 当前可用积分余额
|
||||
private Long balance;
|
||||
|
||||
/// 累计获得积分
|
||||
private Long totalEarned;
|
||||
|
||||
/// 累计撤销积分
|
||||
private Long totalRevoked;
|
||||
|
||||
/// 累计人工调整积分,可正可负
|
||||
private Long totalAdjusted;
|
||||
|
||||
/// 乐观锁版本
|
||||
private Long version;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.imyeyu.api.modules.gao.entity;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/// GAO 客户积分流水
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-11
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class GaoPointLedger extends UUIDEntity {
|
||||
|
||||
/// 流水变化类型
|
||||
public enum ChangeType {
|
||||
|
||||
/// 登记事件积分变化
|
||||
EARN,
|
||||
|
||||
/// 删除登记记录撤销积分
|
||||
REVOKE,
|
||||
|
||||
/// 人工调整积分
|
||||
ADJUST
|
||||
}
|
||||
|
||||
/// 流水方向
|
||||
public enum Direction {
|
||||
|
||||
/// 增加积分
|
||||
INCREASE,
|
||||
|
||||
/// 减少积分
|
||||
DECREASE
|
||||
}
|
||||
|
||||
/// 客户积分账户 ID
|
||||
private String accountId;
|
||||
|
||||
/// 门店 ID
|
||||
private String storeId;
|
||||
|
||||
/// 客户 ID
|
||||
private String customerId;
|
||||
|
||||
/// 变化类型
|
||||
private ChangeType changeType;
|
||||
|
||||
/// 方向
|
||||
private Direction direction;
|
||||
|
||||
/// 本次变化积分,增加为正,减少为负
|
||||
private Long pointDelta;
|
||||
|
||||
/// 变化前余额
|
||||
private Long balanceBefore;
|
||||
|
||||
/// 变化后余额
|
||||
private Long balanceAfter;
|
||||
|
||||
/// 命中的积分规则 ID
|
||||
private String ruleId;
|
||||
|
||||
/// 登记事件 ID
|
||||
private String eventId;
|
||||
|
||||
/// 登记记录 ID
|
||||
private String eventRecordId;
|
||||
|
||||
/// 来源快照
|
||||
private JsonNode sourcePayload;
|
||||
|
||||
/// 幂等键
|
||||
private String idempotencyKey;
|
||||
|
||||
/// 备注
|
||||
private String remark;
|
||||
|
||||
/// 操作用户 ID
|
||||
private String operatorUserId;
|
||||
|
||||
/// 发生时间
|
||||
private Long occurredAt;
|
||||
|
||||
/// 客户信息
|
||||
@Transient
|
||||
private GaoCustomer customer;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user