Showing
60 changed files
with
1246 additions
and
97 deletions
| ... | @@ -48,6 +48,7 @@ dependencies { | ... | @@ -48,6 +48,7 @@ dependencies { |
| 48 | implementation 'com.aliyun:aliyun-java-sdk-core:4.6.4' //阿里云SDK核心库 | 48 | implementation 'com.aliyun:aliyun-java-sdk-core:4.6.4' //阿里云SDK核心库 |
| 49 | implementation 'com.aliyun:aliyun-java-sdk-dysmsapi:2.2.1'//阿里云短信服务SDK | 49 | implementation 'com.aliyun:aliyun-java-sdk-dysmsapi:2.2.1'//阿里云短信服务SDK |
| 50 | implementation 'com.aliyun:aliyun-java-sdk-dm:3.3.2'//阿里云邮件服务SDK | 50 | implementation 'com.aliyun:aliyun-java-sdk-dm:3.3.2'//阿里云邮件服务SDK |
| 51 | + implementation "com.aliyun.oss:aliyun-sdk-oss:3.11.1"//阿里云OSS服务 | ||
| 51 | 52 | ||
| 52 | implementation "io.zipkin.brave:brave:5.12.5" | 53 | implementation "io.zipkin.brave:brave:5.12.5" |
| 53 | implementation "io.zipkin.brave:brave-context-slf4j:5.12.5" | 54 | implementation "io.zipkin.brave:brave-context-slf4j:5.12.5" |
| ... | @@ -61,8 +62,8 @@ dependencies { | ... | @@ -61,8 +62,8 @@ dependencies { |
| 61 | 62 | ||
| 62 | // compileOnly 'org.projectlombok:lombok' | 63 | // compileOnly 'org.projectlombok:lombok' |
| 63 | // annotationProcessor 'org.projectlombok:lombok' | 64 | // annotationProcessor 'org.projectlombok:lombok' |
| 64 | - compileOnly 'org.projectlombok:lombok:1.18.20' | 65 | + compileOnly 'org.projectlombok:lombok:1.18.24' |
| 65 | - annotationProcessor 'org.projectlombok:lombok:1.18.20' | 66 | + annotationProcessor 'org.projectlombok:lombok:1.18.24' |
| 66 | 67 | ||
| 67 | testImplementation 'org.springframework.boot:spring-boot-starter-test' | 68 | testImplementation 'org.springframework.boot:spring-boot-starter-test' |
| 68 | } | 69 | } |
| ... | @@ -113,5 +114,6 @@ sourceSets { | ... | @@ -113,5 +114,6 @@ sourceSets { |
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | test { | 116 | test { |
| 117 | + enabled = false | ||
| 116 | useJUnitPlatform() | 118 | useJUnitPlatform() |
| 117 | } | 119 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -58,7 +58,6 @@ public class RepeatSubmitAspect { | ... | @@ -58,7 +58,6 @@ public class RepeatSubmitAspect { |
| 58 | * 获取LockKey | 58 | * 获取LockKey |
| 59 | * | 59 | * |
| 60 | * @param joinPoint 切入点 | 60 | * @param joinPoint 切入点 |
| 61 | - * @return | ||
| 62 | */ | 61 | */ |
| 63 | public static String getLockKey(ProceedingJoinPoint joinPoint) { | 62 | public static String getLockKey(ProceedingJoinPoint joinPoint) { |
| 64 | //获取连接点的方法签名对象 | 63 | //获取连接点的方法签名对象 |
| ... | @@ -79,13 +78,13 @@ public class RepeatSubmitAspect { | ... | @@ -79,13 +78,13 @@ public class RepeatSubmitAspect { |
| 79 | continue; | 78 | continue; |
| 80 | } | 79 | } |
| 81 | //如果属性是RequestKeyParam注解,则拼接 连接符 "& + RequestKeyParam" | 80 | //如果属性是RequestKeyParam注解,则拼接 连接符 "& + RequestKeyParam" |
| 82 | - if (sb.length() > 0) { | 81 | + if (!sb.isEmpty()) { |
| 83 | sb.append(requestLock.delimiter()); | 82 | sb.append(requestLock.delimiter()); |
| 84 | } | 83 | } |
| 85 | sb.append(args[i]); | 84 | sb.append(args[i]); |
| 86 | } | 85 | } |
| 87 | //如果方法上没有加RequestKeyParam注解 | 86 | //如果方法上没有加RequestKeyParam注解 |
| 88 | - if (StringUtils.isEmpty(sb.toString())) { | 87 | + if (!StringUtils.hasText((sb.toString()))) { |
| 89 | //获取方法上的多个注解(为什么是两层数组:因为第二层数组是只有一个元素的数组) | 88 | //获取方法上的多个注解(为什么是两层数组:因为第二层数组是只有一个元素的数组) |
| 90 | final var parameterAnnotations = method.getParameterAnnotations(); | 89 | final var parameterAnnotations = method.getParameterAnnotations(); |
| 91 | //循环注解 | 90 | //循环注解 |
| ... | @@ -103,7 +102,7 @@ public class RepeatSubmitAspect { | ... | @@ -103,7 +102,7 @@ public class RepeatSubmitAspect { |
| 103 | //如果有,设置Accessible为true(为true时可以使用反射访问私有变量,否则不能访问私有变量) | 102 | //如果有,设置Accessible为true(为true时可以使用反射访问私有变量,否则不能访问私有变量) |
| 104 | field.setAccessible(true); | 103 | field.setAccessible(true); |
| 105 | //如果属性是RequestKeyParam注解,则拼接 连接符" & + RequestKeyParam" | 104 | //如果属性是RequestKeyParam注解,则拼接 连接符" & + RequestKeyParam" |
| 106 | - if (sb.length() > 0) { | 105 | + if (!sb.isEmpty()) { |
| 107 | sb.append(requestLock.delimiter()); | 106 | sb.append(requestLock.delimiter()); |
| 108 | } | 107 | } |
| 109 | sb.append(ReflectionUtils.getField(field, object)); | 108 | sb.append(ReflectionUtils.getField(field, object)); |
| ... | @@ -112,9 +111,9 @@ public class RepeatSubmitAspect { | ... | @@ -112,9 +111,9 @@ public class RepeatSubmitAspect { |
| 112 | } | 111 | } |
| 113 | if (requestLock.isLockByLoginUser()) { | 112 | if (requestLock.isLockByLoginUser()) { |
| 114 | final var operatorId = LoginContextHolder.hasLogin() ? LoginContextHolder.getId() : null; | 113 | final var operatorId = LoginContextHolder.hasLogin() ? LoginContextHolder.getId() : null; |
| 115 | - return requestLock.prefix() + (operatorId != null ? CommonConstants.COLON + operatorId : "") + (sb.length() > 0 ? CommonConstants.UNDERLINE + sb : ""); | 114 | + return requestLock.prefix() + (operatorId != null ? CommonConstants.COLON + operatorId : "") + (!sb.isEmpty() ? CommonConstants.UNDERLINE + sb : ""); |
| 116 | } else { | 115 | } else { |
| 117 | - return requestLock.prefix() + (sb.length() > 0 ? CommonConstants.UNDERLINE + sb : ""); | 116 | + return requestLock.prefix() + (!sb.isEmpty() ? CommonConstants.UNDERLINE + sb : ""); |
| 118 | } | 117 | } |
| 119 | } | 118 | } |
| 120 | } | 119 | } | ... | ... |
| ... | @@ -3,16 +3,22 @@ package com.infoloop.tianting.config; | ... | @@ -3,16 +3,22 @@ package com.infoloop.tianting.config; |
| 3 | import com.aliyuncs.DefaultAcsClient; | 3 | import com.aliyuncs.DefaultAcsClient; |
| 4 | import com.aliyuncs.profile.DefaultProfile; | 4 | import com.aliyuncs.profile.DefaultProfile; |
| 5 | import com.fasterxml.jackson.dataformat.xml.XmlMapper; | 5 | import com.fasterxml.jackson.dataformat.xml.XmlMapper; |
| 6 | +import com.infoloop.tianting.server.StorageService; | ||
| 7 | +import com.infoloop.tianting.server.StorageServiceFactory; | ||
| 6 | import com.infoloop.tianting.store.LoginCodeStore; | 8 | import com.infoloop.tianting.store.LoginCodeStore; |
| 9 | +import com.infoloop.tianting.store.WeeklyTaskStore; | ||
| 7 | import com.infoloop.tianting.utils.SmsUtil; | 10 | import com.infoloop.tianting.utils.SmsUtil; |
| 8 | import io.lettuce.core.api.StatefulRedisConnection; | 11 | import io.lettuce.core.api.StatefulRedisConnection; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.beans.factory.annotation.Qualifier; | 13 | import org.springframework.beans.factory.annotation.Qualifier; |
| 14 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
| 11 | import org.springframework.context.annotation.Bean; | 15 | import org.springframework.context.annotation.Bean; |
| 12 | import org.springframework.context.annotation.Configuration; | 16 | import org.springframework.context.annotation.Configuration; |
| 13 | import org.springframework.context.annotation.Import; | 17 | import org.springframework.context.annotation.Import; |
| 14 | import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter; | 18 | import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter; |
| 15 | 19 | ||
| 20 | +import java.time.Duration; | ||
| 21 | + | ||
| 16 | import static com.infoloop.tianting.constant.ConfigConstants.REDIS_CONNECTION; | 22 | import static com.infoloop.tianting.constant.ConfigConstants.REDIS_CONNECTION; |
| 17 | 23 | ||
| 18 | @Configuration | 24 | @Configuration |
| ... | @@ -26,6 +32,13 @@ public class AppConfig { | ... | @@ -26,6 +32,13 @@ public class AppConfig { |
| 26 | return new LoginCodeStore(commands, 300); | 32 | return new LoginCodeStore(commands, 300); |
| 27 | } | 33 | } |
| 28 | 34 | ||
| 35 | + @Bean | ||
| 36 | + public WeeklyTaskStore weeklyTaskStore(@Autowired @Qualifier(REDIS_CONNECTION) final StatefulRedisConnection<String, String> connection) { | ||
| 37 | + final var commands = connection.sync(); | ||
| 38 | + final var expireSeconds = Duration.ofDays(8).getSeconds(); | ||
| 39 | + return new WeeklyTaskStore(commands, expireSeconds); | ||
| 40 | + } | ||
| 41 | + | ||
| 29 | // init bean | 42 | // init bean |
| 30 | @Bean | 43 | @Bean |
| 31 | public SmsUtil smsUtil(@Autowired SmsConfig smsConfig) { | 44 | public SmsUtil smsUtil(@Autowired SmsConfig smsConfig) { |
| ... | @@ -35,6 +48,12 @@ public class AppConfig { | ... | @@ -35,6 +48,12 @@ public class AppConfig { |
| 35 | } | 48 | } |
| 36 | 49 | ||
| 37 | @Bean | 50 | @Bean |
| 51 | + @ConditionalOnProperty(name = "aliyun.oss.endpoint") | ||
| 52 | + public StorageService storageService(@Autowired OssConfig ossConfig) { | ||
| 53 | + return StorageServiceFactory.createStorageService(ossConfig.getEndpoint(), ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret()); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Bean | ||
| 38 | public MappingJackson2XmlHttpMessageConverter mappingJackson2XmlHttpMessageConverter() { | 57 | public MappingJackson2XmlHttpMessageConverter mappingJackson2XmlHttpMessageConverter() { |
| 39 | return new MappingJackson2XmlHttpMessageConverter(new XmlMapper()); | 58 | return new MappingJackson2XmlHttpMessageConverter(new XmlMapper()); |
| 40 | } | 59 | } | ... | ... |
| ... | @@ -11,6 +11,7 @@ import com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServi | ... | @@ -11,6 +11,7 @@ import com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServi |
| 11 | import com.infoloop.tianting.clientresourcetagservice.ClientResourceTagServiceRpcGrpc; | 11 | import com.infoloop.tianting.clientresourcetagservice.ClientResourceTagServiceRpcGrpc; |
| 12 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; | 12 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; |
| 13 | import com.infoloop.tianting.enterpriseresourcetagservice.EnterpriseResourceTagServiceRpcGrpc; | 13 | import com.infoloop.tianting.enterpriseresourcetagservice.EnterpriseResourceTagServiceRpcGrpc; |
| 14 | +import com.infoloop.tianting.mealorderservice.MealOrderServiceRpcGrpc; | ||
| 14 | import com.infoloop.tianting.menuservice.MenuServiceRpcGrpc; | 15 | import com.infoloop.tianting.menuservice.MenuServiceRpcGrpc; |
| 15 | import com.infoloop.tianting.setmealscheduleservice.SetMealScheduleServiceRpcGrpc; | 16 | import com.infoloop.tianting.setmealscheduleservice.SetMealScheduleServiceRpcGrpc; |
| 16 | import io.grpc.ClientInterceptor; | 17 | import io.grpc.ClientInterceptor; |
| ... | @@ -86,6 +87,11 @@ public class GrpcConfig { | ... | @@ -86,6 +87,11 @@ public class GrpcConfig { |
| 86 | return ClientCustomerOrderServiceRpcGrpc.newBlockingStub(channel); | 87 | return ClientCustomerOrderServiceRpcGrpc.newBlockingStub(channel); |
| 87 | } | 88 | } |
| 88 | 89 | ||
| 90 | + @Bean | ||
| 91 | + public MealOrderServiceRpcGrpc.MealOrderServiceRpcBlockingStub mealOrderServiceRpcBlockingStub(@Autowired @Qualifier(ORDER_SERVICE_CHANNEL) final ManagedChannel channel) { | ||
| 92 | + return MealOrderServiceRpcGrpc.newBlockingStub(channel); | ||
| 93 | + } | ||
| 94 | + | ||
| 89 | @Bean(MENU_SERVICE_CHANNEL) | 95 | @Bean(MENU_SERVICE_CHANNEL) |
| 90 | public ManagedChannel menuServiceChannel(@Value(MENU_SERVICE_RPC_URL) final String url, | 96 | public ManagedChannel menuServiceChannel(@Value(MENU_SERVICE_RPC_URL) final String url, |
| 91 | @Value(MENU_SERVICE_RPC_PORT) final int port, | 97 | @Value(MENU_SERVICE_RPC_PORT) final int port, | ... | ... |
| 1 | +package com.infoloop.tianting.config; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | +import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| 5 | +import org.springframework.context.annotation.PropertySource; | ||
| 6 | +import org.springframework.stereotype.Component; | ||
| 7 | + | ||
| 8 | +@Component | ||
| 9 | +@ConfigurationProperties(prefix = "aliyun.oss") | ||
| 10 | +@Data | ||
| 11 | +@PropertySource(encoding = "UTF-8", value = "classpath:application.properties", ignoreResourceNotFound = true) | ||
| 12 | +public class OssConfig { | ||
| 13 | + | ||
| 14 | + private String accessKeyId; | ||
| 15 | + | ||
| 16 | + private String accessKeySecret; | ||
| 17 | + | ||
| 18 | + private String endpoint; | ||
| 19 | + | ||
| 20 | + private String host; | ||
| 21 | + | ||
| 22 | + private String bucket; | ||
| 23 | +} |
| 1 | package com.infoloop.tianting.config; | 1 | package com.infoloop.tianting.config; |
| 2 | 2 | ||
| 3 | import com.infoloop.tianting.intercepter.ResourceInjector; | 3 | import com.infoloop.tianting.intercepter.ResourceInjector; |
| 4 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 5 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 4 | import org.springframework.context.annotation.Bean; | 6 | import org.springframework.context.annotation.Bean; |
| 5 | import org.springframework.context.annotation.Configuration; | 7 | import org.springframework.context.annotation.Configuration; |
| 6 | 8 | ||
| ... | @@ -8,9 +10,9 @@ import org.springframework.context.annotation.Configuration; | ... | @@ -8,9 +10,9 @@ import org.springframework.context.annotation.Configuration; |
| 8 | public class ResourceInjectorConfig { | 10 | public class ResourceInjectorConfig { |
| 9 | 11 | ||
| 10 | @Bean | 12 | @Bean |
| 11 | - public ResourceInjector resourceInjector( | 13 | + public ResourceInjector resourceInjector(final MealOrderServiceRpcClient mealOrderServiceRpcClient, |
| 12 | - | 14 | + final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient |
| 13 | ) { | 15 | ) { |
| 14 | - return new ResourceInjector(); | 16 | + return new ResourceInjector(mealOrderServiceRpcClient, clientInventoryServiceRpcClient); |
| 15 | } | 17 | } |
| 16 | } | 18 | } | ... | ... |
| ... | @@ -7,6 +7,8 @@ import com.infoloop.tianting.intercepter.LoginInterceptor; | ... | @@ -7,6 +7,8 @@ import com.infoloop.tianting.intercepter.LoginInterceptor; |
| 7 | import com.infoloop.tianting.intercepter.RequestMonitor; | 7 | import com.infoloop.tianting.intercepter.RequestMonitor; |
| 8 | import com.infoloop.tianting.intercepter.ResourceInjector; | 8 | import com.infoloop.tianting.intercepter.ResourceInjector; |
| 9 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; | 9 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; |
| 10 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 11 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 10 | import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; | 12 | import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; |
| 11 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; | 13 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; |
| 12 | import com.infoloop.tianting.service.client.WOperatorServiceRpcClient; | 14 | import com.infoloop.tianting.service.client.WOperatorServiceRpcClient; |
| ... | @@ -38,12 +40,15 @@ public class WebMvcConfig implements WebMvcConfigurer { | ... | @@ -38,12 +40,15 @@ public class WebMvcConfig implements WebMvcConfigurer { |
| 38 | final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient, | 40 | final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient, |
| 39 | final OperatorServiceRpcClient operatorServiceRpcClient, | 41 | final OperatorServiceRpcClient operatorServiceRpcClient, |
| 40 | final WOperatorServiceRpcClient wOperatorServiceRpcClient, | 42 | final WOperatorServiceRpcClient wOperatorServiceRpcClient, |
| 41 | - final MeiZhongYiHeServiceClient meiZhongYiHeServiceClient) { | 43 | + final MeiZhongYiHeServiceClient meiZhongYiHeServiceClient, |
| 44 | + final MealOrderServiceRpcClient mealOrderServiceRpcClient, | ||
| 45 | + final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient) { | ||
| 42 | this.httpInterceptors = new ArrayList<>(); | 46 | this.httpInterceptors = new ArrayList<>(); |
| 43 | this.httpInterceptors.add(new HttpTracingInterceptor(tracing)); | 47 | this.httpInterceptors.add(new HttpTracingInterceptor(tracing)); |
| 44 | this.httpInterceptors.add(new RequestMonitor()); | 48 | this.httpInterceptors.add(new RequestMonitor()); |
| 45 | this.httpInterceptors.add(new ApiSignInterceptor()); | 49 | this.httpInterceptors.add(new ApiSignInterceptor()); |
| 46 | this.httpInterceptors.add(new LoginInterceptor(clientCustomerServiceRpcClient, meiZhongYiHeServiceClient, operatorServiceRpcClient, wOperatorServiceRpcClient)); | 50 | this.httpInterceptors.add(new LoginInterceptor(clientCustomerServiceRpcClient, meiZhongYiHeServiceClient, operatorServiceRpcClient, wOperatorServiceRpcClient)); |
| 51 | + this.httpInterceptors.add(new ResourceInjector(mealOrderServiceRpcClient, clientInventoryServiceRpcClient)); | ||
| 47 | this.httpInterceptors.add(resourceInjector); | 52 | this.httpInterceptors.add(resourceInjector); |
| 48 | 53 | ||
| 49 | } | 54 | } | ... | ... |
| ... | @@ -24,10 +24,6 @@ public interface ConfigConstants { | ... | @@ -24,10 +24,6 @@ public interface ConfigConstants { |
| 24 | String ENTERPRISE_REDIS_PASSWORD = "${enterprise.redis.password}"; | 24 | String ENTERPRISE_REDIS_PASSWORD = "${enterprise.redis.password}"; |
| 25 | String ENTERPRISE_REDIS_DATABASE = "${enterprise.redis.database}"; | 25 | String ENTERPRISE_REDIS_DATABASE = "${enterprise.redis.database}"; |
| 26 | 26 | ||
| 27 | - String EXAMPLE_SERVICE_RPC_URL = "${grpc.example-service.url}"; | ||
| 28 | - String EXAMPLE_SERVICE_RPC_PORT = "${grpc.example-service.port}"; | ||
| 29 | - String EXAMPLE_SERVICE_CHANNEL = "example-service-channel"; | ||
| 30 | - | ||
| 31 | String ORDER_SERVICE_RPC_URL = "${grpc.order-service.url}"; | 27 | String ORDER_SERVICE_RPC_URL = "${grpc.order-service.url}"; |
| 32 | String ORDER_SERVICE_RPC_PORT = "${grpc.order-service.port}"; | 28 | String ORDER_SERVICE_RPC_PORT = "${grpc.order-service.port}"; |
| 33 | String ORDER_SERVICE_CHANNEL = "order-service-channel"; | 29 | String ORDER_SERVICE_CHANNEL = "order-service-channel"; | ... | ... |
| ... | @@ -2,9 +2,21 @@ package com.infoloop.tianting.constant; | ... | @@ -2,9 +2,21 @@ package com.infoloop.tianting.constant; |
| 2 | 2 | ||
| 3 | public interface PathVariableResourceConstants { | 3 | public interface PathVariableResourceConstants { |
| 4 | 4 | ||
| 5 | - String INJECTED_TEST_EXAMPLE_DB = "testExampleDb"; | ||
| 6 | - String TEST_EXAMPLE_DB_ID_PATH_VARIABLE = "testExampleDbId"; | ||
| 7 | 5 | ||
| 6 | + String INJECTED_MP_ACCOUNT = "mpAccount"; | ||
| 7 | + String MP_ACCOUNT_ID_PATH_VARIABLE = "mpAccountId"; | ||
| 8 | + | ||
| 9 | + String INJECTED_CLIENT = "client"; | ||
| 10 | + String CLIENT_ID_PATH_VARIABLE = "clientId"; | ||
| 11 | + | ||
| 12 | + String INJECTED_DINER = "diner"; | ||
| 13 | + String DINER_ID_PATH_VARIABLE = "dinerId"; | ||
| 14 | + | ||
| 15 | + String INJECTED_GRADE_CLASS = "gradeClass"; | ||
| 16 | + String GRADE_CLASS_ID_PATH_VARIABLE = "gradeClassId"; | ||
| 17 | + | ||
| 18 | + String INJECTED_MEAL_ORDER = "mealOrder"; | ||
| 19 | + String MEAL_ORDER_ID_PATH_VARIABLE = "mealOrderId"; | ||
| 8 | 20 | ||
| 9 | 21 | ||
| 10 | } | 22 | } | ... | ... |
| ... | @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController; | ... | @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController; |
| 16 | 16 | ||
| 17 | import java.util.List; | 17 | import java.util.List; |
| 18 | 18 | ||
| 19 | -@Api(tags = "Category") | 19 | +@Api(tags = "品类") |
| 20 | @ApiSupport(order = -1) | 20 | @ApiSupport(order = -1) |
| 21 | @Slf4j | 21 | @Slf4j |
| 22 | @Validated | 22 | @Validated | ... | ... |
| ... | @@ -2,10 +2,10 @@ package com.infoloop.tianting.controller; | ... | @@ -2,10 +2,10 @@ package com.infoloop.tianting.controller; |
| 2 | 2 | ||
| 3 | import cn.dev33.satoken.annotation.SaIgnore; | 3 | import cn.dev33.satoken.annotation.SaIgnore; |
| 4 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; | 4 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; |
| 5 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto; | 5 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientDto; |
| 6 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientTableCodeDto; | 6 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientTableCodeDto; |
| 7 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto; | 7 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.TableCodeQueryConditionDto; |
| 8 | -import com.infoloop.tianting.service.InventoryService; | 8 | +import com.infoloop.tianting.service.ClientInventoryService; |
| 9 | import io.swagger.annotations.Api; | 9 | import io.swagger.annotations.Api; |
| 10 | import io.swagger.annotations.ApiOperation; | 10 | import io.swagger.annotations.ApiOperation; |
| 11 | import lombok.RequiredArgsConstructor; | 11 | import lombok.RequiredArgsConstructor; |
| ... | @@ -17,40 +17,48 @@ import org.springframework.web.bind.annotation.GetMapping; | ... | @@ -17,40 +17,48 @@ import org.springframework.web.bind.annotation.GetMapping; |
| 17 | import org.springframework.web.bind.annotation.PathVariable; | 17 | import org.springframework.web.bind.annotation.PathVariable; |
| 18 | import org.springframework.web.bind.annotation.PostMapping; | 18 | import org.springframework.web.bind.annotation.PostMapping; |
| 19 | import org.springframework.web.bind.annotation.RequestBody; | 19 | import org.springframework.web.bind.annotation.RequestBody; |
| 20 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 20 | import org.springframework.web.bind.annotation.ResponseStatus; | 21 | import org.springframework.web.bind.annotation.ResponseStatus; |
| 21 | import org.springframework.web.bind.annotation.RestController; | 22 | import org.springframework.web.bind.annotation.RestController; |
| 22 | 23 | ||
| 23 | import javax.validation.Valid; | 24 | import javax.validation.Valid; |
| 24 | import java.util.List; | 25 | import java.util.List; |
| 25 | 26 | ||
| 26 | -@Api(tags = "院区") | 27 | +@Api(tags = "项目点") |
| 27 | @ApiSupport(order = -1) | 28 | @ApiSupport(order = -1) |
| 28 | @Slf4j | 29 | @Slf4j |
| 29 | @Validated | 30 | @Validated |
| 30 | @RestController | 31 | @RestController |
| 31 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) | 32 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) |
| 32 | -public class InventoryController { | 33 | +public class ClientController { |
| 33 | - private final InventoryService inventoryService; | 34 | + private final ClientInventoryService clientInventoryService; |
| 34 | 35 | ||
| 35 | @SaIgnore | 36 | @SaIgnore |
| 36 | @ApiOperation(value = "根据Id获取Client") | 37 | @ApiOperation(value = "根据Id获取Client") |
| 37 | @GetMapping("/enterprises/{enterpriseId}/clients/{clientId}") | 38 | @GetMapping("/enterprises/{enterpriseId}/clients/{clientId}") |
| 38 | @ResponseStatus(HttpStatus.OK) | 39 | @ResponseStatus(HttpStatus.OK) |
| 39 | public ClientDto getClientById(@PathVariable Integer enterpriseId, @PathVariable Integer clientId) { | 40 | public ClientDto getClientById(@PathVariable Integer enterpriseId, @PathVariable Integer clientId) { |
| 40 | - return inventoryService.getClientById(enterpriseId, clientId); | 41 | + return clientInventoryService.getClientById(enterpriseId, clientId); |
| 42 | + } | ||
| 43 | + | ||
| 44 | + @ApiOperation(value = "根据Codes获取Clients") | ||
| 45 | + @GetMapping("/clients/bycodes") | ||
| 46 | + @ResponseStatus(HttpStatus.OK) | ||
| 47 | + public List<ClientDto> getClientsByCodes(@RequestParam List<String> codes) { | ||
| 48 | + return clientInventoryService.getClientsByCodes(codes); | ||
| 41 | } | 49 | } |
| 42 | 50 | ||
| 43 | @ApiOperation(value = "根据ClientId获取Stalls") | 51 | @ApiOperation(value = "根据ClientId获取Stalls") |
| 44 | @GetMapping("/enterprises/{enterpriseId}/clients/{clientId}/stalls") | 52 | @GetMapping("/enterprises/{enterpriseId}/clients/{clientId}/stalls") |
| 45 | @ResponseStatus(HttpStatus.OK) | 53 | @ResponseStatus(HttpStatus.OK) |
| 46 | public List<ClientDto> getStallsByClientId(@PathVariable Integer enterpriseId, @PathVariable Integer clientId) { | 54 | public List<ClientDto> getStallsByClientId(@PathVariable Integer enterpriseId, @PathVariable Integer clientId) { |
| 47 | - return inventoryService.getStallsByClientId(enterpriseId, clientId); | 55 | + return clientInventoryService.getStallsByClientId(enterpriseId, clientId); |
| 48 | } | 56 | } |
| 49 | 57 | ||
| 50 | @ApiOperation(value = "获取桌号") | 58 | @ApiOperation(value = "获取桌号") |
| 51 | @PostMapping("/tableCodes") | 59 | @PostMapping("/tableCodes") |
| 52 | @ResponseStatus(HttpStatus.OK) | 60 | @ResponseStatus(HttpStatus.OK) |
| 53 | public List<ClientTableCodeDto> getTableCodes(@Valid @RequestBody TableCodeQueryConditionDto tableCodeQueryConditionDto) { | 61 | public List<ClientTableCodeDto> getTableCodes(@Valid @RequestBody TableCodeQueryConditionDto tableCodeQueryConditionDto) { |
| 54 | - return inventoryService.queryClientTableCodesByCondition(tableCodeQueryConditionDto); | 62 | + return clientInventoryService.queryClientTableCodesByCondition(tableCodeQueryConditionDto); |
| 55 | } | 63 | } |
| 56 | } | 64 | } | ... | ... |
| ... | @@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController; | ... | @@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController; |
| 22 | import java.io.IOException; | 22 | import java.io.IOException; |
| 23 | import java.util.List; | 23 | import java.util.List; |
| 24 | 24 | ||
| 25 | -@Api(tags = "客户") | 25 | +@Api(tags = "项目点客户") |
| 26 | @ApiSupport(order = -1) | 26 | @ApiSupport(order = -1) |
| 27 | @Slf4j | 27 | @Slf4j |
| 28 | @Validated | 28 | @Validated | ... | ... |
| 1 | +package com.infoloop.tianting.controller; | ||
| 2 | + | ||
| 3 | +import com.github.xiaoymin.knife4j.annotations.ApiSupport; | ||
| 4 | +import com.infoloop.tianting.annotation.RepeatSubmit; | ||
| 5 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 6 | +import com.infoloop.tianting.mealorderservice.SingleDinerRpcResponse; | ||
| 7 | +import com.infoloop.tianting.mealorderservice.SingleGradeClassRpcResponse; | ||
| 8 | +import com.infoloop.tianting.model.common.CreatedResult; | ||
| 9 | +import com.infoloop.tianting.model.dto.DinerDTO; | ||
| 10 | +import com.infoloop.tianting.model.vo.DinerVO; | ||
| 11 | +import com.infoloop.tianting.model.vo.GradeClassVO; | ||
| 12 | +import com.infoloop.tianting.service.DinerService; | ||
| 13 | +import io.swagger.annotations.Api; | ||
| 14 | +import io.swagger.annotations.ApiOperation; | ||
| 15 | +import lombok.RequiredArgsConstructor; | ||
| 16 | +import lombok.extern.slf4j.Slf4j; | ||
| 17 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 18 | +import org.springframework.http.HttpStatus; | ||
| 19 | +import org.springframework.validation.annotation.Validated; | ||
| 20 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 21 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 22 | +import org.springframework.web.bind.annotation.PatchMapping; | ||
| 23 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 24 | +import org.springframework.web.bind.annotation.PutMapping; | ||
| 25 | +import org.springframework.web.bind.annotation.RequestAttribute; | ||
| 26 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 27 | +import org.springframework.web.bind.annotation.ResponseStatus; | ||
| 28 | +import org.springframework.web.bind.annotation.RestController; | ||
| 29 | + | ||
| 30 | +import javax.validation.Valid; | ||
| 31 | +import java.util.List; | ||
| 32 | + | ||
| 33 | +import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_CLIENT; | ||
| 34 | +import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_DINER; | ||
| 35 | +import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_GRADE_CLASS; | ||
| 36 | + | ||
| 37 | +@Api(tags = "就餐人") | ||
| 38 | +@ApiSupport(order = -1) | ||
| 39 | +@Slf4j | ||
| 40 | +@Validated | ||
| 41 | +@RestController | ||
| 42 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 43 | +public class DinerController { | ||
| 44 | + | ||
| 45 | + private final DinerService dinerService; | ||
| 46 | + | ||
| 47 | + @ApiOperation(value = "用户就餐人列表") | ||
| 48 | + @GetMapping("/mpaccount/diners") | ||
| 49 | + @ResponseStatus(HttpStatus.OK) | ||
| 50 | + public List<DinerVO> getMpAccountDiners() { | ||
| 51 | + return dinerService.getMpAccountDiners(); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @ApiOperation(value = "添加就餐人") | ||
| 55 | + @PutMapping("/mpaccount/diner") | ||
| 56 | + @RepeatSubmit(prefix = "create.diner", isLockByLoginUser = false) | ||
| 57 | + @ResponseStatus(HttpStatus.CREATED) | ||
| 58 | + public CreatedResult<DinerVO> createMpAccountDiner(@RequestBody @Valid final DinerDTO.CreateDinerDTO createDinerDTO) { | ||
| 59 | + return dinerService.createMpAccountDiner(createDinerDTO); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @ApiOperation(value = "学校年级班级列表") | ||
| 63 | + @GetMapping("/client/{clientId}/gradeclasses") | ||
| 64 | + @ResponseStatus(HttpStatus.OK) | ||
| 65 | + public List<GradeClassVO> getClientGradeClasses(@RequestAttribute(INJECTED_CLIENT) final SingleClientRpcResponse client) { | ||
| 66 | + return dinerService.getClientGradeClasses(client); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @ApiOperation(value = "根据学校,班级和学号查询就餐人") | ||
| 70 | + @PostMapping("/client/{clientId}/gradeclass/{gradeClassId}/diner") | ||
| 71 | + @ResponseStatus(HttpStatus.OK) | ||
| 72 | + public DinerVO getClientClassDiner(@RequestAttribute(INJECTED_CLIENT) final SingleClientRpcResponse client, | ||
| 73 | + @RequestAttribute(INJECTED_GRADE_CLASS) final SingleGradeClassRpcResponse gradeClass, | ||
| 74 | + @RequestBody @Valid final DinerDTO.QueryUniqueDinerDTO queryUniqueDinerDTO) { | ||
| 75 | + return dinerService.getClientClassDiner(client, gradeClass, queryUniqueDinerDTO.getStudentNo()); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @ApiOperation(value = "修改就餐人") | ||
| 79 | + @PatchMapping("/mpaccount/diner/{dinerId}") | ||
| 80 | + @ResponseStatus(HttpStatus.NO_CONTENT) | ||
| 81 | + public void updateMpAccountDiner(@RequestAttribute(INJECTED_DINER) final SingleDinerRpcResponse diner, | ||
| 82 | + @RequestBody @Valid final DinerDTO.UpdateDinerDTO updateDinerDTO) { | ||
| 83 | + dinerService.updateMpAccountDiner(diner, updateDinerDTO); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + @ApiOperation(value = "删除就餐人") | ||
| 87 | + @DeleteMapping("/mpaccount/diner/{dinerId}") | ||
| 88 | + @ResponseStatus(HttpStatus.NO_CONTENT) | ||
| 89 | + public void deleteMpAccountDiner(@RequestAttribute(INJECTED_DINER) final SingleDinerRpcResponse diner) { | ||
| 90 | + dinerService.deleteMpAccountDiner(diner); | ||
| 91 | + } | ||
| 92 | +} |
| ... | @@ -3,7 +3,10 @@ package com.infoloop.tianting.controller; | ... | @@ -3,7 +3,10 @@ package com.infoloop.tianting.controller; |
| 3 | import cn.dev33.satoken.annotation.SaIgnore; | 3 | import cn.dev33.satoken.annotation.SaIgnore; |
| 4 | import cn.dev33.satoken.stp.SaTokenInfo; | 4 | import cn.dev33.satoken.stp.SaTokenInfo; |
| 5 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; | 5 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; |
| 6 | +import com.infoloop.tianting.mealorderservice.SingleMpAccountRpcResponse; | ||
| 7 | +import com.infoloop.tianting.model.dto.MpAccountDTO; | ||
| 6 | import com.infoloop.tianting.model.dto.PermissionDTO; | 8 | import com.infoloop.tianting.model.dto.PermissionDTO; |
| 9 | +import com.infoloop.tianting.model.vo.MpAccountVO; | ||
| 7 | import com.infoloop.tianting.service.LoginService; | 10 | import com.infoloop.tianting.service.LoginService; |
| 8 | import io.swagger.annotations.Api; | 11 | import io.swagger.annotations.Api; |
| 9 | import io.swagger.annotations.ApiOperation; | 12 | import io.swagger.annotations.ApiOperation; |
| ... | @@ -12,7 +15,11 @@ import lombok.extern.slf4j.Slf4j; | ... | @@ -12,7 +15,11 @@ import lombok.extern.slf4j.Slf4j; |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.http.HttpStatus; | 16 | import org.springframework.http.HttpStatus; |
| 14 | import org.springframework.validation.annotation.Validated; | 17 | import org.springframework.validation.annotation.Validated; |
| 18 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 19 | +import org.springframework.web.bind.annotation.PatchMapping; | ||
| 20 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 15 | import org.springframework.web.bind.annotation.PostMapping; | 21 | import org.springframework.web.bind.annotation.PostMapping; |
| 22 | +import org.springframework.web.bind.annotation.RequestAttribute; | ||
| 16 | import org.springframework.web.bind.annotation.RequestBody; | 23 | import org.springframework.web.bind.annotation.RequestBody; |
| 17 | import org.springframework.web.bind.annotation.ResponseStatus; | 24 | import org.springframework.web.bind.annotation.ResponseStatus; |
| 18 | import org.springframework.web.bind.annotation.RestController; | 25 | import org.springframework.web.bind.annotation.RestController; |
| ... | @@ -20,6 +27,8 @@ import org.springframework.web.bind.annotation.RestController; | ... | @@ -20,6 +27,8 @@ import org.springframework.web.bind.annotation.RestController; |
| 20 | import javax.validation.Valid; | 27 | import javax.validation.Valid; |
| 21 | import java.security.NoSuchAlgorithmException; | 28 | import java.security.NoSuchAlgorithmException; |
| 22 | 29 | ||
| 30 | +import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_MP_ACCOUNT; | ||
| 31 | + | ||
| 23 | @Api(tags = "登陆") | 32 | @Api(tags = "登陆") |
| 24 | @ApiSupport(order = -1) | 33 | @ApiSupport(order = -1) |
| 25 | @Slf4j | 34 | @Slf4j |
| ... | @@ -36,4 +45,20 @@ public class LoginController { | ... | @@ -36,4 +45,20 @@ public class LoginController { |
| 36 | public SaTokenInfo login(@Valid @RequestBody PermissionDTO.LoginDto loginDto) throws NoSuchAlgorithmException { | 45 | public SaTokenInfo login(@Valid @RequestBody PermissionDTO.LoginDto loginDto) throws NoSuchAlgorithmException { |
| 37 | return loginService.login(loginDto); | 46 | return loginService.login(loginDto); |
| 38 | } | 47 | } |
| 48 | + | ||
| 49 | + @SaIgnore | ||
| 50 | + @ApiOperation(value = "根据openId获取小程序用户") | ||
| 51 | + @GetMapping("/mpaccount/{openId}") | ||
| 52 | + @ResponseStatus(HttpStatus.OK) | ||
| 53 | + public MpAccountVO getMpAccountByOpenId(@PathVariable("openId") String openId) { | ||
| 54 | + return loginService.getMpAccountByOpenId(openId); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @ApiOperation(value = "修改小程序用户") | ||
| 58 | + @PatchMapping("/mpaccount/{mpAccountId}") | ||
| 59 | + @ResponseStatus(HttpStatus.NO_CONTENT) | ||
| 60 | + public void updateMpAccount(@RequestAttribute(INJECTED_MP_ACCOUNT) final SingleMpAccountRpcResponse mpAccount, | ||
| 61 | + @RequestBody @Valid MpAccountDTO.ModifyMpAccountDTO modifyMpAccountDTO) { | ||
| 62 | + loginService.updateMpAccount(mpAccount, modifyMpAccountDTO); | ||
| 63 | + } | ||
| 39 | } | 64 | } | ... | ... |
| 1 | +package com.infoloop.tianting.controller; | ||
| 2 | + | ||
| 3 | +import com.github.xiaoymin.knife4j.annotations.ApiSupport; | ||
| 4 | +import com.infoloop.tianting.annotation.RepeatSubmit; | ||
| 5 | +import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; | ||
| 6 | +import com.infoloop.tianting.model.common.CreatedResult; | ||
| 7 | +import com.infoloop.tianting.model.dto.MealOrderDTO; | ||
| 8 | +import com.infoloop.tianting.model.vo.DeliveryRuleVO; | ||
| 9 | +import com.infoloop.tianting.model.vo.MealOrderVO; | ||
| 10 | +import com.infoloop.tianting.service.MealOrderService; | ||
| 11 | +import io.swagger.annotations.Api; | ||
| 12 | +import io.swagger.annotations.ApiOperation; | ||
| 13 | +import lombok.RequiredArgsConstructor; | ||
| 14 | +import lombok.extern.slf4j.Slf4j; | ||
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 16 | +import org.springframework.http.HttpStatus; | ||
| 17 | +import org.springframework.validation.annotation.Validated; | ||
| 18 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 19 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 20 | +import org.springframework.web.bind.annotation.PutMapping; | ||
| 21 | +import org.springframework.web.bind.annotation.RequestAttribute; | ||
| 22 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 23 | +import org.springframework.web.bind.annotation.ResponseStatus; | ||
| 24 | +import org.springframework.web.bind.annotation.RestController; | ||
| 25 | + | ||
| 26 | +import javax.validation.Valid; | ||
| 27 | +import java.util.List; | ||
| 28 | + | ||
| 29 | +import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_MEAL_ORDER; | ||
| 30 | + | ||
| 31 | +@Api(tags = "订餐") | ||
| 32 | +@ApiSupport(order = -1) | ||
| 33 | +@Slf4j | ||
| 34 | +@Validated | ||
| 35 | +@RestController | ||
| 36 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 37 | +public class MealOrderController { | ||
| 38 | + | ||
| 39 | + private final MealOrderService mealOrderService; | ||
| 40 | + | ||
| 41 | + @ApiOperation(value = "订餐记录") | ||
| 42 | + @PostMapping("/mealorders") | ||
| 43 | + @ResponseStatus(HttpStatus.OK) | ||
| 44 | + public List<MealOrderVO> queryMealOrders(@RequestBody @Valid final MealOrderDTO.QueryMealOrderDTO queryMealOrderDTO) { | ||
| 45 | + return mealOrderService.queryMealOrders(queryMealOrderDTO); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @ApiOperation(value = "立即订餐") | ||
| 49 | + @PutMapping("/mealorder") | ||
| 50 | + @RepeatSubmit(prefix = "create.meal.order", isLockByLoginUser = false) | ||
| 51 | + @ResponseStatus(HttpStatus.CREATED) | ||
| 52 | + public CreatedResult<MealOrderVO> createMealOrder(@RequestBody @Valid final MealOrderDTO.CreateMealOrderDTO createMealOrderDTO) { | ||
| 53 | + return mealOrderService.createMealOrder(createMealOrderDTO); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @ApiOperation(value = "订餐记录详情") | ||
| 57 | + @GetMapping("/mealorder/{mealOrderId}") | ||
| 58 | + @ResponseStatus(HttpStatus.OK) | ||
| 59 | + public MealOrderVO getMealOrderById(@RequestAttribute(INJECTED_MEAL_ORDER) final SingleMealOrderRpcResponse mealOrder) { | ||
| 60 | + return mealOrderService.getMealOrderById(mealOrder); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @ApiOperation(value = "订餐规则") | ||
| 64 | + @GetMapping("/deliveryrule") | ||
| 65 | + @ResponseStatus(HttpStatus.OK) | ||
| 66 | + public DeliveryRuleVO getDeliveryRule() { | ||
| 67 | + return mealOrderService.getDeliveryRule(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | +} |
| 1 | package com.infoloop.tianting.controller; | 1 | package com.infoloop.tianting.controller; |
| 2 | 2 | ||
| 3 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; | 3 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; |
| 4 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 4 | import com.infoloop.tianting.model.dto.MenuDbDTO; | 5 | import com.infoloop.tianting.model.dto.MenuDbDTO; |
| 5 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsDto; | 6 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsDto; |
| 6 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsResponseDto; | 7 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsResponseDto; |
| ... | @@ -18,6 +19,7 @@ import org.springframework.validation.annotation.Validated; | ... | @@ -18,6 +19,7 @@ import org.springframework.validation.annotation.Validated; |
| 18 | import org.springframework.web.bind.annotation.GetMapping; | 19 | import org.springframework.web.bind.annotation.GetMapping; |
| 19 | import org.springframework.web.bind.annotation.PathVariable; | 20 | import org.springframework.web.bind.annotation.PathVariable; |
| 20 | import org.springframework.web.bind.annotation.PostMapping; | 21 | import org.springframework.web.bind.annotation.PostMapping; |
| 22 | +import org.springframework.web.bind.annotation.RequestAttribute; | ||
| 21 | import org.springframework.web.bind.annotation.RequestBody; | 23 | import org.springframework.web.bind.annotation.RequestBody; |
| 22 | import org.springframework.web.bind.annotation.ResponseStatus; | 24 | import org.springframework.web.bind.annotation.ResponseStatus; |
| 23 | import org.springframework.web.bind.annotation.RestController; | 25 | import org.springframework.web.bind.annotation.RestController; |
| ... | @@ -25,6 +27,8 @@ import org.springframework.web.bind.annotation.RestController; | ... | @@ -25,6 +27,8 @@ import org.springframework.web.bind.annotation.RestController; |
| 25 | import javax.validation.Valid; | 27 | import javax.validation.Valid; |
| 26 | import java.util.List; | 28 | import java.util.List; |
| 27 | 29 | ||
| 30 | +import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_CLIENT; | ||
| 31 | + | ||
| 28 | @Api(tags = "餐单") | 32 | @Api(tags = "餐单") |
| 29 | @ApiSupport(order = -1) | 33 | @ApiSupport(order = -1) |
| 30 | @Slf4j | 34 | @Slf4j |
| ... | @@ -76,4 +80,11 @@ public class MenuController { | ... | @@ -76,4 +80,11 @@ public class MenuController { |
| 76 | return menuService.batchCreateMenuRefs(batchCreateMenuRefsDto); | 80 | return menuService.batchCreateMenuRefs(batchCreateMenuRefsDto); |
| 77 | } | 81 | } |
| 78 | 82 | ||
| 83 | + @ApiOperation(value = "查询学校最新餐单") | ||
| 84 | + @GetMapping("/client/{clientId}/mealmenurecord") | ||
| 85 | + @ResponseStatus(HttpStatus.OK) | ||
| 86 | + public String queryClientLatestMealMenuRecord(@RequestAttribute(INJECTED_CLIENT) final SingleClientRpcResponse client) { | ||
| 87 | + return menuService.queryClientLatestMealMenuRecord(client); | ||
| 88 | + } | ||
| 89 | + | ||
| 79 | } | 90 | } | ... | ... |
| ... | @@ -27,6 +27,7 @@ public class MiniProgramController { | ... | @@ -27,6 +27,7 @@ public class MiniProgramController { |
| 27 | 27 | ||
| 28 | private final WxMiniProgramService wxMiniProgramService; | 28 | private final WxMiniProgramService wxMiniProgramService; |
| 29 | 29 | ||
| 30 | + @SaIgnore | ||
| 30 | @ApiOperation(value = "小程序:根据code获取openId") | 31 | @ApiOperation(value = "小程序:根据code获取openId") |
| 31 | @GetMapping("/wx/miniprogram/customers/openid/{code}") | 32 | @GetMapping("/wx/miniprogram/customers/openid/{code}") |
| 32 | @ResponseStatus(HttpStatus.OK) | 33 | @ResponseStatus(HttpStatus.OK) | ... | ... |
| 1 | +package com.infoloop.tianting.controller; | ||
| 2 | + | ||
| 3 | +import cn.dev33.satoken.annotation.SaIgnore; | ||
| 4 | +import cn.hutool.core.io.IoUtil; | ||
| 5 | +import cn.hutool.core.io.file.FileNameUtil; | ||
| 6 | +import cn.hutool.core.util.IdUtil; | ||
| 7 | +import com.github.xiaoymin.knife4j.annotations.ApiSupport; | ||
| 8 | +import com.infoloop.tianting.config.OssConfig; | ||
| 9 | +import com.infoloop.tianting.server.StorageService; | ||
| 10 | +import io.swagger.annotations.Api; | ||
| 11 | +import io.swagger.annotations.ApiOperation; | ||
| 12 | +import lombok.extern.slf4j.Slf4j; | ||
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | +import org.springframework.http.HttpStatus; | ||
| 15 | +import org.springframework.http.MediaType; | ||
| 16 | +import org.springframework.util.Assert; | ||
| 17 | +import org.springframework.validation.annotation.Validated; | ||
| 18 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 19 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 20 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 21 | +import org.springframework.web.bind.annotation.ResponseStatus; | ||
| 22 | +import org.springframework.web.bind.annotation.RestController; | ||
| 23 | +import org.springframework.web.multipart.MultipartFile; | ||
| 24 | + | ||
| 25 | +import javax.annotation.Nullable; | ||
| 26 | +import javax.servlet.ServletOutputStream; | ||
| 27 | +import javax.servlet.http.HttpServletResponse; | ||
| 28 | +import java.io.File; | ||
| 29 | +import java.io.InputStream; | ||
| 30 | +import java.net.URLEncoder; | ||
| 31 | +import java.nio.charset.StandardCharsets; | ||
| 32 | +import java.time.LocalDateTime; | ||
| 33 | +import java.time.format.DateTimeFormatter; | ||
| 34 | + | ||
| 35 | +@Api(tags = "上传、下载管理") | ||
| 36 | +@ApiSupport(order = 99) | ||
| 37 | +@Slf4j | ||
| 38 | +@Validated | ||
| 39 | +@RestController | ||
| 40 | +public class UploadController { | ||
| 41 | + | ||
| 42 | + private final OssConfig ossConfig; | ||
| 43 | + | ||
| 44 | + private final StorageService storageService; | ||
| 45 | + | ||
| 46 | + @Autowired(required = false) | ||
| 47 | + public UploadController(OssConfig ossConfig, @Nullable StorageService storageService) { | ||
| 48 | + this.ossConfig = ossConfig; | ||
| 49 | + this.storageService = storageService; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @SaIgnore | ||
| 53 | + @ApiOperation("上传") | ||
| 54 | + @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) | ||
| 55 | + @ResponseStatus(HttpStatus.OK) | ||
| 56 | + public String upload(@RequestParam("file") MultipartFile file, | ||
| 57 | + @RequestParam(value = "folder", defaultValue = "upload") String folder) throws Exception { | ||
| 58 | + Assert.notNull(storageService, "存储服务未初始化,请检查配置 aliyun.oss.endpoint"); | ||
| 59 | + String extension = FileNameUtil.getSuffix(file.getOriginalFilename()); | ||
| 60 | + String path = generateUploadPath(folder, extension); | ||
| 61 | + File tempFile = File.createTempFile(IdUtil.fastSimpleUUID(), null); | ||
| 62 | + try { | ||
| 63 | + file.transferTo(tempFile); | ||
| 64 | + storageService.putObject(ossConfig.getBucket(), path, tempFile); | ||
| 65 | + } catch (Exception e) { | ||
| 66 | + log.error("上传失败: {}", file.getOriginalFilename(), e); | ||
| 67 | + throw new RuntimeException("文件上传失败,请稍后重试"); | ||
| 68 | + } finally { | ||
| 69 | + tempFile.delete(); | ||
| 70 | + } | ||
| 71 | + return String.format("%s/%s", ossConfig.getHost(), path); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @SaIgnore | ||
| 75 | + @ApiOperation("下载") | ||
| 76 | + @GetMapping(value = "/download", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) | ||
| 77 | + @ResponseStatus(HttpStatus.OK) | ||
| 78 | + public void download(@RequestParam("path") String path, HttpServletResponse response) { | ||
| 79 | + Assert.notNull(storageService, "存储服务未初始化,请检查配置 aliyun.oss.endpoint"); | ||
| 80 | + try (InputStream inputStream = storageService.getObjectInputStream(ossConfig.getBucket(), path); | ||
| 81 | + ServletOutputStream outputStream = response.getOutputStream()) { | ||
| 82 | + String fileName = path.substring(path.lastIndexOf("/") + 1); | ||
| 83 | + response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); | ||
| 84 | + response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(fileName, StandardCharsets.UTF_8) + "\""); | ||
| 85 | + IoUtil.copy(inputStream, outputStream); | ||
| 86 | + } catch (Exception e) { | ||
| 87 | + log.error("下载失败: {}", path, e); | ||
| 88 | + throw new RuntimeException("文件下载失败,请稍后重试"); | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + private String generateUploadPath(String folder, String extension) { | ||
| 93 | + String datePath = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); | ||
| 94 | + return String.format("nutri-api/%s/%s/%s.%s", folder, datePath, IdUtil.fastSimpleUUID(), extension); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | +} |
| ... | @@ -42,7 +42,29 @@ public enum ErrorCodeEnum implements BaseEnum { | ... | @@ -42,7 +42,29 @@ public enum ErrorCodeEnum implements BaseEnum { |
| 42 | 42 | ||
| 43 | ORDER_NOT_ONLINE_PAY(406000012, "该订单不是在线支付"), | 43 | ORDER_NOT_ONLINE_PAY(406000012, "该订单不是在线支付"), |
| 44 | 44 | ||
| 45 | - ORDER_NOT_SUCCESS(406000013, "该订单未支付成功") | 45 | + ORDER_NOT_SUCCESS(406000013, "该订单未支付成功"), |
| 46 | + | ||
| 47 | + CLIENT_CODE_NOT_EXISTS(406000014, "学校编码不正确"), | ||
| 48 | + | ||
| 49 | + DINER_ALREADY_EXISTS(406000015, "该就餐人已存在"), | ||
| 50 | + | ||
| 51 | + DINER_ALREADY_RESERVED(406000016, "该就餐人已订餐"), | ||
| 52 | + | ||
| 53 | + DINER_NOT_FOUND(406000017, "该就餐人不存在"), | ||
| 54 | + | ||
| 55 | + MEAL_MENU_NOT_FOUND(406000018, "预定餐单不存在"), | ||
| 56 | + | ||
| 57 | + CLIENT_NOT_FOUND(406000019, "学校不存在"), | ||
| 58 | + | ||
| 59 | + CLIENT_NOT_ENABLED(406000020, "学校未启用"), | ||
| 60 | + | ||
| 61 | + GRADE_CLASS_NOT_FOUND(406000021, "班级不存在"), | ||
| 62 | + | ||
| 63 | + MEAL_ORDER_TIME_NOT_IN_RANGE(406000022, "当前时间不在选餐时间内"), | ||
| 64 | + | ||
| 65 | + DINER_NAME_STUDENT_NO_NOT_MISMATCH(406000023, "该就餐人学号和名称不匹配") | ||
| 66 | + | ||
| 67 | + | ||
| 46 | ; | 68 | ; |
| 47 | private final int code; | 69 | private final int code; |
| 48 | 70 | ... | ... |
| ... | @@ -70,6 +70,7 @@ public class LoginInterceptor implements HandlerInterceptor { | ... | @@ -70,6 +70,7 @@ public class LoginInterceptor implements HandlerInterceptor { |
| 70 | StpUtil.checkLogin(); | 70 | StpUtil.checkLogin(); |
| 71 | final var enterpriseId = Convert.toInt(StpUtil.getExtra(CommonConstants.ENTERPRISE_ID)); | 71 | final var enterpriseId = Convert.toInt(StpUtil.getExtra(CommonConstants.ENTERPRISE_ID)); |
| 72 | final var loginSource = Convert.toInt(StpUtil.getExtra(CommonConstants.LOGIN_SOURCE)); | 72 | final var loginSource = Convert.toInt(StpUtil.getExtra(CommonConstants.LOGIN_SOURCE)); |
| 73 | + final var userId = StpUtil.getExtra(CommonConstants.USER_ID); | ||
| 73 | if (loginSource.equals(LoginSourceEnum.CUSTOMER.getValue())) { | 74 | if (loginSource.equals(LoginSourceEnum.CUSTOMER.getValue())) { |
| 74 | final var openId = Convert.toStr(StpUtil.getExtra(CommonConstants.OPEN_ID)); | 75 | final var openId = Convert.toStr(StpUtil.getExtra(CommonConstants.OPEN_ID)); |
| 75 | final var loginId = StpUtil.getLoginIdAsInt(); | 76 | final var loginId = StpUtil.getLoginIdAsInt(); |
| ... | @@ -115,8 +116,7 @@ public class LoginInterceptor implements HandlerInterceptor { | ... | @@ -115,8 +116,7 @@ public class LoginInterceptor implements HandlerInterceptor { |
| 115 | builder.id(loginId).enterpriseId(enterpriseId).name(operator.getName()).loginSource(LoginSourceEnum.KDS); | 116 | builder.id(loginId).enterpriseId(enterpriseId).name(operator.getName()).loginSource(LoginSourceEnum.KDS); |
| 116 | return true; | 117 | return true; |
| 117 | } else { | 118 | } else { |
| 118 | - final var loginId = StpUtil.getLoginIdAsString(); | 119 | + builder.id(userId == null ? null : Convert.toInt(userId)).openId(StpUtil.getLoginIdAsString()).enterpriseId(enterpriseId).loginSource(LoginSourceEnum.MINI_PROGRAM); |
| 119 | - builder.openId(loginId).enterpriseId(enterpriseId).loginSource(LoginSourceEnum.MINI_PROGRAM); | ||
| 120 | return true; | 120 | return true; |
| 121 | } | 121 | } |
| 122 | } | 122 | } | ... | ... |
| ... | @@ -2,6 +2,12 @@ package com.infoloop.tianting.intercepter; | ... | @@ -2,6 +2,12 @@ package com.infoloop.tianting.intercepter; |
| 2 | 2 | ||
| 3 | import cn.dev33.satoken.annotation.SaIgnore; | 3 | import cn.dev33.satoken.annotation.SaIgnore; |
| 4 | import cn.dev33.satoken.strategy.SaStrategy; | 4 | import cn.dev33.satoken.strategy.SaStrategy; |
| 5 | +import cn.hutool.core.convert.Convert; | ||
| 6 | +import com.infoloop.tianting.constant.PathVariableResourceConstants; | ||
| 7 | +import com.infoloop.tianting.context.LoginContextHolder; | ||
| 8 | +import com.infoloop.tianting.exception.ClientEndExceptions; | ||
| 9 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 10 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 5 | import lombok.RequiredArgsConstructor; | 11 | import lombok.RequiredArgsConstructor; |
| 6 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 7 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | @@ -18,6 +24,10 @@ import java.util.Map; | ... | @@ -18,6 +24,10 @@ import java.util.Map; |
| 18 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) | 24 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) |
| 19 | public class ResourceInjector implements HandlerInterceptor { | 25 | public class ResourceInjector implements HandlerInterceptor { |
| 20 | 26 | ||
| 27 | + private final MealOrderServiceRpcClient mealOrderServiceRpcClient; | ||
| 28 | + | ||
| 29 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; | ||
| 30 | + | ||
| 21 | @Override | 31 | @Override |
| 22 | @SuppressWarnings("unchecked") | 32 | @SuppressWarnings("unchecked") |
| 23 | public boolean preHandle(@NonNull final HttpServletRequest httpServletRequest, @NonNull final HttpServletResponse httpServletResponse, @NonNull final Object handler) { | 33 | public boolean preHandle(@NonNull final HttpServletRequest httpServletRequest, @NonNull final HttpServletResponse httpServletResponse, @NonNull final Object handler) { |
| ... | @@ -33,6 +43,91 @@ public class ResourceInjector implements HandlerInterceptor { | ... | @@ -33,6 +43,91 @@ public class ResourceInjector implements HandlerInterceptor { |
| 33 | if (pathVariables == null) { | 43 | if (pathVariables == null) { |
| 34 | return true; | 44 | return true; |
| 35 | } | 45 | } |
| 46 | + | ||
| 47 | + /* | ||
| 48 | + 注入MpAccount | ||
| 49 | + */ | ||
| 50 | + if (pathVariables.containsKey(PathVariableResourceConstants.MP_ACCOUNT_ID_PATH_VARIABLE)) { | ||
| 51 | + final var idStr = pathVariables.get(PathVariableResourceConstants.MP_ACCOUNT_ID_PATH_VARIABLE); | ||
| 52 | + final var id = Convert.toInt(idStr, 0); | ||
| 53 | + if (id <= 0) { | ||
| 54 | + throw ClientEndExceptions.ResourceNotFound.build("小程序用户不存在"); | ||
| 55 | + } | ||
| 56 | + final var response = mealOrderServiceRpcClient.getMpAccountById(LoginContextHolder.getEnterpriseId(), id); | ||
| 57 | + if (response == null) { | ||
| 58 | + log.info("Resource not found; id:{}", id); | ||
| 59 | + throw ClientEndExceptions.ResourceNotFound.build("小程序用户不存在"); | ||
| 60 | + } | ||
| 61 | + httpServletRequest.setAttribute(PathVariableResourceConstants.INJECTED_MP_ACCOUNT, response); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /* | ||
| 65 | + 注入Client | ||
| 66 | + */ | ||
| 67 | + if (pathVariables.containsKey(PathVariableResourceConstants.CLIENT_ID_PATH_VARIABLE)) { | ||
| 68 | + final var idStr = pathVariables.get(PathVariableResourceConstants.CLIENT_ID_PATH_VARIABLE); | ||
| 69 | + final var id = Convert.toInt(idStr, 0); | ||
| 70 | + if (id <= 0) { | ||
| 71 | + throw ClientEndExceptions.ResourceNotFound.build("项目点不存在"); | ||
| 72 | + } | ||
| 73 | + final var response = clientInventoryServiceRpcClient.getClientById(LoginContextHolder.getEnterpriseId(), id); | ||
| 74 | + if (response == null) { | ||
| 75 | + log.info("Resource not found; id:{}", id); | ||
| 76 | + throw ClientEndExceptions.ResourceNotFound.build("项目点不存在"); | ||
| 77 | + } | ||
| 78 | + httpServletRequest.setAttribute(PathVariableResourceConstants.INJECTED_CLIENT, response.getClient()); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /* | ||
| 82 | + 注入Diner | ||
| 83 | + */ | ||
| 84 | + if (pathVariables.containsKey(PathVariableResourceConstants.DINER_ID_PATH_VARIABLE)) { | ||
| 85 | + final var idStr = pathVariables.get(PathVariableResourceConstants.DINER_ID_PATH_VARIABLE); | ||
| 86 | + final var id = Convert.toInt(idStr, 0); | ||
| 87 | + if (id <= 0) { | ||
| 88 | + throw ClientEndExceptions.ResourceNotFound.build("就餐人不存在"); | ||
| 89 | + } | ||
| 90 | + final var response = mealOrderServiceRpcClient.getDinerById(LoginContextHolder.getEnterpriseId(), id); | ||
| 91 | + if (response == null) { | ||
| 92 | + log.info("Resource not found; id:{}", id); | ||
| 93 | + throw ClientEndExceptions.ResourceNotFound.build("就餐人不存在"); | ||
| 94 | + } | ||
| 95 | + httpServletRequest.setAttribute(PathVariableResourceConstants.INJECTED_DINER, response); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + /* | ||
| 99 | + 注入GradeClass | ||
| 100 | + */ | ||
| 101 | + if (pathVariables.containsKey(PathVariableResourceConstants.GRADE_CLASS_ID_PATH_VARIABLE)) { | ||
| 102 | + final var idStr = pathVariables.get(PathVariableResourceConstants.GRADE_CLASS_ID_PATH_VARIABLE); | ||
| 103 | + final var id = Convert.toInt(idStr, 0); | ||
| 104 | + if (id <= 0) { | ||
| 105 | + throw ClientEndExceptions.ResourceNotFound.build("年级班级不存在"); | ||
| 106 | + } | ||
| 107 | + final var response = mealOrderServiceRpcClient.getGradeClassById(LoginContextHolder.getEnterpriseId(), id); | ||
| 108 | + if (response == null) { | ||
| 109 | + log.info("Resource not found; id:{}", id); | ||
| 110 | + throw ClientEndExceptions.ResourceNotFound.build("年级班级不存在"); | ||
| 111 | + } | ||
| 112 | + httpServletRequest.setAttribute(PathVariableResourceConstants.INJECTED_GRADE_CLASS, response); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + /* | ||
| 116 | + 注入MealOrder | ||
| 117 | + */ | ||
| 118 | + if (pathVariables.containsKey(PathVariableResourceConstants.MEAL_ORDER_ID_PATH_VARIABLE)) { | ||
| 119 | + final var idStr = pathVariables.get(PathVariableResourceConstants.MEAL_ORDER_ID_PATH_VARIABLE); | ||
| 120 | + final var id = Convert.toInt(idStr, 0); | ||
| 121 | + if (id <= 0) { | ||
| 122 | + throw ClientEndExceptions.ResourceNotFound.build("订餐记录不存在"); | ||
| 123 | + } | ||
| 124 | + final var response = mealOrderServiceRpcClient.getMealOrderById(LoginContextHolder.getEnterpriseId(), id); | ||
| 125 | + if (response == null) { | ||
| 126 | + log.info("Resource not found; id:{}", id); | ||
| 127 | + throw ClientEndExceptions.ResourceNotFound.build("订餐记录不存在"); | ||
| 128 | + } | ||
| 129 | + httpServletRequest.setAttribute(PathVariableResourceConstants.INJECTED_MEAL_ORDER, response); | ||
| 130 | + } | ||
| 36 | return true; | 131 | return true; |
| 37 | } | 132 | } |
| 38 | } | 133 | } | ... | ... |
| ... | @@ -21,8 +21,8 @@ import com.infoloop.tianting.server.message.data.CustomerAlterRoomNoData; | ... | @@ -21,8 +21,8 @@ import com.infoloop.tianting.server.message.data.CustomerAlterRoomNoData; |
| 21 | import com.infoloop.tianting.server.session.UserSessionKey; | 21 | import com.infoloop.tianting.server.session.UserSessionKey; |
| 22 | import com.infoloop.tianting.server.session.UserTypeEnum; | 22 | import com.infoloop.tianting.server.session.UserTypeEnum; |
| 23 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; | 23 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; |
| 24 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 24 | import com.infoloop.tianting.service.client.ClientResourceTagServiceRpcClient; | 25 | import com.infoloop.tianting.service.client.ClientResourceTagServiceRpcClient; |
| 25 | -import com.infoloop.tianting.service.client.InventoryServiceRpcClient; | ||
| 26 | import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; | 26 | import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; |
| 27 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; | 27 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; |
| 28 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; | 28 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; |
| ... | @@ -48,7 +48,7 @@ public class HisCustomerRoomNoTask { | ... | @@ -48,7 +48,7 @@ public class HisCustomerRoomNoTask { |
| 48 | 48 | ||
| 49 | private final ClientResourceTagServiceRpcClient clientResourceTagServiceRpcClient; | 49 | private final ClientResourceTagServiceRpcClient clientResourceTagServiceRpcClient; |
| 50 | 50 | ||
| 51 | - private final InventoryServiceRpcClient inventoryServiceRpcClient; | 51 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; |
| 52 | 52 | ||
| 53 | private final MeiZhongYiHeServiceClient meiZhongYiHeServiceClient; | 53 | private final MeiZhongYiHeServiceClient meiZhongYiHeServiceClient; |
| 54 | 54 | ||
| ... | @@ -62,7 +62,7 @@ public class HisCustomerRoomNoTask { | ... | @@ -62,7 +62,7 @@ public class HisCustomerRoomNoTask { |
| 62 | 62 | ||
| 63 | final var stallIdsList = clientResourceTagServiceRpcClient.getUserResources(cOperatorById.getEnterpriseId(), cOperatorById.getClientId(), cOperatorById.getId()).getStallIdsList(); | 63 | final var stallIdsList = clientResourceTagServiceRpcClient.getUserResources(cOperatorById.getEnterpriseId(), cOperatorById.getClientId(), cOperatorById.getId()).getStallIdsList(); |
| 64 | 64 | ||
| 65 | - final var stalls = inventoryServiceRpcClient.getStallsByIds(cOperatorById.getEnterpriseId(), stallIdsList).getClientsList(); | 65 | + final var stalls = clientInventoryServiceRpcClient.getStallsByIds(cOperatorById.getEnterpriseId(), stallIdsList).getClientsList(); |
| 66 | 66 | ||
| 67 | final var queryOrderDto = OrderDbDTO.QueryOrderByConditionDto.builder() | 67 | final var queryOrderDto = OrderDbDTO.QueryOrderByConditionDto.builder() |
| 68 | .enterpriseId(loginInfo.getEnterpriseId()) | 68 | .enterpriseId(loginInfo.getEnterpriseId()) | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -10,7 +10,7 @@ import java.util.List; | ... | @@ -10,7 +10,7 @@ import java.util.List; |
| 10 | 10 | ||
| 11 | @Data | 11 | @Data |
| 12 | @ApiModel(description = "院区DTO") | 12 | @ApiModel(description = "院区DTO") |
| 13 | -public class InventoryDbDTO { | 13 | +public class ClientInventoryDbDTO { |
| 14 | 14 | ||
| 15 | @Data | 15 | @Data |
| 16 | @Builder | 16 | @Builder |
| ... | @@ -30,7 +30,7 @@ public class InventoryDbDTO { | ... | @@ -30,7 +30,7 @@ public class InventoryDbDTO { |
| 30 | private Integer allowedPaid; | 30 | private Integer allowedPaid; |
| 31 | private Integer regionId; | 31 | private Integer regionId; |
| 32 | private ClientType type; | 32 | private ClientType type; |
| 33 | - CustomerSource customerSource; | 33 | + private CustomerSource customerSource; |
| 34 | private boolean isDelivery; | 34 | private boolean isDelivery; |
| 35 | } | 35 | } |
| 36 | 36 | ... | ... |
| 1 | +package com.infoloop.tianting.model.dto; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.annotation.RequestKeyParam; | ||
| 4 | +import io.swagger.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +import javax.validation.constraints.NotEmpty; | ||
| 9 | +import javax.validation.constraints.NotNull; | ||
| 10 | + | ||
| 11 | +@Data | ||
| 12 | +@ApiModel(description = "就餐人DTO") | ||
| 13 | +public class DinerDTO { | ||
| 14 | + | ||
| 15 | + @Data | ||
| 16 | + @ApiModel(description = "查询唯一就餐人") | ||
| 17 | + public static class QueryUniqueDinerDTO { | ||
| 18 | + | ||
| 19 | + @ApiModelProperty(value = "学号") | ||
| 20 | + @NotEmpty(message = "学号不能为空") | ||
| 21 | + private String studentNo; | ||
| 22 | + | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + @Data | ||
| 27 | + @ApiModel(description = "添加就餐人") | ||
| 28 | + public static class CreateDinerDTO { | ||
| 29 | + | ||
| 30 | + @ApiModelProperty(value = "学校编码") | ||
| 31 | + @NotEmpty(message = "学校编码不能为空") | ||
| 32 | + @RequestKeyParam | ||
| 33 | + private String clientCode; | ||
| 34 | + | ||
| 35 | + @ApiModelProperty(value = "班级") | ||
| 36 | + @NotNull(message = "班级不能为空") | ||
| 37 | + @RequestKeyParam | ||
| 38 | + private Integer classId; | ||
| 39 | + | ||
| 40 | + @ApiModelProperty(value = "学号") | ||
| 41 | + @NotEmpty(message = "学号不能为空") | ||
| 42 | + @RequestKeyParam | ||
| 43 | + private String studentNo; | ||
| 44 | + | ||
| 45 | + @ApiModelProperty(value = "姓名") | ||
| 46 | + @NotEmpty(message = "姓名不能为空") | ||
| 47 | + private String name; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Data | ||
| 51 | + @ApiModel(description = "修改就餐人") | ||
| 52 | + public static class UpdateDinerDTO { | ||
| 53 | + | ||
| 54 | + @ApiModelProperty(value = "学校编码") | ||
| 55 | + @NotEmpty(message = "学校编码不能为空") | ||
| 56 | + private String clientCode; | ||
| 57 | + | ||
| 58 | + @ApiModelProperty(value = "班级") | ||
| 59 | + @NotNull(message = "班级不能为空") | ||
| 60 | + private Integer classId; | ||
| 61 | + | ||
| 62 | + @ApiModelProperty(value = "学号") | ||
| 63 | + private String studentNo; | ||
| 64 | + | ||
| 65 | + @ApiModelProperty(value = "姓名") | ||
| 66 | + private String name; | ||
| 67 | + } | ||
| 68 | +} |
| ... | @@ -2,7 +2,7 @@ package com.infoloop.tianting.model.dto; | ... | @@ -2,7 +2,7 @@ package com.infoloop.tianting.model.dto; |
| 2 | 2 | ||
| 3 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; | 3 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; |
| 4 | import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; | 4 | import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; |
| 5 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto; | 5 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientDto; |
| 6 | import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerDetailDto; | 6 | import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerDetailDto; |
| 7 | import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice; | 7 | import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice; |
| 8 | import io.swagger.annotations.ApiModel; | 8 | import io.swagger.annotations.ApiModel; | ... | ... |
| 1 | +package com.infoloop.tianting.model.dto; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.annotation.RequestKeyParam; | ||
| 4 | +import com.infoloop.tianting.enums.QueryMealOrderStatusEnum; | ||
| 5 | +import io.swagger.annotations.ApiModel; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +import javax.validation.Valid; | ||
| 9 | +import javax.validation.constraints.NotEmpty; | ||
| 10 | +import javax.validation.constraints.NotNull; | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +@Data | ||
| 14 | +@ApiModel(description = "订餐DTO") | ||
| 15 | +public class MealOrderDTO { | ||
| 16 | + | ||
| 17 | + @Data | ||
| 18 | + @ApiModel(description = "查询订餐记录") | ||
| 19 | + public static class QueryMealOrderDTO { | ||
| 20 | + | ||
| 21 | + @NotNull(message = "status不能为空") | ||
| 22 | + private QueryMealOrderStatusEnum status; | ||
| 23 | + | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @Data | ||
| 27 | + @ApiModel(description = "创建订餐记录") | ||
| 28 | + public static class CreateMealOrderDTO { | ||
| 29 | + | ||
| 30 | + @NotNull(message = "就餐人 ID 不能为空") | ||
| 31 | + @RequestKeyParam | ||
| 32 | + private Integer dinerId; | ||
| 33 | + | ||
| 34 | + @NotEmpty(message = "订餐详情不能为空") | ||
| 35 | + @NotNull(message = "订餐详情不能为空") | ||
| 36 | + @Valid | ||
| 37 | + private List<CreateMeals> meals; | ||
| 38 | + | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @Data | ||
| 42 | + @ApiModel(description = "创建订餐记录详情") | ||
| 43 | + public static class CreateMeals { | ||
| 44 | + | ||
| 45 | + @NotEmpty(message = "日期不能为空") | ||
| 46 | + private String date; | ||
| 47 | + | ||
| 48 | + @NotEmpty(message = "菜单不能为空") | ||
| 49 | + private String menu; | ||
| 50 | + } | ||
| 51 | +} |
| 1 | +package com.infoloop.tianting.model.dto; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.mealorderservice.MpAccountGenderEnum; | ||
| 4 | +import io.swagger.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Data | ||
| 9 | +@ApiModel(description = "小程序用户DTO") | ||
| 10 | +public class MpAccountDTO { | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + @Data | ||
| 14 | + @ApiModel(description = "修改小程序用户") | ||
| 15 | + public static class ModifyMpAccountDTO { | ||
| 16 | + | ||
| 17 | + @ApiModelProperty(value = "昵称") | ||
| 18 | + private String nickName; | ||
| 19 | + | ||
| 20 | + @ApiModelProperty(value = "头像") | ||
| 21 | + private String avatarUrl; | ||
| 22 | + | ||
| 23 | + @ApiModelProperty(value = "性别") | ||
| 24 | + private MpAccountGenderEnum gender; | ||
| 25 | + } | ||
| 26 | +} |
| ... | @@ -27,6 +27,10 @@ public class PermissionDTO { | ... | @@ -27,6 +27,10 @@ public class PermissionDTO { |
| 27 | @Builder.Default | 27 | @Builder.Default |
| 28 | private String openCode = ""; | 28 | private String openCode = ""; |
| 29 | @Builder.Default | 29 | @Builder.Default |
| 30 | + private boolean shouldLoginWithOpenId = false; | ||
| 31 | + @Builder.Default | ||
| 32 | + private String openId = ""; | ||
| 33 | + @Builder.Default | ||
| 30 | private boolean shouldLoginWithKdsEmail = false; | 34 | private boolean shouldLoginWithKdsEmail = false; |
| 31 | @Builder.Default | 35 | @Builder.Default |
| 32 | private String email = ""; | 36 | private String email = ""; | ... | ... |
| 1 | +package com.infoloop.tianting.model.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Builder; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Data | ||
| 9 | +@ApiModel(value = "订餐规则") | ||
| 10 | +@Builder | ||
| 11 | +public class DeliveryRuleVO { | ||
| 12 | + | ||
| 13 | + @ApiModelProperty(value = "订餐开始时间") | ||
| 14 | + private String startTime; | ||
| 15 | + | ||
| 16 | + @ApiModelProperty(value = "订餐结束时间") | ||
| 17 | + private String endTime; | ||
| 18 | + | ||
| 19 | + private Boolean monday; | ||
| 20 | + private Boolean tuesday; | ||
| 21 | + private Boolean wednesday; | ||
| 22 | + private Boolean thursday; | ||
| 23 | + private Boolean friday; | ||
| 24 | + private Boolean saturday; | ||
| 25 | + private Boolean sunday; | ||
| 26 | +} |
| 1 | +package com.infoloop.tianting.model.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Builder; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Data | ||
| 9 | +@ApiModel(value = "就餐人信息") | ||
| 10 | +@Builder | ||
| 11 | +public class DinerVO { | ||
| 12 | + | ||
| 13 | + @ApiModelProperty(value = "就餐人 ID") | ||
| 14 | + private int id; | ||
| 15 | + | ||
| 16 | + @ApiModelProperty(value = "企业 ID") | ||
| 17 | + private int enterpriseId; | ||
| 18 | + | ||
| 19 | + @ApiModelProperty(value = "就餐人学校 ID") | ||
| 20 | + private int clientId; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty(value = "就餐人学校代码") | ||
| 23 | + private String clientCode; | ||
| 24 | + | ||
| 25 | + @ApiModelProperty(value = "就餐人学校名称") | ||
| 26 | + private String clientName; | ||
| 27 | + | ||
| 28 | + @ApiModelProperty(value = "就餐人班级 ID") | ||
| 29 | + private int classId; | ||
| 30 | + | ||
| 31 | + @ApiModelProperty(value = "就餐人年级名称") | ||
| 32 | + private String gradeName; | ||
| 33 | + | ||
| 34 | + @ApiModelProperty(value = "就餐人班级名称") | ||
| 35 | + private String className; | ||
| 36 | + | ||
| 37 | + @ApiModelProperty(value = "就餐人学号") | ||
| 38 | + private String studentNo; | ||
| 39 | + | ||
| 40 | + @ApiModelProperty(value = "就餐人姓名") | ||
| 41 | + private String name; | ||
| 42 | + | ||
| 43 | + @ApiModelProperty(value = "是否已预定") | ||
| 44 | + private boolean isReserve; | ||
| 45 | +} |
| 1 | +package com.infoloop.tianting.model.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Builder; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Data | ||
| 9 | +@ApiModel(value = "班级年级信息") | ||
| 10 | +@Builder | ||
| 11 | +public class GradeClassVO { | ||
| 12 | + | ||
| 13 | + @ApiModelProperty("ID") | ||
| 14 | + private Integer id; | ||
| 15 | + | ||
| 16 | + @ApiModelProperty("企业 ID") | ||
| 17 | + private Integer enterpriseId; | ||
| 18 | + | ||
| 19 | + @ApiModelProperty("年级") | ||
| 20 | + private String gradeName; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty("班级") | ||
| 23 | + private String className; | ||
| 24 | +} |
| 1 | +package com.infoloop.tianting.model.vo; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.mealorderservice.MealOrderOrderMethodEnum; | ||
| 4 | +import io.swagger.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import lombok.Builder; | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +@Data | ||
| 12 | +@Builder | ||
| 13 | +@ApiModel(value = "订餐记录信息") | ||
| 14 | +public class MealOrderVO { | ||
| 15 | + | ||
| 16 | + @ApiModelProperty("ID") | ||
| 17 | + private int id; | ||
| 18 | + | ||
| 19 | + @ApiModelProperty("项目点ID") | ||
| 20 | + private int clientId; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty("餐单ID") | ||
| 23 | + private int menuId; | ||
| 24 | + | ||
| 25 | + @ApiModelProperty("用户ID") | ||
| 26 | + private int accountId; | ||
| 27 | + | ||
| 28 | + @ApiModelProperty("订餐方式") | ||
| 29 | + private MealOrderOrderMethodEnum orderMethod; | ||
| 30 | + | ||
| 31 | + @ApiModelProperty("就餐人 id") | ||
| 32 | + private int dinerId; | ||
| 33 | + | ||
| 34 | + @ApiModelProperty("就餐人名称") | ||
| 35 | + private String dinerName; | ||
| 36 | + | ||
| 37 | + @ApiModelProperty("项目点名称") | ||
| 38 | + private String clientName; | ||
| 39 | + | ||
| 40 | + @ApiModelProperty("年级名称") | ||
| 41 | + private String gradeName; | ||
| 42 | + | ||
| 43 | + @ApiModelProperty("班级名称") | ||
| 44 | + private String className; | ||
| 45 | + | ||
| 46 | + @ApiModelProperty("学生学号") | ||
| 47 | + private String studentNo; | ||
| 48 | + | ||
| 49 | + @ApiModelProperty("订餐时间") | ||
| 50 | + private String reserveDate; | ||
| 51 | + | ||
| 52 | + @ApiModelProperty("订餐餐单") | ||
| 53 | + private List<Meals> meals; | ||
| 54 | + | ||
| 55 | + @Data | ||
| 56 | + @Builder | ||
| 57 | + @ApiModel(description = "订餐信息") | ||
| 58 | + public static class Meals { | ||
| 59 | + | ||
| 60 | + @ApiModelProperty("订餐日期") | ||
| 61 | + private String date; | ||
| 62 | + | ||
| 63 | + @ApiModelProperty("订餐餐单") | ||
| 64 | + private String menu; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + | ||
| 69 | +} |
| 1 | +package com.infoloop.tianting.model.vo; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.mealorderservice.MpAccountGenderEnum; | ||
| 4 | +import io.swagger.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import lombok.Builder; | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | +@Data | ||
| 10 | +@ApiModel(value = "小程序账号信息") | ||
| 11 | +@Builder | ||
| 12 | +public class MpAccountVO { | ||
| 13 | + | ||
| 14 | + @ApiModelProperty("ID") | ||
| 15 | + private Integer id; | ||
| 16 | + | ||
| 17 | + @ApiModelProperty("企业 ID") | ||
| 18 | + private Integer enterpriseId; | ||
| 19 | + | ||
| 20 | + @ApiModelProperty("openId") | ||
| 21 | + private String openId; | ||
| 22 | + | ||
| 23 | + @ApiModelProperty("unionId") | ||
| 24 | + private String unionId; | ||
| 25 | + | ||
| 26 | + @ApiModelProperty("昵称") | ||
| 27 | + private String nickname; | ||
| 28 | + | ||
| 29 | + @ApiModelProperty("头像地址") | ||
| 30 | + private String avatarUrl; | ||
| 31 | + | ||
| 32 | + @ApiModelProperty("性别") | ||
| 33 | + private MpAccountGenderEnum gender; | ||
| 34 | + | ||
| 35 | + @ApiModelProperty("手机号") | ||
| 36 | + private String phoneNumber; | ||
| 37 | +} |
| 1 | +package com.infoloop.tianting.server; | ||
| 2 | + | ||
| 3 | +import com.aliyun.oss.OSS; | ||
| 4 | +import com.aliyun.oss.OSSClientBuilder; | ||
| 5 | +import com.aliyun.oss.model.GetObjectRequest; | ||
| 6 | + | ||
| 7 | +import java.io.ByteArrayInputStream; | ||
| 8 | +import java.io.File; | ||
| 9 | +import java.io.InputStream; | ||
| 10 | + | ||
| 11 | +public class OssStorageService implements StorageService{ | ||
| 12 | + private final OSS ossClient; | ||
| 13 | + | ||
| 14 | + public OssStorageService(String endpoint, String accessKeyId, String accessKeySecret) { | ||
| 15 | + this.ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + @Override | ||
| 19 | + public void putObject(String bucketName, String key, byte[] data) { | ||
| 20 | + ossClient.putObject(bucketName, key, new ByteArrayInputStream(data)); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + @Override | ||
| 24 | + public void putObject(String bucketName, String key, File file) { | ||
| 25 | + ossClient.putObject(bucketName, key, file); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + public void putObject(String bucketName, String key, InputStream stream) { | ||
| 30 | + ossClient.putObject(bucketName, key, stream); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public InputStream getObjectInputStream(String bucketName, String key) { | ||
| 35 | + return ossClient.getObject(new GetObjectRequest(bucketName, key)).getObjectContent(); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + @Override | ||
| 39 | + public void close() throws Exception { | ||
| 40 | + ossClient.shutdown(); | ||
| 41 | + } | ||
| 42 | +} |
| 1 | +package com.infoloop.tianting.server; | ||
| 2 | + | ||
| 3 | +import java.io.File; | ||
| 4 | +import java.io.InputStream; | ||
| 5 | + | ||
| 6 | +public interface StorageService extends AutoCloseable { | ||
| 7 | + | ||
| 8 | + void putObject(String bucketName, String key, byte[] data) throws Exception; | ||
| 9 | + | ||
| 10 | + void putObject(String bucketName, String key, File file) throws Exception; | ||
| 11 | + | ||
| 12 | + void putObject(String bucketName, String key, InputStream stream) throws Exception; | ||
| 13 | + | ||
| 14 | + InputStream getObjectInputStream(String bucketName, String key); | ||
| 15 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +package com.infoloop.tianting.server; | ||
| 2 | + | ||
| 3 | +public class StorageServiceFactory { | ||
| 4 | + public static StorageService createStorageService(String endpoint, String accessKey, String accessSecret) { | ||
| 5 | + if (endpoint.contains("aliyuncs.com")) { | ||
| 6 | + return new OssStorageService(endpoint, accessKey, accessSecret); | ||
| 7 | + } else { | ||
| 8 | + throw new IllegalArgumentException("Unsupported storage type: " + endpoint); | ||
| 9 | + } | ||
| 10 | + } | ||
| 11 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +package com.infoloop.tianting.service; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientDto; | ||
| 4 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientTableCodeDto; | ||
| 5 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.TableCodeQueryConditionDto; | ||
| 6 | + | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 9 | +public interface ClientInventoryService { | ||
| 10 | + | ||
| 11 | + ClientDto getClientById(Integer enterpriseId, Integer clientId); | ||
| 12 | + | ||
| 13 | + List<ClientDto> getStallsByClientId(Integer enterpriseId, Integer clientId); | ||
| 14 | + | ||
| 15 | + List<ClientTableCodeDto> queryClientTableCodesByCondition(TableCodeQueryConditionDto tableCodeQueryConditionDto); | ||
| 16 | + | ||
| 17 | + List<ClientDto> getClientsByCodes(List<String> codes); | ||
| 18 | +} |
| 1 | +package com.infoloop.tianting.service; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 4 | +import com.infoloop.tianting.mealorderservice.SingleDinerRpcResponse; | ||
| 5 | +import com.infoloop.tianting.mealorderservice.SingleGradeClassRpcResponse; | ||
| 6 | +import com.infoloop.tianting.model.common.CreatedResult; | ||
| 7 | +import com.infoloop.tianting.model.dto.DinerDTO; | ||
| 8 | +import com.infoloop.tianting.model.vo.DinerVO; | ||
| 9 | +import com.infoloop.tianting.model.vo.GradeClassVO; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +public interface DinerService { | ||
| 14 | + | ||
| 15 | + List<DinerVO> getMpAccountDiners(); | ||
| 16 | + | ||
| 17 | + CreatedResult<DinerVO> createMpAccountDiner(DinerDTO.CreateDinerDTO createDinerDTO); | ||
| 18 | + | ||
| 19 | + List<GradeClassVO> getClientGradeClasses(SingleClientRpcResponse client); | ||
| 20 | + | ||
| 21 | + void updateMpAccountDiner(SingleDinerRpcResponse diner, DinerDTO.UpdateDinerDTO updateDinerDTO); | ||
| 22 | + | ||
| 23 | + void deleteMpAccountDiner(SingleDinerRpcResponse diner); | ||
| 24 | + | ||
| 25 | + DinerVO getClientClassDiner(SingleClientRpcResponse client, SingleGradeClassRpcResponse gradeClass, String studentNo); | ||
| 26 | +} |
| 1 | -package com.infoloop.tianting.service; | ||
| 2 | - | ||
| 3 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto; | ||
| 4 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientTableCodeDto; | ||
| 5 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto; | ||
| 6 | - | ||
| 7 | -import java.util.List; | ||
| 8 | - | ||
| 9 | -public interface InventoryService { | ||
| 10 | - | ||
| 11 | - ClientDto getClientById(Integer enterpriseId, Integer clientId); | ||
| 12 | - | ||
| 13 | - List<ClientDto> getStallsByClientId(Integer enterpriseId, Integer clientId); | ||
| 14 | - | ||
| 15 | - List<ClientTableCodeDto> queryClientTableCodesByCondition( | ||
| 16 | - TableCodeQueryConditionDto tableCodeQueryConditionDto); | ||
| 17 | - | ||
| 18 | -} |
| 1 | package com.infoloop.tianting.service; | 1 | package com.infoloop.tianting.service; |
| 2 | 2 | ||
| 3 | import cn.dev33.satoken.stp.SaTokenInfo; | 3 | import cn.dev33.satoken.stp.SaTokenInfo; |
| 4 | +import com.infoloop.tianting.mealorderservice.SingleMpAccountRpcResponse; | ||
| 5 | +import com.infoloop.tianting.model.dto.MpAccountDTO; | ||
| 4 | import com.infoloop.tianting.model.dto.PermissionDTO.LoginDto; | 6 | import com.infoloop.tianting.model.dto.PermissionDTO.LoginDto; |
| 7 | +import com.infoloop.tianting.model.vo.MpAccountVO; | ||
| 5 | 8 | ||
| 6 | import java.security.NoSuchAlgorithmException; | 9 | import java.security.NoSuchAlgorithmException; |
| 7 | 10 | ||
| 8 | public interface LoginService { | 11 | public interface LoginService { |
| 9 | SaTokenInfo login(LoginDto loginDto) throws NoSuchAlgorithmException; | 12 | SaTokenInfo login(LoginDto loginDto) throws NoSuchAlgorithmException; |
| 13 | + | ||
| 14 | + MpAccountVO getMpAccountByOpenId(String openId); | ||
| 15 | + | ||
| 16 | + void updateMpAccount(SingleMpAccountRpcResponse mpAccount, MpAccountDTO.ModifyMpAccountDTO modifyMpAccountDTO); | ||
| 10 | } | 17 | } | ... | ... |
| 1 | +package com.infoloop.tianting.service; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; | ||
| 4 | +import com.infoloop.tianting.model.common.CreatedResult; | ||
| 5 | +import com.infoloop.tianting.model.dto.MealOrderDTO; | ||
| 6 | +import com.infoloop.tianting.model.vo.DeliveryRuleVO; | ||
| 7 | +import com.infoloop.tianting.model.vo.MealOrderVO; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +public interface MealOrderService { | ||
| 12 | + | ||
| 13 | + List<MealOrderVO> queryMealOrders(MealOrderDTO.QueryMealOrderDTO queryMealOrderDTO); | ||
| 14 | + | ||
| 15 | + CreatedResult<MealOrderVO> createMealOrder(MealOrderDTO.CreateMealOrderDTO createMealOrderDTO); | ||
| 16 | + | ||
| 17 | + MealOrderVO getMealOrderById(SingleMealOrderRpcResponse mealOrder); | ||
| 18 | + | ||
| 19 | + DeliveryRuleVO getDeliveryRule(); | ||
| 20 | +} |
| 1 | package com.infoloop.tianting.service; | 1 | package com.infoloop.tianting.service; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 4 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsDto; | 5 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsDto; |
| 5 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsResponseDto; | 6 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsResponseDto; |
| 6 | import com.infoloop.tianting.model.dto.MenuDbDTO.MenuDetailDto; | 7 | import com.infoloop.tianting.model.dto.MenuDbDTO.MenuDetailDto; |
| ... | @@ -24,4 +25,6 @@ public interface MenuService { | ... | @@ -24,4 +25,6 @@ public interface MenuService { |
| 24 | BatchCreateMenuRefsResponseDto batchCreateMenuRefs(BatchCreateMenuRefsDto batchCreateMenuRefsDto); | 25 | BatchCreateMenuRefsResponseDto batchCreateMenuRefs(BatchCreateMenuRefsDto batchCreateMenuRefsDto); |
| 25 | 26 | ||
| 26 | List<Integer> queryMenuSkuIdsByStallId(int enterpriseId, int stallId); | 27 | List<Integer> queryMenuSkuIdsByStallId(int enterpriseId, int stallId); |
| 28 | + | ||
| 29 | + String queryClientLatestMealMenuRecord(SingleClientRpcResponse client); | ||
| 27 | } | 30 | } | ... | ... |
| ... | @@ -2,6 +2,7 @@ package com.infoloop.tianting.service.client; | ... | @@ -2,6 +2,7 @@ package com.infoloop.tianting.service.client; |
| 2 | 2 | ||
| 3 | import com.infoloop.tianting.clientinventoryservice.GetClientByIdRpcRequest; | 3 | import com.infoloop.tianting.clientinventoryservice.GetClientByIdRpcRequest; |
| 4 | import com.infoloop.tianting.clientinventoryservice.GetClientByIdRpcResponse; | 4 | import com.infoloop.tianting.clientinventoryservice.GetClientByIdRpcResponse; |
| 5 | +import com.infoloop.tianting.clientinventoryservice.GetClientsByCodesRpcRequest; | ||
| 5 | import com.infoloop.tianting.clientinventoryservice.GetClientsByIdsRpcRequest; | 6 | import com.infoloop.tianting.clientinventoryservice.GetClientsByIdsRpcRequest; |
| 6 | import com.infoloop.tianting.clientinventoryservice.GetClientsByIdsRpcResponse; | 7 | import com.infoloop.tianting.clientinventoryservice.GetClientsByIdsRpcResponse; |
| 7 | import com.infoloop.tianting.clientinventoryservice.GetStallsByClientIdRpcRequest; | 8 | import com.infoloop.tianting.clientinventoryservice.GetStallsByClientIdRpcRequest; |
| ... | @@ -10,8 +11,9 @@ import com.infoloop.tianting.clientinventoryservice.GetStallsByIdsRpcRequest; | ... | @@ -10,8 +11,9 @@ import com.infoloop.tianting.clientinventoryservice.GetStallsByIdsRpcRequest; |
| 10 | import com.infoloop.tianting.clientinventoryservice.GetStallsByIdsRpcResponse; | 11 | import com.infoloop.tianting.clientinventoryservice.GetStallsByIdsRpcResponse; |
| 11 | import com.infoloop.tianting.clientinventoryservice.QueryClientTableCodesByConditionRpcRequest; | 12 | import com.infoloop.tianting.clientinventoryservice.QueryClientTableCodesByConditionRpcRequest; |
| 12 | import com.infoloop.tianting.clientinventoryservice.QueryClientTableCodesByConditionRpcResponse; | 13 | import com.infoloop.tianting.clientinventoryservice.QueryClientTableCodesByConditionRpcResponse; |
| 14 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 13 | import com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServiceRpcGrpc; | 15 | import com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServiceRpcGrpc; |
| 14 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto; | 16 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.TableCodeQueryConditionDto; |
| 15 | import lombok.RequiredArgsConstructor; | 17 | import lombok.RequiredArgsConstructor; |
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| ... | @@ -20,7 +22,7 @@ import java.util.List; | ... | @@ -20,7 +22,7 @@ import java.util.List; |
| 20 | 22 | ||
| 21 | @Service | 23 | @Service |
| 22 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) | 24 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) |
| 23 | -public class InventoryServiceRpcClient { | 25 | +public class ClientInventoryServiceRpcClient { |
| 24 | 26 | ||
| 25 | private final TiantingClientInventoryServiceRpcGrpc.TiantingClientInventoryServiceRpcBlockingStub | 27 | private final TiantingClientInventoryServiceRpcGrpc.TiantingClientInventoryServiceRpcBlockingStub |
| 26 | inventoryServiceRpcBlockingStub; | 28 | inventoryServiceRpcBlockingStub; |
| ... | @@ -43,6 +45,15 @@ public class InventoryServiceRpcClient { | ... | @@ -43,6 +45,15 @@ public class InventoryServiceRpcClient { |
| 43 | return inventoryServiceRpcBlockingStub.getClientsByIds(request); | 45 | return inventoryServiceRpcBlockingStub.getClientsByIds(request); |
| 44 | } | 46 | } |
| 45 | 47 | ||
| 48 | + public List<SingleClientRpcResponse> getClientsByCodes(Integer enterpriseId, List<String> codes) { | ||
| 49 | + final var request = GetClientsByCodesRpcRequest.newBuilder() | ||
| 50 | + .setEnterpriseId(enterpriseId) | ||
| 51 | + .addAllCodes(codes) | ||
| 52 | + .setIncludeDeleted(false) | ||
| 53 | + .build(); | ||
| 54 | + return inventoryServiceRpcBlockingStub.getClientsByCodes(request).getClientsList(); | ||
| 55 | + } | ||
| 56 | + | ||
| 46 | public GetStallsByIdsRpcResponse getStallsByIds(Integer enterpriseId, List<Integer> stallIds) { | 57 | public GetStallsByIdsRpcResponse getStallsByIds(Integer enterpriseId, List<Integer> stallIds) { |
| 47 | final var request = GetStallsByIdsRpcRequest.newBuilder() | 58 | final var request = GetStallsByIdsRpcRequest.newBuilder() |
| 48 | .setEnterpriseId(enterpriseId) | 59 | .setEnterpriseId(enterpriseId) | ... | ... |
| 1 | package com.infoloop.tianting.service.client; | 1 | package com.infoloop.tianting.service.client; |
| 2 | 2 | ||
| 3 | +import com.infoloop.tianting.deliveryruleservice.DeliveryTemplateTypeEnum; | ||
| 3 | import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcRequest; | 4 | import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcRequest; |
| 4 | import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcResponse; | 5 | import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcResponse; |
| 6 | +import com.infoloop.tianting.deliveryruleservice.GetDefaultDeliveryTemplateAndRuleRpcRequest; | ||
| 7 | +import com.infoloop.tianting.deliveryruleservice.GetDefaultDeliveryTemplateAndRuleRpcResponse; | ||
| 5 | import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcRequest; | 8 | import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcRequest; |
| 6 | import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcResponse; | 9 | import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcResponse; |
| 7 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; | 10 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; |
| ... | @@ -40,5 +43,14 @@ public class DeliveryRuleServiceRpcClient { | ... | @@ -40,5 +43,14 @@ public class DeliveryRuleServiceRpcClient { |
| 40 | return deliveryRuleServiceRpcBlockingStub.getClientLabelsByIds(request); | 43 | return deliveryRuleServiceRpcBlockingStub.getClientLabelsByIds(request); |
| 41 | } | 44 | } |
| 42 | 45 | ||
| 46 | + public GetDefaultDeliveryTemplateAndRuleRpcResponse getDefaultDeliveryTemplateAndRule(int enterpriseId) { | ||
| 47 | + final var request = GetDefaultDeliveryTemplateAndRuleRpcRequest | ||
| 48 | + .newBuilder() | ||
| 49 | + .setEnterpriseId(enterpriseId) | ||
| 50 | + .setType(DeliveryTemplateTypeEnum.DELIVERY_TEMPLATE_TYPE_DELIVERY) | ||
| 51 | + .build(); | ||
| 52 | + return deliveryRuleServiceRpcBlockingStub.getDefaultDeliveryTemplateAndRule(request); | ||
| 53 | + } | ||
| 54 | + | ||
| 43 | 55 | ||
| 44 | } | 56 | } | ... | ... |
This diff is collapsed. Click to expand it.
| 1 | package com.infoloop.tianting.service.impl; | 1 | package com.infoloop.tianting.service.impl; |
| 2 | 2 | ||
| 3 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto; | 3 | +import com.infoloop.tianting.context.LoginContextHolder; |
| 4 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientTableCodeDto; | 4 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientDto; |
| 5 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto; | 5 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientTableCodeDto; |
| 6 | -import com.infoloop.tianting.service.InventoryService; | 6 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.TableCodeQueryConditionDto; |
| 7 | -import com.infoloop.tianting.service.client.InventoryServiceRpcClient; | 7 | +import com.infoloop.tianting.service.ClientInventoryService; |
| 8 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 8 | import com.infoloop.tianting.utils.DateUtil; | 9 | import com.infoloop.tianting.utils.DateUtil; |
| 9 | import lombok.RequiredArgsConstructor; | 10 | import lombok.RequiredArgsConstructor; |
| 10 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| ... | @@ -17,13 +18,13 @@ import java.util.stream.Collectors; | ... | @@ -17,13 +18,13 @@ import java.util.stream.Collectors; |
| 17 | @Slf4j | 18 | @Slf4j |
| 18 | @Service | 19 | @Service |
| 19 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) | 20 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) |
| 20 | -public class InventoryServiceImpl implements InventoryService { | 21 | +public class ClientClientInventoryServiceImpl implements ClientInventoryService { |
| 21 | 22 | ||
| 22 | - private final InventoryServiceRpcClient inventoryServiceRpcClient; | 23 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; |
| 23 | 24 | ||
| 24 | @Override | 25 | @Override |
| 25 | public ClientDto getClientById(Integer enterpriseId, Integer clientId) { | 26 | public ClientDto getClientById(Integer enterpriseId, Integer clientId) { |
| 26 | - final var response = inventoryServiceRpcClient.getClientById(enterpriseId, clientId); | 27 | + final var response = clientInventoryServiceRpcClient.getClientById(enterpriseId, clientId); |
| 27 | return ClientDto.builder() | 28 | return ClientDto.builder() |
| 28 | .id(response.getClient().getId()) | 29 | .id(response.getClient().getId()) |
| 29 | .address(response.getClient().getAddress()) | 30 | .address(response.getClient().getAddress()) |
| ... | @@ -46,7 +47,7 @@ public class InventoryServiceImpl implements InventoryService { | ... | @@ -46,7 +47,7 @@ public class InventoryServiceImpl implements InventoryService { |
| 46 | 47 | ||
| 47 | @Override | 48 | @Override |
| 48 | public List<ClientDto> getStallsByClientId(Integer enterpriseId, Integer clientId) { | 49 | public List<ClientDto> getStallsByClientId(Integer enterpriseId, Integer clientId) { |
| 49 | - final var response = inventoryServiceRpcClient.getStallsByClientId(enterpriseId, clientId); | 50 | + final var response = clientInventoryServiceRpcClient.getStallsByClientId(enterpriseId, clientId); |
| 50 | return response.getStallsList().stream().map(stall -> | 51 | return response.getStallsList().stream().map(stall -> |
| 51 | ClientDto.builder() | 52 | ClientDto.builder() |
| 52 | .id(stall.getId()) | 53 | .id(stall.getId()) |
| ... | @@ -69,7 +70,7 @@ public class InventoryServiceImpl implements InventoryService { | ... | @@ -69,7 +70,7 @@ public class InventoryServiceImpl implements InventoryService { |
| 69 | 70 | ||
| 70 | @Override | 71 | @Override |
| 71 | public List<ClientTableCodeDto> queryClientTableCodesByCondition(TableCodeQueryConditionDto tableCodeQueryConditionDto) { | 72 | public List<ClientTableCodeDto> queryClientTableCodesByCondition(TableCodeQueryConditionDto tableCodeQueryConditionDto) { |
| 72 | - final var response = inventoryServiceRpcClient.queryClientTableCodesByCondition(tableCodeQueryConditionDto); | 73 | + final var response = clientInventoryServiceRpcClient.queryClientTableCodesByCondition(tableCodeQueryConditionDto); |
| 73 | return response.getResponsesList().stream().map(tableCode -> | 74 | return response.getResponsesList().stream().map(tableCode -> |
| 74 | ClientTableCodeDto.builder() | 75 | ClientTableCodeDto.builder() |
| 75 | .id(tableCode.getId()) | 76 | .id(tableCode.getId()) |
| ... | @@ -87,4 +88,28 @@ public class InventoryServiceImpl implements InventoryService { | ... | @@ -87,4 +88,28 @@ public class InventoryServiceImpl implements InventoryService { |
| 87 | .updateSource(tableCode.getUpdateSource()) | 88 | .updateSource(tableCode.getUpdateSource()) |
| 88 | .build()).collect(Collectors.toList()); | 89 | .build()).collect(Collectors.toList()); |
| 89 | } | 90 | } |
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + public List<ClientDto> getClientsByCodes(List<String> codes) { | ||
| 94 | + final var response = clientInventoryServiceRpcClient.getClientsByCodes(LoginContextHolder.getEnterpriseId(), codes); | ||
| 95 | + return response.stream().map(client -> | ||
| 96 | + ClientDto.builder() | ||
| 97 | + .id(client.getId()) | ||
| 98 | + .address(client.getAddress()) | ||
| 99 | + .area(client.getArea()) | ||
| 100 | + .province(client.getProvince()) | ||
| 101 | + .city(client.getCity()) | ||
| 102 | + .code(client.getCode()) | ||
| 103 | + .customerSource(client.getCustomerSource()) | ||
| 104 | + .enterpriseId(client.getEnterpriseId()) | ||
| 105 | + .operatorName(client.getOperatorName()) | ||
| 106 | + .parentId(client.getParentId()) | ||
| 107 | + .status(client.getStatus()) | ||
| 108 | + .regionId(client.getRegionId()) | ||
| 109 | + .type(client.getType()) | ||
| 110 | + .name(client.getName()) | ||
| 111 | + .isDelivery(client.getIsDelivery()) | ||
| 112 | + .build()).collect(Collectors.toList()); | ||
| 113 | + } | ||
| 114 | + | ||
| 90 | } | 115 | } | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -6,7 +6,7 @@ import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; | ... | @@ -6,7 +6,7 @@ import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; |
| 6 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; | 6 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; |
| 7 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; | 7 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; |
| 8 | import com.infoloop.tianting.context.LoginContextHolder; | 8 | import com.infoloop.tianting.context.LoginContextHolder; |
| 9 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto; | 9 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientDto; |
| 10 | import com.infoloop.tianting.model.dto.KdsDTO.KdsMealDetailDto; | 10 | import com.infoloop.tianting.model.dto.KdsDTO.KdsMealDetailDto; |
| 11 | import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDetailDto; | 11 | import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDetailDto; |
| 12 | import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDto; | 12 | import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDto; |
| ... | @@ -19,8 +19,8 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice; | ... | @@ -19,8 +19,8 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice; |
| 19 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; | 19 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; |
| 20 | import com.infoloop.tianting.service.KdsService; | 20 | import com.infoloop.tianting.service.KdsService; |
| 21 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; | 21 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; |
| 22 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 22 | import com.infoloop.tianting.service.client.EnterpriseResourceServiceRpcClient; | 23 | import com.infoloop.tianting.service.client.EnterpriseResourceServiceRpcClient; |
| 23 | -import com.infoloop.tianting.service.client.InventoryServiceRpcClient; | ||
| 24 | import com.infoloop.tianting.service.client.MealServiceRpcClient; | 24 | import com.infoloop.tianting.service.client.MealServiceRpcClient; |
| 25 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; | 25 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; |
| 26 | import com.infoloop.tianting.service.client.SkuServiceRpcClient; | 26 | import com.infoloop.tianting.service.client.SkuServiceRpcClient; |
| ... | @@ -47,7 +47,7 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -47,7 +47,7 @@ public class KdsServiceImpl implements KdsService { |
| 47 | private final WOperatorServiceRpcClient wOperatorServiceRpcClient; | 47 | private final WOperatorServiceRpcClient wOperatorServiceRpcClient; |
| 48 | private final MealServiceRpcClient mealServiceRpcClient; | 48 | private final MealServiceRpcClient mealServiceRpcClient; |
| 49 | private final SkuServiceRpcClient skuServiceRpcClient; | 49 | private final SkuServiceRpcClient skuServiceRpcClient; |
| 50 | - private final InventoryServiceRpcClient inventoryServiceRpcClient; | 50 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; |
| 51 | private final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient; | 51 | private final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient; |
| 52 | 52 | ||
| 53 | @Override | 53 | @Override |
| ... | @@ -87,14 +87,14 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -87,14 +87,14 @@ public class KdsServiceImpl implements KdsService { |
| 87 | .map(SingleClientCustomerOrderRpcResponse::getClientId) | 87 | .map(SingleClientCustomerOrderRpcResponse::getClientId) |
| 88 | .distinct() | 88 | .distinct() |
| 89 | .collect(Collectors.toList()); | 89 | .collect(Collectors.toList()); |
| 90 | - final var clients = inventoryServiceRpcClient.getClientsByIds( | 90 | + final var clients = clientInventoryServiceRpcClient.getClientsByIds( |
| 91 | operator.getEnterpriseId(), clientIds); | 91 | operator.getEnterpriseId(), clientIds); |
| 92 | 92 | ||
| 93 | final var orderStallIds = orderList.stream() | 93 | final var orderStallIds = orderList.stream() |
| 94 | .map(SingleClientCustomerOrderRpcResponse::getStallId) | 94 | .map(SingleClientCustomerOrderRpcResponse::getStallId) |
| 95 | .distinct() | 95 | .distinct() |
| 96 | .collect(Collectors.toList()); | 96 | .collect(Collectors.toList()); |
| 97 | - final var stalls = inventoryServiceRpcClient.getStallsByIds( | 97 | + final var stalls = clientInventoryServiceRpcClient.getStallsByIds( |
| 98 | operator.getEnterpriseId(), orderStallIds); | 98 | operator.getEnterpriseId(), orderStallIds); |
| 99 | 99 | ||
| 100 | final var customerIds = orderList.stream().map(SingleClientCustomerOrderRpcResponse::getCustomerId).collect(Collectors.toList()); | 100 | final var customerIds = orderList.stream().map(SingleClientCustomerOrderRpcResponse::getCustomerId).collect(Collectors.toList()); |
| ... | @@ -321,14 +321,14 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -321,14 +321,14 @@ public class KdsServiceImpl implements KdsService { |
| 321 | .map(SingleClientCustomerOrderRpcResponse::getClientId) | 321 | .map(SingleClientCustomerOrderRpcResponse::getClientId) |
| 322 | .distinct() | 322 | .distinct() |
| 323 | .collect(Collectors.toList()); | 323 | .collect(Collectors.toList()); |
| 324 | - final var clients = inventoryServiceRpcClient.getClientsByIds( | 324 | + final var clients = clientInventoryServiceRpcClient.getClientsByIds( |
| 325 | operator.getEnterpriseId(), clientIds); | 325 | operator.getEnterpriseId(), clientIds); |
| 326 | 326 | ||
| 327 | final var orderStallIds = orderList.stream() | 327 | final var orderStallIds = orderList.stream() |
| 328 | .map(SingleClientCustomerOrderRpcResponse::getStallId) | 328 | .map(SingleClientCustomerOrderRpcResponse::getStallId) |
| 329 | .distinct() | 329 | .distinct() |
| 330 | .collect(Collectors.toList()); | 330 | .collect(Collectors.toList()); |
| 331 | - final var stalls = inventoryServiceRpcClient.getStallsByIds( | 331 | + final var stalls = clientInventoryServiceRpcClient.getStallsByIds( |
| 332 | operator.getEnterpriseId(), orderStallIds); | 332 | operator.getEnterpriseId(), orderStallIds); |
| 333 | 333 | ||
| 334 | final var customerIds = orderList.stream().map(SingleClientCustomerOrderRpcResponse::getCustomerId).collect(Collectors.toList()); | 334 | final var customerIds = orderList.stream().map(SingleClientCustomerOrderRpcResponse::getCustomerId).collect(Collectors.toList()); | ... | ... |
| ... | @@ -7,11 +7,19 @@ import com.infoloop.rpc.meizhongyiheservice.HospitalStatus; | ... | @@ -7,11 +7,19 @@ import com.infoloop.rpc.meizhongyiheservice.HospitalStatus; |
| 7 | import com.infoloop.tianting.WOperatorStatus; | 7 | import com.infoloop.tianting.WOperatorStatus; |
| 8 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerHospitalRecordHospitalStatusEnum; | 8 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerHospitalRecordHospitalStatusEnum; |
| 9 | import com.infoloop.tianting.constant.CommonConstants; | 9 | import com.infoloop.tianting.constant.CommonConstants; |
| 10 | +import com.infoloop.tianting.context.LoginContextHolder; | ||
| 10 | import com.infoloop.tianting.exception.ClientEndExceptions; | 11 | import com.infoloop.tianting.exception.ClientEndExceptions; |
| 11 | import com.infoloop.tianting.exception.ErrorCodeEnum; | 12 | import com.infoloop.tianting.exception.ErrorCodeEnum; |
| 13 | +import com.infoloop.tianting.mealorderservice.MpAccountCreation; | ||
| 14 | +import com.infoloop.tianting.mealorderservice.MpAccountModification; | ||
| 15 | +import com.infoloop.tianting.mealorderservice.MpAccountStatusEnum; | ||
| 16 | +import com.infoloop.tianting.mealorderservice.SingleMpAccountRpcResponse; | ||
| 17 | +import com.infoloop.tianting.model.dto.MpAccountDTO; | ||
| 12 | import com.infoloop.tianting.model.dto.PermissionDTO.LoginDto; | 18 | import com.infoloop.tianting.model.dto.PermissionDTO.LoginDto; |
| 19 | +import com.infoloop.tianting.model.vo.MpAccountVO; | ||
| 13 | import com.infoloop.tianting.service.LoginService; | 20 | import com.infoloop.tianting.service.LoginService; |
| 14 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; | 21 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; |
| 22 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 15 | import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; | 23 | import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; |
| 16 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; | 24 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; |
| 17 | import com.infoloop.tianting.service.client.WOperatorServiceRpcClient; | 25 | import com.infoloop.tianting.service.client.WOperatorServiceRpcClient; |
| ... | @@ -20,6 +28,7 @@ import lombok.RequiredArgsConstructor; | ... | @@ -20,6 +28,7 @@ import lombok.RequiredArgsConstructor; |
| 20 | import lombok.extern.slf4j.Slf4j; | 28 | import lombok.extern.slf4j.Slf4j; |
| 21 | import org.springframework.beans.factory.annotation.Autowired; | 29 | import org.springframework.beans.factory.annotation.Autowired; |
| 22 | import org.springframework.stereotype.Service; | 30 | import org.springframework.stereotype.Service; |
| 31 | +import org.springframework.util.Assert; | ||
| 23 | 32 | ||
| 24 | import java.security.MessageDigest; | 33 | import java.security.MessageDigest; |
| 25 | import java.security.NoSuchAlgorithmException; | 34 | import java.security.NoSuchAlgorithmException; |
| ... | @@ -30,6 +39,7 @@ import java.security.NoSuchAlgorithmException; | ... | @@ -30,6 +39,7 @@ import java.security.NoSuchAlgorithmException; |
| 30 | public class LoginServiceImpl implements LoginService { | 39 | public class LoginServiceImpl implements LoginService { |
| 31 | 40 | ||
| 32 | private final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient; | 41 | private final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient; |
| 42 | + private final MealOrderServiceRpcClient mealOrderServiceRpcClient; | ||
| 33 | private final OperatorServiceRpcClient operatorServiceRpcClient; | 43 | private final OperatorServiceRpcClient operatorServiceRpcClient; |
| 34 | private final WxMiniProgramHttpClient wxMiniProgramHttpClient; | 44 | private final WxMiniProgramHttpClient wxMiniProgramHttpClient; |
| 35 | private final WOperatorServiceRpcClient wOperatorServiceRpcClient; | 45 | private final WOperatorServiceRpcClient wOperatorServiceRpcClient; |
| ... | @@ -44,6 +54,25 @@ public class LoginServiceImpl implements LoginService { | ... | @@ -44,6 +54,25 @@ public class LoginServiceImpl implements LoginService { |
| 44 | .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) | 54 | .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) |
| 45 | .build()); | 55 | .build()); |
| 46 | return StpUtil.getTokenInfo(); | 56 | return StpUtil.getTokenInfo(); |
| 57 | + } else if (loginDto.isShouldLoginWithOpenId()){ | ||
| 58 | + final var mpAccountByOpenId = mealOrderServiceRpcClient.getMpAccountByOpenId(loginDto.getOpenId()); | ||
| 59 | + int mpAccountId; | ||
| 60 | + if (mpAccountByOpenId == null) { | ||
| 61 | + mpAccountId = mealOrderServiceRpcClient.createMpAccount(loginDto.getEnterpriseId(), MpAccountCreation.newBuilder() | ||
| 62 | + .setOpenId(loginDto.getOpenId()) | ||
| 63 | + .setStatus(MpAccountStatusEnum.MP_ACCOUNT_STATUS_ENABLE) | ||
| 64 | + .setPhoneNumber(loginDto.getOperatorPhone() != null ? loginDto.getOperatorPhone() : "") | ||
| 65 | + .build()).getId(); | ||
| 66 | + } else { | ||
| 67 | + mpAccountId = mpAccountByOpenId.getId(); | ||
| 68 | + } | ||
| 69 | + Assert.isTrue(mpAccountId != 0, "创建小程序账号失败"); | ||
| 70 | + StpUtil.login(loginDto.getOpenId(), SaLoginModel.create() | ||
| 71 | + .setExtra(CommonConstants.ENTERPRISE_ID, loginDto.getEnterpriseId()) | ||
| 72 | + .setExtra(CommonConstants.USER_ID, mpAccountId) | ||
| 73 | + .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) | ||
| 74 | + .build()); | ||
| 75 | + return StpUtil.getTokenInfo(); | ||
| 47 | } else if (loginDto.isShouldLoginWithHisCustomerNo()) { | 76 | } else if (loginDto.isShouldLoginWithHisCustomerNo()) { |
| 48 | var customer = clientCustomerServiceRpcClient.getClientCustomerByHISCustomerNo(loginDto.getHisCustomerNo()).getResponse(); | 77 | var customer = clientCustomerServiceRpcClient.getClientCustomerByHISCustomerNo(loginDto.getHisCustomerNo()).getResponse(); |
| 49 | if (customer.getId() == 0) { | 78 | if (customer.getId() == 0) { |
| ... | @@ -110,6 +139,37 @@ public class LoginServiceImpl implements LoginService { | ... | @@ -110,6 +139,37 @@ public class LoginServiceImpl implements LoginService { |
| 110 | } | 139 | } |
| 111 | } | 140 | } |
| 112 | 141 | ||
| 142 | + @Override | ||
| 143 | + public MpAccountVO getMpAccountByOpenId(String openId) { | ||
| 144 | + final var mpAccountByOpenId = mealOrderServiceRpcClient.getMpAccountByOpenId(openId); | ||
| 145 | + if (mpAccountByOpenId == null) { | ||
| 146 | + return null; | ||
| 147 | + } | ||
| 148 | + return MpAccountVO.builder() | ||
| 149 | + .id(mpAccountByOpenId.getId()) | ||
| 150 | + .enterpriseId(mpAccountByOpenId.getEnterpriseId()) | ||
| 151 | + .openId(mpAccountByOpenId.getOpenId()) | ||
| 152 | + .unionId(mpAccountByOpenId.getUnionId()) | ||
| 153 | + .nickname(mpAccountByOpenId.getNickname()) | ||
| 154 | + .avatarUrl(mpAccountByOpenId.getAvatarUrl()) | ||
| 155 | + .gender(mpAccountByOpenId.getGender()) | ||
| 156 | + .phoneNumber(mpAccountByOpenId.getPhoneNumber()) | ||
| 157 | + .build(); | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + @Override | ||
| 161 | + public void updateMpAccount(SingleMpAccountRpcResponse mpAccount, MpAccountDTO.ModifyMpAccountDTO modifyMpAccountDTO) { | ||
| 162 | + mealOrderServiceRpcClient.updateMpAccount(LoginContextHolder.getLoginInfo(), MpAccountModification.newBuilder() | ||
| 163 | + .setId(mpAccount.getId()) | ||
| 164 | + .setShouldUpdateNickname(modifyMpAccountDTO.getNickName() != null) | ||
| 165 | + .setNickname(modifyMpAccountDTO.getNickName() != null ? modifyMpAccountDTO.getNickName() : mpAccount.getNickname()) | ||
| 166 | + .setShouldUpdateAvatarUrl(modifyMpAccountDTO.getAvatarUrl() != null) | ||
| 167 | + .setAvatarUrl(modifyMpAccountDTO.getAvatarUrl() != null ? modifyMpAccountDTO.getAvatarUrl() : mpAccount.getAvatarUrl()) | ||
| 168 | + .setShouldUpdateGender(modifyMpAccountDTO.getGender() != null) | ||
| 169 | + .setGender(modifyMpAccountDTO.getGender() != null ? modifyMpAccountDTO.getGender() : mpAccount.getGender()) | ||
| 170 | + .build()); | ||
| 171 | + } | ||
| 172 | + | ||
| 113 | public static String sha1Hash(String input) throws NoSuchAlgorithmException { | 173 | public static String sha1Hash(String input) throws NoSuchAlgorithmException { |
| 114 | MessageDigest md = MessageDigest.getInstance("SHA-1"); | 174 | MessageDigest md = MessageDigest.getInstance("SHA-1"); |
| 115 | md.update(input.getBytes()); | 175 | md.update(input.getBytes()); | ... | ... |
This diff is collapsed. Click to expand it.
| 1 | package com.infoloop.tianting.service.impl; | 1 | package com.infoloop.tianting.service.impl; |
| 2 | 2 | ||
| 3 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 3 | import com.infoloop.tianting.context.LoginContextHolder; | 4 | import com.infoloop.tianting.context.LoginContextHolder; |
| 4 | import com.infoloop.tianting.menuservice.SingleMenuDetailRpcResponse; | 5 | import com.infoloop.tianting.menuservice.SingleMenuDetailRpcResponse; |
| 5 | import com.infoloop.tianting.menuservice.SingleMenuRpcResponse; | 6 | import com.infoloop.tianting.menuservice.SingleMenuRpcResponse; |
| ... | @@ -11,6 +12,7 @@ import com.infoloop.tianting.model.dto.MenuDbDTO.MenuDto; | ... | @@ -11,6 +12,7 @@ import com.infoloop.tianting.model.dto.MenuDbDTO.MenuDto; |
| 11 | import com.infoloop.tianting.model.dto.MenuDbDTO.MenuRefDto; | 12 | import com.infoloop.tianting.model.dto.MenuDbDTO.MenuRefDto; |
| 12 | import com.infoloop.tianting.model.dto.MenuDbDTO.OrderRuleJson; | 13 | import com.infoloop.tianting.model.dto.MenuDbDTO.OrderRuleJson; |
| 13 | import com.infoloop.tianting.service.MenuService; | 14 | import com.infoloop.tianting.service.MenuService; |
| 15 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 14 | import com.infoloop.tianting.service.client.MenuServiceRpcClient; | 16 | import com.infoloop.tianting.service.client.MenuServiceRpcClient; |
| 15 | import com.infoloop.tianting.utils.DateUtil; | 17 | import com.infoloop.tianting.utils.DateUtil; |
| 16 | import lombok.RequiredArgsConstructor; | 18 | import lombok.RequiredArgsConstructor; |
| ... | @@ -29,6 +31,8 @@ public class MenuServiceImpl implements MenuService { | ... | @@ -29,6 +31,8 @@ public class MenuServiceImpl implements MenuService { |
| 29 | 31 | ||
| 30 | private final MenuServiceRpcClient menuServiceRpcClient; | 32 | private final MenuServiceRpcClient menuServiceRpcClient; |
| 31 | 33 | ||
| 34 | + private final MealOrderServiceRpcClient mealOrderServiceRpcClient; | ||
| 35 | + | ||
| 32 | @Override | 36 | @Override |
| 33 | public List<MenuDto> queryMiniProgramPublishedMenusByStallId(Integer enterpriseId, Integer stallId) { | 37 | public List<MenuDto> queryMiniProgramPublishedMenusByStallId(Integer enterpriseId, Integer stallId) { |
| 34 | final var response = menuServiceRpcClient.queryMiniProgramPublishedMenusByStallId(enterpriseId, stallId); | 38 | final var response = menuServiceRpcClient.queryMiniProgramPublishedMenusByStallId(enterpriseId, stallId); |
| ... | @@ -209,4 +213,11 @@ public class MenuServiceImpl implements MenuService { | ... | @@ -209,4 +213,11 @@ public class MenuServiceImpl implements MenuService { |
| 209 | return menuServiceRpcClient.queryMenuDetailsByMenuIds(LoginContextHolder.getEnterpriseId(), menuIds).getResponsesList().stream().map(SingleMenuDetailRpcResponse::getSkuId).distinct().collect(Collectors.toList()); | 213 | return menuServiceRpcClient.queryMenuDetailsByMenuIds(LoginContextHolder.getEnterpriseId(), menuIds).getResponsesList().stream().map(SingleMenuDetailRpcResponse::getSkuId).distinct().collect(Collectors.toList()); |
| 210 | } | 214 | } |
| 211 | 215 | ||
| 216 | + @Override | ||
| 217 | + public String queryClientLatestMealMenuRecord(SingleClientRpcResponse client) { | ||
| 218 | + final var singleMealMenuRecordRpcResponses = mealOrderServiceRpcClient.queryLatestMealMenuRecordsByClientIds(LoginContextHolder.getEnterpriseId(), List.of(client.getId())); | ||
| 219 | + return singleMealMenuRecordRpcResponses.isEmpty() ? "" : singleMealMenuRecordRpcResponses.get(0).getImageUrl(); | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + | ||
| 212 | } | 223 | } | ... | ... |
| ... | @@ -18,7 +18,7 @@ import com.infoloop.tianting.model.dto.SettlementDTO.SettlementMenuMealDto; | ... | @@ -18,7 +18,7 @@ import com.infoloop.tianting.model.dto.SettlementDTO.SettlementMenuMealDto; |
| 18 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementMenuSkuDto; | 18 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementMenuSkuDto; |
| 19 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto; | 19 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto; |
| 20 | import com.infoloop.tianting.service.SettlementService; | 20 | import com.infoloop.tianting.service.SettlementService; |
| 21 | -import com.infoloop.tianting.service.client.InventoryServiceRpcClient; | 21 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; |
| 22 | import com.infoloop.tianting.service.client.MealServiceRpcClient; | 22 | import com.infoloop.tianting.service.client.MealServiceRpcClient; |
| 23 | import com.infoloop.tianting.service.client.MenuServiceRpcClient; | 23 | import com.infoloop.tianting.service.client.MenuServiceRpcClient; |
| 24 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; | 24 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; |
| ... | @@ -55,7 +55,7 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -55,7 +55,7 @@ public class SettlementServiceImpl implements SettlementService { |
| 55 | private final OrderServiceRpcClient orderServiceRpcClient; | 55 | private final OrderServiceRpcClient orderServiceRpcClient; |
| 56 | private final MenuServiceRpcClient menuServiceRpcClient; | 56 | private final MenuServiceRpcClient menuServiceRpcClient; |
| 57 | private final SkuServiceRpcClient skuServiceRpcClient; | 57 | private final SkuServiceRpcClient skuServiceRpcClient; |
| 58 | - private final InventoryServiceRpcClient inventoryServiceRpcClient; | 58 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; |
| 59 | private final MealServiceRpcClient mealServiceRpcClient; | 59 | private final MealServiceRpcClient mealServiceRpcClient; |
| 60 | 60 | ||
| 61 | public static ByteArrayOutputStream writeToExcelBySku(SettlementDataDto settlementDataDto) | 61 | public static ByteArrayOutputStream writeToExcelBySku(SettlementDataDto settlementDataDto) |
| ... | @@ -403,7 +403,7 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -403,7 +403,7 @@ public class SettlementServiceImpl implements SettlementService { |
| 403 | 403 | ||
| 404 | } | 404 | } |
| 405 | } | 405 | } |
| 406 | - final var stalls = inventoryServiceRpcClient.getStallsByIds(enterpriseId, settlementRequest.getStallIds()).getClientsList(); | 406 | + final var stalls = clientInventoryServiceRpcClient.getStallsByIds(enterpriseId, settlementRequest.getStallIds()).getClientsList(); |
| 407 | final var stallNames = stalls.stream() | 407 | final var stallNames = stalls.stream() |
| 408 | .filter(s -> settlementRequest.getStallIds().contains(s.getId())) | 408 | .filter(s -> settlementRequest.getStallIds().contains(s.getId())) |
| 409 | .map(SingleClientRpcResponse::getName).collect(Collectors.toList()); | 409 | .map(SingleClientRpcResponse::getName).collect(Collectors.toList()); |
| ... | @@ -525,7 +525,7 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -525,7 +525,7 @@ public class SettlementServiceImpl implements SettlementService { |
| 525 | } | 525 | } |
| 526 | 526 | ||
| 527 | } | 527 | } |
| 528 | - final var client = inventoryServiceRpcClient.getClientById(enterpriseId, | 528 | + final var client = clientInventoryServiceRpcClient.getClientById(enterpriseId, |
| 529 | settlementRequest.getClientId()).getClient(); | 529 | settlementRequest.getClientId()).getClient(); |
| 530 | final var settlementDataByMealDto = SettlementDataByMealDto.builder() | 530 | final var settlementDataByMealDto = SettlementDataByMealDto.builder() |
| 531 | .classifyOrders(classifyOrders) | 531 | .classifyOrders(classifyOrders) | ... | ... |
| ... | @@ -115,14 +115,12 @@ public class SkuServiceImpl implements SkuService { | ... | @@ -115,14 +115,12 @@ public class SkuServiceImpl implements SkuService { |
| 115 | if (querySkuSellQuantityDTO.getStatus() != SkuSellQuantityStatus.ALL) { | 115 | if (querySkuSellQuantityDTO.getStatus() != SkuSellQuantityStatus.ALL) { |
| 116 | responses = responses.stream() | 116 | responses = responses.stream() |
| 117 | .filter(e -> { | 117 | .filter(e -> { |
| 118 | - switch (querySkuSellQuantityDTO.getStatus()) { | 118 | + if (querySkuSellQuantityDTO.getStatus() == SkuSellQuantityStatus.SOLD_OUT) { |
| 119 | - case SOLD_OUT: | 119 | + return e.getMaxSellQuantity() == e.getTodaySellQuantity(); |
| 120 | - return e.getMaxSellQuantity() == e.getTodaySellQuantity(); | 120 | + } else if (querySkuSellQuantityDTO.getStatus() == SkuSellQuantityStatus.ON_SALE) { |
| 121 | - case ON_SALE: | 121 | + return e.getMaxSellQuantity() != e.getTodaySellQuantity(); |
| 122 | - return e.getMaxSellQuantity() != e.getTodaySellQuantity(); | ||
| 123 | - default: | ||
| 124 | - return true; | ||
| 125 | } | 122 | } |
| 123 | + return true; | ||
| 126 | }) | 124 | }) |
| 127 | .collect(Collectors.toList()); | 125 | .collect(Collectors.toList()); |
| 128 | } | 126 | } | ... | ... |
| 1 | +package com.infoloop.tianting.store; | ||
| 2 | + | ||
| 3 | +import io.lettuce.core.SetArgs; | ||
| 4 | +import io.lettuce.core.api.sync.RedisCommands; | ||
| 5 | + | ||
| 6 | +import java.time.DayOfWeek; | ||
| 7 | +import java.time.LocalDate; | ||
| 8 | +import java.time.temporal.WeekFields; | ||
| 9 | + | ||
| 10 | +public class WeeklyTaskStore { | ||
| 11 | + | ||
| 12 | + private final RedisCommands<String, String> commands; | ||
| 13 | + private final long expire; | ||
| 14 | + | ||
| 15 | + public WeeklyTaskStore(final RedisCommands<String, String> commands, final long expire) { | ||
| 16 | + this.commands = commands; | ||
| 17 | + this.expire = expire; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + public boolean isExecutedThisWeek(String keyPrefix, int enterpriseId, LocalDate date) { | ||
| 21 | + String key = getWeeklyKey(keyPrefix, enterpriseId, date); | ||
| 22 | + return commands.exists(key) > 0; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public void markExecuted(String keyPrefix, int enterpriseId, LocalDate date) { | ||
| 26 | + String key = getWeeklyKey(keyPrefix, enterpriseId, date); | ||
| 27 | + commands.set(key, "1", new SetArgs().ex(expire)); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + public void clearExecutedThisWeek(String keyPrefix, int enterpriseId, LocalDate date) { | ||
| 31 | + String key = getWeeklyKey(keyPrefix, enterpriseId, date); | ||
| 32 | + commands.del(key); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + private String getWeeklyKey(String keyPrefix, int enterpriseId, LocalDate date) { | ||
| 36 | + WeekFields weekFields = WeekFields.of(DayOfWeek.MONDAY, 1); | ||
| 37 | + int year = date.getYear(); | ||
| 38 | + int week = date.get(weekFields.weekOfWeekBasedYear()); | ||
| 39 | + return String.format("%s:%d:%d-W%d", keyPrefix, enterpriseId, year, week); | ||
| 40 | + } | ||
| 41 | +} |
| ... | @@ -4,11 +4,22 @@ import com.infoloop.tianting.model.common.OrderPageResult; | ... | @@ -4,11 +4,22 @@ import com.infoloop.tianting.model.common.OrderPageResult; |
| 4 | import com.infoloop.tianting.model.common.PageResult; | 4 | import com.infoloop.tianting.model.common.PageResult; |
| 5 | import com.infoloop.tianting.model.dto.OrderDbDTO.OrderCountByStatusDto; | 5 | import com.infoloop.tianting.model.dto.OrderDbDTO.OrderCountByStatusDto; |
| 6 | 6 | ||
| 7 | +import java.lang.reflect.InvocationTargetException; | ||
| 7 | import java.util.LinkedList; | 8 | import java.util.LinkedList; |
| 8 | import java.util.List; | 9 | import java.util.List; |
| 9 | 10 | ||
| 10 | public class PageUtil { | 11 | public class PageUtil { |
| 11 | 12 | ||
| 13 | + public static <T> PageResult<T> buildEmpty(Class<T> clazz) { | ||
| 14 | + T instance; | ||
| 15 | + try { | ||
| 16 | + instance = clazz.getDeclaredConstructor().newInstance(); | ||
| 17 | + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { | ||
| 18 | + throw new RuntimeException(e); | ||
| 19 | + } | ||
| 20 | + return buildEmpty(instance); | ||
| 21 | + } | ||
| 22 | + | ||
| 12 | public static <T> PageResult<T> buildEmpty(T t) { | 23 | public static <T> PageResult<T> buildEmpty(T t) { |
| 13 | PageResult<T> pageRet = new PageResult<>(); | 24 | PageResult<T> pageRet = new PageResult<>(); |
| 14 | pageRet.setTotalCount(0); | 25 | pageRet.setTotalCount(0); | ... | ... |
src/main/proto/MealOrderService.proto
0 → 100644
This diff is collapsed. Click to expand it.
| ... | @@ -34,8 +34,8 @@ okhttp.max-idle-connections=10 | ... | @@ -34,8 +34,8 @@ okhttp.max-idle-connections=10 |
| 34 | okhttp.keep-alive-duration=300 | 34 | okhttp.keep-alive-duration=300 |
| 35 | 35 | ||
| 36 | ##GRPC\u914D\u7F6E | 36 | ##GRPC\u914D\u7F6E |
| 37 | -grpc.order-service.url=localhost | 37 | +grpc.order-service.url=47.101.193.136 |
| 38 | -grpc.order-service.port=4096 | 38 | +grpc.order-service.port=4065 |
| 39 | 39 | ||
| 40 | grpc.menu-service.url=47.101.193.136 | 40 | grpc.menu-service.url=47.101.193.136 |
| 41 | grpc.menu-service.port=3017 | 41 | grpc.menu-service.port=3017 |
| ... | @@ -76,10 +76,10 @@ grpc.meizhongyihe-service.port=3040 | ... | @@ -76,10 +76,10 @@ grpc.meizhongyihe-service.port=3040 |
| 76 | miniprogram.appId=wx40ec496d73b58ec6 | 76 | miniprogram.appId=wx40ec496d73b58ec6 |
| 77 | miniprogram.appSecret=5b309517bf918abf760b2195e91b99f3 | 77 | miniprogram.appSecret=5b309517bf918abf760b2195e91b99f3 |
| 78 | 78 | ||
| 79 | -business-config.hisCustomerQueryUrl = https://nutri.amcare.com.cn/v3/hiscustomers/current/query | 79 | +business-config.hisCustomerQueryUrl = http://localhost:8903/hiscustomers/current/query |
| 80 | -business-config.clientCustomerQueryUrl = https://nutri.amcare.com.cn/v3/clientcustomers/current/query | 80 | +business-config.clientCustomerQueryUrl = http://localhost:8903/clientcustomers/current/query |
| 81 | -business-config.payUrl = http://10.2.5.162:21051/API/Microapp/CreateOrder?appid={0} | 81 | +business-config.payUrl = http://36.110.128.86:21051/API/Microapp/CreateOrder?appid={0} |
| 82 | -business-config.payClientId = Order | 82 | +business-config.payClientId = Order00001 |
| 83 | business-config.cancelPayUrl = http://10.2.5.162:21051/frame/requestbase64 | 83 | business-config.cancelPayUrl = http://10.2.5.162:21051/frame/requestbase64 |
| 84 | business-config.refundSecurityKey = 0987654321 | 84 | business-config.refundSecurityKey = 0987654321 |
| 85 | 85 | ||
| ... | @@ -104,6 +104,12 @@ sa-token.sign.secret-key=4Jk2giMQw8D7lHJcU8fv8CXjSOhjp5Ee | ... | @@ -104,6 +104,12 @@ sa-token.sign.secret-key=4Jk2giMQw8D7lHJcU8fv8CXjSOhjp5Ee |
| 104 | ##\u65E5\u5FD7\u914D\u7F6E | 104 | ##\u65E5\u5FD7\u914D\u7F6E |
| 105 | logging.config=classpath:logback-spring.xml | 105 | logging.config=classpath:logback-spring.xml |
| 106 | 106 | ||
| 107 | +aliyun.oss.endPoint=oss-cn-shanghai.aliyuncs.com | ||
| 108 | +aliyun.oss.host=infoloop-public-qa.oss-cn-shanghai.aliyuncs.com | ||
| 109 | +aliyun.oss.accessKeyId=LTAIo9gcY5sjIZdN | ||
| 110 | +aliyun.oss.accessKeySecret=gOOkVY4Euj3MSbPyg1tZvPbZbUssj5 | ||
| 111 | +aliyun.oss.bucket=infoloop-public-qa | ||
| 112 | + | ||
| 107 | ##\u77ED\u4FE1\u914D\u7F6E | 113 | ##\u77ED\u4FE1\u914D\u7F6E |
| 108 | sms-config.accessKeyId= | 114 | sms-config.accessKeyId= |
| 109 | sms-config.accessKeySecret= | 115 | sms-config.accessKeySecret= | ... | ... |
| 1 | package com.infoloop.tianting; | 1 | package com.infoloop.tianting; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | -import org.junit.runner.RunWith; | 4 | +import org.junit.jupiter.api.Test; |
| 5 | +import org.junit.jupiter.api.extension.ExtendWith; | ||
| 5 | import org.springframework.boot.test.context.SpringBootTest; | 6 | import org.springframework.boot.test.context.SpringBootTest; |
| 6 | -import org.springframework.test.context.junit4.SpringRunner; | 7 | +import org.springframework.test.context.junit.jupiter.SpringExtension; |
| 7 | 8 | ||
| 8 | -@SpringBootTest(classes = App.class) | 9 | +@ExtendWith(SpringExtension.class) |
| 9 | -@RunWith(SpringRunner.class) | 10 | +@SpringBootTest |
| 10 | public class AppTest { | 11 | public class AppTest { |
| 11 | 12 | ||
| 13 | + @Test | ||
| 14 | + void testSomething() { | ||
| 15 | + System.out.println("test"); | ||
| 16 | + } | ||
| 12 | 17 | ||
| 13 | } | 18 | } | ... | ... |
-
Please register or login to post a comment