zhuyifan

农信点餐小程序

Showing 38 changed files with 2815 additions and 32 deletions
...@@ -6,13 +6,12 @@ ...@@ -6,13 +6,12 @@
6 */ 6 */
7 7
8 plugins { 8 plugins {
9 - // Apply the application plugin to add support for building a CLI application in Java.
10 id 'java' 9 id 'java'
11 id 'idea' 10 id 'idea'
12 id 'application' 11 id 'application'
13 - id 'org.springframework.boot' version '2.3.3.RELEASE' 12 + id 'org.springframework.boot' version '2.5.12'
14 - id 'io.spring.dependency-management' version '1.0.10.RELEASE' 13 + id 'io.spring.dependency-management' version '1.1.6'
15 - id 'com.google.protobuf' version '0.9.3' 14 + id 'com.google.protobuf' version '0.9.4'
16 } 15 }
17 16
18 repositories { 17 repositories {
...@@ -29,8 +28,8 @@ application { ...@@ -29,8 +28,8 @@ application {
29 } 28 }
30 29
31 ext { 30 ext {
32 - grpcVersion = '1.39.0' 31 + grpcVersion = '1.62.2'
33 - protobufVersion = '3.17.2' 32 + protobufVersion = '3.25.3'
34 } 33 }
35 34
36 dependencies { 35 dependencies {
...@@ -55,20 +54,13 @@ dependencies { ...@@ -55,20 +54,13 @@ dependencies {
55 testImplementation "io.grpc:grpc-testing:${grpcVersion}" 54 testImplementation "io.grpc:grpc-testing:${grpcVersion}"
56 } 55 }
57 56
58 -static def isAppleSilicon() {
59 - // 检测 macOS 并且使用的是 Apple Silicon 架构
60 - return System.getProperty('os.name').toLowerCase().contains('mac') && System.getProperty('os.arch').equals('aarch64')
61 -}
62 -
63 -def protocPlatform = isAppleSilicon() ? ':osx-x86_64' : '';
64 -
65 protobuf { 57 protobuf {
66 protoc { 58 protoc {
67 - artifact = "com.google.protobuf:protoc:${protobufVersion}${protocPlatform}" 59 + artifact = "com.google.protobuf:protoc:${protobufVersion}"
68 } 60 }
69 plugins { 61 plugins {
70 grpc { 62 grpc {
71 - artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}${protocPlatform}" 63 + artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
72 } 64 }
73 } 65 }
74 generateProtoTasks { 66 generateProtoTasks {
...@@ -87,6 +79,13 @@ tasks.withType(JavaCompile).configureEach { ...@@ -87,6 +79,13 @@ tasks.withType(JavaCompile).configureEach {
87 it.options.fork = true 79 it.options.fork = true
88 } 80 }
89 81
82 +tasks {
83 + compileJava {
84 + dependsOn generateProto
85 + source fileTree('build/generated/source/proto/main/java')
86 + }
87 +}
88 +
90 sourceSets { 89 sourceSets {
91 main { 90 main {
92 java { 91 java {
......
1 org.gradle.daemon=true 1 org.gradle.daemon=true
2 org.gradle.parallel=true 2 org.gradle.parallel=true
3 org.gradle.caching=true 3 org.gradle.caching=true
4 -org.gradle.jvmargs=-Xmx4096m -XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 4 +org.gradle.jvmargs=-Xmx8g -XX:MaxMetaspaceSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
5 +org.gradle.incremental=true
5 org.gradle.configureondemand=true 6 org.gradle.configureondemand=true
6 -org.gradle.java.home=/usr/lib/jvm/java-11-openjdk-amd64
...\ No newline at end of file ...\ No newline at end of file
7 +org.gradle.configuration-cache=true
...\ No newline at end of file ...\ No newline at end of file
......
1 distributionBase=GRADLE_USER_HOME 1 distributionBase=GRADLE_USER_HOME
2 distributionPath=wrapper/dists 2 distributionPath=wrapper/dists
3 -distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-6.9-bin.zip 3 +distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-8.11-bin.zip
4 networkTimeout=10000 4 networkTimeout=10000
5 zipStoreBase=GRADLE_USER_HOME 5 zipStoreBase=GRADLE_USER_HOME
6 zipStorePath=wrapper/dists 6 zipStorePath=wrapper/dists
7 +#org.gradle.java.home=/usr/lib/jvm/java-17-openjdk-amd64
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -9,6 +9,7 @@ import brave.propagation.B3Propagation; ...@@ -9,6 +9,7 @@ import brave.propagation.B3Propagation;
9 import brave.propagation.CurrentTraceContext; 9 import brave.propagation.CurrentTraceContext;
10 import brave.propagation.TraceContext; 10 import brave.propagation.TraceContext;
11 import brave.sampler.Sampler; 11 import brave.sampler.Sampler;
12 +import com.tianting.infoloop.service.grpc.MealOrderGrpcService;
12 import com.tianting.infoloop.service.grpc.OrderGrpcService; 13 import com.tianting.infoloop.service.grpc.OrderGrpcService;
13 import io.grpc.Server; 14 import io.grpc.Server;
14 import io.grpc.ServerInterceptor; 15 import io.grpc.ServerInterceptor;
...@@ -64,10 +65,12 @@ public class AppConfig implements ApplicationContextAware { ...@@ -64,10 +65,12 @@ public class AppConfig implements ApplicationContextAware {
64 @Bean 65 @Bean
65 public Server serviceServer(@Value(SERVICE_PORT) final int port, 66 public Server serviceServer(@Value(SERVICE_PORT) final int port,
66 final ServerInterceptor serverInterceptor, 67 final ServerInterceptor serverInterceptor,
67 - final OrderGrpcService orderGrpcService) { 68 + final OrderGrpcService orderGrpcService,
69 + final MealOrderGrpcService mealOrderGrpcService) {
68 return NettyServerBuilder 70 return NettyServerBuilder
69 .forPort(port) 71 .forPort(port)
70 .addService(ServerInterceptors.intercept(orderGrpcService, serverInterceptor)) 72 .addService(ServerInterceptors.intercept(orderGrpcService, serverInterceptor))
73 + .addService(ServerInterceptors.intercept(mealOrderGrpcService, serverInterceptor))
71 .build(); 74 .build();
72 } 75 }
73 } 76 }
......
1 +package com.tianting.infoloop.mapper;
2 +
3 +import com.tianting.infoloop.inject.MyBaseMapper;
4 +import com.tianting.infoloop.model.db.Diner;
5 +
6 +/**
7 +* @author zhuyf
8 +* @description 针对表【diners(就餐人表)】的数据库操作Mapper
9 +* @createDate 2025-04-10 13:22:20
10 +* @Entity com.tianting.infoloop.model.db.Diner
11 +*/
12 +public interface DinerMapper extends MyBaseMapper<Diner> {
13 +
14 +}
15 +
16 +
17 +
18 +
1 +package com.tianting.infoloop.mapper;
2 +
3 +import com.tianting.infoloop.inject.MyBaseMapper;
4 +import com.tianting.infoloop.model.db.GradeClass;
5 +
6 +/**
7 +* @author zhuyf
8 +* @description 针对表【grade_classes(年级班级表)】的数据库操作Mapper
9 +* @createDate 2025-04-10 13:22:20
10 +* @Entity com.tianting.infoloop.model.db.GradeClass
11 +*/
12 +public interface GradeClassMapper extends MyBaseMapper<GradeClass> {
13 +
14 +}
15 +
16 +
17 +
18 +
1 +package com.tianting.infoloop.mapper;
2 +
3 +import com.tianting.infoloop.inject.MyBaseMapper;
4 +import com.tianting.infoloop.model.db.MealMenuRecord;
5 +
6 +/**
7 +* @author zhuyf
8 +* @description 针对表【meal_menu_records(餐单记录表)】的数据库操作Mapper
9 +* @createDate 2025-04-10 13:22:20
10 +* @Entity com.tianting.infoloop.model.db.MealMenuRecord
11 +*/
12 +public interface MealMenuRecordMapper extends MyBaseMapper<MealMenuRecord> {
13 +
14 +}
15 +
16 +
17 +
18 +
1 +package com.tianting.infoloop.mapper;
2 +
3 +import com.tianting.infoloop.inject.MyBaseMapper;
4 +import com.tianting.infoloop.model.db.MealOrder;
5 +
6 +/**
7 +* @author zhuyf
8 +* @description 针对表【meal_orders(订餐记录表)】的数据库操作Mapper
9 +* @createDate 2025-04-10 13:22:20
10 +* @Entity com.tianting.infoloop.model.db.MealOrder
11 +*/
12 +public interface MealOrderMapper extends MyBaseMapper<MealOrder> {
13 +
14 +}
15 +
16 +
17 +
18 +
1 +package com.tianting.infoloop.mapper;
2 +
3 +import com.tianting.infoloop.inject.MyBaseMapper;
4 +import com.tianting.infoloop.model.db.MpAccountDinerRef;
5 +
6 +/**
7 +* @author zhuyf
8 +* @description 针对表【mp_account_diner_refs(小程序账号和就餐人关联表)】的数据库操作Mapper
9 +* @createDate 2025-04-10 13:22:20
10 +* @Entity com.tianting.infoloop.model.db.MpAccountDinerRef
11 +*/
12 +public interface MpAccountDinerRefMapper extends MyBaseMapper<MpAccountDinerRef> {
13 +
14 +}
15 +
16 +
17 +
18 +
1 +package com.tianting.infoloop.mapper;
2 +
3 +import com.tianting.infoloop.inject.MyBaseMapper;
4 +import com.tianting.infoloop.model.db.MpAccount;
5 +
6 +/**
7 +* @author zhuyf
8 +* @description 针对表【mp_accounts(小程序账号表)】的数据库操作Mapper
9 +* @createDate 2025-04-10 13:22:20
10 +* @Entity com.tianting.infoloop.model.db.MpAccount
11 +*/
12 +public interface MpAccountMapper extends MyBaseMapper<MpAccount> {
13 +
14 +}
15 +
16 +
17 +
18 +
1 +package com.tianting.infoloop.model.db;
2 +
3 +import com.baomidou.mybatisplus.annotation.FieldFill;
4 +import com.baomidou.mybatisplus.annotation.IdType;
5 +import com.baomidou.mybatisplus.annotation.TableField;
6 +import com.baomidou.mybatisplus.annotation.TableId;
7 +import com.baomidou.mybatisplus.annotation.TableLogic;
8 +import com.baomidou.mybatisplus.annotation.TableName;
9 +import com.baomidou.mybatisplus.extension.activerecord.Model;
10 +import lombok.Data;
11 +import lombok.EqualsAndHashCode;
12 +import lombok.experimental.Accessors;
13 +
14 +import java.io.Serializable;
15 +import java.time.LocalDateTime;
16 +
17 +/**
18 + * @TableName diners
19 + */
20 +@Data
21 +@Accessors(chain = true)
22 +@EqualsAndHashCode(callSuper = true)
23 +@TableName(value ="diners")
24 +public class Diner extends Model<Diner> implements Serializable {
25 +
26 + @TableId(type = IdType.AUTO)
27 + private Integer id;
28 +
29 + private Integer enterpriseId;
30 +
31 + private Integer clientId;
32 +
33 + private Integer classId;
34 +
35 + private String studentNo;
36 +
37 + private String name;
38 +
39 + private Integer createdBy;
40 +
41 + @TableField(fill = FieldFill.INSERT)
42 + private LocalDateTime createdAt;
43 +
44 + private Integer creationSource;
45 +
46 + private Integer updatedBy;
47 +
48 + @TableField(fill = FieldFill.INSERT_UPDATE)
49 + private LocalDateTime updatedAt;
50 +
51 + private Integer updateSource;
52 +
53 + @TableLogic
54 + private Boolean isDeleted;
55 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.tianting.infoloop.model.db;
2 +
3 +import com.baomidou.mybatisplus.annotation.FieldFill;
4 +import com.baomidou.mybatisplus.annotation.IdType;
5 +import com.baomidou.mybatisplus.annotation.TableField;
6 +import com.baomidou.mybatisplus.annotation.TableId;
7 +import com.baomidou.mybatisplus.annotation.TableName;
8 +import com.baomidou.mybatisplus.extension.activerecord.Model;
9 +import lombok.Data;
10 +import lombok.EqualsAndHashCode;
11 +import lombok.experimental.Accessors;
12 +
13 +import java.io.Serializable;
14 +import java.time.LocalDateTime;
15 +
16 +/**
17 + * @TableName grade_classes
18 + */
19 +@Data
20 +@Accessors(chain = true)
21 +@EqualsAndHashCode(callSuper = true)
22 +@TableName(value ="grade_classes")
23 +public class GradeClass extends Model<GradeClass> implements Serializable {
24 +
25 + @TableId(type = IdType.AUTO)
26 + private Integer id;
27 +
28 + private Integer enterpriseId;
29 +
30 + private Integer clientId;
31 +
32 + private String gradeName;
33 +
34 + private String className;
35 +
36 + private String fullName;
37 +
38 + private Integer createdBy;
39 +
40 + @TableField(fill = FieldFill.INSERT)
41 + private LocalDateTime createdAt;
42 +
43 + private Integer creationSource;
44 +
45 + private Integer updatedBy;
46 +
47 + @TableField(fill = FieldFill.INSERT_UPDATE)
48 + private LocalDateTime updatedAt;
49 +
50 + private Integer updateSource;
51 +
52 + private Boolean isDeleted;
53 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.tianting.infoloop.model.db;
2 +
3 +import com.baomidou.mybatisplus.annotation.FieldFill;
4 +import com.baomidou.mybatisplus.annotation.IdType;
5 +import com.baomidou.mybatisplus.annotation.TableField;
6 +import com.baomidou.mybatisplus.annotation.TableId;
7 +import com.baomidou.mybatisplus.annotation.TableName;
8 +import com.baomidou.mybatisplus.extension.activerecord.Model;
9 +import lombok.Data;
10 +import lombok.EqualsAndHashCode;
11 +import lombok.experimental.Accessors;
12 +
13 +import java.io.Serializable;
14 +import java.time.LocalDateTime;
15 +
16 +/**
17 + * @TableName meal_menu_records
18 + */
19 +@Data
20 +@Accessors(chain = true)
21 +@EqualsAndHashCode(callSuper = true)
22 +@TableName(value ="meal_menu_records")
23 +public class MealMenuRecord extends Model<MealMenuRecord> implements Serializable {
24 +
25 + @TableId(type = IdType.AUTO)
26 + private Integer id;
27 +
28 + private Integer enterpriseId;
29 +
30 + private Integer clientId;
31 +
32 + private String name;
33 +
34 + private String imageUrl;
35 +
36 + private Integer createdBy;
37 +
38 + @TableField(fill = FieldFill.INSERT)
39 + private LocalDateTime createdAt;
40 +
41 + private Integer creationSource;
42 +
43 + private Integer updatedBy;
44 +
45 + @TableField(fill = FieldFill.INSERT_UPDATE)
46 + private LocalDateTime updatedAt;
47 +
48 + private Integer updateSource;
49 +
50 + private Boolean isDeleted;
51 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.tianting.infoloop.model.db;
2 +
3 +import com.baomidou.mybatisplus.annotation.FieldFill;
4 +import com.baomidou.mybatisplus.annotation.IdType;
5 +import com.baomidou.mybatisplus.annotation.TableField;
6 +import com.baomidou.mybatisplus.annotation.TableId;
7 +import com.baomidou.mybatisplus.annotation.TableName;
8 +import com.baomidou.mybatisplus.extension.activerecord.Model;
9 +import lombok.Data;
10 +import lombok.EqualsAndHashCode;
11 +import lombok.experimental.Accessors;
12 +
13 +import java.io.Serializable;
14 +import java.time.LocalDateTime;
15 +
16 +/**
17 + * @TableName meal_orders
18 + */
19 +@Data
20 +@Accessors(chain = true)
21 +@EqualsAndHashCode(callSuper = true)
22 +@TableName(value ="meal_orders")
23 +public class MealOrder extends Model<MealOrder> implements Serializable {
24 +
25 + @TableId(type = IdType.AUTO)
26 + private Integer id;
27 +
28 + private Integer enterpriseId;
29 +
30 + private Integer clientId;
31 +
32 + private Integer menuId;
33 +
34 + private Integer accountId;
35 +
36 + private Integer orderMethod;
37 +
38 + private Integer dinerId;
39 +
40 + private String dinerName;
41 +
42 + private String clientName;
43 +
44 + private String gradeName;
45 +
46 + private String className;
47 +
48 + private String studentNo;
49 +
50 + private LocalDateTime reserveDate;
51 +
52 + private String meals;
53 +
54 + private Integer createdBy;
55 +
56 + @TableField(fill = FieldFill.INSERT)
57 + private LocalDateTime createdAt;
58 +
59 + private Integer creationSource;
60 +
61 + private Integer updatedBy;
62 +
63 + @TableField(fill = FieldFill.INSERT_UPDATE)
64 + private LocalDateTime updatedAt;
65 +
66 + private Integer updateSource;
67 +
68 + private Boolean isDeleted;
69 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.tianting.infoloop.model.db;
2 +
3 +import com.baomidou.mybatisplus.annotation.FieldFill;
4 +import com.baomidou.mybatisplus.annotation.IdType;
5 +import com.baomidou.mybatisplus.annotation.TableField;
6 +import com.baomidou.mybatisplus.annotation.TableId;
7 +import com.baomidou.mybatisplus.annotation.TableName;
8 +import com.baomidou.mybatisplus.extension.activerecord.Model;
9 +import lombok.Data;
10 +import lombok.EqualsAndHashCode;
11 +import lombok.experimental.Accessors;
12 +
13 +import java.io.Serializable;
14 +import java.time.LocalDateTime;
15 +
16 +/**
17 + * @TableName mp_accounts
18 + */
19 +@Data
20 +@Accessors(chain = true)
21 +@EqualsAndHashCode(callSuper = true)
22 +@TableName(value ="mp_accounts")
23 +public class MpAccount extends Model<MpAccount> implements Serializable {
24 +
25 + @TableId(type = IdType.AUTO)
26 + private Integer id;
27 +
28 + private Integer enterpriseId;
29 +
30 + private String openId;
31 +
32 + private String unionId;
33 +
34 + private String nickname;
35 +
36 + private String avatarUrl;
37 +
38 + private Integer gender;
39 +
40 + private String phoneNumber;
41 +
42 + private Integer status;
43 +
44 + private Integer createdBy;
45 +
46 + @TableField(fill = FieldFill.INSERT)
47 + private LocalDateTime createdAt;
48 +
49 + private Integer creationSource;
50 +
51 + private Integer updatedBy;
52 +
53 + @TableField(fill = FieldFill.INSERT_UPDATE)
54 + private LocalDateTime updatedAt;
55 +
56 + private Integer updateSource;
57 +
58 + private Boolean isDeleted;
59 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.tianting.infoloop.model.db;
2 +
3 +import com.baomidou.mybatisplus.annotation.FieldFill;
4 +import com.baomidou.mybatisplus.annotation.IdType;
5 +import com.baomidou.mybatisplus.annotation.TableField;
6 +import com.baomidou.mybatisplus.annotation.TableId;
7 +import com.baomidou.mybatisplus.annotation.TableName;
8 +import com.baomidou.mybatisplus.extension.activerecord.Model;
9 +import lombok.Data;
10 +import lombok.EqualsAndHashCode;
11 +import lombok.experimental.Accessors;
12 +
13 +import java.io.Serializable;
14 +import java.time.LocalDateTime;
15 +
16 +/**
17 + * @TableName mp_account_diner_refs
18 + */
19 +@Data
20 +@Accessors(chain = true)
21 +@EqualsAndHashCode(callSuper = true)
22 +@TableName(value ="mp_account_diner_refs")
23 +public class MpAccountDinerRef extends Model<MpAccountDinerRef> implements Serializable {
24 +
25 + @TableId(type = IdType.AUTO)
26 + private Integer id;
27 +
28 + private Integer enterpriseId;
29 +
30 + private Integer accountId;
31 +
32 + private Integer dinerId;
33 +
34 + private Integer createdBy;
35 +
36 + @TableField(fill = FieldFill.INSERT)
37 + private LocalDateTime createdAt;
38 +
39 + private Integer creationSource;
40 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.tianting.infoloop.service;
2 +
3 +import com.baomidou.mybatisplus.extension.service.IService;
4 +import com.tianting.infoloop.model.db.Diner;
5 +
6 +/**
7 +* @author zhuyf
8 +* @description 针对表【diners(就餐人表)】的数据库操作Service
9 +* @createDate 2025-04-10 13:22:20
10 +*/
11 +public interface DinerService extends IService<Diner> {
12 +
13 +}
1 +package com.tianting.infoloop.service;
2 +
3 +import com.baomidou.mybatisplus.extension.service.IService;
4 +import com.tianting.infoloop.model.db.GradeClass;
5 +
6 +/**
7 +* @author zhuyf
8 +* @description 针对表【grade_classes(年级班级表)】的数据库操作Service
9 +* @createDate 2025-04-10 13:22:20
10 +*/
11 +public interface GradeClassService extends IService<GradeClass> {
12 +
13 +}
1 +package com.tianting.infoloop.service;
2 +
3 +import com.baomidou.mybatisplus.extension.service.IService;
4 +import com.tianting.infoloop.model.db.MealMenuRecord;
5 +
6 +/**
7 +* @author zhuyf
8 +* @description 针对表【meal_menu_records(餐单记录表)】的数据库操作Service
9 +* @createDate 2025-04-10 13:22:20
10 +*/
11 +public interface MealMenuRecordService extends IService<MealMenuRecord> {
12 +
13 +}
1 +package com.tianting.infoloop.service;
2 +
3 +import com.baomidou.mybatisplus.extension.service.IService;
4 +import com.tianting.infoloop.model.db.MealOrder;
5 +
6 +/**
7 +* @author zhuyf
8 +* @description 针对表【meal_orders(订餐记录表)】的数据库操作Service
9 +* @createDate 2025-04-10 13:22:20
10 +*/
11 +public interface MealOrderService extends IService<MealOrder> {
12 +
13 +}
1 +package com.tianting.infoloop.service;
2 +
3 +import com.baomidou.mybatisplus.extension.service.IService;
4 +import com.tianting.infoloop.model.db.MpAccountDinerRef;
5 +
6 +/**
7 +* @author zhuyf
8 +* @description 针对表【mp_account_diner_refs(小程序账号和就餐人关联表)】的数据库操作Service
9 +* @createDate 2025-04-10 13:22:20
10 +*/
11 +public interface MpAccountDinerRefService extends IService<MpAccountDinerRef> {
12 +
13 +}
1 +package com.tianting.infoloop.service;
2 +
3 +import com.baomidou.mybatisplus.extension.service.IService;
4 +import com.tianting.infoloop.model.db.MpAccount;
5 +
6 +/**
7 +* @author zhuyf
8 +* @description 针对表【mp_accounts(小程序账号表)】的数据库操作Service
9 +* @createDate 2025-04-10 13:22:20
10 +*/
11 +public interface MpAccountService extends IService<MpAccount> {
12 +
13 +}
1 +package com.tianting.infoloop.service.grpc;
2 +
3 +import cn.hutool.core.date.LocalDateTimeUtil;
4 +import com.baomidou.dynamic.datasource.annotation.DS;
5 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
6 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
7 +import com.infoloop.tianting.mealorderservice.BatchCreateGradeClassesRpcRequest;
8 +import com.infoloop.tianting.mealorderservice.BatchCreateGradeClassesRpcResponse;
9 +import com.infoloop.tianting.mealorderservice.BatchCreateMealOrdersRpcRequest;
10 +import com.infoloop.tianting.mealorderservice.BatchCreateMealOrdersRpcResponse;
11 +import com.infoloop.tianting.mealorderservice.BatchSaveOrUpdateDinersRpcRequest;
12 +import com.infoloop.tianting.mealorderservice.BatchSaveOrUpdateDinersRpcResponse;
13 +import com.infoloop.tianting.mealorderservice.BatchSaveOrUpdateGradeClassesRpcRequest;
14 +import com.infoloop.tianting.mealorderservice.BatchSaveOrUpdateGradeClassesRpcResponse;
15 +import com.infoloop.tianting.mealorderservice.CreateDinerRpcRequest;
16 +import com.infoloop.tianting.mealorderservice.CreateDinerRpcResponse;
17 +import com.infoloop.tianting.mealorderservice.CreateGradeClassRpcRequest;
18 +import com.infoloop.tianting.mealorderservice.CreateGradeClassRpcResponse;
19 +import com.infoloop.tianting.mealorderservice.CreateMealMenuRecordRpcRequest;
20 +import com.infoloop.tianting.mealorderservice.CreateMealMenuRecordRpcResponse;
21 +import com.infoloop.tianting.mealorderservice.CreateMealOrderRpcRequest;
22 +import com.infoloop.tianting.mealorderservice.CreateMealOrderRpcResponse;
23 +import com.infoloop.tianting.mealorderservice.CreateMpAccountDinerRefRpcRequest;
24 +import com.infoloop.tianting.mealorderservice.CreateMpAccountDinerRefRpcResponse;
25 +import com.infoloop.tianting.mealorderservice.CreateMpAccountRpcRequest;
26 +import com.infoloop.tianting.mealorderservice.CreateMpAccountRpcResponse;
27 +import com.infoloop.tianting.mealorderservice.DeleteDinersByIdsRpcRequest;
28 +import com.infoloop.tianting.mealorderservice.DeleteDinersRpcResponse;
29 +import com.infoloop.tianting.mealorderservice.DeleteGradeClassesAndDinersByClientIdsRpcRequest;
30 +import com.infoloop.tianting.mealorderservice.DeleteGradeClassesAndDinersByClientIdsRpcResponse;
31 +import com.infoloop.tianting.mealorderservice.DeleteGradeClassesByIdsRpcRequest;
32 +import com.infoloop.tianting.mealorderservice.DeleteGradeClassesRpcResponse;
33 +import com.infoloop.tianting.mealorderservice.DeleteMealOrdersByIdsRpcRequest;
34 +import com.infoloop.tianting.mealorderservice.DeleteMealOrdersRpcResponse;
35 +import com.infoloop.tianting.mealorderservice.DeleteMpAccountDinerRefsByIdsRpcRequest;
36 +import com.infoloop.tianting.mealorderservice.DeleteMpAccountDinerRefsRpcResponse;
37 +import com.infoloop.tianting.mealorderservice.DeleteMpAccountsByIdsRpcRequest;
38 +import com.infoloop.tianting.mealorderservice.DeleteMpAccountsRpcResponse;
39 +import com.infoloop.tianting.mealorderservice.DinerModification;
40 +import com.infoloop.tianting.mealorderservice.GetDinerByIdRpcRequest;
41 +import com.infoloop.tianting.mealorderservice.GetDinerByIdRpcResponse;
42 +import com.infoloop.tianting.mealorderservice.GetDinersByIdsRpcRequest;
43 +import com.infoloop.tianting.mealorderservice.GetDinersByIdsRpcResponse;
44 +import com.infoloop.tianting.mealorderservice.GetGradeClassByIdRpcRequest;
45 +import com.infoloop.tianting.mealorderservice.GetGradeClassByIdRpcResponse;
46 +import com.infoloop.tianting.mealorderservice.GetGradeClassesByIdsRpcRequest;
47 +import com.infoloop.tianting.mealorderservice.GetGradeClassesByIdsRpcResponse;
48 +import com.infoloop.tianting.mealorderservice.GetMealMenuRecordByIdRpcRequest;
49 +import com.infoloop.tianting.mealorderservice.GetMealMenuRecordByIdRpcResponse;
50 +import com.infoloop.tianting.mealorderservice.GetMealMenuRecordsByIdsRpcRequest;
51 +import com.infoloop.tianting.mealorderservice.GetMealMenuRecordsByIdsRpcResponse;
52 +import com.infoloop.tianting.mealorderservice.GetMealOrderByIdRpcRequest;
53 +import com.infoloop.tianting.mealorderservice.GetMealOrderByIdRpcResponse;
54 +import com.infoloop.tianting.mealorderservice.GetMealOrdersByIdsRpcRequest;
55 +import com.infoloop.tianting.mealorderservice.GetMealOrdersByIdsRpcResponse;
56 +import com.infoloop.tianting.mealorderservice.GetMpAccountByIdRpcRequest;
57 +import com.infoloop.tianting.mealorderservice.GetMpAccountByIdRpcResponse;
58 +import com.infoloop.tianting.mealorderservice.GetMpAccountByOpenIdRpcRequest;
59 +import com.infoloop.tianting.mealorderservice.GetMpAccountByOpenIdRpcResponse;
60 +import com.infoloop.tianting.mealorderservice.GetMpAccountDinerRefsByIdsRpcRequest;
61 +import com.infoloop.tianting.mealorderservice.GetMpAccountDinerRefsByIdsRpcResponse;
62 +import com.infoloop.tianting.mealorderservice.GetMpAccountsByIdsRpcRequest;
63 +import com.infoloop.tianting.mealorderservice.GetMpAccountsByIdsRpcResponse;
64 +import com.infoloop.tianting.mealorderservice.MealOrderServiceRpcGrpc;
65 +import com.infoloop.tianting.mealorderservice.QueryDinersByConditionRpcRequest;
66 +import com.infoloop.tianting.mealorderservice.QueryDinersByConditionRpcResponse;
67 +import com.infoloop.tianting.mealorderservice.QueryGradeClassesByConditionRpcRequest;
68 +import com.infoloop.tianting.mealorderservice.QueryGradeClassesByConditionRpcResponse;
69 +import com.infoloop.tianting.mealorderservice.QueryLatestMealMenuRecordsByClientIdsRpcRequest;
70 +import com.infoloop.tianting.mealorderservice.QueryLatestMealMenuRecordsByClientIdsRpcResponse;
71 +import com.infoloop.tianting.mealorderservice.QueryMealMenuRecordsByConditionRpcRequest;
72 +import com.infoloop.tianting.mealorderservice.QueryMealMenuRecordsByConditionRpcResponse;
73 +import com.infoloop.tianting.mealorderservice.QueryMealOrdersByConditionRpcRequest;
74 +import com.infoloop.tianting.mealorderservice.QueryMealOrdersByConditionRpcResponse;
75 +import com.infoloop.tianting.mealorderservice.QueryMpAccountDinerRefsByConditionRpcRequest;
76 +import com.infoloop.tianting.mealorderservice.QueryMpAccountDinerRefsByConditionRpcResponse;
77 +import com.infoloop.tianting.mealorderservice.QueryMpAccountsByConditionRpcRequest;
78 +import com.infoloop.tianting.mealorderservice.QueryMpAccountsByConditionRpcResponse;
79 +import com.infoloop.tianting.mealorderservice.QueryReserveMealOrdersByDinerIdsRpcRequest;
80 +import com.infoloop.tianting.mealorderservice.QueryReserveMealOrdersByDinerIdsRpcResponse;
81 +import com.infoloop.tianting.mealorderservice.SingleDinerRpcResponse;
82 +import com.infoloop.tianting.mealorderservice.SingleGradeClassRpcResponse;
83 +import com.infoloop.tianting.mealorderservice.SingleMealMenuRecordRpcResponse;
84 +import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse;
85 +import com.infoloop.tianting.mealorderservice.SingleMpAccountDinerRefRpcResponse;
86 +import com.infoloop.tianting.mealorderservice.SingleMpAccountRpcResponse;
87 +import com.infoloop.tianting.mealorderservice.UpdateDinerRpcRequest;
88 +import com.infoloop.tianting.mealorderservice.UpdateDinerRpcResponse;
89 +import com.infoloop.tianting.mealorderservice.UpdateGradeClassRpcRequest;
90 +import com.infoloop.tianting.mealorderservice.UpdateGradeClassRpcResponse;
91 +import com.infoloop.tianting.mealorderservice.UpdateMpAccountRpcRequest;
92 +import com.infoloop.tianting.mealorderservice.UpdateMpAccountRpcResponse;
93 +import com.tianting.infoloop.model.db.Diner;
94 +import com.tianting.infoloop.model.db.GradeClass;
95 +import com.tianting.infoloop.model.db.MealMenuRecord;
96 +import com.tianting.infoloop.model.db.MealOrder;
97 +import com.tianting.infoloop.model.db.MpAccount;
98 +import com.tianting.infoloop.model.db.MpAccountDinerRef;
99 +import com.tianting.infoloop.service.DinerService;
100 +import com.tianting.infoloop.service.GradeClassService;
101 +import com.tianting.infoloop.service.MealMenuRecordService;
102 +import com.tianting.infoloop.service.MealOrderService;
103 +import com.tianting.infoloop.service.MpAccountDinerRefService;
104 +import com.tianting.infoloop.service.MpAccountService;
105 +import com.tianting.infoloop.utils.ProtoBeanUtil;
106 +import io.grpc.Status;
107 +import io.grpc.stub.StreamObserver;
108 +import lombok.RequiredArgsConstructor;
109 +import lombok.extern.slf4j.Slf4j;
110 +import org.springframework.beans.factory.annotation.Autowired;
111 +import org.springframework.stereotype.Service;
112 +import org.springframework.transaction.annotation.Transactional;
113 +
114 +import java.time.DayOfWeek;
115 +import java.time.LocalDate;
116 +import java.time.LocalDateTime;
117 +import java.time.LocalTime;
118 +import java.time.temporal.TemporalAdjusters;
119 +import java.util.ArrayList;
120 +import java.util.List;
121 +import java.util.function.Function;
122 +import java.util.stream.Collectors;
123 +
124 +import static com.tianting.infoloop.constants.ConfigConstants.DATA_SOURCE_MASTER;
125 +import static com.tianting.infoloop.constants.ConfigConstants.DATA_SOURCE_SLAVE;
126 +
127 +@Slf4j
128 +@Service
129 +@RequiredArgsConstructor(onConstructor_ = @Autowired)
130 +public class MealOrderGrpcService extends MealOrderServiceRpcGrpc.MealOrderServiceRpcImplBase {
131 +
132 + private final DinerService dinerService;
133 +
134 + private final GradeClassService gradeClassService;
135 +
136 + private final MealMenuRecordService mealMenuRecordService;
137 +
138 + private final MealOrderService mealOrderService;
139 +
140 + private final MpAccountDinerRefService mpAccountDinerRefService;
141 +
142 + private final MpAccountService mpAccountService;
143 +
144 + @Override
145 + @DS(DATA_SOURCE_SLAVE)
146 + public void getMealOrderById(final GetMealOrderByIdRpcRequest request,
147 + final StreamObserver<GetMealOrderByIdRpcResponse> responseObserver) {
148 + final var builder = GetMealOrderByIdRpcResponse.newBuilder();
149 + try {
150 + final var mealOrder = mealOrderService.getById(request.getId());
151 + if (mealOrder != null) {
152 + builder.setResponse(ProtoBeanUtil.beanToProto(mealOrder, SingleMealOrderRpcResponse.class));
153 + }
154 + } catch (final Exception e) {
155 + log.error("getMealOrderById error;", e);
156 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
157 + }
158 + responseObserver.onNext(builder.build());
159 + responseObserver.onCompleted();
160 + }
161 +
162 + @Override
163 + @DS(DATA_SOURCE_SLAVE)
164 + public void getMealOrdersByIds(final GetMealOrdersByIdsRpcRequest request,
165 + final StreamObserver<GetMealOrdersByIdsRpcResponse> responseObserver) {
166 + final var builder = GetMealOrdersByIdsRpcResponse.newBuilder();
167 + try {
168 + final var mealOrders = mealOrderService.listByIds(request.getIdsList());
169 + if (!mealOrders.isEmpty()) {
170 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealOrders, SingleMealOrderRpcResponse.class));
171 + }
172 + } catch (final Exception e) {
173 + log.error("getMealOrdersByIds error;", e);
174 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
175 + }
176 + responseObserver.onNext(builder.build());
177 + responseObserver.onCompleted();
178 + }
179 +
180 + @Override
181 + @DS(DATA_SOURCE_SLAVE)
182 + public void queryMealOrdersByCondition(final QueryMealOrdersByConditionRpcRequest request,
183 + final StreamObserver<QueryMealOrdersByConditionRpcResponse> responseObserver) {
184 + final var builder = QueryMealOrdersByConditionRpcResponse.newBuilder();
185 + try {
186 + LambdaQueryWrapper<MealOrder> queryWrapper = new LambdaQueryWrapper<>();
187 + queryWrapper.eq(MealOrder::getEnterpriseId, request.getEnterpriseId());
188 + if (request.getShouldFilterClientIds()) {
189 + queryWrapper.in(!request.getClientIdsList().isEmpty(), MealOrder::getClientId, request.getClientIdsList());
190 + }
191 + if (request.getShouldFilterMenuIds()) {
192 + queryWrapper.in(!request.getMenuIdsList().isEmpty(), MealOrder::getMenuId, request.getMenuIdsList());
193 + }
194 + if (request.getShouldFilterAccountIds()) {
195 + queryWrapper.in(!request.getAccountIdsList().isEmpty(), MealOrder::getAccountId, request.getAccountIdsList());
196 + }
197 + if (request.getShouldFilterOrderMethod()) {
198 + queryWrapper.eq(MealOrder::getOrderMethod, request.getOrderMethodValue());
199 + }
200 + if (request.getShouldFilterDinerIds()) {
201 + queryWrapper.in(!request.getDinerIdsList().isEmpty(), MealOrder::getDinerId, request.getDinerIdsList());
202 + }
203 + if (request.getShouldFilterReserveDateStart()) {
204 + queryWrapper.ge(MealOrder::getReserveDate, LocalDateTimeUtil.of(request.getReserveDateStart()));
205 + }
206 + if (request.getShouldFilterReserveDateEnd()) {
207 + queryWrapper.lt(MealOrder::getReserveDate, LocalDateTimeUtil.of(request.getReserveDateEnd()));
208 + }
209 + final var mealOrders = mealOrderService.list(queryWrapper);
210 + if (!mealOrders.isEmpty()) {
211 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealOrders, SingleMealOrderRpcResponse.class));
212 + }
213 + } catch (final Exception e) {
214 + log.error("queryMealOrdersByCondition error;", e);
215 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
216 + }
217 + responseObserver.onNext(builder.build());
218 + responseObserver.onCompleted();
219 + }
220 +
221 + @Override
222 + @DS(DATA_SOURCE_SLAVE)
223 + public void queryReserveMealOrdersByDinerIds(final QueryReserveMealOrdersByDinerIdsRpcRequest request,
224 + final StreamObserver<QueryReserveMealOrdersByDinerIdsRpcResponse> responseObserver) {
225 + final var builder = QueryReserveMealOrdersByDinerIdsRpcResponse.newBuilder();
226 + try {
227 + LambdaQueryWrapper<MealOrder> queryWrapper = new LambdaQueryWrapper<>();
228 + queryWrapper.eq(MealOrder::getEnterpriseId, request.getEnterpriseId());
229 + queryWrapper.in(!request.getDinerIdsList().isEmpty(), MealOrder::getDinerId, request.getDinerIdsList());
230 + LocalDate today = LocalDate.now();
231 + LocalDate nextMonday = today.with(TemporalAdjusters.next(DayOfWeek.MONDAY));
232 + LocalDateTime nextMondayStart = LocalDateTime.of(nextMonday, LocalTime.MIN);
233 + LocalDate nextSunday = nextMonday.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
234 + LocalDateTime nextSundayEnd = LocalDateTime.of(nextSunday, LocalTime.MAX);
235 + queryWrapper.ge(MealOrder::getReserveDate, nextMondayStart);
236 + queryWrapper.lt(MealOrder::getReserveDate, nextSundayEnd);
237 + final var mealOrders = mealOrderService.list(queryWrapper);
238 + if (!mealOrders.isEmpty()) {
239 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealOrders, SingleMealOrderRpcResponse.class));
240 + }
241 + } catch (final Exception e) {
242 + log.error("queryReserveMealOrdersByDinerIds error;", e);
243 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
244 + }
245 + responseObserver.onNext(builder.build());
246 + responseObserver.onCompleted();
247 + }
248 +
249 + @Override
250 + @DS(DATA_SOURCE_MASTER)
251 + public void createMealOrder(final CreateMealOrderRpcRequest request,
252 + final StreamObserver<CreateMealOrderRpcResponse> responseObserver) {
253 + final var builder = CreateMealOrderRpcResponse.newBuilder();
254 + try {
255 + MealOrder mealOrder = new MealOrder();
256 + mealOrder.setEnterpriseId(request.getEnterpriseId());
257 + mealOrder.setCreatedBy(request.getCreatedBy());
258 + mealOrder.setCreationSource(request.getCreationSource());
259 + mealOrder.setUpdatedBy(request.getCreatedBy());
260 + mealOrder.setUpdateSource(request.getCreationSource());
261 + mealOrder.setClientId(request.getCreation().getClientId());
262 + mealOrder.setMenuId(request.getCreation().getMenuId());
263 + mealOrder.setAccountId(request.getCreation().getAccountId());
264 + mealOrder.setOrderMethod(request.getCreation().getOrderMethodValue());
265 + mealOrder.setDinerId(request.getCreation().getDinerId());
266 + mealOrder.setDinerName(request.getCreation().getDinerName());
267 + mealOrder.setClientName(request.getCreation().getClientName());
268 + mealOrder.setGradeName(request.getCreation().getGradeName());
269 + mealOrder.setClassName(request.getCreation().getClassName());
270 + mealOrder.setStudentNo(request.getCreation().getStudentNo());
271 + mealOrder.setReserveDate(LocalDateTimeUtil.of(request.getCreation().getReserveDate()));
272 + mealOrder.setMeals(ProtoBeanUtil.protoListToJson(request.getCreation().getMealsList()));
273 + builder.setIsCreated(mealOrderService.save(mealOrder)).setId(mealOrder.getId());
274 + } catch (final Exception e) {
275 + log.error("createMealOrder error;", e);
276 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
277 + }
278 + responseObserver.onNext(builder.build());
279 + responseObserver.onCompleted();
280 + }
281 +
282 + @Override
283 + @DS(DATA_SOURCE_MASTER)
284 + public void batchCreateMealOrders(final BatchCreateMealOrdersRpcRequest request,
285 + final StreamObserver<BatchCreateMealOrdersRpcResponse> responseObserver) {
286 + final var builder = BatchCreateMealOrdersRpcResponse.newBuilder();
287 + try {
288 + final var mealOrders = new ArrayList<MealOrder>();
289 + for (final var creation : request.getCreationsList()) {
290 + MealOrder mealOrder = new MealOrder();
291 + mealOrder.setEnterpriseId(request.getEnterpriseId());
292 + mealOrder.setCreatedBy(request.getCreatedBy());
293 + mealOrder.setCreationSource(request.getCreationSource());
294 + mealOrder.setUpdatedBy(request.getCreatedBy());
295 + mealOrder.setUpdateSource(request.getCreationSource());
296 + mealOrder.setClientId(creation.getClientId());
297 + mealOrder.setMenuId(creation.getMenuId());
298 + mealOrder.setAccountId(creation.getAccountId());
299 + mealOrder.setOrderMethod(creation.getOrderMethodValue());
300 + mealOrder.setDinerId(creation.getDinerId());
301 + mealOrder.setDinerName(creation.getDinerName());
302 + mealOrder.setClientName(creation.getClientName());
303 + mealOrder.setGradeName(creation.getGradeName());
304 + mealOrder.setClassName(creation.getClassName());
305 + mealOrder.setStudentNo(creation.getStudentNo());
306 + mealOrder.setReserveDate(LocalDateTimeUtil.of(creation.getReserveDate()));
307 + mealOrder.setMeals(ProtoBeanUtil.protoListToJson(creation.getMealsList()));
308 + mealOrders.add(mealOrder);
309 + }
310 + builder.setIsCreated(mealOrderService.saveBatch(mealOrders)).addAllIds(mealOrders.stream().map(MealOrder::getId).toList());
311 + } catch (final Exception e) {
312 + log.error("batchCreateMealOrders error;", e);
313 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
314 + }
315 + responseObserver.onNext(builder.build());
316 + responseObserver.onCompleted();
317 + }
318 +
319 + @Override
320 + @DS(DATA_SOURCE_MASTER)
321 + public void deleteMealOrdersByIds(final DeleteMealOrdersByIdsRpcRequest request,
322 + final StreamObserver<DeleteMealOrdersRpcResponse> responseObserver) {
323 + final var builder = DeleteMealOrdersRpcResponse.newBuilder();
324 + try {
325 + builder.setIsDeleted(mealOrderService.removeBatchByIds(request.getIdsList()));
326 + } catch (final Exception e) {
327 + log.error("deleteMealOrdersByIds error;", e);
328 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
329 + }
330 + responseObserver.onNext(builder.build());
331 + responseObserver.onCompleted();
332 + }
333 +
334 + @Override
335 + @DS(DATA_SOURCE_SLAVE)
336 + public void getMpAccountById(final GetMpAccountByIdRpcRequest request,
337 + final StreamObserver<GetMpAccountByIdRpcResponse> responseObserver) {
338 + final var builder = GetMpAccountByIdRpcResponse.newBuilder();
339 + try {
340 + final var mealOrder = mpAccountService.getById(request.getId());
341 + if (mealOrder != null) {
342 + builder.setResponse(ProtoBeanUtil.beanToProto(mealOrder, SingleMpAccountRpcResponse.class));
343 + }
344 + } catch (final Exception e) {
345 + log.error("getMpAccountById error;", e);
346 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
347 + }
348 + responseObserver.onNext(builder.build());
349 + responseObserver.onCompleted();
350 + }
351 +
352 + @Override
353 + @DS(DATA_SOURCE_SLAVE)
354 + public void getMpAccountByOpenId(final GetMpAccountByOpenIdRpcRequest request,
355 + final StreamObserver<GetMpAccountByOpenIdRpcResponse> responseObserver) {
356 + final var builder = GetMpAccountByOpenIdRpcResponse.newBuilder();
357 + try {
358 + LambdaQueryWrapper<MpAccount> queryWrapper = Wrappers.lambdaQuery();
359 + queryWrapper.eq(MpAccount::getOpenId, request.getOpenId());
360 + final var mpAccount = mpAccountService.getOne(queryWrapper);
361 + if (mpAccount != null) {
362 + builder.setResponse(ProtoBeanUtil.beanToProto(mpAccount, SingleMpAccountRpcResponse.class));
363 + }
364 + } catch (final Exception e) {
365 + log.error("getMpAccountByOpenId error;", e);
366 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
367 + }
368 + responseObserver.onNext(builder.build());
369 + responseObserver.onCompleted();
370 + }
371 +
372 + @Override
373 + @DS(DATA_SOURCE_SLAVE)
374 + public void getMpAccountsByIds(final GetMpAccountsByIdsRpcRequest request,
375 + final StreamObserver<GetMpAccountsByIdsRpcResponse> responseObserver) {
376 + final var builder = GetMpAccountsByIdsRpcResponse.newBuilder();
377 + try {
378 + final var mealOrders = mpAccountService.listByIds(request.getIdsList());
379 + if (!mealOrders.isEmpty()) {
380 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealOrders, SingleMpAccountRpcResponse.class));
381 + }
382 + } catch (final Exception e) {
383 + log.error("getMpAccountsByIds error;", e);
384 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
385 + }
386 + responseObserver.onNext(builder.build());
387 + responseObserver.onCompleted();
388 + }
389 +
390 + @Override
391 + @DS(DATA_SOURCE_SLAVE)
392 + public void queryMpAccountsByCondition(final QueryMpAccountsByConditionRpcRequest request,
393 + final StreamObserver<QueryMpAccountsByConditionRpcResponse> responseObserver) {
394 + final var builder = QueryMpAccountsByConditionRpcResponse.newBuilder();
395 + try {
396 + LambdaQueryWrapper<MpAccount> queryWrapper = new LambdaQueryWrapper<>();
397 + queryWrapper.eq(MpAccount::getEnterpriseId, request.getEnterpriseId());
398 + if (request.getShouldFilterOpenId()) {
399 + queryWrapper.eq(MpAccount::getOpenId, request.getOpenId());
400 + }
401 + if (request.getShouldFilterUnionId()) {
402 + queryWrapper.eq(MpAccount::getUnionId, request.getUnionId());
403 + }
404 + if (request.getShouldFilterPhoneNumber()) {
405 + queryWrapper.eq(MpAccount::getPhoneNumber, request.getPhoneNumber());
406 + }
407 + if (request.getShouldFilterStatus()) {
408 + queryWrapper.eq(MpAccount::getStatus, request.getStatusValue());
409 + }
410 + final var mealOrders = mpAccountService.list(queryWrapper);
411 + if (!mealOrders.isEmpty()) {
412 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealOrders, SingleMpAccountRpcResponse.class));
413 + }
414 + } catch (final Exception e) {
415 + log.error("queryMpAccountsByCondition error;", e);
416 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
417 + }
418 + responseObserver.onNext(builder.build());
419 + responseObserver.onCompleted();
420 + }
421 +
422 + @Override
423 + @DS(DATA_SOURCE_MASTER)
424 + public void createMpAccount(final CreateMpAccountRpcRequest request,
425 + final StreamObserver<CreateMpAccountRpcResponse> responseObserver) {
426 + final var builder = CreateMpAccountRpcResponse.newBuilder();
427 + try {
428 + MpAccount mpAccount = new MpAccount();
429 + mpAccount.setEnterpriseId(request.getEnterpriseId());
430 + mpAccount.setCreatedBy(request.getCreatedBy());
431 + mpAccount.setCreationSource(request.getCreationSource());
432 + mpAccount.setUpdatedBy(request.getCreatedBy());
433 + mpAccount.setUpdateSource(request.getCreationSource());
434 + mpAccount.setOpenId(request.getCreation().getOpenId());
435 + if (request.getCreation().getShouldCreateUnionId()) {
436 + mpAccount.setUnionId(request.getCreation().getUnionId());
437 + }
438 + if (request.getCreation().getShouldCreateNickname()) {
439 + mpAccount.setNickname(request.getCreation().getNickname());
440 + }
441 + if (request.getCreation().getShouldCreateAvatarUrl()) {
442 + mpAccount.setAvatarUrl(request.getCreation().getAvatarUrl());
443 + }
444 + mpAccount.setGender(request.getCreation().getGenderValue());
445 + mpAccount.setPhoneNumber(request.getCreation().getPhoneNumber());
446 + mpAccount.setStatus(request.getCreation().getStatusValue());
447 + builder.setIsCreated(mpAccountService.save(mpAccount)).setId(mpAccount.getId());
448 + } catch (final Exception e) {
449 + log.error("createMpAccount error;", e);
450 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
451 + }
452 + responseObserver.onNext(builder.build());
453 + responseObserver.onCompleted();
454 + }
455 +
456 + @Override
457 + @DS(DATA_SOURCE_MASTER)
458 + public void updateMpAccount(final UpdateMpAccountRpcRequest request,
459 + final StreamObserver<UpdateMpAccountRpcResponse> responseObserver) {
460 + final var builder = UpdateMpAccountRpcResponse.newBuilder();
461 + try {
462 + MpAccount mpAccount = new MpAccount();
463 + mpAccount.setId(request.getModification().getId());
464 + mpAccount.setEnterpriseId(request.getEnterpriseId());
465 + mpAccount.setUpdatedBy(request.getUpdatedBy());
466 + mpAccount.setUpdateSource(request.getUpdateSource());
467 + if (request.getModification().getShouldUpdateNickname()) {
468 + mpAccount.setNickname(request.getModification().getNickname());
469 + }
470 + if (request.getModification().getShouldUpdateAvatarUrl()) {
471 + mpAccount.setAvatarUrl(request.getModification().getAvatarUrl());
472 + }
473 + if (request.getModification().getShouldUpdateGender()) {
474 + mpAccount.setGender(request.getModification().getGenderValue());
475 + }
476 + if (request.getModification().getShouldUpdatePhoneNumber()) {
477 + mpAccount.setPhoneNumber(request.getModification().getPhoneNumber());
478 + }
479 + if (request.getModification().getShouldUpdateStatus()) {
480 + mpAccount.setStatus(request.getModification().getStatusValue());
481 + }
482 + builder.setIsUpdated(mpAccountService.updateById(mpAccount));
483 + } catch (final Exception e) {
484 + log.error("updateMpAccount error;", e);
485 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
486 + }
487 + responseObserver.onNext(builder.build());
488 + responseObserver.onCompleted();
489 + }
490 +
491 + @Override
492 + @DS(DATA_SOURCE_MASTER)
493 + public void deleteMpAccountsByIds(final DeleteMpAccountsByIdsRpcRequest request,
494 + final StreamObserver<DeleteMpAccountsRpcResponse> responseObserver) {
495 + final var builder = DeleteMpAccountsRpcResponse.newBuilder();
496 + try {
497 + builder.setIsDeleted(mpAccountService.removeBatchByIds(request.getIdsList()));
498 + } catch (final Exception e) {
499 + log.error("deleteMpAccountsByIds error;", e);
500 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
501 + }
502 + responseObserver.onNext(builder.build());
503 + responseObserver.onCompleted();
504 + }
505 +
506 + @Override
507 + @DS(DATA_SOURCE_SLAVE)
508 + public void getDinerById(final GetDinerByIdRpcRequest request,
509 + final StreamObserver<GetDinerByIdRpcResponse> responseObserver) {
510 + final var builder = GetDinerByIdRpcResponse.newBuilder();
511 + try {
512 + final var mealOrder = dinerService.getById(request.getId());
513 + if (mealOrder != null) {
514 + builder.setResponse(ProtoBeanUtil.beanToProto(mealOrder, SingleDinerRpcResponse.class));
515 + }
516 + } catch (final Exception e) {
517 + log.error("getDinerById error;", e);
518 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
519 + }
520 + responseObserver.onNext(builder.build());
521 + responseObserver.onCompleted();
522 + }
523 +
524 + @Override
525 + @DS(DATA_SOURCE_SLAVE)
526 + public void getDinersByIds(final GetDinersByIdsRpcRequest request,
527 + final StreamObserver<GetDinersByIdsRpcResponse> responseObserver) {
528 + final var builder = GetDinersByIdsRpcResponse.newBuilder();
529 + try {
530 + final var mealOrders = dinerService.listByIds(request.getIdsList());
531 + if (!mealOrders.isEmpty()) {
532 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealOrders, SingleDinerRpcResponse.class));
533 + }
534 + } catch (final Exception e) {
535 + log.error("getDinersByIds error;", e);
536 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
537 + }
538 + responseObserver.onNext(builder.build());
539 + responseObserver.onCompleted();
540 + }
541 +
542 + @Override
543 + @DS(DATA_SOURCE_SLAVE)
544 + public void queryDinersByCondition(final QueryDinersByConditionRpcRequest request,
545 + final StreamObserver<QueryDinersByConditionRpcResponse> responseObserver) {
546 + final var builder = QueryDinersByConditionRpcResponse.newBuilder();
547 + try {
548 + LambdaQueryWrapper<Diner> queryWrapper = new LambdaQueryWrapper<>();
549 + queryWrapper.eq(Diner::getEnterpriseId, request.getEnterpriseId());
550 + if (request.getShouldFilterClientIds()) {
551 + queryWrapper.in(!request.getClientIdsList().isEmpty(), Diner::getClientId, request.getClientIdsList());
552 + }
553 + if (request.getShouldFilterClassIds()) {
554 + queryWrapper.in(!request.getClassIdsList().isEmpty(), Diner::getClassId, request.getClassIdsList());
555 + }
556 + if (request.getShouldFilterStudentNo()) {
557 + queryWrapper.eq(Diner::getStudentNo, request.getStudentNo());
558 + }
559 + if (request.getShouldFilterName()) {
560 + queryWrapper.eq(Diner::getName, request.getName());
561 + }
562 + final var diners = dinerService.list(queryWrapper);
563 + if (!diners.isEmpty()) {
564 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(diners, SingleDinerRpcResponse.class));
565 + }
566 + } catch (final Exception e) {
567 + log.error("queryDinersByCondition error;", e);
568 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
569 + }
570 + responseObserver.onNext(builder.build());
571 + responseObserver.onCompleted();
572 + }
573 +
574 + @Override
575 + @DS(DATA_SOURCE_MASTER)
576 + public void createDiner(final CreateDinerRpcRequest request,
577 + final StreamObserver<CreateDinerRpcResponse> responseObserver) {
578 + final var builder = CreateDinerRpcResponse.newBuilder();
579 + try {
580 + Diner diner = new Diner();
581 + diner.setEnterpriseId(request.getEnterpriseId());
582 + diner.setCreatedBy(request.getCreatedBy());
583 + diner.setCreationSource(request.getCreationSource());
584 + diner.setUpdatedBy(request.getCreatedBy());
585 + diner.setUpdateSource(request.getCreationSource());
586 + diner.setClientId(request.getCreation().getClientId());
587 + diner.setClassId(request.getCreation().getClassId());
588 + diner.setStudentNo(request.getCreation().getStudentNo());
589 + diner.setName(request.getCreation().getName());
590 + builder.setIsCreated(dinerService.save(diner)).setId(diner.getId());
591 + } catch (final Exception e) {
592 + log.error("createDiner error;", e);
593 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
594 + }
595 + responseObserver.onNext(builder.build());
596 + responseObserver.onCompleted();
597 + }
598 +
599 + @Override
600 + @DS(DATA_SOURCE_MASTER)
601 + public void updateDiner(final UpdateDinerRpcRequest request,
602 + final StreamObserver<UpdateDinerRpcResponse> responseObserver) {
603 + final var builder = UpdateDinerRpcResponse.newBuilder();
604 + try {
605 + Diner diner = new Diner();
606 + diner.setId(request.getModification().getId());
607 + diner.setEnterpriseId(request.getEnterpriseId());
608 + diner.setUpdatedBy(request.getUpdatedBy());
609 + diner.setUpdateSource(request.getUpdateSource());
610 + if (request.getModification().getShouldUpdateClientId()) {
611 + diner.setClientId(request.getModification().getClientId());
612 + }
613 + if (request.getModification().getShouldUpdateClassId()) {
614 + diner.setClassId(request.getModification().getClassId());
615 + }
616 + if (request.getModification().getShouldUpdateStudentNo()) {
617 + diner.setStudentNo(request.getModification().getStudentNo());
618 + }
619 + if (request.getModification().getShouldUpdateName()) {
620 + diner.setName(request.getModification().getName());
621 + }
622 + builder.setIsUpdated(dinerService.updateById(diner));
623 + } catch (final Exception e) {
624 + log.error("updateDiner error;", e);
625 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
626 + }
627 + responseObserver.onNext(builder.build());
628 + responseObserver.onCompleted();
629 + }
630 +
631 + @Override
632 + @DS(DATA_SOURCE_MASTER)
633 + public void batchSaveOrUpdateDiners(final BatchSaveOrUpdateDinersRpcRequest request,
634 + final StreamObserver<BatchSaveOrUpdateDinersRpcResponse> responseObserver) {
635 + final var builder = BatchSaveOrUpdateDinersRpcResponse.newBuilder();
636 + try {
637 + final var diners = new ArrayList<Diner>();
638 + for (DinerModification modification : request.getModificationsList()) {
639 + Diner diner = new Diner();
640 + diner.setId(modification.getId() == 0 ? null : modification.getId());
641 + diner.setEnterpriseId(request.getEnterpriseId());
642 + if (modification.getId() == 0) {
643 + diner.setCreatedBy(request.getUpdatedBy());
644 + diner.setCreationSource(request.getUpdateSource());
645 + }
646 + diner.setUpdatedBy(request.getUpdatedBy());
647 + diner.setUpdateSource(request.getUpdateSource());
648 + if (modification.getShouldUpdateClientId()) {
649 + diner.setClientId(modification.getClientId());
650 + }
651 + if (modification.getShouldUpdateClassId()) {
652 + diner.setClassId(modification.getClassId());
653 + }
654 + if (modification.getShouldUpdateStudentNo()) {
655 + diner.setStudentNo(modification.getStudentNo());
656 + }
657 + if (modification.getShouldUpdateName()) {
658 + diner.setName(modification.getName());
659 + }
660 + diners.add(diner);
661 + }
662 + builder.setIsUpdated(dinerService.saveOrUpdateBatch(diners));
663 + } catch (final Exception e) {
664 + log.error("batchSaveOrUpdateDiners error;", e);
665 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
666 + }
667 + responseObserver.onNext(builder.build());
668 + responseObserver.onCompleted();
669 + }
670 +
671 + @Override
672 + @DS(DATA_SOURCE_MASTER)
673 + public void deleteDinersByIds(final DeleteDinersByIdsRpcRequest request,
674 + final StreamObserver<DeleteDinersRpcResponse> responseObserver) {
675 + final var builder = DeleteDinersRpcResponse.newBuilder();
676 + try {
677 + builder.setIsDeleted(dinerService.removeBatchByIds(request.getIdsList()));
678 + } catch (final Exception e) {
679 + log.error("deleteDinersByIds error;", e);
680 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
681 + }
682 + responseObserver.onNext(builder.build());
683 + responseObserver.onCompleted();
684 + }
685 +
686 + @Override
687 + @DS(DATA_SOURCE_SLAVE)
688 + public void getMpAccountDinerRefsByIds(final GetMpAccountDinerRefsByIdsRpcRequest request,
689 + final StreamObserver<GetMpAccountDinerRefsByIdsRpcResponse> responseObserver) {
690 + final var builder = GetMpAccountDinerRefsByIdsRpcResponse.newBuilder();
691 + try {
692 + final var mpAccountDinerRefs = mpAccountDinerRefService.listByIds(request.getIdsList());
693 + if (!mpAccountDinerRefs.isEmpty()) {
694 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mpAccountDinerRefs, SingleMpAccountDinerRefRpcResponse.class));
695 + }
696 + } catch (final Exception e) {
697 + log.error("getMpAccountDinerRefsByIds error;", e);
698 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
699 + }
700 + responseObserver.onNext(builder.build());
701 + responseObserver.onCompleted();
702 + }
703 +
704 + @Override
705 + @DS(DATA_SOURCE_SLAVE)
706 + public void queryMpAccountDinerRefsByCondition(final QueryMpAccountDinerRefsByConditionRpcRequest request,
707 + final StreamObserver<QueryMpAccountDinerRefsByConditionRpcResponse> responseObserver) {
708 + final var builder = QueryMpAccountDinerRefsByConditionRpcResponse.newBuilder();
709 + try {
710 + LambdaQueryWrapper<MpAccountDinerRef> queryWrapper = new LambdaQueryWrapper<>();
711 + queryWrapper.eq(MpAccountDinerRef::getEnterpriseId, request.getEnterpriseId());
712 + if (request.getShouldFilterAccountIds()) {
713 + queryWrapper.in(!request.getAccountIdsList().isEmpty(), MpAccountDinerRef::getAccountId, request.getAccountIdsList());
714 + }
715 + if (request.getShouldFilterDinerIds()) {
716 + queryWrapper.in(!request.getDinerIdsList().isEmpty(), MpAccountDinerRef::getDinerId, request.getDinerIdsList());
717 + }
718 + final var diners = mpAccountDinerRefService.list(queryWrapper);
719 + if (!diners.isEmpty()) {
720 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(diners, SingleMpAccountDinerRefRpcResponse.class));
721 + }
722 + } catch (final Exception e) {
723 + log.error("queryMpAccountDinerRefsByCondition error;", e);
724 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
725 + }
726 + responseObserver.onNext(builder.build());
727 + responseObserver.onCompleted();
728 + }
729 +
730 + @Override
731 + @DS(DATA_SOURCE_MASTER)
732 + public void createMpAccountDinerRef(final CreateMpAccountDinerRefRpcRequest request,
733 + final StreamObserver<CreateMpAccountDinerRefRpcResponse> responseObserver) {
734 + final var builder = CreateMpAccountDinerRefRpcResponse.newBuilder();
735 + try {
736 + MpAccountDinerRef mpAccountDinerRef = new MpAccountDinerRef();
737 + mpAccountDinerRef.setEnterpriseId(request.getEnterpriseId());
738 + mpAccountDinerRef.setCreatedBy(request.getCreatedBy());
739 + mpAccountDinerRef.setCreationSource(request.getCreationSource());
740 + mpAccountDinerRef.setAccountId(request.getCreation().getAccountId());
741 + mpAccountDinerRef.setDinerId(request.getCreation().getDinerId());
742 + builder.setIsCreated(mpAccountDinerRefService.save(mpAccountDinerRef)).setId(mpAccountDinerRef.getId());
743 + } catch (final Exception e) {
744 + log.error("createMpAccountDinerRef error;", e);
745 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
746 + }
747 + responseObserver.onNext(builder.build());
748 + responseObserver.onCompleted();
749 + }
750 +
751 + @Override
752 + @DS(DATA_SOURCE_MASTER)
753 + public void deleteMpAccountDinerRefsByIds(final DeleteMpAccountDinerRefsByIdsRpcRequest request,
754 + final StreamObserver<DeleteMpAccountDinerRefsRpcResponse> responseObserver) {
755 + final var builder = DeleteMpAccountDinerRefsRpcResponse.newBuilder();
756 + try {
757 + builder.setIsDeleted(mpAccountDinerRefService.removeBatchByIds(request.getIdsList()));
758 + } catch (final Exception e) {
759 + log.error("deleteMpAccountDinerRefsByIds error;", e);
760 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
761 + }
762 + responseObserver.onNext(builder.build());
763 + responseObserver.onCompleted();
764 + }
765 +
766 + @Override
767 + @DS(DATA_SOURCE_SLAVE)
768 + public void getGradeClassById(final GetGradeClassByIdRpcRequest request,
769 + final StreamObserver<GetGradeClassByIdRpcResponse> responseObserver) {
770 + final var builder = GetGradeClassByIdRpcResponse.newBuilder();
771 + try {
772 + final var gradeClass = gradeClassService.getById(request.getId());
773 + if (gradeClass != null) {
774 + builder.setResponse(ProtoBeanUtil.beanToProto(gradeClass, SingleGradeClassRpcResponse.class));
775 + }
776 + } catch (final Exception e) {
777 + log.error("getGradeClassById error;", e);
778 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
779 + }
780 + responseObserver.onNext(builder.build());
781 + responseObserver.onCompleted();
782 + }
783 +
784 + @Override
785 + @DS(DATA_SOURCE_SLAVE)
786 + public void getGradeClassesByIds(final GetGradeClassesByIdsRpcRequest request,
787 + final StreamObserver<GetGradeClassesByIdsRpcResponse> responseObserver) {
788 + final var builder = GetGradeClassesByIdsRpcResponse.newBuilder();
789 + try {
790 + final var gradeClasses = gradeClassService.listByIds(request.getIdsList());
791 + if (!gradeClasses.isEmpty()) {
792 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(gradeClasses, SingleGradeClassRpcResponse.class));
793 + }
794 + } catch (final Exception e) {
795 + log.error("getGradeClassesByIds error;", e);
796 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
797 + }
798 + responseObserver.onNext(builder.build());
799 + responseObserver.onCompleted();
800 + }
801 +
802 + @Override
803 + @DS(DATA_SOURCE_SLAVE)
804 + public void queryGradeClassesByCondition(final QueryGradeClassesByConditionRpcRequest request,
805 + final StreamObserver<QueryGradeClassesByConditionRpcResponse> responseObserver) {
806 + final var builder = QueryGradeClassesByConditionRpcResponse.newBuilder();
807 + try {
808 + LambdaQueryWrapper<GradeClass> queryWrapper = new LambdaQueryWrapper<>();
809 + queryWrapper.eq(GradeClass::getEnterpriseId, request.getEnterpriseId());
810 + if (request.getShouldFilterClientIds()) {
811 + queryWrapper.in(!request.getClientIdsList().isEmpty(), GradeClass::getClientId, request.getClientIdsList());
812 + }
813 + if (request.getShouldFilterGradeName()) {
814 + queryWrapper.eq(GradeClass::getGradeName, request.getGradeName());
815 + }
816 + final var gradeClasses = gradeClassService.list(queryWrapper);
817 + if (!gradeClasses.isEmpty()) {
818 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(gradeClasses, SingleGradeClassRpcResponse.class));
819 + }
820 + } catch (final Exception e) {
821 + log.error("queryGradeClassesByCondition error;", e);
822 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
823 + }
824 + responseObserver.onNext(builder.build());
825 + responseObserver.onCompleted();
826 + }
827 +
828 + @Override
829 + @DS(DATA_SOURCE_MASTER)
830 + public void createGradeClass(final CreateGradeClassRpcRequest request,
831 + final StreamObserver<CreateGradeClassRpcResponse> responseObserver) {
832 + final var builder = CreateGradeClassRpcResponse.newBuilder();
833 + try {
834 + GradeClass gradeClass = new GradeClass();
835 + gradeClass.setEnterpriseId(request.getEnterpriseId());
836 + gradeClass.setCreatedBy(request.getCreatedBy());
837 + gradeClass.setCreationSource(request.getCreationSource());
838 + gradeClass.setUpdatedBy(request.getCreatedBy());
839 + gradeClass.setUpdateSource(request.getCreationSource());
840 + gradeClass.setClientId(request.getCreation().getClientId());
841 + gradeClass.setGradeName(request.getCreation().getGradeName());
842 + gradeClass.setClassName(request.getCreation().getClassName());
843 + builder.setIsCreated(gradeClassService.save(gradeClass)).setId(gradeClass.getId());
844 + } catch (final Exception e) {
845 + log.error("createGradeClass error;", e);
846 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
847 + }
848 + responseObserver.onNext(builder.build());
849 + responseObserver.onCompleted();
850 + }
851 +
852 + @Override
853 + @DS(DATA_SOURCE_MASTER)
854 + public void batchCreateGradeClasses(final BatchCreateGradeClassesRpcRequest request,
855 + final StreamObserver<BatchCreateGradeClassesRpcResponse> responseObserver) {
856 + final var builder = BatchCreateGradeClassesRpcResponse.newBuilder();
857 + try {
858 + final var gradeClasses = new ArrayList<GradeClass>();
859 + for (final var creation : request.getCreationsList()) {
860 + final var gradeClass = new GradeClass();
861 + gradeClass.setEnterpriseId(request.getEnterpriseId());
862 + gradeClass.setCreatedBy(request.getCreatedBy());
863 + gradeClass.setCreationSource(request.getCreationSource());
864 + gradeClass.setClientId(creation.getClientId());
865 + gradeClass.setGradeName(creation.getGradeName());
866 + gradeClass.setClassName(creation.getClassName());
867 + gradeClasses.add(gradeClass);
868 + }
869 + builder.setIsCreated(gradeClassService.saveBatch(gradeClasses)).addAllIds(gradeClasses.stream().map(GradeClass::getId).collect(Collectors.toList()));
870 + } catch (final Exception e) {
871 + log.error("batchCreateGradeClasses error;", e);
872 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
873 + }
874 + responseObserver.onNext(builder.build());
875 + responseObserver.onCompleted();
876 + }
877 +
878 + @Override
879 + @DS(DATA_SOURCE_MASTER)
880 + public void updateGradeClass(final UpdateGradeClassRpcRequest request,
881 + final StreamObserver<UpdateGradeClassRpcResponse> responseObserver) {
882 + final var builder = UpdateGradeClassRpcResponse.newBuilder();
883 + try {
884 + GradeClass gradeClass = new GradeClass();
885 + gradeClass.setId(request.getModification().getId());
886 + gradeClass.setEnterpriseId(request.getEnterpriseId());
887 + gradeClass.setUpdatedBy(request.getUpdatedBy());
888 + gradeClass.setUpdateSource(request.getUpdateSource());
889 + if (request.getModification().getShouldUpdateClientId()) {
890 + gradeClass.setClientId(request.getModification().getClientId());
891 + }
892 + if (request.getModification().getShouldUpdateClassName()) {
893 + gradeClass.setClassName(request.getModification().getClassName());
894 + }
895 + if (request.getModification().getShouldUpdateGradeName()) {
896 + gradeClass.setGradeName(request.getModification().getGradeName());
897 + }
898 + builder.setIsUpdated(gradeClassService.updateById(gradeClass));
899 + } catch (final Exception e) {
900 + log.error("updateGradeClass error;", e);
901 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
902 + }
903 + responseObserver.onNext(builder.build());
904 + responseObserver.onCompleted();
905 + }
906 +
907 + @Override
908 + @DS(DATA_SOURCE_MASTER)
909 + public void batchSaveOrUpdateGradeClasses(final BatchSaveOrUpdateGradeClassesRpcRequest request,
910 + final StreamObserver<BatchSaveOrUpdateGradeClassesRpcResponse> responseObserver) {
911 + final var builder = BatchSaveOrUpdateGradeClassesRpcResponse.newBuilder();
912 + try {
913 + List<GradeClass> gradeClasses = new ArrayList<>();
914 + for (final var modification : request.getModificationsList()) {
915 + GradeClass gradeClass = new GradeClass();
916 + gradeClass.setId(modification.getId() == 0 ? null : modification.getId());
917 + gradeClass.setEnterpriseId(request.getEnterpriseId());
918 + if (modification.getId() == 0) {
919 + gradeClass.setCreatedBy(request.getUpdatedBy());
920 + gradeClass.setCreationSource(request.getUpdateSource());
921 + }
922 + gradeClass.setUpdatedBy(request.getUpdatedBy());
923 + gradeClass.setUpdateSource(request.getUpdateSource());
924 + if (modification.getShouldUpdateClientId()) {
925 + gradeClass.setClientId(modification.getClientId());
926 + }
927 + if (modification.getShouldUpdateClassName()) {
928 + gradeClass.setClassName(modification.getClassName());
929 + }
930 + if (modification.getShouldUpdateGradeName()) {
931 + gradeClass.setGradeName(modification.getGradeName());
932 + }
933 + gradeClasses.add(gradeClass);
934 + }
935 + builder.setIsUpdated(gradeClassService.saveOrUpdateBatch(gradeClasses));
936 + } catch (final Exception e) {
937 + log.error("updateGradeClass error;", e);
938 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
939 + }
940 + responseObserver.onNext(builder.build());
941 + responseObserver.onCompleted();
942 + }
943 +
944 + @Override
945 + @DS(DATA_SOURCE_MASTER)
946 + public void deleteGradeClassesByIds(final DeleteGradeClassesByIdsRpcRequest request,
947 + final StreamObserver<DeleteGradeClassesRpcResponse> responseObserver) {
948 + final var builder = DeleteGradeClassesRpcResponse.newBuilder();
949 + try {
950 + builder.setIsDeleted(gradeClassService.removeBatchByIds(request.getIdsList()));
951 + } catch (final Exception e) {
952 + log.error("deleteGradeClassesByIds error;", e);
953 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
954 + }
955 + responseObserver.onNext(builder.build());
956 + responseObserver.onCompleted();
957 + }
958 +
959 + @Override
960 + @DS(DATA_SOURCE_MASTER)
961 + @Transactional(rollbackFor = Exception.class)
962 + public void deleteGradeClassesAndDinersByClientIds(final DeleteGradeClassesAndDinersByClientIdsRpcRequest request,
963 + final StreamObserver<DeleteGradeClassesAndDinersByClientIdsRpcResponse> responseObserver) {
964 + final var builder = DeleteGradeClassesAndDinersByClientIdsRpcResponse.newBuilder();
965 + try {
966 + LambdaQueryWrapper<GradeClass> queryWrapper = Wrappers.lambdaQuery();
967 + queryWrapper.in(GradeClass::getEnterpriseId, request.getEnterpriseId());
968 + queryWrapper.in(GradeClass::getClientId, request.getClientIdsList());
969 + final boolean remove = gradeClassService.remove(queryWrapper);
970 + LambdaQueryWrapper<Diner> dinerLambdaQueryWrapper = Wrappers.lambdaQuery();
971 + dinerLambdaQueryWrapper.in(Diner::getEnterpriseId, request.getEnterpriseId());
972 + dinerLambdaQueryWrapper.in(Diner::getClientId, request.getClientIdsList());
973 + final var diners = dinerService.list(dinerLambdaQueryWrapper);
974 + final var remove1 = dinerService.remove(dinerLambdaQueryWrapper);
975 + boolean remove2 = false;
976 + if (!diners.isEmpty()) {
977 + LambdaQueryWrapper<MpAccountDinerRef> mpAccountDinerRefLambdaQueryWrapper = Wrappers.lambdaQuery();
978 + mpAccountDinerRefLambdaQueryWrapper.in(MpAccountDinerRef::getEnterpriseId, request.getEnterpriseId());
979 + mpAccountDinerRefLambdaQueryWrapper.in(MpAccountDinerRef::getDinerId, diners.stream().map(Diner::getId).collect(Collectors.toList()));
980 + remove2 = mpAccountDinerRefService.remove(mpAccountDinerRefLambdaQueryWrapper);
981 + }
982 + builder.setIsDeleted(remove && remove1 && remove2);
983 + } catch (final Exception e) {
984 + log.error("deleteGradeClassesAndDinersByClientIds error;", e);
985 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
986 + }
987 + responseObserver.onNext(builder.build());
988 + responseObserver.onCompleted();
989 + }
990 +
991 + @Override
992 + @DS(DATA_SOURCE_SLAVE)
993 + public void getMealMenuRecordById(final GetMealMenuRecordByIdRpcRequest request,
994 + final StreamObserver<GetMealMenuRecordByIdRpcResponse> responseObserver) {
995 + final var builder = GetMealMenuRecordByIdRpcResponse.newBuilder();
996 + try {
997 + final var mealMenuRecord = mealMenuRecordService.getById(request.getId());
998 + if (mealMenuRecord != null) {
999 + builder.setResponse(ProtoBeanUtil.beanToProto(mealMenuRecord, SingleMealMenuRecordRpcResponse.class));
1000 + }
1001 + } catch (final Exception e) {
1002 + log.error("getMealMenuRecordById error;", e);
1003 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1004 + }
1005 + responseObserver.onNext(builder.build());
1006 + responseObserver.onCompleted();
1007 + }
1008 +
1009 + @Override
1010 + @DS(DATA_SOURCE_SLAVE)
1011 + public void getMealMenuRecordsByIds(final GetMealMenuRecordsByIdsRpcRequest request,
1012 + final StreamObserver<GetMealMenuRecordsByIdsRpcResponse> responseObserver) {
1013 + final var builder = GetMealMenuRecordsByIdsRpcResponse.newBuilder();
1014 + try {
1015 + final var mealMenuRecords = mealMenuRecordService.listByIds(request.getIdsList());
1016 + if (!mealMenuRecords.isEmpty()) {
1017 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealMenuRecords, SingleMealMenuRecordRpcResponse.class));
1018 + }
1019 + } catch (final Exception e) {
1020 + log.error("getMealMenuRecordsByIds error;", e);
1021 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1022 + }
1023 + responseObserver.onNext(builder.build());
1024 + responseObserver.onCompleted();
1025 + }
1026 +
1027 + @Override
1028 + @DS(DATA_SOURCE_SLAVE)
1029 + public void queryMealMenuRecordsByCondition(final QueryMealMenuRecordsByConditionRpcRequest request,
1030 + final StreamObserver<QueryMealMenuRecordsByConditionRpcResponse> responseObserver) {
1031 + final var builder = QueryMealMenuRecordsByConditionRpcResponse.newBuilder();
1032 + try {
1033 + LambdaQueryWrapper<MealMenuRecord> queryWrapper = new LambdaQueryWrapper<>();
1034 + queryWrapper.eq(MealMenuRecord::getEnterpriseId, request.getEnterpriseId());
1035 + if (request.getShouldFilterClientIds()) {
1036 + queryWrapper.in(!request.getClientIdsList().isEmpty(), MealMenuRecord::getClientId, request.getClientIdsList());
1037 + }
1038 + if (request.getShouldFilterName()) {
1039 + queryWrapper.eq(MealMenuRecord::getName, request.getName());
1040 + }
1041 + final var diners = mealMenuRecordService.list(queryWrapper);
1042 + if (!diners.isEmpty()) {
1043 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(diners, SingleMealMenuRecordRpcResponse.class));
1044 + }
1045 + } catch (final Exception e) {
1046 + log.error("queryMealMenuRecordsByCondition error;", e);
1047 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1048 + }
1049 + responseObserver.onNext(builder.build());
1050 + responseObserver.onCompleted();
1051 + }
1052 +
1053 + @Override
1054 + @DS(DATA_SOURCE_SLAVE)
1055 + public void queryLatestMealMenuRecordsByClientIds(final QueryLatestMealMenuRecordsByClientIdsRpcRequest request,
1056 + final StreamObserver<QueryLatestMealMenuRecordsByClientIdsRpcResponse> responseObserver) {
1057 + final var builder = QueryLatestMealMenuRecordsByClientIdsRpcResponse.newBuilder();
1058 + try {
1059 + final var queryWrapper = new LambdaQueryWrapper<MealMenuRecord>();
1060 + queryWrapper.eq(MealMenuRecord::getEnterpriseId, request.getEnterpriseId());
1061 + queryWrapper.in(MealMenuRecord::getClientId, request.getClientIdList());
1062 + queryWrapper.orderByDesc(MealMenuRecord::getCreatedAt);
1063 + final var allRecords = mealMenuRecordService.list(queryWrapper);
1064 + final var latestRecordsMap = allRecords.stream().collect(Collectors.toMap(MealMenuRecord::getClientId, Function.identity(), (existing, replacement) -> existing));
1065 + if (!latestRecordsMap.isEmpty()) {
1066 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(new ArrayList<>(latestRecordsMap.values()), SingleMealMenuRecordRpcResponse.class));
1067 + }
1068 + } catch (final Exception e) {
1069 + log.error("queryLatestMealMenuRecordsByClientIds error;", e);
1070 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1071 + }
1072 + responseObserver.onNext(builder.build());
1073 + responseObserver.onCompleted();
1074 + }
1075 +
1076 + @Override
1077 + @DS(DATA_SOURCE_MASTER)
1078 + public void createMealMenuRecord(final CreateMealMenuRecordRpcRequest request,
1079 + final StreamObserver<CreateMealMenuRecordRpcResponse> responseObserver) {
1080 + final var builder = CreateMealMenuRecordRpcResponse.newBuilder();
1081 + try {
1082 + MealMenuRecord mealMenuRecord = new MealMenuRecord();
1083 + mealMenuRecord.setEnterpriseId(request.getEnterpriseId());
1084 + mealMenuRecord.setCreatedBy(request.getCreatedBy());
1085 + mealMenuRecord.setCreationSource(request.getCreationSource());
1086 + mealMenuRecord.setUpdatedBy(request.getCreatedBy());
1087 + mealMenuRecord.setUpdateSource(request.getCreationSource());
1088 + mealMenuRecord.setClientId(request.getCreation().getClientId());
1089 + mealMenuRecord.setName(request.getCreation().getName());
1090 + mealMenuRecord.setImageUrl(request.getCreation().getImageUrl());
1091 + builder.setIsCreated(mealMenuRecordService.save(mealMenuRecord)).setId(mealMenuRecord.getId());
1092 + } catch (final Exception e) {
1093 + log.error("createMealMenuRecord error;", e);
1094 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1095 + }
1096 + responseObserver.onNext(builder.build());
1097 + responseObserver.onCompleted();
1098 + }
1099 +}
1 +package com.tianting.infoloop.service.impl;
2 +
3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 +import com.tianting.infoloop.mapper.DinerMapper;
5 +import com.tianting.infoloop.model.db.Diner;
6 +import com.tianting.infoloop.service.DinerService;
7 +import org.springframework.stereotype.Service;
8 +
9 +/**
10 +* @author zhuyf
11 +* @description 针对表【diners(就餐人表)】的数据库操作Service实现
12 +* @createDate 2025-04-10 13:22:20
13 +*/
14 +@Service
15 +public class DinerServiceImpl extends ServiceImpl<DinerMapper, Diner>
16 + implements DinerService{
17 +
18 +}
19 +
20 +
21 +
22 +
1 +package com.tianting.infoloop.service.impl;
2 +
3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 +import com.tianting.infoloop.mapper.GradeClassMapper;
5 +import com.tianting.infoloop.model.db.GradeClass;
6 +import com.tianting.infoloop.service.GradeClassService;
7 +import org.springframework.stereotype.Service;
8 +
9 +/**
10 +* @author zhuyf
11 +* @description 针对表【grade_classes(年级班级表)】的数据库操作Service实现
12 +* @createDate 2025-04-10 13:22:20
13 +*/
14 +@Service
15 +public class GradeClassServiceImpl extends ServiceImpl<GradeClassMapper, GradeClass>
16 + implements GradeClassService{
17 +
18 +}
19 +
20 +
21 +
22 +
1 +package com.tianting.infoloop.service.impl;
2 +
3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 +import com.tianting.infoloop.mapper.MealMenuRecordMapper;
5 +import com.tianting.infoloop.model.db.MealMenuRecord;
6 +import com.tianting.infoloop.service.MealMenuRecordService;
7 +import org.springframework.stereotype.Service;
8 +
9 +/**
10 +* @author zhuyf
11 +* @description 针对表【meal_menu_records(餐单记录表)】的数据库操作Service实现
12 +* @createDate 2025-04-10 13:22:20
13 +*/
14 +@Service
15 +public class MealMenuRecordServiceImpl extends ServiceImpl<MealMenuRecordMapper, MealMenuRecord>
16 + implements MealMenuRecordService{
17 +
18 +}
19 +
20 +
21 +
22 +
1 +package com.tianting.infoloop.service.impl;
2 +
3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 +import com.tianting.infoloop.mapper.MealOrderMapper;
5 +import com.tianting.infoloop.model.db.MealOrder;
6 +import com.tianting.infoloop.service.MealOrderService;
7 +import org.springframework.stereotype.Service;
8 +
9 +/**
10 +* @author zhuyf
11 +* @description 针对表【meal_orders(订餐记录表)】的数据库操作Service实现
12 +* @createDate 2025-04-10 13:22:20
13 +*/
14 +@Service
15 +public class MealOrderServiceImpl extends ServiceImpl<MealOrderMapper, MealOrder>
16 + implements MealOrderService{
17 +
18 +}
19 +
20 +
21 +
22 +
1 +package com.tianting.infoloop.service.impl;
2 +
3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 +import com.tianting.infoloop.mapper.MpAccountDinerRefMapper;
5 +import com.tianting.infoloop.model.db.MpAccountDinerRef;
6 +import com.tianting.infoloop.service.MpAccountDinerRefService;
7 +import org.springframework.stereotype.Service;
8 +
9 +/**
10 +* @author zhuyf
11 +* @description 针对表【mp_account_diner_refs(小程序账号和就餐人关联表)】的数据库操作Service实现
12 +* @createDate 2025-04-10 13:22:20
13 +*/
14 +@Service
15 +public class MpAccountDinerRefServiceImpl extends ServiceImpl<MpAccountDinerRefMapper, MpAccountDinerRef>
16 + implements MpAccountDinerRefService{
17 +
18 +}
19 +
20 +
21 +
22 +
1 +package com.tianting.infoloop.service.impl;
2 +
3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 +import com.tianting.infoloop.mapper.MpAccountMapper;
5 +import com.tianting.infoloop.model.db.MpAccount;
6 +import com.tianting.infoloop.service.MpAccountService;
7 +import org.springframework.stereotype.Service;
8 +
9 +/**
10 +* @author zhuyf
11 +* @description 针对表【mp_accounts(小程序账号表)】的数据库操作Service实现
12 +* @createDate 2025-04-10 13:22:20
13 +*/
14 +@Service
15 +public class MpAccountServiceImpl extends ServiceImpl<MpAccountMapper, MpAccount>
16 + implements MpAccountService{
17 +
18 +}
19 +
20 +
21 +
22 +
...@@ -3,6 +3,9 @@ package com.tianting.infoloop.utils; ...@@ -3,6 +3,9 @@ package com.tianting.infoloop.utils;
3 import cn.hutool.core.date.LocalDateTimeUtil; 3 import cn.hutool.core.date.LocalDateTimeUtil;
4 import com.google.gson.Gson; 4 import com.google.gson.Gson;
5 import com.google.gson.GsonBuilder; 5 import com.google.gson.GsonBuilder;
6 +import com.google.gson.JsonArray;
7 +import com.google.gson.JsonElement;
8 +import com.google.gson.JsonParser;
6 import com.google.gson.TypeAdapter; 9 import com.google.gson.TypeAdapter;
7 import com.google.gson.stream.JsonReader; 10 import com.google.gson.stream.JsonReader;
8 import com.google.gson.stream.JsonWriter; 11 import com.google.gson.stream.JsonWriter;
...@@ -23,6 +26,8 @@ import java.util.List; ...@@ -23,6 +26,8 @@ import java.util.List;
23 26
24 public class ProtoBeanUtil { 27 public class ProtoBeanUtil {
25 28
29 + private static Gson gson = getGson();
30 +
26 /** 31 /**
27 * protoBean -> string 32 * protoBean -> string
28 * 33 *
...@@ -31,13 +36,68 @@ public class ProtoBeanUtil { ...@@ -31,13 +36,68 @@ public class ProtoBeanUtil {
31 */ 36 */
32 public static String protoToJson(MessageOrBuilder sourceMessage) { 37 public static String protoToJson(MessageOrBuilder sourceMessage) {
33 try { 38 try {
34 - return JsonFormat.printer().print(sourceMessage); 39 + return JsonFormat.printer().includingDefaultValueFields().print(sourceMessage);
35 } catch (Exception e) { 40 } catch (Exception e) {
36 throw new IllegalArgumentException("ProtoBeanUtil->toJson->errorMessage:proto序列化string异常", e); 41 throw new IllegalArgumentException("ProtoBeanUtil->toJson->errorMessage:proto序列化string异常", e);
37 } 42 }
38 } 43 }
39 44
40 - private static Gson gson = getGson(); 45 + @SuppressWarnings("unchecked")
46 + public static <T extends Message> T jsonToProto(String json, Class<T> protoBean) {
47 + try {
48 + Constructor<T> declaredConstructor = protoBean.getDeclaredConstructor((Class<?>[]) null);
49 + declaredConstructor.setAccessible(Boolean.TRUE);
50 + T instance = declaredConstructor.newInstance();
51 + final var builder = instance.toBuilder();
52 + if (json == null || json.isEmpty() || json.trim().equals("{}")) {
53 + return (T) builder.build();
54 + }
55 + JsonFormat.parser().ignoringUnknownFields().merge(json, builder);
56 + return (T) builder.build();
57 + } catch (Exception e) {
58 + throw new IllegalArgumentException("json to proto error", e);
59 + }
60 + }
61 +
62 + @SuppressWarnings("unchecked")
63 + public static <T extends Message> List<T> jsonToProtoList(String jsonArray, Class<T> protoBean) {
64 + try {
65 + if (jsonArray == null || jsonArray.isEmpty() || jsonArray.trim().equals("[]")) {
66 + return new ArrayList<>();
67 + }
68 + Constructor<T> declaredConstructor = protoBean.getDeclaredConstructor();
69 + declaredConstructor.setAccessible(true);
70 + List<T> protoList = new ArrayList<>();
71 + JsonArray jsonElements = JsonParser.parseString(jsonArray).getAsJsonArray();
72 + for (JsonElement jsonElement : jsonElements) {
73 + T instance = declaredConstructor.newInstance();
74 + Message.Builder builder = instance.toBuilder();
75 + JsonFormat.parser().ignoringUnknownFields().merge(jsonElement.toString(), builder);
76 + protoList.add((T) builder.build());
77 + }
78 + return protoList;
79 + } catch (Exception e) {
80 + throw new IllegalArgumentException("jsonArray to protoList error", e);
81 + }
82 + }
83 +
84 + public static String protoListToJson(List<? extends Message> sourceList) {
85 + try {
86 + StringBuilder jsonArrayBuilder = new StringBuilder();
87 + jsonArrayBuilder.append("[");
88 + for (int i = 0; i < sourceList.size(); i++) {
89 + String json = protoToJson(sourceList.get(i));
90 + jsonArrayBuilder.append(json);
91 + if (i < sourceList.size() - 1) {
92 + jsonArrayBuilder.append(",");
93 + }
94 + }
95 + jsonArrayBuilder.append("]");
96 + return jsonArrayBuilder.toString();
97 + } catch (Exception e) {
98 + throw new IllegalArgumentException("ProtoList to jsonArray error", e);
99 + }
100 + }
41 101
42 /** 102 /**
43 * @desc: String 转 Builder对象 103 * @desc: String 转 Builder对象
......
1 +syntax = "proto3";
2 +
3 +option java_multiple_files = true;
4 +option java_package = "com.infoloop.tianting.mealorderservice";
5 +option java_outer_classname = "MealOrderServiceProto";
6 +option objc_class_prefix = "OP";
7 +
8 +package com.infoloop.tianting.mealorderservice;
9 +
10 +service MealOrderServiceRpc {
11 + rpc GetMealOrderById (GetMealOrderByIdRpcRequest) returns (GetMealOrderByIdRpcResponse) {}
12 + rpc GetMealOrdersByIds (GetMealOrdersByIdsRpcRequest) returns (GetMealOrdersByIdsRpcResponse) {}
13 + rpc QueryMealOrdersByCondition (QueryMealOrdersByConditionRpcRequest) returns (QueryMealOrdersByConditionRpcResponse) {}
14 + rpc QueryReserveMealOrdersByDinerIds (QueryReserveMealOrdersByDinerIdsRpcRequest) returns (QueryReserveMealOrdersByDinerIdsRpcResponse) {}
15 + rpc CreateMealOrder (CreateMealOrderRpcRequest) returns (CreateMealOrderRpcResponse) {}
16 + rpc BatchCreateMealOrders (BatchCreateMealOrdersRpcRequest) returns (BatchCreateMealOrdersRpcResponse) {}
17 + rpc DeleteMealOrdersByIds (DeleteMealOrdersByIdsRpcRequest) returns (DeleteMealOrdersRpcResponse) {}
18 +
19 + rpc GetMpAccountById (GetMpAccountByIdRpcRequest) returns (GetMpAccountByIdRpcResponse) {}
20 + rpc GetMpAccountByOpenId (GetMpAccountByOpenIdRpcRequest) returns (GetMpAccountByOpenIdRpcResponse) {}
21 + rpc GetMpAccountsByIds (GetMpAccountsByIdsRpcRequest) returns (GetMpAccountsByIdsRpcResponse) {}
22 + rpc QueryMpAccountsByCondition (QueryMpAccountsByConditionRpcRequest) returns (QueryMpAccountsByConditionRpcResponse) {}
23 + rpc CreateMpAccount (CreateMpAccountRpcRequest) returns (CreateMpAccountRpcResponse) {}
24 + rpc UpdateMpAccount (UpdateMpAccountRpcRequest) returns (UpdateMpAccountRpcResponse) {}
25 + rpc DeleteMpAccountsByIds (DeleteMpAccountsByIdsRpcRequest) returns (DeleteMpAccountsRpcResponse) {}
26 +
27 + rpc GetDinerById (GetDinerByIdRpcRequest) returns (GetDinerByIdRpcResponse) {}
28 + rpc GetDinersByIds (GetDinersByIdsRpcRequest) returns (GetDinersByIdsRpcResponse) {}
29 + rpc QueryDinersByCondition (QueryDinersByConditionRpcRequest) returns (QueryDinersByConditionRpcResponse) {}
30 + rpc CreateDiner (CreateDinerRpcRequest) returns (CreateDinerRpcResponse) {}
31 + rpc UpdateDiner (UpdateDinerRpcRequest) returns (UpdateDinerRpcResponse) {}
32 + rpc BatchSaveOrUpdateDiners (BatchSaveOrUpdateDinersRpcRequest) returns (BatchSaveOrUpdateDinersRpcResponse) {}
33 + rpc DeleteDinersByIds (DeleteDinersByIdsRpcRequest) returns (DeleteDinersRpcResponse) {}
34 +
35 + rpc GetMpAccountDinerRefsByIds (GetMpAccountDinerRefsByIdsRpcRequest) returns (GetMpAccountDinerRefsByIdsRpcResponse) {}
36 + rpc QueryMpAccountDinerRefsByCondition (QueryMpAccountDinerRefsByConditionRpcRequest) returns (QueryMpAccountDinerRefsByConditionRpcResponse) {}
37 + rpc CreateMpAccountDinerRef (CreateMpAccountDinerRefRpcRequest) returns (CreateMpAccountDinerRefRpcResponse) {}
38 + rpc DeleteMpAccountDinerRefsByIds (DeleteMpAccountDinerRefsByIdsRpcRequest) returns (DeleteMpAccountDinerRefsRpcResponse) {}
39 +
40 + rpc GetGradeClassById (GetGradeClassByIdRpcRequest) returns (GetGradeClassByIdRpcResponse) {}
41 + rpc GetGradeClassesByIds (GetGradeClassesByIdsRpcRequest) returns (GetGradeClassesByIdsRpcResponse) {}
42 + rpc QueryGradeClassesByCondition (QueryGradeClassesByConditionRpcRequest) returns (QueryGradeClassesByConditionRpcResponse) {}
43 + rpc CreateGradeClass (CreateGradeClassRpcRequest) returns (CreateGradeClassRpcResponse) {}
44 + rpc BatchCreateGradeClasses (BatchCreateGradeClassesRpcRequest) returns (BatchCreateGradeClassesRpcResponse) {}
45 + rpc UpdateGradeClass (UpdateGradeClassRpcRequest) returns (UpdateGradeClassRpcResponse) {}
46 + rpc BatchSaveOrUpdateGradeClasses (BatchSaveOrUpdateGradeClassesRpcRequest) returns (BatchSaveOrUpdateGradeClassesRpcResponse) {}
47 + rpc DeleteGradeClassesByIds (DeleteGradeClassesByIdsRpcRequest) returns (DeleteGradeClassesRpcResponse) {}
48 + rpc DeleteGradeClassesAndDinersByClientIds (DeleteGradeClassesAndDinersByClientIdsRpcRequest) returns (DeleteGradeClassesAndDinersByClientIdsRpcResponse) {}
49 +
50 + rpc GetMealMenuRecordById (GetMealMenuRecordByIdRpcRequest) returns (GetMealMenuRecordByIdRpcResponse) {}
51 + rpc GetMealMenuRecordsByIds (GetMealMenuRecordsByIdsRpcRequest) returns (GetMealMenuRecordsByIdsRpcResponse) {}
52 + rpc QueryMealMenuRecordsByCondition (QueryMealMenuRecordsByConditionRpcRequest) returns (QueryMealMenuRecordsByConditionRpcResponse) {}
53 + rpc CreateMealMenuRecord (CreateMealMenuRecordRpcRequest) returns (CreateMealMenuRecordRpcResponse) {}
54 + rpc QueryLatestMealMenuRecordsByClientIds (QueryLatestMealMenuRecordsByClientIdsRpcRequest) returns (QueryLatestMealMenuRecordsByClientIdsRpcResponse) {}
55 +}
56 +
57 +enum MealOrderOrderMethodEnum {
58 + MEAL_ORDER_METHOD_SYSTEM = 0;
59 + MEAL_ORDER_METHOD_MICRO = 1;
60 +}
61 +
62 +message SingleMealOrderRpcResponse {
63 + int32 id = 1;
64 + int32 enterpriseId = 2;
65 + int32 clientId = 3;
66 + int32 menuId = 4;
67 + int32 accountId = 5;
68 + MealOrderOrderMethodEnum orderMethod = 6;
69 + int32 dinerId = 7;
70 + string dinerName = 8;
71 + string clientName = 9;
72 + string gradeName = 10;
73 + string className = 11;
74 + string studentNo = 12;
75 + int64 reserveDate = 13;
76 + repeated MenuSchedule meals = 14;
77 + int32 createdBy = 15;
78 + int64 createdAt = 16;
79 + int32 creationSource = 17;
80 + int32 updatedBy = 18;
81 + int64 updatedAt = 19;
82 + int32 updateSource = 20;
83 + bool isDeleted = 21;
84 +}
85 +
86 +message GetMealOrderByIdRpcRequest {
87 + int32 id = 1;
88 + int32 enterpriseId = 2;
89 + bool includeDeleted = 3;
90 +}
91 +
92 +message GetMealOrderByIdRpcResponse {
93 + SingleMealOrderRpcResponse response = 1;
94 +}
95 +
96 +message GetMealOrdersByIdsRpcRequest {
97 + repeated int32 ids = 1;
98 + int32 enterpriseId = 2;
99 + bool includeDeleted = 3;
100 +}
101 +
102 +message GetMealOrdersByIdsRpcResponse {
103 + repeated SingleMealOrderRpcResponse responses = 1;
104 +}
105 +
106 +message QueryMealOrdersByConditionRpcRequest {
107 + int32 enterpriseId = 1;
108 + bool shouldFilterClientIds = 2;
109 + repeated int32 clientIds = 3;
110 + bool shouldFilterMenuIds = 4;
111 + repeated int32 menuIds = 5;
112 + bool shouldFilterAccountIds = 6;
113 + repeated int32 accountIds = 7;
114 + bool shouldFilterOrderMethod = 8;
115 + MealOrderOrderMethodEnum orderMethod = 9;
116 + bool shouldFilterDinerIds = 10;
117 + repeated int32 dinerIds = 11;
118 + bool shouldFilterReserveDateStart = 12;
119 + int64 reserveDateStart = 13;
120 + bool shouldFilterReserveDateEnd = 14;
121 + int64 reserveDateEnd = 15;
122 + bool includeDeleted = 16;
123 +}
124 +
125 +message QueryMealOrdersByConditionRpcResponse {
126 + repeated SingleMealOrderRpcResponse responses = 1;
127 +}
128 +
129 +message QueryReserveMealOrdersByDinerIdsRpcRequest {
130 + int32 enterpriseId = 1;
131 + repeated int32 dinerIds = 2;
132 +}
133 +
134 +message QueryReserveMealOrdersByDinerIdsRpcResponse {
135 + repeated SingleMealOrderRpcResponse responses = 1;
136 +}
137 +
138 +message MealOrderCreation{
139 + int32 clientId = 1;
140 + int32 menuId = 2;
141 + int32 accountId = 3;
142 + MealOrderOrderMethodEnum orderMethod = 4;
143 + int32 dinerId = 5;
144 + string dinerName = 6;
145 + string clientName = 7;
146 + string gradeName = 8;
147 + string className = 9;
148 + string studentNo = 10;
149 + int64 reserveDate = 11;
150 + repeated MenuSchedule meals = 12;
151 +}
152 +
153 +message MenuSchedule {
154 + string date = 1; // 日期字段,类型是 string
155 + string menu = 2; // 菜单字段,类型是 string
156 +}
157 +
158 +message CreateMealOrderRpcRequest {
159 + MealOrderCreation creation = 1;
160 + int32 enterpriseId = 2;
161 + int32 createdBy = 3;
162 + int32 creationSource = 4;
163 +}
164 +
165 +message CreateMealOrderRpcResponse {
166 + int32 id = 1;
167 + bool isCreated = 2;
168 +}
169 +
170 +message BatchCreateMealOrdersRpcRequest {
171 + repeated MealOrderCreation creations = 1;
172 + int32 enterpriseId = 2;
173 + int32 createdBy = 3;
174 + int32 creationSource = 4;
175 +}
176 +
177 +message BatchCreateMealOrdersRpcResponse {
178 + repeated int32 ids = 1;
179 + bool isCreated = 2;
180 +}
181 +
182 +message MealOrderModification {
183 + int32 id = 1;
184 + bool shouldUpdateClientId = 2;
185 + int32 clientId = 3;
186 + bool shouldUpdateMenuId = 4;
187 + int32 menuId = 5;
188 + bool shouldUpdateAccountId = 6;
189 + int32 accountId = 7;
190 + bool shouldUpdateOrderMethod = 8;
191 + MealOrderOrderMethodEnum orderMethod = 9;
192 + bool shouldUpdateDinerId = 10;
193 + int32 dinerId = 11;
194 + bool shouldUpdateDinerName = 12;
195 + string dinerName = 13;
196 + bool shouldUpdateClientName = 14;
197 + string clientName = 15;
198 + bool shouldUpdateGradeName = 16;
199 + string gradeName = 17;
200 + bool shouldUpdateClassName = 18;
201 + string className = 19;
202 + bool shouldUpdateStudentNo = 20;
203 + string studentNo = 21;
204 + bool shouldUpdateReserveDate = 22;
205 + int64 reserveDate = 23;
206 + bool shouldUpdateMeals = 24;
207 + repeated MenuSchedule meals = 25;
208 +}
209 +
210 +message UpdateMealOrderRpcRequest {
211 + MealOrderModification modification = 1;
212 + int32 enterpriseId = 2;
213 + int32 updatedBy = 3;
214 + int32 updateSource = 4;
215 +}
216 +
217 +message UpdateMealOrderRpcResponse {
218 + bool isUpdated = 1;
219 +}
220 +
221 +message BatchUpdateMealOrdersRpcRequest {
222 + repeated MealOrderModification modifications = 1;
223 + int32 enterpriseId = 2;
224 + int32 updatedBy = 3;
225 + int32 updateSource = 4;
226 +}
227 +
228 +message BatchUpdateMealOrdersRpcResponse {
229 + bool isUpdated = 1;
230 +}
231 +
232 +message DeleteMealOrdersByIdsRpcRequest {
233 + repeated int32 ids = 1;
234 + int32 enterpriseId = 2;
235 + int32 updatedBy = 3;
236 + int32 updateSource = 4;
237 +}
238 +
239 +message DeleteMealOrdersRpcResponse {
240 + bool isDeleted = 1;
241 +}
242 +
243 +message SingleDinerRpcResponse {
244 + int32 id = 1;
245 + int32 enterpriseId = 2;
246 + int32 clientId = 3;
247 + int32 classId = 4;
248 + string studentNo = 5;
249 + string name = 6;
250 + int32 createdBy = 7;
251 + int64 createdAt = 8;
252 + int32 creationSource = 9;
253 + int32 updatedBy = 10;
254 + int64 updatedAt = 11;
255 + int32 updateSource = 12;
256 + bool isDeleted = 13;
257 +}
258 +
259 +message GetDinerByIdRpcRequest {
260 + int32 id = 1;
261 + int32 enterpriseId = 2;
262 + bool includeDeleted = 3;
263 +}
264 +
265 +message GetDinerByIdRpcResponse {
266 + SingleDinerRpcResponse response = 1;
267 +}
268 +
269 +message GetDinersByIdsRpcRequest {
270 + repeated int32 ids = 1;
271 + int32 enterpriseId = 2;
272 + bool includeDeleted = 3;
273 +}
274 +
275 +message GetDinersByIdsRpcResponse {
276 + repeated SingleDinerRpcResponse responses = 1;
277 +}
278 +
279 +message QueryDinersByConditionRpcRequest {
280 + int32 enterpriseId = 1;
281 + bool shouldFilterClientIds = 2;
282 + repeated int32 clientIds = 3;
283 + bool shouldFilterClassIds = 4;
284 + repeated int32 classIds = 5;
285 + bool shouldFilterStudentNo = 6;
286 + string studentNo = 7;
287 + bool shouldFilterName = 8;
288 + string name = 9;
289 + bool includeDeleted = 10;
290 +}
291 +
292 +message QueryDinersByConditionRpcResponse {
293 + repeated SingleDinerRpcResponse responses = 1;
294 +}
295 +
296 +message DinerCreation{
297 + int32 clientId = 1;
298 + int32 classId = 2;
299 + string studentNo = 3;
300 + string name = 4;
301 +}
302 +
303 +message CreateDinerRpcRequest {
304 + DinerCreation creation = 1;
305 + int32 enterpriseId = 2;
306 + int32 createdBy = 3;
307 + int32 creationSource = 4;
308 +}
309 +
310 +message CreateDinerRpcResponse {
311 + int32 id = 1;
312 + bool isCreated = 2;
313 +}
314 +
315 +message DinerModification {
316 + int32 id = 1;
317 + bool shouldUpdateClientId = 2;
318 + int32 clientId = 3;
319 + bool shouldUpdateClassId = 4;
320 + int32 classId = 5;
321 + bool shouldUpdateStudentNo = 6;
322 + string studentNo = 7;
323 + bool shouldUpdateName = 8;
324 + string name = 9;
325 +}
326 +
327 +message UpdateDinerRpcRequest {
328 + DinerModification modification = 1;
329 + int32 enterpriseId = 2;
330 + int32 updatedBy = 3;
331 + int32 updateSource = 4;
332 +}
333 +
334 +message UpdateDinerRpcResponse {
335 + bool isUpdated = 1;
336 +}
337 +
338 +message BatchSaveOrUpdateDinersRpcRequest {
339 + repeated DinerModification modifications = 1;
340 + int32 enterpriseId = 2;
341 + int32 updatedBy = 3;
342 + int32 updateSource = 4;
343 +}
344 +
345 +message BatchSaveOrUpdateDinersRpcResponse {
346 + bool isUpdated = 1;
347 +}
348 +
349 +message DeleteDinersByIdsRpcRequest {
350 + repeated int32 ids = 1;
351 + int32 enterpriseId = 2;
352 + int32 updatedBy = 3;
353 + int32 updateSource = 4;
354 +}
355 +
356 +message DeleteDinersRpcResponse {
357 + bool isDeleted = 1;
358 +}
359 +
360 +enum MpAccountGenderEnum {
361 + MP_ACCOUNT_GENDER_MAN = 0;
362 + MP_ACCOUNT_GENDER_WOMAN = 1;
363 +}
364 +enum MpAccountStatusEnum {
365 + MP_ACCOUNT_STATUS_ENABLE = 0;
366 + MP_ACCOUNT_STATUS_DISABLE = 1;
367 +}
368 +
369 +message SingleMpAccountRpcResponse {
370 + int32 id = 1;
371 + int32 enterpriseId = 2;
372 + string openId = 3;
373 + string unionId = 4;
374 + string nickname = 5;
375 + string avatarUrl = 6;
376 + MpAccountGenderEnum gender = 7;
377 + string phoneNumber = 8;
378 + MpAccountStatusEnum status = 9;
379 + int32 createdBy = 10;
380 + int64 createdAt = 11;
381 + int32 creationSource = 12;
382 + int32 updatedBy = 13;
383 + int64 updatedAt = 14;
384 + int32 updateSource = 15;
385 + bool isDeleted = 16;
386 +}
387 +
388 +message GetMpAccountByIdRpcRequest {
389 + int32 id = 1;
390 + int32 enterpriseId = 2;
391 + bool includeDeleted = 3;
392 +}
393 +
394 +message GetMpAccountByIdRpcResponse {
395 + SingleMpAccountRpcResponse response = 1;
396 +}
397 +
398 +message GetMpAccountByOpenIdRpcRequest {
399 + string openId = 1;
400 +}
401 +
402 +message GetMpAccountByOpenIdRpcResponse {
403 + SingleMpAccountRpcResponse response = 1;
404 +}
405 +
406 +message GetMpAccountsByIdsRpcRequest {
407 + repeated int32 ids = 1;
408 + int32 enterpriseId = 2;
409 + bool includeDeleted = 3;
410 +}
411 +
412 +message GetMpAccountsByIdsRpcResponse {
413 + repeated SingleMpAccountRpcResponse responses = 1;
414 +}
415 +
416 +message QueryMpAccountsByConditionRpcRequest {
417 + int32 enterpriseId = 1;
418 + bool shouldFilterOpenId = 2;
419 + string openId = 3;
420 + bool shouldFilterUnionId = 4;
421 + string unionId = 5;
422 + bool shouldFilterPhoneNumber = 6;
423 + string phoneNumber = 7;
424 + bool shouldFilterStatus = 8;
425 + MpAccountStatusEnum status = 9;
426 + bool includeDeleted = 10;
427 +}
428 +
429 +message QueryMpAccountsByConditionRpcResponse {
430 + repeated SingleMpAccountRpcResponse responses = 1;
431 +}
432 +
433 +message MpAccountCreation{
434 + string openId = 1;
435 + bool shouldCreateUnionId = 2;
436 + string unionId = 3;
437 + bool shouldCreateNickname = 4;
438 + string nickname = 5;
439 + bool shouldCreateAvatarUrl = 6;
440 + string avatarUrl = 7;
441 + MpAccountGenderEnum gender = 8;
442 + string phoneNumber = 9;
443 + MpAccountStatusEnum status = 10;
444 +}
445 +
446 +message CreateMpAccountRpcRequest {
447 + MpAccountCreation creation = 1;
448 + int32 enterpriseId = 2;
449 + int32 createdBy = 3;
450 + int32 creationSource = 4;
451 +}
452 +
453 +message CreateMpAccountRpcResponse {
454 + int32 id = 1;
455 + bool isCreated = 2;
456 +}
457 +
458 +message MpAccountModification {
459 + int32 id = 1;
460 + bool shouldUpdateOpenId = 2;
461 + string openId = 3;
462 + bool shouldUpdateUnionId = 4;
463 + string unionId = 5;
464 + bool shouldUpdateNickname = 6;
465 + string nickname = 7;
466 + bool shouldUpdateAvatarUrl = 8;
467 + string avatarUrl = 9;
468 + bool shouldUpdateGender = 10;
469 + MpAccountGenderEnum gender = 11;
470 + bool shouldUpdatePhoneNumber = 12;
471 + string phoneNumber = 13;
472 + bool shouldUpdateStatus = 14;
473 + MpAccountStatusEnum status = 15;
474 +}
475 +
476 +message UpdateMpAccountRpcRequest {
477 + MpAccountModification modification = 1;
478 + int32 enterpriseId = 2;
479 + int32 updatedBy = 3;
480 + int32 updateSource = 4;
481 +}
482 +
483 +message UpdateMpAccountRpcResponse {
484 + bool isUpdated = 1;
485 +}
486 +
487 +message DeleteMpAccountsByIdsRpcRequest {
488 + repeated int32 ids = 1;
489 + int32 enterpriseId = 2;
490 + int32 updatedBy = 3;
491 + int32 updateSource = 4;
492 +}
493 +
494 +message DeleteMpAccountsRpcResponse {
495 + bool isDeleted = 1;
496 +}
497 +
498 +message SingleMpAccountDinerRefRpcResponse {
499 + int32 id = 1;
500 + int32 enterpriseId = 2;
501 + int32 accountId = 3;
502 + int32 dinerId = 4;
503 + int32 createdBy = 5;
504 + int64 createdAt = 6;
505 + int32 creationSource = 7;
506 +}
507 +
508 +message GetMpAccountDinerRefsByIdsRpcRequest {
509 + repeated int32 ids = 1;
510 + int32 enterpriseId = 2;
511 +}
512 +
513 +message GetMpAccountDinerRefsByIdsRpcResponse {
514 + repeated SingleMpAccountDinerRefRpcResponse responses = 1;
515 +}
516 +
517 +message QueryMpAccountDinerRefsByConditionRpcRequest {
518 + int32 enterpriseId = 1;
519 + bool shouldFilterAccountIds = 2;
520 + repeated int32 accountIds = 3;
521 + bool shouldFilterDinerIds = 4;
522 + repeated int32 dinerIds = 5;
523 +}
524 +
525 +message QueryMpAccountDinerRefsByConditionRpcResponse {
526 + repeated SingleMpAccountDinerRefRpcResponse responses = 1;
527 +}
528 +
529 +message MpAccountDinerRefCreation{
530 + int32 accountId = 1;
531 + int32 dinerId = 2;
532 +}
533 +
534 +message CreateMpAccountDinerRefRpcRequest {
535 + MpAccountDinerRefCreation creation = 1;
536 + int32 enterpriseId = 2;
537 + int32 createdBy = 3;
538 + int32 creationSource = 4;
539 +}
540 +
541 +message CreateMpAccountDinerRefRpcResponse {
542 + int32 id = 1;
543 + bool isCreated = 2;
544 +}
545 +
546 +message BatchCreateMpAccountDinerRefsRpcRequest {
547 + repeated MpAccountDinerRefCreation creations = 1;
548 + int32 enterpriseId = 2;
549 + int32 createdBy = 3;
550 + int32 creationSource = 4;
551 +}
552 +
553 +message BatchCreateMpAccountDinerRefsRpcResponse {
554 + repeated int32 ids = 1;
555 + bool isCreated = 2;
556 +}
557 +
558 +message DeleteMpAccountDinerRefsByIdsRpcRequest {
559 + repeated int32 ids = 1;
560 + int32 enterpriseId = 2;
561 +}
562 +
563 +message DeleteMpAccountDinerRefsRpcResponse {
564 + bool isDeleted = 1;
565 +}
566 +
567 +message SingleGradeClassRpcResponse {
568 + int32 id = 1;
569 + int32 enterpriseId = 2;
570 + int32 clientId = 3;
571 + string gradeName = 4;
572 + string className = 5;
573 + string fullName = 6;
574 + int32 createdBy = 7;
575 + int64 createdAt = 8;
576 + int32 creationSource = 9;
577 + int32 updatedBy = 10;
578 + int64 updatedAt = 11;
579 + int32 updateSource = 12;
580 + bool isDeleted = 13;
581 +}
582 +
583 +message GetGradeClassByIdRpcRequest {
584 + int32 id = 1;
585 + int32 enterpriseId = 2;
586 + bool includeDeleted = 3;
587 +}
588 +
589 +message GetGradeClassByIdRpcResponse {
590 + SingleGradeClassRpcResponse response = 1;
591 +}
592 +
593 +message GetGradeClassesByIdsRpcRequest {
594 + repeated int32 ids = 1;
595 + int32 enterpriseId = 2;
596 + bool includeDeleted = 3;
597 +}
598 +
599 +message GetGradeClassesByIdsRpcResponse {
600 + repeated SingleGradeClassRpcResponse responses = 1;
601 +}
602 +
603 +message GetAllGradeClassesRpcRequest {
604 + int32 enterpriseId = 1;
605 + bool includeDeleted = 2;
606 +}
607 +
608 +message GetAllGradeClassesRpcResponse {
609 + repeated SingleGradeClassRpcResponse responses = 1;
610 +}
611 +
612 +message QueryGradeClassesByConditionRpcRequest {
613 + int32 enterpriseId = 1;
614 + bool shouldFilterClientIds = 2;
615 + repeated int32 clientIds = 3;
616 + bool shouldFilterGradeName = 4;
617 + string gradeName = 5;
618 + bool includeDeleted = 6;
619 +}
620 +
621 +message QueryGradeClassesByConditionRpcResponse {
622 + repeated SingleGradeClassRpcResponse responses = 1;
623 +}
624 +
625 +message GradeClassCreation{
626 + int32 clientId = 1;
627 + string gradeName = 2;
628 + string className = 3;
629 + bool shouldCreateFullName = 4;
630 + string fullName = 5;
631 +}
632 +
633 +message CreateGradeClassRpcRequest {
634 + GradeClassCreation creation = 1;
635 + int32 enterpriseId = 2;
636 + int32 createdBy = 3;
637 + int32 creationSource = 4;
638 +}
639 +
640 +message CreateGradeClassRpcResponse {
641 + int32 id = 1;
642 + bool isCreated = 2;
643 +}
644 +
645 +message BatchCreateGradeClassesRpcRequest {
646 + repeated GradeClassCreation creations = 1;
647 + int32 enterpriseId = 2;
648 + int32 createdBy = 3;
649 + int32 creationSource = 4;
650 +}
651 +
652 +message BatchCreateGradeClassesRpcResponse {
653 + repeated int32 ids = 1;
654 + bool isCreated = 2;
655 +}
656 +
657 +message GradeClassModification {
658 + int32 id = 1;
659 + bool shouldUpdateClientId = 2;
660 + int32 clientId = 3;
661 + bool shouldUpdateGradeName = 4;
662 + string gradeName = 5;
663 + bool shouldUpdateClassName = 6;
664 + string className = 7;
665 + bool shouldUpdateFullName = 8;
666 + string fullName = 9;
667 +}
668 +
669 +message UpdateGradeClassRpcRequest {
670 + GradeClassModification modification = 1;
671 + int32 enterpriseId = 2;
672 + int32 updatedBy = 3;
673 + int32 updateSource = 4;
674 +}
675 +
676 +message UpdateGradeClassRpcResponse {
677 + bool isUpdated = 1;
678 +}
679 +
680 +message BatchSaveOrUpdateGradeClassesRpcRequest {
681 + repeated GradeClassModification modifications = 1;
682 + int32 enterpriseId = 2;
683 + int32 updatedBy = 3;
684 + int32 updateSource = 4;
685 +}
686 +
687 +message BatchSaveOrUpdateGradeClassesRpcResponse {
688 + bool isUpdated = 1;
689 +}
690 +
691 +message BatchUpdateGradeClassesRpcRequest {
692 + repeated GradeClassModification modifications = 1;
693 + int32 enterpriseId = 2;
694 + int32 updatedBy = 3;
695 + int32 updateSource = 4;
696 +}
697 +
698 +message BatchUpdateGradeClassesRpcResponse {
699 + bool isUpdated = 1;
700 +}
701 +
702 +message DeleteGradeClassesByIdsRpcRequest {
703 + repeated int32 ids = 1;
704 + int32 enterpriseId = 2;
705 + int32 updatedBy = 3;
706 + int32 updateSource = 4;
707 +}
708 +
709 +message DeleteGradeClassesRpcResponse {
710 + bool isDeleted = 1;
711 +}
712 +
713 +message DeleteGradeClassesAndDinersByClientIdsRpcRequest {
714 + repeated int32 clientIds = 1;
715 + int32 enterpriseId = 2;
716 + int32 updatedBy = 3;
717 + int32 updateSource = 4;
718 +}
719 +
720 +message DeleteGradeClassesAndDinersByClientIdsRpcResponse {
721 + bool isDeleted = 1;
722 +}
723 +
724 +message SingleMealMenuRecordRpcResponse {
725 + int32 id = 1;
726 + int32 enterpriseId = 2;
727 + int32 clientId = 3;
728 + string name = 4;
729 + string imageUrl = 5;
730 + int32 createdBy = 6;
731 + int64 createdAt = 7;
732 + int32 creationSource = 8;
733 + int32 updatedBy = 9;
734 + int64 updatedAt = 10;
735 + int32 updateSource = 11;
736 + bool isDeleted = 12;
737 +}
738 +
739 +message GetMealMenuRecordByIdRpcRequest {
740 + int32 id = 1;
741 + int32 enterpriseId = 2;
742 + bool includeDeleted = 3;
743 +}
744 +
745 +message GetMealMenuRecordByIdRpcResponse {
746 + SingleMealMenuRecordRpcResponse response = 1;
747 +}
748 +
749 +message GetMealMenuRecordsByIdsRpcRequest {
750 + repeated int32 ids = 1;
751 + int32 enterpriseId = 2;
752 + bool includeDeleted = 3;
753 +}
754 +
755 +message GetMealMenuRecordsByIdsRpcResponse {
756 + repeated SingleMealMenuRecordRpcResponse responses = 1;
757 +}
758 +
759 +message QueryMealMenuRecordsByConditionRpcRequest {
760 + int32 enterpriseId = 1;
761 + bool shouldFilterClientIds = 2;
762 + repeated int32 clientIds = 3;
763 + bool shouldFilterName = 4;
764 + string name = 5;
765 + bool includeDeleted = 6;
766 +}
767 +
768 +message QueryMealMenuRecordsByConditionRpcResponse {
769 + repeated SingleMealMenuRecordRpcResponse responses = 1;
770 +}
771 +
772 +message MealMenuRecordCreation{
773 + int32 clientId = 1;
774 + string name = 2;
775 + bool shouldCreateImageUrl = 3;
776 + string imageUrl = 4;
777 +}
778 +
779 +message CreateMealMenuRecordRpcRequest {
780 + MealMenuRecordCreation creation = 1;
781 + int32 enterpriseId = 2;
782 + int32 createdBy = 3;
783 + int32 creationSource = 4;
784 +}
785 +
786 +message CreateMealMenuRecordRpcResponse {
787 + int32 id = 1;
788 + bool isCreated = 2;
789 +}
790 +
791 +message QueryLatestMealMenuRecordsByClientIdsRpcRequest {
792 + int32 enterpriseId = 1;
793 + repeated int32 clientId = 2;
794 +}
795 +
796 +message QueryLatestMealMenuRecordsByClientIdsRpcResponse {
797 + repeated SingleMealMenuRecordRpcResponse responses = 1;
798 +}
...@@ -7,20 +7,13 @@ spring.main.web-application-type=none ...@@ -7,20 +7,13 @@ spring.main.web-application-type=none
7 spring.application.name=order-service 7 spring.application.name=order-service
8 spring.datasource.driver-class-name=com.mysql.jdbc.Driver 8 spring.datasource.driver-class-name=com.mysql.jdbc.Driver
9 9
10 -spring.datasource.dynamic.datasource.master.url=jdbc:mysql://localhost:3306/cater?autoReconnect=true&tcpKeepAlive=true&rewriteBatchedStatements=true&statementInterceptors=com.tianting.infoloop.tracing.MysqlZipkinInterceptor&useSSL=false 10 +spring.datasource.dynamic.datasource.master.url=jdbc:mysql://localhost:3306/test?autoReconnect=true&tcpKeepAlive=true&rewriteBatchedStatements=true&statementInterceptors=com.tianting.infoloop.tracing.MysqlZipkinInterceptor&useSSL=false
11 spring.datasource.dynamic.datasource.master.username=root 11 spring.datasource.dynamic.datasource.master.username=root
12 -spring.datasource.dynamic.datasource.master.password=QAZwsx098 12 +spring.datasource.dynamic.datasource.master.password=123456
13 -spring.datasource.dynamic.datasource.slave.url=jdbc:mysql://localhost:3306/cater_slave?autoReconnect=true&tcpKeepAlive=true&statementInterceptors=com.tianting.infoloop.tracing.MysqlZipkinInterceptor&useSSL=false 13 +spring.datasource.dynamic.datasource.slave.url=jdbc:mysql://localhost:3306/test?autoReconnect=true&tcpKeepAlive=true&statementInterceptors=com.tianting.infoloop.tracing.MysqlZipkinInterceptor&useSSL=false
14 spring.datasource.dynamic.datasource.slave.username=root 14 spring.datasource.dynamic.datasource.slave.username=root
15 -spring.datasource.dynamic.datasource.slave.password=QAZwsx098 15 +spring.datasource.dynamic.datasource.slave.password=123456
16 spring.datasource.dynamic.primary=master 16 spring.datasource.dynamic.primary=master
17 -#spring.datasource.dynamic.datasource.master.url=jdbc:mysql://rm-uf63gfjzejp163e3g4o.mysql.rds.aliyuncs.com:3306/qingniu?autoReconnect=true&tcpKeepAlive=true&rewriteBatchedStatements=true&statementInterceptors=com.tianting.infoloop.tracing.MysqlZipkinInterceptor&useSSL=false
18 -#spring.datasource.dynamic.datasource.master.username=jj_infoloop_stage
19 -#spring.datasource.dynamic.datasource.master.password=H8kjNeChi1wimXw
20 -#spring.datasource.dynamic.datasource.slave.url=jdbc:mysql://rm-uf63gfjzejp163e3g4o.mysql.rds.aliyuncs.com:3306/qingniu?autoReconnect=true&tcpKeepAlive=true&statementInterceptors=com.tianting.infoloop.tracing.MysqlZipkinInterceptor&useSSL=false
21 -#spring.datasource.dynamic.datasource.slave.username=jj_infoloop_stage
22 -#spring.datasource.dynamic.datasource.slave.password=H8kjNeChi1wimXw
23 -#spring.datasource.dynamic.primary=master
24 17
25 logging.config=classpath:logback-spring.xml 18 logging.config=classpath:logback-spring.xml
26 19
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!DOCTYPE mapper
3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 +<mapper namespace="com.tianting.infoloop.mapper.DinerMapper">
6 +
7 + <resultMap id="BaseResultMap" type="com.tianting.infoloop.model.db.Diner">
8 + <id property="id" column="id" jdbcType="INTEGER"/>
9 + <result property="enterpriseId" column="enterpriseId" jdbcType="INTEGER"/>
10 + <result property="clientId" column="clientId" jdbcType="INTEGER"/>
11 + <result property="classId" column="classId" jdbcType="INTEGER"/>
12 + <result property="studentNo" column="studentNo" jdbcType="VARCHAR"/>
13 + <result property="name" column="name" jdbcType="VARCHAR"/>
14 + <result property="createdBy" column="createdBy" jdbcType="INTEGER"/>
15 + <result property="createdAt" column="createdAt" jdbcType="TIMESTAMP"/>
16 + <result property="creationSource" column="creationSource" jdbcType="INTEGER"/>
17 + <result property="updatedBy" column="updatedBy" jdbcType="INTEGER"/>
18 + <result property="updatedAt" column="updatedAt" jdbcType="TIMESTAMP"/>
19 + <result property="updateSource" column="updateSource" jdbcType="INTEGER"/>
20 + <result property="isDeleted" column="isDeleted" jdbcType="TINYINT"/>
21 + </resultMap>
22 +
23 + <sql id="Base_Column_List">
24 + id,enterpriseId,clientId,
25 + classId,studentNo,name,
26 + createdBy,createdAt,creationSource,
27 + updatedBy,updatedAt,updateSource,
28 + isDeleted
29 + </sql>
30 +</mapper>
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!DOCTYPE mapper
3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 +<mapper namespace="com.tianting.infoloop.mapper.GradeClassMapper">
6 +
7 + <resultMap id="BaseResultMap" type="com.tianting.infoloop.model.db.GradeClass">
8 + <id property="id" column="id" jdbcType="INTEGER"/>
9 + <result property="enterpriseId" column="enterpriseId" jdbcType="INTEGER"/>
10 + <result property="clientId" column="clientId" jdbcType="INTEGER"/>
11 + <result property="gradeName" column="gradeName" jdbcType="VARCHAR"/>
12 + <result property="className" column="className" jdbcType="VARCHAR"/>
13 + <result property="fullName" column="fullName" jdbcType="VARCHAR"/>
14 + <result property="createdBy" column="createdBy" jdbcType="INTEGER"/>
15 + <result property="createdAt" column="createdAt" jdbcType="TIMESTAMP"/>
16 + <result property="creationSource" column="creationSource" jdbcType="INTEGER"/>
17 + <result property="updatedBy" column="updatedBy" jdbcType="INTEGER"/>
18 + <result property="updatedAt" column="updatedAt" jdbcType="TIMESTAMP"/>
19 + <result property="updateSource" column="updateSource" jdbcType="INTEGER"/>
20 + <result property="isDeleted" column="isDeleted" jdbcType="TINYINT"/>
21 + </resultMap>
22 +
23 + <sql id="Base_Column_List">
24 + id,enterpriseId,clientId,
25 + gradeName,className,fullName,
26 + createdBy,createdAt,creationSource,
27 + updatedBy,updatedAt,updateSource,
28 + isDeleted
29 + </sql>
30 +</mapper>
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!DOCTYPE mapper
3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 +<mapper namespace="com.tianting.infoloop.mapper.MealMenuRecordMapper">
6 +
7 + <resultMap id="BaseResultMap" type="com.tianting.infoloop.model.db.MealMenuRecord">
8 + <id property="id" column="id" jdbcType="INTEGER"/>
9 + <result property="enterpriseId" column="enterpriseId" jdbcType="INTEGER"/>
10 + <result property="clientId" column="clientId" jdbcType="INTEGER"/>
11 + <result property="name" column="name" jdbcType="VARCHAR"/>
12 + <result property="imageUrl" column="imageUrl" jdbcType="VARCHAR"/>
13 + <result property="createdBy" column="createdBy" jdbcType="INTEGER"/>
14 + <result property="createdAt" column="createdAt" jdbcType="TIMESTAMP"/>
15 + <result property="creationSource" column="creationSource" jdbcType="INTEGER"/>
16 + <result property="updatedBy" column="updatedBy" jdbcType="INTEGER"/>
17 + <result property="updatedAt" column="updatedAt" jdbcType="TIMESTAMP"/>
18 + <result property="updateSource" column="updateSource" jdbcType="INTEGER"/>
19 + <result property="isDeleted" column="isDeleted" jdbcType="TINYINT"/>
20 + </resultMap>
21 +
22 + <sql id="Base_Column_List">
23 + id,enterpriseId,clientId,
24 + name,imageUrl,createdBy,
25 + createdAt,creationSource,updatedBy,
26 + updatedAt,updateSource,isDeleted
27 + </sql>
28 +</mapper>
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!DOCTYPE mapper
3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 +<mapper namespace="com.tianting.infoloop.mapper.MealOrderMapper">
6 +
7 + <resultMap id="BaseResultMap" type="com.tianting.infoloop.model.db.MealOrder">
8 + <id property="id" column="id" jdbcType="INTEGER"/>
9 + <result property="enterpriseId" column="enterpriseId" jdbcType="INTEGER"/>
10 + <result property="clientId" column="clientId" jdbcType="INTEGER"/>
11 + <result property="menuId" column="menuId" jdbcType="INTEGER"/>
12 + <result property="accountId" column="accountId" jdbcType="INTEGER"/>
13 + <result property="orderMethod" column="orderMethod" jdbcType="TINYINT"/>
14 + <result property="dinerId" column="dinerId" jdbcType="INTEGER"/>
15 + <result property="dinerName" column="dinerName" jdbcType="VARCHAR"/>
16 + <result property="clientName" column="clientName" jdbcType="VARCHAR"/>
17 + <result property="gradeName" column="gradeName" jdbcType="VARCHAR"/>
18 + <result property="className" column="className" jdbcType="VARCHAR"/>
19 + <result property="studentNo" column="studentNo" jdbcType="VARCHAR"/>
20 + <result property="reserveDate" column="reserveDate" jdbcType="TIMESTAMP"/>
21 + <result property="meals" column="meals" jdbcType="OTHER"/>
22 + <result property="createdBy" column="createdBy" jdbcType="INTEGER"/>
23 + <result property="createdAt" column="createdAt" jdbcType="TIMESTAMP"/>
24 + <result property="creationSource" column="creationSource" jdbcType="INTEGER"/>
25 + <result property="updatedBy" column="updatedBy" jdbcType="INTEGER"/>
26 + <result property="updatedAt" column="updatedAt" jdbcType="TIMESTAMP"/>
27 + <result property="updateSource" column="updateSource" jdbcType="INTEGER"/>
28 + <result property="isDeleted" column="isDeleted" jdbcType="TINYINT"/>
29 + </resultMap>
30 +
31 + <sql id="Base_Column_List">
32 + id,enterpriseId,clientId,
33 + menuId,accountId,orderMethod,
34 + dinerId,dinerName,clientName,
35 + gradeName,className,studentNo,
36 + reserveDate,meals,createdBy,
37 + createdAt,creationSource,updatedBy,
38 + updatedAt,updateSource,isDeleted
39 + </sql>
40 +</mapper>
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!DOCTYPE mapper
3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 +<mapper namespace="com.tianting.infoloop.mapper.MpAccountDinerRefMapper">
6 +
7 + <resultMap id="BaseResultMap" type="com.tianting.infoloop.model.db.MpAccountDinerRef">
8 + <id property="id" column="id" jdbcType="INTEGER"/>
9 + <result property="enterpriseId" column="enterpriseId" jdbcType="INTEGER"/>
10 + <result property="accountId" column="accountId" jdbcType="INTEGER"/>
11 + <result property="dinerId" column="dinerId" jdbcType="INTEGER"/>
12 + <result property="createdBy" column="createdBy" jdbcType="INTEGER"/>
13 + <result property="createdAt" column="createdAt" jdbcType="TIMESTAMP"/>
14 + <result property="creationSource" column="creationSource" jdbcType="INTEGER"/>
15 + </resultMap>
16 +
17 + <sql id="Base_Column_List">
18 + id,enterpriseId,accountId,
19 + dinerId,createdBy,createdAt,
20 + creationSource
21 + </sql>
22 +</mapper>
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!DOCTYPE mapper
3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 +<mapper namespace="com.tianting.infoloop.mapper.MpAccountMapper">
6 +
7 + <resultMap id="BaseResultMap" type="com.tianting.infoloop.model.db.MpAccount">
8 + <id property="id" column="id" jdbcType="INTEGER"/>
9 + <result property="enterpriseId" column="enterpriseId" jdbcType="INTEGER"/>
10 + <result property="openId" column="openId" jdbcType="VARCHAR"/>
11 + <result property="unionId" column="unionId" jdbcType="VARCHAR"/>
12 + <result property="nickname" column="nickname" jdbcType="VARCHAR"/>
13 + <result property="avatarUrl" column="avatarUrl" jdbcType="VARCHAR"/>
14 + <result property="gender" column="gender" jdbcType="TINYINT"/>
15 + <result property="phoneNumber" column="phoneNumber" jdbcType="VARCHAR"/>
16 + <result property="status" column="status" jdbcType="TINYINT"/>
17 + <result property="createdBy" column="createdBy" jdbcType="INTEGER"/>
18 + <result property="createdAt" column="createdAt" jdbcType="TIMESTAMP"/>
19 + <result property="creationSource" column="creationSource" jdbcType="INTEGER"/>
20 + <result property="updatedBy" column="updatedBy" jdbcType="INTEGER"/>
21 + <result property="updatedAt" column="updatedAt" jdbcType="TIMESTAMP"/>
22 + <result property="updateSource" column="updateSource" jdbcType="INTEGER"/>
23 + <result property="isDeleted" column="isDeleted" jdbcType="TINYINT"/>
24 + </resultMap>
25 +
26 + <sql id="Base_Column_List">
27 + id,enterpriseId,openId,
28 + unionId,nickname,avatarUrl,
29 + gender,phoneNumber,status,
30 + createdBy,createdAt,creationSource,
31 + updatedBy,updatedAt,updateSource,
32 + isDeleted
33 + </sql>
34 +</mapper>