zhuyifan

农信点餐小程序

Showing 39 changed files with 2918 additions and 39 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.MenuSchedule;
66 +import com.infoloop.tianting.mealorderservice.QueryDinersByConditionRpcRequest;
67 +import com.infoloop.tianting.mealorderservice.QueryDinersByConditionRpcResponse;
68 +import com.infoloop.tianting.mealorderservice.QueryGradeClassesByConditionRpcRequest;
69 +import com.infoloop.tianting.mealorderservice.QueryGradeClassesByConditionRpcResponse;
70 +import com.infoloop.tianting.mealorderservice.QueryLatestMealMenuRecordsByClientIdsRpcRequest;
71 +import com.infoloop.tianting.mealorderservice.QueryLatestMealMenuRecordsByClientIdsRpcResponse;
72 +import com.infoloop.tianting.mealorderservice.QueryMealMenuRecordsByConditionRpcRequest;
73 +import com.infoloop.tianting.mealorderservice.QueryMealMenuRecordsByConditionRpcResponse;
74 +import com.infoloop.tianting.mealorderservice.QueryMealOrdersByConditionRpcRequest;
75 +import com.infoloop.tianting.mealorderservice.QueryMealOrdersByConditionRpcResponse;
76 +import com.infoloop.tianting.mealorderservice.QueryMpAccountDinerRefsByConditionRpcRequest;
77 +import com.infoloop.tianting.mealorderservice.QueryMpAccountDinerRefsByConditionRpcResponse;
78 +import com.infoloop.tianting.mealorderservice.QueryMpAccountsByConditionRpcRequest;
79 +import com.infoloop.tianting.mealorderservice.QueryMpAccountsByConditionRpcResponse;
80 +import com.infoloop.tianting.mealorderservice.QueryReserveMealOrdersByDinerIdsRpcRequest;
81 +import com.infoloop.tianting.mealorderservice.QueryReserveMealOrdersByDinerIdsRpcResponse;
82 +import com.infoloop.tianting.mealorderservice.SingleDinerRpcResponse;
83 +import com.infoloop.tianting.mealorderservice.SingleGradeClassRpcResponse;
84 +import com.infoloop.tianting.mealorderservice.SingleMealMenuRecordRpcResponse;
85 +import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse;
86 +import com.infoloop.tianting.mealorderservice.SingleMpAccountDinerRefRpcResponse;
87 +import com.infoloop.tianting.mealorderservice.SingleMpAccountRpcResponse;
88 +import com.infoloop.tianting.mealorderservice.UpdateDinerRpcRequest;
89 +import com.infoloop.tianting.mealorderservice.UpdateDinerRpcResponse;
90 +import com.infoloop.tianting.mealorderservice.UpdateGradeClassRpcRequest;
91 +import com.infoloop.tianting.mealorderservice.UpdateGradeClassRpcResponse;
92 +import com.infoloop.tianting.mealorderservice.UpdateMpAccountRpcRequest;
93 +import com.infoloop.tianting.mealorderservice.UpdateMpAccountRpcResponse;
94 +import com.tianting.infoloop.model.db.Diner;
95 +import com.tianting.infoloop.model.db.GradeClass;
96 +import com.tianting.infoloop.model.db.MealMenuRecord;
97 +import com.tianting.infoloop.model.db.MealOrder;
98 +import com.tianting.infoloop.model.db.MpAccount;
99 +import com.tianting.infoloop.model.db.MpAccountDinerRef;
100 +import com.tianting.infoloop.service.DinerService;
101 +import com.tianting.infoloop.service.GradeClassService;
102 +import com.tianting.infoloop.service.MealMenuRecordService;
103 +import com.tianting.infoloop.service.MealOrderService;
104 +import com.tianting.infoloop.service.MpAccountDinerRefService;
105 +import com.tianting.infoloop.service.MpAccountService;
106 +import com.tianting.infoloop.utils.ProtoBeanUtil;
107 +import io.grpc.Status;
108 +import io.grpc.stub.StreamObserver;
109 +import lombok.RequiredArgsConstructor;
110 +import lombok.extern.slf4j.Slf4j;
111 +import org.springframework.beans.factory.annotation.Autowired;
112 +import org.springframework.stereotype.Service;
113 +import org.springframework.transaction.annotation.Transactional;
114 +
115 +import java.time.DayOfWeek;
116 +import java.time.LocalDate;
117 +import java.time.LocalDateTime;
118 +import java.time.LocalTime;
119 +import java.time.temporal.TemporalAdjusters;
120 +import java.util.ArrayList;
121 +import java.util.List;
122 +import java.util.function.Function;
123 +import java.util.stream.Collectors;
124 +
125 +import static com.tianting.infoloop.constants.ConfigConstants.DATA_SOURCE_MASTER;
126 +import static com.tianting.infoloop.constants.ConfigConstants.DATA_SOURCE_SLAVE;
127 +
128 +@Slf4j
129 +@Service
130 +@RequiredArgsConstructor(onConstructor_ = @Autowired)
131 +public class MealOrderGrpcService extends MealOrderServiceRpcGrpc.MealOrderServiceRpcImplBase {
132 +
133 + private final DinerService dinerService;
134 +
135 + private final GradeClassService gradeClassService;
136 +
137 + private final MealMenuRecordService mealMenuRecordService;
138 +
139 + private final MealOrderService mealOrderService;
140 +
141 + private final MpAccountDinerRefService mpAccountDinerRefService;
142 +
143 + private final MpAccountService mpAccountService;
144 +
145 + @Override
146 + @DS(DATA_SOURCE_SLAVE)
147 + public void getMealOrderById(final GetMealOrderByIdRpcRequest request,
148 + final StreamObserver<GetMealOrderByIdRpcResponse> responseObserver) {
149 + final var builder = GetMealOrderByIdRpcResponse.newBuilder();
150 + try {
151 + final var mealOrder = mealOrderService.getById(request.getId());
152 + if (mealOrder != null) {
153 + final var mealOrderRpcResponse = ProtoBeanUtil.beanToProto(mealOrder, SingleMealOrderRpcResponse.class, "meals");
154 + final var build = mealOrderRpcResponse.toBuilder().addAllMeals(ProtoBeanUtil.jsonToProtoList(mealOrder.getMeals(), MenuSchedule.class)).build();
155 + builder.setResponse(build);
156 + }
157 + } catch (final Exception e) {
158 + log.error("getMealOrderById error;", e);
159 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
160 + }
161 + responseObserver.onNext(builder.build());
162 + responseObserver.onCompleted();
163 + }
164 +
165 + @Override
166 + @DS(DATA_SOURCE_SLAVE)
167 + public void getMealOrdersByIds(final GetMealOrdersByIdsRpcRequest request,
168 + final StreamObserver<GetMealOrdersByIdsRpcResponse> responseObserver) {
169 + final var builder = GetMealOrdersByIdsRpcResponse.newBuilder();
170 + try {
171 + final var mealOrders = mealOrderService.listByIds(request.getIdsList());
172 + if (!mealOrders.isEmpty()) {
173 + for (final var mealOrder : mealOrders) {
174 + final var mealOrderRpcResponse = ProtoBeanUtil.beanToProto(mealOrder, SingleMealOrderRpcResponse.class, "meals");
175 + final var build = mealOrderRpcResponse.toBuilder().addAllMeals(ProtoBeanUtil.jsonToProtoList(mealOrder.getMeals(), MenuSchedule.class)).build();
176 + builder.addResponses(build);
177 + }
178 + }
179 + } catch (final Exception e) {
180 + log.error("getMealOrdersByIds error;", e);
181 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
182 + }
183 + responseObserver.onNext(builder.build());
184 + responseObserver.onCompleted();
185 + }
186 +
187 + @Override
188 + @DS(DATA_SOURCE_SLAVE)
189 + public void queryMealOrdersByCondition(final QueryMealOrdersByConditionRpcRequest request,
190 + final StreamObserver<QueryMealOrdersByConditionRpcResponse> responseObserver) {
191 + final var builder = QueryMealOrdersByConditionRpcResponse.newBuilder();
192 + try {
193 + LambdaQueryWrapper<MealOrder> queryWrapper = new LambdaQueryWrapper<>();
194 + queryWrapper.eq(MealOrder::getEnterpriseId, request.getEnterpriseId());
195 + if (request.getShouldFilterClientIds()) {
196 + queryWrapper.in(!request.getClientIdsList().isEmpty(), MealOrder::getClientId, request.getClientIdsList());
197 + }
198 + if (request.getShouldFilterMenuIds()) {
199 + queryWrapper.in(!request.getMenuIdsList().isEmpty(), MealOrder::getMenuId, request.getMenuIdsList());
200 + }
201 + if (request.getShouldFilterAccountIds()) {
202 + queryWrapper.in(!request.getAccountIdsList().isEmpty(), MealOrder::getAccountId, request.getAccountIdsList());
203 + }
204 + if (request.getShouldFilterOrderMethod()) {
205 + queryWrapper.eq(MealOrder::getOrderMethod, request.getOrderMethodValue());
206 + }
207 + if (request.getShouldFilterDinerIds()) {
208 + queryWrapper.in(!request.getDinerIdsList().isEmpty(), MealOrder::getDinerId, request.getDinerIdsList());
209 + }
210 + if (request.getShouldFilterReserveDateStart()) {
211 + queryWrapper.ge(MealOrder::getReserveDate, LocalDateTimeUtil.of(request.getReserveDateStart()));
212 + }
213 + if (request.getShouldFilterReserveDateEnd()) {
214 + queryWrapper.lt(MealOrder::getReserveDate, LocalDateTimeUtil.of(request.getReserveDateEnd()));
215 + }
216 + final var mealOrders = mealOrderService.list(queryWrapper);
217 + if (!mealOrders.isEmpty()) {
218 + for (final var mealOrder : mealOrders) {
219 + final var mealOrderRpcResponse = ProtoBeanUtil.beanToProto(mealOrder, SingleMealOrderRpcResponse.class, "meals");
220 + final var build = mealOrderRpcResponse.toBuilder().addAllMeals(ProtoBeanUtil.jsonToProtoList(mealOrder.getMeals(), MenuSchedule.class)).build();
221 + builder.addResponses(build);
222 + }
223 + }
224 + } catch (final Exception e) {
225 + log.error("queryMealOrdersByCondition error;", e);
226 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
227 + }
228 + responseObserver.onNext(builder.build());
229 + responseObserver.onCompleted();
230 + }
231 +
232 + @Override
233 + @DS(DATA_SOURCE_SLAVE)
234 + public void queryReserveMealOrdersByDinerIds(final QueryReserveMealOrdersByDinerIdsRpcRequest request,
235 + final StreamObserver<QueryReserveMealOrdersByDinerIdsRpcResponse> responseObserver) {
236 + final var builder = QueryReserveMealOrdersByDinerIdsRpcResponse.newBuilder();
237 + try {
238 + LambdaQueryWrapper<MealOrder> queryWrapper = new LambdaQueryWrapper<>();
239 + queryWrapper.eq(MealOrder::getEnterpriseId, request.getEnterpriseId());
240 + queryWrapper.in(!request.getDinerIdsList().isEmpty(), MealOrder::getDinerId, request.getDinerIdsList());
241 + LocalDate today = LocalDate.now();
242 + LocalDate nextMonday = today.with(TemporalAdjusters.next(DayOfWeek.MONDAY));
243 + LocalDateTime nextMondayStart = LocalDateTime.of(nextMonday, LocalTime.MIN);
244 + LocalDate nextSunday = nextMonday.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
245 + LocalDateTime nextSundayEnd = LocalDateTime.of(nextSunday, LocalTime.MAX);
246 + queryWrapper.ge(MealOrder::getReserveDate, nextMondayStart);
247 + queryWrapper.lt(MealOrder::getReserveDate, nextSundayEnd);
248 + final var mealOrders = mealOrderService.list(queryWrapper);
249 + if (!mealOrders.isEmpty()) {
250 + for (final var mealOrder : mealOrders) {
251 + final var mealOrderRpcResponse = ProtoBeanUtil.beanToProto(mealOrder, SingleMealOrderRpcResponse.class, "meals");
252 + final var build = mealOrderRpcResponse.toBuilder().addAllMeals(ProtoBeanUtil.jsonToProtoList(mealOrder.getMeals(), MenuSchedule.class)).build();
253 + builder.addResponses(build);
254 + }
255 + }
256 + } catch (final Exception e) {
257 + log.error("queryReserveMealOrdersByDinerIds error;", e);
258 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
259 + }
260 + responseObserver.onNext(builder.build());
261 + responseObserver.onCompleted();
262 + }
263 +
264 + @Override
265 + @DS(DATA_SOURCE_MASTER)
266 + public void createMealOrder(final CreateMealOrderRpcRequest request,
267 + final StreamObserver<CreateMealOrderRpcResponse> responseObserver) {
268 + final var builder = CreateMealOrderRpcResponse.newBuilder();
269 + try {
270 + MealOrder mealOrder = new MealOrder();
271 + mealOrder.setEnterpriseId(request.getEnterpriseId());
272 + mealOrder.setCreatedBy(request.getCreatedBy());
273 + mealOrder.setCreationSource(request.getCreationSource());
274 + mealOrder.setUpdatedBy(request.getCreatedBy());
275 + mealOrder.setUpdateSource(request.getCreationSource());
276 + mealOrder.setClientId(request.getCreation().getClientId());
277 + mealOrder.setMenuId(request.getCreation().getMenuId());
278 + mealOrder.setAccountId(request.getCreation().getAccountId());
279 + mealOrder.setOrderMethod(request.getCreation().getOrderMethodValue());
280 + mealOrder.setDinerId(request.getCreation().getDinerId());
281 + mealOrder.setDinerName(request.getCreation().getDinerName());
282 + mealOrder.setClientName(request.getCreation().getClientName());
283 + mealOrder.setGradeName(request.getCreation().getGradeName());
284 + mealOrder.setClassName(request.getCreation().getClassName());
285 + mealOrder.setStudentNo(request.getCreation().getStudentNo());
286 + mealOrder.setReserveDate(LocalDateTimeUtil.of(request.getCreation().getReserveDate()));
287 + mealOrder.setMeals(ProtoBeanUtil.protoListToJson(request.getCreation().getMealsList()));
288 + builder.setIsCreated(mealOrderService.save(mealOrder)).setId(mealOrder.getId());
289 + } catch (final Exception e) {
290 + log.error("createMealOrder error;", e);
291 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
292 + }
293 + responseObserver.onNext(builder.build());
294 + responseObserver.onCompleted();
295 + }
296 +
297 + @Override
298 + @DS(DATA_SOURCE_MASTER)
299 + public void batchCreateMealOrders(final BatchCreateMealOrdersRpcRequest request,
300 + final StreamObserver<BatchCreateMealOrdersRpcResponse> responseObserver) {
301 + final var builder = BatchCreateMealOrdersRpcResponse.newBuilder();
302 + try {
303 + final var mealOrders = new ArrayList<MealOrder>();
304 + for (final var creation : request.getCreationsList()) {
305 + MealOrder mealOrder = new MealOrder();
306 + mealOrder.setEnterpriseId(request.getEnterpriseId());
307 + mealOrder.setCreatedBy(request.getCreatedBy());
308 + mealOrder.setCreationSource(request.getCreationSource());
309 + mealOrder.setUpdatedBy(request.getCreatedBy());
310 + mealOrder.setUpdateSource(request.getCreationSource());
311 + mealOrder.setClientId(creation.getClientId());
312 + mealOrder.setMenuId(creation.getMenuId());
313 + mealOrder.setAccountId(creation.getAccountId());
314 + mealOrder.setOrderMethod(creation.getOrderMethodValue());
315 + mealOrder.setDinerId(creation.getDinerId());
316 + mealOrder.setDinerName(creation.getDinerName());
317 + mealOrder.setClientName(creation.getClientName());
318 + mealOrder.setGradeName(creation.getGradeName());
319 + mealOrder.setClassName(creation.getClassName());
320 + mealOrder.setStudentNo(creation.getStudentNo());
321 + mealOrder.setReserveDate(LocalDateTimeUtil.of(creation.getReserveDate()));
322 + mealOrder.setMeals(ProtoBeanUtil.protoListToJson(creation.getMealsList()));
323 + mealOrders.add(mealOrder);
324 + }
325 + builder.setIsCreated(mealOrderService.saveBatch(mealOrders)).addAllIds(mealOrders.stream().map(MealOrder::getId).toList());
326 + } catch (final Exception e) {
327 + log.error("batchCreateMealOrders 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_MASTER)
336 + public void deleteMealOrdersByIds(final DeleteMealOrdersByIdsRpcRequest request,
337 + final StreamObserver<DeleteMealOrdersRpcResponse> responseObserver) {
338 + final var builder = DeleteMealOrdersRpcResponse.newBuilder();
339 + try {
340 + builder.setIsDeleted(mealOrderService.removeBatchByIds(request.getIdsList()));
341 + } catch (final Exception e) {
342 + log.error("deleteMealOrdersByIds error;", e);
343 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
344 + }
345 + responseObserver.onNext(builder.build());
346 + responseObserver.onCompleted();
347 + }
348 +
349 + @Override
350 + @DS(DATA_SOURCE_SLAVE)
351 + public void getMpAccountById(final GetMpAccountByIdRpcRequest request,
352 + final StreamObserver<GetMpAccountByIdRpcResponse> responseObserver) {
353 + final var builder = GetMpAccountByIdRpcResponse.newBuilder();
354 + try {
355 + final var mealOrder = mpAccountService.getById(request.getId());
356 + if (mealOrder != null) {
357 + builder.setResponse(ProtoBeanUtil.beanToProto(mealOrder, SingleMpAccountRpcResponse.class));
358 + }
359 + } catch (final Exception e) {
360 + log.error("getMpAccountById error;", e);
361 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
362 + }
363 + responseObserver.onNext(builder.build());
364 + responseObserver.onCompleted();
365 + }
366 +
367 + @Override
368 + @DS(DATA_SOURCE_SLAVE)
369 + public void getMpAccountByOpenId(final GetMpAccountByOpenIdRpcRequest request,
370 + final StreamObserver<GetMpAccountByOpenIdRpcResponse> responseObserver) {
371 + final var builder = GetMpAccountByOpenIdRpcResponse.newBuilder();
372 + try {
373 + LambdaQueryWrapper<MpAccount> queryWrapper = Wrappers.lambdaQuery();
374 + queryWrapper.eq(MpAccount::getOpenId, request.getOpenId());
375 + final var mpAccount = mpAccountService.getOne(queryWrapper);
376 + if (mpAccount != null) {
377 + builder.setResponse(ProtoBeanUtil.beanToProto(mpAccount, SingleMpAccountRpcResponse.class));
378 + }
379 + } catch (final Exception e) {
380 + log.error("getMpAccountByOpenId error;", e);
381 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
382 + }
383 + responseObserver.onNext(builder.build());
384 + responseObserver.onCompleted();
385 + }
386 +
387 + @Override
388 + @DS(DATA_SOURCE_SLAVE)
389 + public void getMpAccountsByIds(final GetMpAccountsByIdsRpcRequest request,
390 + final StreamObserver<GetMpAccountsByIdsRpcResponse> responseObserver) {
391 + final var builder = GetMpAccountsByIdsRpcResponse.newBuilder();
392 + try {
393 + final var mealOrders = mpAccountService.listByIds(request.getIdsList());
394 + if (!mealOrders.isEmpty()) {
395 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealOrders, SingleMpAccountRpcResponse.class));
396 + }
397 + } catch (final Exception e) {
398 + log.error("getMpAccountsByIds error;", e);
399 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
400 + }
401 + responseObserver.onNext(builder.build());
402 + responseObserver.onCompleted();
403 + }
404 +
405 + @Override
406 + @DS(DATA_SOURCE_SLAVE)
407 + public void queryMpAccountsByCondition(final QueryMpAccountsByConditionRpcRequest request,
408 + final StreamObserver<QueryMpAccountsByConditionRpcResponse> responseObserver) {
409 + final var builder = QueryMpAccountsByConditionRpcResponse.newBuilder();
410 + try {
411 + LambdaQueryWrapper<MpAccount> queryWrapper = new LambdaQueryWrapper<>();
412 + queryWrapper.eq(MpAccount::getEnterpriseId, request.getEnterpriseId());
413 + if (request.getShouldFilterOpenId()) {
414 + queryWrapper.eq(MpAccount::getOpenId, request.getOpenId());
415 + }
416 + if (request.getShouldFilterUnionId()) {
417 + queryWrapper.eq(MpAccount::getUnionId, request.getUnionId());
418 + }
419 + if (request.getShouldFilterPhoneNumber()) {
420 + queryWrapper.eq(MpAccount::getPhoneNumber, request.getPhoneNumber());
421 + }
422 + if (request.getShouldFilterStatus()) {
423 + queryWrapper.eq(MpAccount::getStatus, request.getStatusValue());
424 + }
425 + final var mealOrders = mpAccountService.list(queryWrapper);
426 + if (!mealOrders.isEmpty()) {
427 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealOrders, SingleMpAccountRpcResponse.class));
428 + }
429 + } catch (final Exception e) {
430 + log.error("queryMpAccountsByCondition error;", e);
431 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
432 + }
433 + responseObserver.onNext(builder.build());
434 + responseObserver.onCompleted();
435 + }
436 +
437 + @Override
438 + @DS(DATA_SOURCE_MASTER)
439 + public void createMpAccount(final CreateMpAccountRpcRequest request,
440 + final StreamObserver<CreateMpAccountRpcResponse> responseObserver) {
441 + final var builder = CreateMpAccountRpcResponse.newBuilder();
442 + try {
443 + MpAccount mpAccount = new MpAccount();
444 + mpAccount.setEnterpriseId(request.getEnterpriseId());
445 + mpAccount.setCreatedBy(request.getCreatedBy());
446 + mpAccount.setCreationSource(request.getCreationSource());
447 + mpAccount.setUpdatedBy(request.getCreatedBy());
448 + mpAccount.setUpdateSource(request.getCreationSource());
449 + mpAccount.setOpenId(request.getCreation().getOpenId());
450 + if (request.getCreation().getShouldCreateUnionId()) {
451 + mpAccount.setUnionId(request.getCreation().getUnionId());
452 + }
453 + if (request.getCreation().getShouldCreateNickname()) {
454 + mpAccount.setNickname(request.getCreation().getNickname());
455 + }
456 + if (request.getCreation().getShouldCreateAvatarUrl()) {
457 + mpAccount.setAvatarUrl(request.getCreation().getAvatarUrl());
458 + }
459 + mpAccount.setGender(request.getCreation().getGenderValue());
460 + mpAccount.setPhoneNumber(request.getCreation().getPhoneNumber());
461 + mpAccount.setStatus(request.getCreation().getStatusValue());
462 + builder.setIsCreated(mpAccountService.save(mpAccount)).setId(mpAccount.getId());
463 + } catch (final Exception e) {
464 + log.error("createMpAccount error;", e);
465 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
466 + }
467 + responseObserver.onNext(builder.build());
468 + responseObserver.onCompleted();
469 + }
470 +
471 + @Override
472 + @DS(DATA_SOURCE_MASTER)
473 + public void updateMpAccount(final UpdateMpAccountRpcRequest request,
474 + final StreamObserver<UpdateMpAccountRpcResponse> responseObserver) {
475 + final var builder = UpdateMpAccountRpcResponse.newBuilder();
476 + try {
477 + MpAccount mpAccount = new MpAccount();
478 + mpAccount.setId(request.getModification().getId());
479 + mpAccount.setEnterpriseId(request.getEnterpriseId());
480 + mpAccount.setUpdatedBy(request.getUpdatedBy());
481 + mpAccount.setUpdateSource(request.getUpdateSource());
482 + if (request.getModification().getShouldUpdateNickname()) {
483 + mpAccount.setNickname(request.getModification().getNickname());
484 + }
485 + if (request.getModification().getShouldUpdateAvatarUrl()) {
486 + mpAccount.setAvatarUrl(request.getModification().getAvatarUrl());
487 + }
488 + if (request.getModification().getShouldUpdateGender()) {
489 + mpAccount.setGender(request.getModification().getGenderValue());
490 + }
491 + if (request.getModification().getShouldUpdatePhoneNumber()) {
492 + mpAccount.setPhoneNumber(request.getModification().getPhoneNumber());
493 + }
494 + if (request.getModification().getShouldUpdateStatus()) {
495 + mpAccount.setStatus(request.getModification().getStatusValue());
496 + }
497 + builder.setIsUpdated(mpAccountService.updateById(mpAccount));
498 + } catch (final Exception e) {
499 + log.error("updateMpAccount 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_MASTER)
508 + public void deleteMpAccountsByIds(final DeleteMpAccountsByIdsRpcRequest request,
509 + final StreamObserver<DeleteMpAccountsRpcResponse> responseObserver) {
510 + final var builder = DeleteMpAccountsRpcResponse.newBuilder();
511 + try {
512 + builder.setIsDeleted(mpAccountService.removeBatchByIds(request.getIdsList()));
513 + } catch (final Exception e) {
514 + log.error("deleteMpAccountsByIds error;", e);
515 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
516 + }
517 + responseObserver.onNext(builder.build());
518 + responseObserver.onCompleted();
519 + }
520 +
521 + @Override
522 + @DS(DATA_SOURCE_SLAVE)
523 + public void getDinerById(final GetDinerByIdRpcRequest request,
524 + final StreamObserver<GetDinerByIdRpcResponse> responseObserver) {
525 + final var builder = GetDinerByIdRpcResponse.newBuilder();
526 + try {
527 + final var mealOrder = dinerService.getById(request.getId());
528 + if (mealOrder != null) {
529 + builder.setResponse(ProtoBeanUtil.beanToProto(mealOrder, SingleDinerRpcResponse.class));
530 + }
531 + } catch (final Exception e) {
532 + log.error("getDinerById error;", e);
533 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
534 + }
535 + responseObserver.onNext(builder.build());
536 + responseObserver.onCompleted();
537 + }
538 +
539 + @Override
540 + @DS(DATA_SOURCE_SLAVE)
541 + public void getDinersByIds(final GetDinersByIdsRpcRequest request,
542 + final StreamObserver<GetDinersByIdsRpcResponse> responseObserver) {
543 + final var builder = GetDinersByIdsRpcResponse.newBuilder();
544 + try {
545 + final var mealOrders = dinerService.listByIds(request.getIdsList());
546 + if (!mealOrders.isEmpty()) {
547 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealOrders, SingleDinerRpcResponse.class));
548 + }
549 + } catch (final Exception e) {
550 + log.error("getDinersByIds error;", e);
551 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
552 + }
553 + responseObserver.onNext(builder.build());
554 + responseObserver.onCompleted();
555 + }
556 +
557 + @Override
558 + @DS(DATA_SOURCE_SLAVE)
559 + public void queryDinersByCondition(final QueryDinersByConditionRpcRequest request,
560 + final StreamObserver<QueryDinersByConditionRpcResponse> responseObserver) {
561 + final var builder = QueryDinersByConditionRpcResponse.newBuilder();
562 + try {
563 + LambdaQueryWrapper<Diner> queryWrapper = new LambdaQueryWrapper<>();
564 + queryWrapper.eq(Diner::getEnterpriseId, request.getEnterpriseId());
565 + if (request.getShouldFilterClientIds()) {
566 + queryWrapper.in(!request.getClientIdsList().isEmpty(), Diner::getClientId, request.getClientIdsList());
567 + }
568 + if (request.getShouldFilterClassIds()) {
569 + queryWrapper.in(!request.getClassIdsList().isEmpty(), Diner::getClassId, request.getClassIdsList());
570 + }
571 + if (request.getShouldFilterStudentNo()) {
572 + queryWrapper.eq(Diner::getStudentNo, request.getStudentNo());
573 + }
574 + if (request.getShouldFilterName()) {
575 + queryWrapper.eq(Diner::getName, request.getName());
576 + }
577 + final var diners = dinerService.list(queryWrapper);
578 + if (!diners.isEmpty()) {
579 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(diners, SingleDinerRpcResponse.class));
580 + }
581 + } catch (final Exception e) {
582 + log.error("queryDinersByCondition error;", e);
583 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
584 + }
585 + responseObserver.onNext(builder.build());
586 + responseObserver.onCompleted();
587 + }
588 +
589 + @Override
590 + @DS(DATA_SOURCE_MASTER)
591 + public void createDiner(final CreateDinerRpcRequest request,
592 + final StreamObserver<CreateDinerRpcResponse> responseObserver) {
593 + final var builder = CreateDinerRpcResponse.newBuilder();
594 + try {
595 + Diner diner = new Diner();
596 + diner.setEnterpriseId(request.getEnterpriseId());
597 + diner.setCreatedBy(request.getCreatedBy());
598 + diner.setCreationSource(request.getCreationSource());
599 + diner.setUpdatedBy(request.getCreatedBy());
600 + diner.setUpdateSource(request.getCreationSource());
601 + diner.setClientId(request.getCreation().getClientId());
602 + diner.setClassId(request.getCreation().getClassId());
603 + diner.setStudentNo(request.getCreation().getStudentNo());
604 + diner.setName(request.getCreation().getName());
605 + builder.setIsCreated(dinerService.save(diner)).setId(diner.getId());
606 + } catch (final Exception e) {
607 + log.error("createDiner error;", e);
608 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
609 + }
610 + responseObserver.onNext(builder.build());
611 + responseObserver.onCompleted();
612 + }
613 +
614 + @Override
615 + @DS(DATA_SOURCE_MASTER)
616 + public void updateDiner(final UpdateDinerRpcRequest request,
617 + final StreamObserver<UpdateDinerRpcResponse> responseObserver) {
618 + final var builder = UpdateDinerRpcResponse.newBuilder();
619 + try {
620 + Diner diner = new Diner();
621 + diner.setId(request.getModification().getId());
622 + diner.setEnterpriseId(request.getEnterpriseId());
623 + diner.setUpdatedBy(request.getUpdatedBy());
624 + diner.setUpdateSource(request.getUpdateSource());
625 + if (request.getModification().getShouldUpdateClientId()) {
626 + diner.setClientId(request.getModification().getClientId());
627 + }
628 + if (request.getModification().getShouldUpdateClassId()) {
629 + diner.setClassId(request.getModification().getClassId());
630 + }
631 + if (request.getModification().getShouldUpdateStudentNo()) {
632 + diner.setStudentNo(request.getModification().getStudentNo());
633 + }
634 + if (request.getModification().getShouldUpdateName()) {
635 + diner.setName(request.getModification().getName());
636 + }
637 + builder.setIsUpdated(dinerService.updateById(diner));
638 + } catch (final Exception e) {
639 + log.error("updateDiner error;", e);
640 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
641 + }
642 + responseObserver.onNext(builder.build());
643 + responseObserver.onCompleted();
644 + }
645 +
646 + @Override
647 + @DS(DATA_SOURCE_MASTER)
648 + public void batchSaveOrUpdateDiners(final BatchSaveOrUpdateDinersRpcRequest request,
649 + final StreamObserver<BatchSaveOrUpdateDinersRpcResponse> responseObserver) {
650 + final var builder = BatchSaveOrUpdateDinersRpcResponse.newBuilder();
651 + try {
652 + final var diners = new ArrayList<Diner>();
653 + for (DinerModification modification : request.getModificationsList()) {
654 + Diner diner = new Diner();
655 + diner.setId(modification.getId() == 0 ? null : modification.getId());
656 + diner.setEnterpriseId(request.getEnterpriseId());
657 + if (modification.getId() == 0) {
658 + diner.setCreatedBy(request.getUpdatedBy());
659 + diner.setCreationSource(request.getUpdateSource());
660 + }
661 + diner.setUpdatedBy(request.getUpdatedBy());
662 + diner.setUpdateSource(request.getUpdateSource());
663 + if (modification.getShouldUpdateClientId()) {
664 + diner.setClientId(modification.getClientId());
665 + }
666 + if (modification.getShouldUpdateClassId()) {
667 + diner.setClassId(modification.getClassId());
668 + }
669 + if (modification.getShouldUpdateStudentNo()) {
670 + diner.setStudentNo(modification.getStudentNo());
671 + }
672 + if (modification.getShouldUpdateName()) {
673 + diner.setName(modification.getName());
674 + }
675 + diners.add(diner);
676 + }
677 + builder.setIsUpdated(dinerService.saveOrUpdateBatch(diners));
678 + } catch (final Exception e) {
679 + log.error("batchSaveOrUpdateDiners 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_MASTER)
688 + public void deleteDinersByIds(final DeleteDinersByIdsRpcRequest request,
689 + final StreamObserver<DeleteDinersRpcResponse> responseObserver) {
690 + final var builder = DeleteDinersRpcResponse.newBuilder();
691 + try {
692 + builder.setIsDeleted(dinerService.removeBatchByIds(request.getIdsList()));
693 + } catch (final Exception e) {
694 + log.error("deleteDinersByIds error;", e);
695 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
696 + }
697 + responseObserver.onNext(builder.build());
698 + responseObserver.onCompleted();
699 + }
700 +
701 + @Override
702 + @DS(DATA_SOURCE_SLAVE)
703 + public void getMpAccountDinerRefsByIds(final GetMpAccountDinerRefsByIdsRpcRequest request,
704 + final StreamObserver<GetMpAccountDinerRefsByIdsRpcResponse> responseObserver) {
705 + final var builder = GetMpAccountDinerRefsByIdsRpcResponse.newBuilder();
706 + try {
707 + final var mpAccountDinerRefs = mpAccountDinerRefService.listByIds(request.getIdsList());
708 + if (!mpAccountDinerRefs.isEmpty()) {
709 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mpAccountDinerRefs, SingleMpAccountDinerRefRpcResponse.class));
710 + }
711 + } catch (final Exception e) {
712 + log.error("getMpAccountDinerRefsByIds error;", e);
713 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
714 + }
715 + responseObserver.onNext(builder.build());
716 + responseObserver.onCompleted();
717 + }
718 +
719 + @Override
720 + @DS(DATA_SOURCE_SLAVE)
721 + public void queryMpAccountDinerRefsByCondition(final QueryMpAccountDinerRefsByConditionRpcRequest request,
722 + final StreamObserver<QueryMpAccountDinerRefsByConditionRpcResponse> responseObserver) {
723 + final var builder = QueryMpAccountDinerRefsByConditionRpcResponse.newBuilder();
724 + try {
725 + LambdaQueryWrapper<MpAccountDinerRef> queryWrapper = new LambdaQueryWrapper<>();
726 + queryWrapper.eq(MpAccountDinerRef::getEnterpriseId, request.getEnterpriseId());
727 + if (request.getShouldFilterAccountIds()) {
728 + queryWrapper.in(!request.getAccountIdsList().isEmpty(), MpAccountDinerRef::getAccountId, request.getAccountIdsList());
729 + }
730 + if (request.getShouldFilterDinerIds()) {
731 + queryWrapper.in(!request.getDinerIdsList().isEmpty(), MpAccountDinerRef::getDinerId, request.getDinerIdsList());
732 + }
733 + final var diners = mpAccountDinerRefService.list(queryWrapper);
734 + if (!diners.isEmpty()) {
735 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(diners, SingleMpAccountDinerRefRpcResponse.class));
736 + }
737 + } catch (final Exception e) {
738 + log.error("queryMpAccountDinerRefsByCondition error;", e);
739 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
740 + }
741 + responseObserver.onNext(builder.build());
742 + responseObserver.onCompleted();
743 + }
744 +
745 + @Override
746 + @DS(DATA_SOURCE_MASTER)
747 + public void createMpAccountDinerRef(final CreateMpAccountDinerRefRpcRequest request,
748 + final StreamObserver<CreateMpAccountDinerRefRpcResponse> responseObserver) {
749 + final var builder = CreateMpAccountDinerRefRpcResponse.newBuilder();
750 + try {
751 + MpAccountDinerRef mpAccountDinerRef = new MpAccountDinerRef();
752 + mpAccountDinerRef.setEnterpriseId(request.getEnterpriseId());
753 + mpAccountDinerRef.setCreatedBy(request.getCreatedBy());
754 + mpAccountDinerRef.setCreationSource(request.getCreationSource());
755 + mpAccountDinerRef.setAccountId(request.getCreation().getAccountId());
756 + mpAccountDinerRef.setDinerId(request.getCreation().getDinerId());
757 + builder.setIsCreated(mpAccountDinerRefService.save(mpAccountDinerRef)).setId(mpAccountDinerRef.getId());
758 + } catch (final Exception e) {
759 + log.error("createMpAccountDinerRef 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_MASTER)
768 + public void deleteMpAccountDinerRefsByIds(final DeleteMpAccountDinerRefsByIdsRpcRequest request,
769 + final StreamObserver<DeleteMpAccountDinerRefsRpcResponse> responseObserver) {
770 + final var builder = DeleteMpAccountDinerRefsRpcResponse.newBuilder();
771 + try {
772 + builder.setIsDeleted(mpAccountDinerRefService.removeBatchByIds(request.getIdsList()));
773 + } catch (final Exception e) {
774 + log.error("deleteMpAccountDinerRefsByIds error;", e);
775 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
776 + }
777 + responseObserver.onNext(builder.build());
778 + responseObserver.onCompleted();
779 + }
780 +
781 + @Override
782 + @DS(DATA_SOURCE_SLAVE)
783 + public void getGradeClassById(final GetGradeClassByIdRpcRequest request,
784 + final StreamObserver<GetGradeClassByIdRpcResponse> responseObserver) {
785 + final var builder = GetGradeClassByIdRpcResponse.newBuilder();
786 + try {
787 + final var gradeClass = gradeClassService.getById(request.getId());
788 + if (gradeClass != null) {
789 + builder.setResponse(ProtoBeanUtil.beanToProto(gradeClass, SingleGradeClassRpcResponse.class));
790 + }
791 + } catch (final Exception e) {
792 + log.error("getGradeClassById error;", e);
793 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
794 + }
795 + responseObserver.onNext(builder.build());
796 + responseObserver.onCompleted();
797 + }
798 +
799 + @Override
800 + @DS(DATA_SOURCE_SLAVE)
801 + public void getGradeClassesByIds(final GetGradeClassesByIdsRpcRequest request,
802 + final StreamObserver<GetGradeClassesByIdsRpcResponse> responseObserver) {
803 + final var builder = GetGradeClassesByIdsRpcResponse.newBuilder();
804 + try {
805 + final var gradeClasses = gradeClassService.listByIds(request.getIdsList());
806 + if (!gradeClasses.isEmpty()) {
807 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(gradeClasses, SingleGradeClassRpcResponse.class));
808 + }
809 + } catch (final Exception e) {
810 + log.error("getGradeClassesByIds error;", e);
811 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
812 + }
813 + responseObserver.onNext(builder.build());
814 + responseObserver.onCompleted();
815 + }
816 +
817 + @Override
818 + @DS(DATA_SOURCE_SLAVE)
819 + public void queryGradeClassesByCondition(final QueryGradeClassesByConditionRpcRequest request,
820 + final StreamObserver<QueryGradeClassesByConditionRpcResponse> responseObserver) {
821 + final var builder = QueryGradeClassesByConditionRpcResponse.newBuilder();
822 + try {
823 + LambdaQueryWrapper<GradeClass> queryWrapper = new LambdaQueryWrapper<>();
824 + queryWrapper.eq(GradeClass::getEnterpriseId, request.getEnterpriseId());
825 + if (request.getShouldFilterClientIds()) {
826 + queryWrapper.in(!request.getClientIdsList().isEmpty(), GradeClass::getClientId, request.getClientIdsList());
827 + }
828 + if (request.getShouldFilterGradeName()) {
829 + queryWrapper.eq(GradeClass::getGradeName, request.getGradeName());
830 + }
831 + final var gradeClasses = gradeClassService.list(queryWrapper);
832 + if (!gradeClasses.isEmpty()) {
833 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(gradeClasses, SingleGradeClassRpcResponse.class));
834 + }
835 + } catch (final Exception e) {
836 + log.error("queryGradeClassesByCondition error;", e);
837 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
838 + }
839 + responseObserver.onNext(builder.build());
840 + responseObserver.onCompleted();
841 + }
842 +
843 + @Override
844 + @DS(DATA_SOURCE_MASTER)
845 + public void createGradeClass(final CreateGradeClassRpcRequest request,
846 + final StreamObserver<CreateGradeClassRpcResponse> responseObserver) {
847 + final var builder = CreateGradeClassRpcResponse.newBuilder();
848 + try {
849 + GradeClass gradeClass = new GradeClass();
850 + gradeClass.setEnterpriseId(request.getEnterpriseId());
851 + gradeClass.setCreatedBy(request.getCreatedBy());
852 + gradeClass.setCreationSource(request.getCreationSource());
853 + gradeClass.setUpdatedBy(request.getCreatedBy());
854 + gradeClass.setUpdateSource(request.getCreationSource());
855 + gradeClass.setClientId(request.getCreation().getClientId());
856 + gradeClass.setGradeName(request.getCreation().getGradeName());
857 + gradeClass.setClassName(request.getCreation().getClassName());
858 + builder.setIsCreated(gradeClassService.save(gradeClass)).setId(gradeClass.getId());
859 + } catch (final Exception e) {
860 + log.error("createGradeClass error;", e);
861 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
862 + }
863 + responseObserver.onNext(builder.build());
864 + responseObserver.onCompleted();
865 + }
866 +
867 + @Override
868 + @DS(DATA_SOURCE_MASTER)
869 + public void batchCreateGradeClasses(final BatchCreateGradeClassesRpcRequest request,
870 + final StreamObserver<BatchCreateGradeClassesRpcResponse> responseObserver) {
871 + final var builder = BatchCreateGradeClassesRpcResponse.newBuilder();
872 + try {
873 + final var gradeClasses = new ArrayList<GradeClass>();
874 + for (final var creation : request.getCreationsList()) {
875 + final var gradeClass = new GradeClass();
876 + gradeClass.setEnterpriseId(request.getEnterpriseId());
877 + gradeClass.setCreatedBy(request.getCreatedBy());
878 + gradeClass.setCreationSource(request.getCreationSource());
879 + gradeClass.setClientId(creation.getClientId());
880 + gradeClass.setGradeName(creation.getGradeName());
881 + gradeClass.setClassName(creation.getClassName());
882 + gradeClasses.add(gradeClass);
883 + }
884 + builder.setIsCreated(gradeClassService.saveBatch(gradeClasses)).addAllIds(gradeClasses.stream().map(GradeClass::getId).collect(Collectors.toList()));
885 + } catch (final Exception e) {
886 + log.error("batchCreateGradeClasses error;", e);
887 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
888 + }
889 + responseObserver.onNext(builder.build());
890 + responseObserver.onCompleted();
891 + }
892 +
893 + @Override
894 + @DS(DATA_SOURCE_MASTER)
895 + public void updateGradeClass(final UpdateGradeClassRpcRequest request,
896 + final StreamObserver<UpdateGradeClassRpcResponse> responseObserver) {
897 + final var builder = UpdateGradeClassRpcResponse.newBuilder();
898 + try {
899 + GradeClass gradeClass = new GradeClass();
900 + gradeClass.setId(request.getModification().getId());
901 + gradeClass.setEnterpriseId(request.getEnterpriseId());
902 + gradeClass.setUpdatedBy(request.getUpdatedBy());
903 + gradeClass.setUpdateSource(request.getUpdateSource());
904 + if (request.getModification().getShouldUpdateClientId()) {
905 + gradeClass.setClientId(request.getModification().getClientId());
906 + }
907 + if (request.getModification().getShouldUpdateClassName()) {
908 + gradeClass.setClassName(request.getModification().getClassName());
909 + }
910 + if (request.getModification().getShouldUpdateGradeName()) {
911 + gradeClass.setGradeName(request.getModification().getGradeName());
912 + }
913 + builder.setIsUpdated(gradeClassService.updateById(gradeClass));
914 + } catch (final Exception e) {
915 + log.error("updateGradeClass error;", e);
916 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
917 + }
918 + responseObserver.onNext(builder.build());
919 + responseObserver.onCompleted();
920 + }
921 +
922 + @Override
923 + @DS(DATA_SOURCE_MASTER)
924 + public void batchSaveOrUpdateGradeClasses(final BatchSaveOrUpdateGradeClassesRpcRequest request,
925 + final StreamObserver<BatchSaveOrUpdateGradeClassesRpcResponse> responseObserver) {
926 + final var builder = BatchSaveOrUpdateGradeClassesRpcResponse.newBuilder();
927 + try {
928 + List<GradeClass> gradeClasses = new ArrayList<>();
929 + for (final var modification : request.getModificationsList()) {
930 + GradeClass gradeClass = new GradeClass();
931 + gradeClass.setId(modification.getId() == 0 ? null : modification.getId());
932 + gradeClass.setEnterpriseId(request.getEnterpriseId());
933 + if (modification.getId() == 0) {
934 + gradeClass.setCreatedBy(request.getUpdatedBy());
935 + gradeClass.setCreationSource(request.getUpdateSource());
936 + }
937 + gradeClass.setUpdatedBy(request.getUpdatedBy());
938 + gradeClass.setUpdateSource(request.getUpdateSource());
939 + if (modification.getShouldUpdateClientId()) {
940 + gradeClass.setClientId(modification.getClientId());
941 + }
942 + if (modification.getShouldUpdateClassName()) {
943 + gradeClass.setClassName(modification.getClassName());
944 + }
945 + if (modification.getShouldUpdateGradeName()) {
946 + gradeClass.setGradeName(modification.getGradeName());
947 + }
948 + gradeClasses.add(gradeClass);
949 + }
950 + builder.setIsUpdated(gradeClassService.saveOrUpdateBatch(gradeClasses));
951 + } catch (final Exception e) {
952 + log.error("updateGradeClass 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 + public void deleteGradeClassesByIds(final DeleteGradeClassesByIdsRpcRequest request,
962 + final StreamObserver<DeleteGradeClassesRpcResponse> responseObserver) {
963 + final var builder = DeleteGradeClassesRpcResponse.newBuilder();
964 + try {
965 + builder.setIsDeleted(gradeClassService.removeBatchByIds(request.getIdsList()));
966 + } catch (final Exception e) {
967 + log.error("deleteGradeClassesByIds error;", e);
968 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
969 + }
970 + responseObserver.onNext(builder.build());
971 + responseObserver.onCompleted();
972 + }
973 +
974 + @Override
975 + @DS(DATA_SOURCE_MASTER)
976 + @Transactional(rollbackFor = Exception.class)
977 + public void deleteGradeClassesAndDinersByClientIds(final DeleteGradeClassesAndDinersByClientIdsRpcRequest request,
978 + final StreamObserver<DeleteGradeClassesAndDinersByClientIdsRpcResponse> responseObserver) {
979 + final var builder = DeleteGradeClassesAndDinersByClientIdsRpcResponse.newBuilder();
980 + try {
981 + LambdaQueryWrapper<GradeClass> queryWrapper = Wrappers.lambdaQuery();
982 + queryWrapper.in(GradeClass::getEnterpriseId, request.getEnterpriseId());
983 + queryWrapper.in(GradeClass::getClientId, request.getClientIdsList());
984 + final boolean remove = gradeClassService.remove(queryWrapper);
985 + LambdaQueryWrapper<Diner> dinerLambdaQueryWrapper = Wrappers.lambdaQuery();
986 + dinerLambdaQueryWrapper.in(Diner::getEnterpriseId, request.getEnterpriseId());
987 + dinerLambdaQueryWrapper.in(Diner::getClientId, request.getClientIdsList());
988 + final var diners = dinerService.list(dinerLambdaQueryWrapper);
989 + final var remove1 = dinerService.remove(dinerLambdaQueryWrapper);
990 + boolean remove2 = false;
991 + if (!diners.isEmpty()) {
992 + LambdaQueryWrapper<MpAccountDinerRef> mpAccountDinerRefLambdaQueryWrapper = Wrappers.lambdaQuery();
993 + mpAccountDinerRefLambdaQueryWrapper.in(MpAccountDinerRef::getEnterpriseId, request.getEnterpriseId());
994 + mpAccountDinerRefLambdaQueryWrapper.in(MpAccountDinerRef::getDinerId, diners.stream().map(Diner::getId).collect(Collectors.toList()));
995 + remove2 = mpAccountDinerRefService.remove(mpAccountDinerRefLambdaQueryWrapper);
996 + }
997 + builder.setIsDeleted(remove && remove1 && remove2);
998 + } catch (final Exception e) {
999 + log.error("deleteGradeClassesAndDinersByClientIds error;", e);
1000 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1001 + }
1002 + responseObserver.onNext(builder.build());
1003 + responseObserver.onCompleted();
1004 + }
1005 +
1006 + @Override
1007 + @DS(DATA_SOURCE_SLAVE)
1008 + public void getMealMenuRecordById(final GetMealMenuRecordByIdRpcRequest request,
1009 + final StreamObserver<GetMealMenuRecordByIdRpcResponse> responseObserver) {
1010 + final var builder = GetMealMenuRecordByIdRpcResponse.newBuilder();
1011 + try {
1012 + final var mealMenuRecord = mealMenuRecordService.getById(request.getId());
1013 + if (mealMenuRecord != null) {
1014 + builder.setResponse(ProtoBeanUtil.beanToProto(mealMenuRecord, SingleMealMenuRecordRpcResponse.class));
1015 + }
1016 + } catch (final Exception e) {
1017 + log.error("getMealMenuRecordById error;", e);
1018 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1019 + }
1020 + responseObserver.onNext(builder.build());
1021 + responseObserver.onCompleted();
1022 + }
1023 +
1024 + @Override
1025 + @DS(DATA_SOURCE_SLAVE)
1026 + public void getMealMenuRecordsByIds(final GetMealMenuRecordsByIdsRpcRequest request,
1027 + final StreamObserver<GetMealMenuRecordsByIdsRpcResponse> responseObserver) {
1028 + final var builder = GetMealMenuRecordsByIdsRpcResponse.newBuilder();
1029 + try {
1030 + final var mealMenuRecords = mealMenuRecordService.listByIds(request.getIdsList());
1031 + if (!mealMenuRecords.isEmpty()) {
1032 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealMenuRecords, SingleMealMenuRecordRpcResponse.class));
1033 + }
1034 + } catch (final Exception e) {
1035 + log.error("getMealMenuRecordsByIds error;", e);
1036 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1037 + }
1038 + responseObserver.onNext(builder.build());
1039 + responseObserver.onCompleted();
1040 + }
1041 +
1042 + @Override
1043 + @DS(DATA_SOURCE_SLAVE)
1044 + public void queryMealMenuRecordsByCondition(final QueryMealMenuRecordsByConditionRpcRequest request,
1045 + final StreamObserver<QueryMealMenuRecordsByConditionRpcResponse> responseObserver) {
1046 + final var builder = QueryMealMenuRecordsByConditionRpcResponse.newBuilder();
1047 + try {
1048 + LambdaQueryWrapper<MealMenuRecord> queryWrapper = new LambdaQueryWrapper<>();
1049 + queryWrapper.eq(MealMenuRecord::getEnterpriseId, request.getEnterpriseId());
1050 + if (request.getShouldFilterClientIds()) {
1051 + queryWrapper.in(!request.getClientIdsList().isEmpty(), MealMenuRecord::getClientId, request.getClientIdsList());
1052 + }
1053 + if (request.getShouldFilterName()) {
1054 + queryWrapper.eq(MealMenuRecord::getName, request.getName());
1055 + }
1056 + final var diners = mealMenuRecordService.list(queryWrapper);
1057 + if (!diners.isEmpty()) {
1058 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(diners, SingleMealMenuRecordRpcResponse.class));
1059 + }
1060 + } catch (final Exception e) {
1061 + log.error("queryMealMenuRecordsByCondition error;", e);
1062 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1063 + }
1064 + responseObserver.onNext(builder.build());
1065 + responseObserver.onCompleted();
1066 + }
1067 +
1068 + @Override
1069 + @DS(DATA_SOURCE_SLAVE)
1070 + public void queryLatestMealMenuRecordsByClientIds(final QueryLatestMealMenuRecordsByClientIdsRpcRequest request,
1071 + final StreamObserver<QueryLatestMealMenuRecordsByClientIdsRpcResponse> responseObserver) {
1072 + final var builder = QueryLatestMealMenuRecordsByClientIdsRpcResponse.newBuilder();
1073 + try {
1074 + final var queryWrapper = new LambdaQueryWrapper<MealMenuRecord>();
1075 + queryWrapper.eq(MealMenuRecord::getEnterpriseId, request.getEnterpriseId());
1076 + queryWrapper.in(MealMenuRecord::getClientId, request.getClientIdList());
1077 + queryWrapper.orderByDesc(MealMenuRecord::getCreatedAt);
1078 + final var allRecords = mealMenuRecordService.list(queryWrapper);
1079 + final var latestRecordsMap = allRecords.stream().collect(Collectors.toMap(MealMenuRecord::getClientId, Function.identity(), (existing, replacement) -> existing));
1080 + if (!latestRecordsMap.isEmpty()) {
1081 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(new ArrayList<>(latestRecordsMap.values()), SingleMealMenuRecordRpcResponse.class));
1082 + }
1083 + } catch (final Exception e) {
1084 + log.error("queryLatestMealMenuRecordsByClientIds error;", e);
1085 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1086 + }
1087 + responseObserver.onNext(builder.build());
1088 + responseObserver.onCompleted();
1089 + }
1090 +
1091 + @Override
1092 + @DS(DATA_SOURCE_MASTER)
1093 + public void createMealMenuRecord(final CreateMealMenuRecordRpcRequest request,
1094 + final StreamObserver<CreateMealMenuRecordRpcResponse> responseObserver) {
1095 + final var builder = CreateMealMenuRecordRpcResponse.newBuilder();
1096 + try {
1097 + MealMenuRecord mealMenuRecord = new MealMenuRecord();
1098 + mealMenuRecord.setEnterpriseId(request.getEnterpriseId());
1099 + mealMenuRecord.setCreatedBy(request.getCreatedBy());
1100 + mealMenuRecord.setCreationSource(request.getCreationSource());
1101 + mealMenuRecord.setUpdatedBy(request.getCreatedBy());
1102 + mealMenuRecord.setUpdateSource(request.getCreationSource());
1103 + mealMenuRecord.setClientId(request.getCreation().getClientId());
1104 + mealMenuRecord.setName(request.getCreation().getName());
1105 + mealMenuRecord.setImageUrl(request.getCreation().getImageUrl());
1106 + builder.setIsCreated(mealMenuRecordService.save(mealMenuRecord)).setId(mealMenuRecord.getId());
1107 + } catch (final Exception e) {
1108 + log.error("createMealMenuRecord error;", e);
1109 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1110 + }
1111 + responseObserver.onNext(builder.build());
1112 + responseObserver.onCompleted();
1113 + }
1114 +}
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 +
1 +package com.tianting.infoloop.utils;
2 +
3 +import com.fasterxml.jackson.annotation.JsonInclude;
4 +import com.fasterxml.jackson.core.JsonProcessingException;
5 +import com.fasterxml.jackson.core.type.TypeReference;
6 +import com.fasterxml.jackson.databind.DeserializationFeature;
7 +import com.fasterxml.jackson.databind.JsonNode;
8 +import com.fasterxml.jackson.databind.ObjectMapper;
9 +import com.fasterxml.jackson.databind.module.SimpleModule;
10 +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
11 +
12 +import java.io.IOException;
13 +import java.util.List;
14 +
15 +public final class JSONUtil {
16 + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
17 +
18 + static {
19 + final SimpleModule module = new SimpleModule();
20 + module.addSerializer(Long.class, ToStringSerializer.instance);
21 + module.addSerializer(long.class, ToStringSerializer.instance);
22 + OBJECT_MAPPER.registerModule(module);
23 + // 如果json中有新增的字段并且是实体类类中不存在的,不报错
24 + OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
25 + // 序列化时忽略值为null的属性
26 + OBJECT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL);
27 + }
28 +
29 + public static String writeAsJson(final Object object) {
30 + try {
31 + return OBJECT_MAPPER.writeValueAsString(object);
32 + } catch (final JsonProcessingException e) {
33 + throw new RuntimeException(e);
34 + }
35 + }
36 +
37 + public static <T> T readJsonAs(final String json, final Class<T> clazz) {
38 + try {
39 + return OBJECT_MAPPER.readerFor(clazz).readValue(json);
40 + } catch (final IOException e) {
41 + throw new RuntimeException(e);
42 + }
43 + }
44 +
45 + public static <T> List<T> readJsonAsList(String jsonString, Class<T> clazz) {
46 + try {
47 + return OBJECT_MAPPER.readValue(jsonString, new TypeReference<>() {
48 + });
49 + } catch (Exception e) {
50 + throw new RuntimeException("Failed to convert JSON to List<" + clazz.getSimpleName() + ">", e);
51 + }
52 + }
53 +
54 + public static <T> JsonNode readTree(final String json) {
55 + try {
56 + return OBJECT_MAPPER.readTree(json);
57 + } catch (final IOException e) {
58 + throw new RuntimeException(e);
59 + }
60 + }
61 + private JSONUtil() {}
62 +}
1 package com.tianting.infoloop.utils; 1 package com.tianting.infoloop.utils;
2 2
3 import cn.hutool.core.date.LocalDateTimeUtil; 3 import cn.hutool.core.date.LocalDateTimeUtil;
4 +import com.fasterxml.jackson.databind.JsonNode;
5 +import com.fasterxml.jackson.databind.ObjectMapper;
6 +import com.fasterxml.jackson.databind.node.ObjectNode;
4 import com.google.gson.Gson; 7 import com.google.gson.Gson;
5 import com.google.gson.GsonBuilder; 8 import com.google.gson.GsonBuilder;
9 +import com.google.gson.JsonArray;
10 +import com.google.gson.JsonElement;
11 +import com.google.gson.JsonParser;
6 import com.google.gson.TypeAdapter; 12 import com.google.gson.TypeAdapter;
7 import com.google.gson.stream.JsonReader; 13 import com.google.gson.stream.JsonReader;
8 import com.google.gson.stream.JsonWriter; 14 import com.google.gson.stream.JsonWriter;
...@@ -23,6 +29,8 @@ import java.util.List; ...@@ -23,6 +29,8 @@ import java.util.List;
23 29
24 public class ProtoBeanUtil { 30 public class ProtoBeanUtil {
25 31
32 + private static Gson gson = getGson();
33 +
26 /** 34 /**
27 * protoBean -> string 35 * protoBean -> string
28 * 36 *
...@@ -31,13 +39,68 @@ public class ProtoBeanUtil { ...@@ -31,13 +39,68 @@ public class ProtoBeanUtil {
31 */ 39 */
32 public static String protoToJson(MessageOrBuilder sourceMessage) { 40 public static String protoToJson(MessageOrBuilder sourceMessage) {
33 try { 41 try {
34 - return JsonFormat.printer().print(sourceMessage); 42 + return JsonFormat.printer().includingDefaultValueFields().print(sourceMessage);
35 } catch (Exception e) { 43 } catch (Exception e) {
36 throw new IllegalArgumentException("ProtoBeanUtil->toJson->errorMessage:proto序列化string异常", e); 44 throw new IllegalArgumentException("ProtoBeanUtil->toJson->errorMessage:proto序列化string异常", e);
37 } 45 }
38 } 46 }
39 47
40 - private static Gson gson = getGson(); 48 + @SuppressWarnings("unchecked")
49 + public static <T extends Message> T jsonToProto(String json, Class<T> protoBean) {
50 + try {
51 + Constructor<T> declaredConstructor = protoBean.getDeclaredConstructor((Class<?>[]) null);
52 + declaredConstructor.setAccessible(Boolean.TRUE);
53 + T instance = declaredConstructor.newInstance();
54 + final var builder = instance.toBuilder();
55 + if (json == null || json.isEmpty() || json.trim().equals("{}")) {
56 + return (T) builder.build();
57 + }
58 + JsonFormat.parser().ignoringUnknownFields().merge(json, builder);
59 + return (T) builder.build();
60 + } catch (Exception e) {
61 + throw new IllegalArgumentException("json to proto error", e);
62 + }
63 + }
64 +
65 + @SuppressWarnings("unchecked")
66 + public static <T extends Message> List<T> jsonToProtoList(String jsonArray, Class<T> protoBean) {
67 + try {
68 + if (jsonArray == null || jsonArray.isEmpty() || jsonArray.trim().equals("[]")) {
69 + return new ArrayList<>();
70 + }
71 + Constructor<T> declaredConstructor = protoBean.getDeclaredConstructor();
72 + declaredConstructor.setAccessible(true);
73 + List<T> protoList = new ArrayList<>();
74 + JsonArray jsonElements = JsonParser.parseString(jsonArray).getAsJsonArray();
75 + for (JsonElement jsonElement : jsonElements) {
76 + T instance = declaredConstructor.newInstance();
77 + Message.Builder builder = instance.toBuilder();
78 + JsonFormat.parser().ignoringUnknownFields().merge(jsonElement.toString(), builder);
79 + protoList.add((T) builder.build());
80 + }
81 + return protoList;
82 + } catch (Exception e) {
83 + throw new IllegalArgumentException("jsonArray to protoList error", e);
84 + }
85 + }
86 +
87 + public static String protoListToJson(List<? extends Message> sourceList) {
88 + try {
89 + StringBuilder jsonArrayBuilder = new StringBuilder();
90 + jsonArrayBuilder.append("[");
91 + for (int i = 0; i < sourceList.size(); i++) {
92 + String json = protoToJson(sourceList.get(i));
93 + jsonArrayBuilder.append(json);
94 + if (i < sourceList.size() - 1) {
95 + jsonArrayBuilder.append(",");
96 + }
97 + }
98 + jsonArrayBuilder.append("]");
99 + return jsonArrayBuilder.toString();
100 + } catch (Exception e) {
101 + throw new IllegalArgumentException("ProtoList to jsonArray error", e);
102 + }
103 + }
41 104
42 /** 105 /**
43 * @desc: String 转 Builder对象 106 * @desc: String 转 Builder对象
...@@ -53,7 +116,7 @@ public class ProtoBeanUtil { ...@@ -53,7 +116,7 @@ public class ProtoBeanUtil {
53 /** 116 /**
54 * @desc: JavaBean 转 Builder对象 117 * @desc: JavaBean 转 Builder对象
55 */ 118 */
56 - private static <M extends Message.Builder, T> M beanToBuilder(T beanSource, Class<M> targetBuilderClass) { 119 + private static <M extends Message.Builder, T> M beanToBuilder(T beanSource, Class<M> targetBuilderClass, String... ignoreFields) {
57 try { 120 try {
58 Constructor<M> declaredConstructor = targetBuilderClass.getDeclaredConstructor((Class<?>[]) null); 121 Constructor<M> declaredConstructor = targetBuilderClass.getDeclaredConstructor((Class<?>[]) null);
59 122
...@@ -65,8 +128,15 @@ public class ProtoBeanUtil { ...@@ -65,8 +128,15 @@ public class ProtoBeanUtil {
65 128
66 String json = gson.toJson(beanSource); 129 String json = gson.toJson(beanSource);
67 130
68 - jsonToBuilder(instance, json); 131 + ObjectMapper mapper = new ObjectMapper();
69 - 132 + JsonNode root = mapper.readTree(json);
133 + if (root instanceof ObjectNode objNode) {
134 + for (String field : ignoreFields) {
135 + objNode.remove(field);
136 + }
137 + }
138 + String filteredJson = mapper.writeValueAsString(root);
139 + jsonToBuilder(instance, filteredJson);
70 return instance; 140 return instance;
71 } catch (Exception e) { 141 } catch (Exception e) {
72 throw new IllegalArgumentException("ProtoBeanUtil->beanToBuilder->errorMessage:JavaBean 转 Builder对象异常", e); 142 throw new IllegalArgumentException("ProtoBeanUtil->beanToBuilder->errorMessage:JavaBean 转 Builder对象异常", e);
...@@ -78,7 +148,7 @@ public class ProtoBeanUtil { ...@@ -78,7 +148,7 @@ public class ProtoBeanUtil {
78 */ 148 */
79 @SneakyThrows 149 @SneakyThrows
80 @SuppressWarnings("unchecked") 150 @SuppressWarnings("unchecked")
81 - public static <M extends Message, T> M beanToProto(T bean, Class<M> targetProtoClass) { 151 + public static <M extends Message, T> M beanToProto(T bean, Class<M> targetProtoClass, String... ignoreFields) {
82 152
83 Constructor<M> declaredConstructor = targetProtoClass.getDeclaredConstructor((Class<?>[]) null); 153 Constructor<M> declaredConstructor = targetProtoClass.getDeclaredConstructor((Class<?>[]) null);
84 154
...@@ -92,7 +162,16 @@ public class ProtoBeanUtil { ...@@ -92,7 +162,16 @@ public class ProtoBeanUtil {
92 162
93 Message.Builder builder = instance.toBuilder(); 163 Message.Builder builder = instance.toBuilder();
94 164
95 - jsonToBuilder(builder, json); 165 + ObjectMapper mapper = new ObjectMapper();
166 + JsonNode root = mapper.readTree(json);
167 + if (root instanceof ObjectNode objNode) {
168 + for (String field : ignoreFields) {
169 + objNode.remove(field);
170 + }
171 + }
172 +
173 + String filteredJson = mapper.writeValueAsString(root);
174 + jsonToBuilder(builder, filteredJson);
96 175
97 return (M) builder.build(); 176 return (M) builder.build();
98 } 177 }
...@@ -101,7 +180,7 @@ public class ProtoBeanUtil { ...@@ -101,7 +180,7 @@ public class ProtoBeanUtil {
101 * @desc: javaBean 列表 转 ProtoBean 列表 180 * @desc: javaBean 列表 转 ProtoBean 列表
102 */ 181 */
103 @SuppressWarnings("unchecked") 182 @SuppressWarnings("unchecked")
104 - public static <M, T extends Message> List<T> beanListToProtoList(Collection<M> beanSourceList, Class<T> protoBean) { 183 + public static <M, T extends Message> List<T> beanListToProtoList(Collection<M> beanSourceList, Class<T> protoBean, String... ignoreFields) {
105 try { 184 try {
106 List<T> resultList = new ArrayList<>(); 185 List<T> resultList = new ArrayList<>();
107 for (Object bean : beanSourceList) { 186 for (Object bean : beanSourceList) {
...@@ -114,7 +193,7 @@ public class ProtoBeanUtil { ...@@ -114,7 +193,7 @@ public class ProtoBeanUtil {
114 193
115 Class<? extends Message.Builder> aClass = instance.toBuilder().getClass(); 194 Class<? extends Message.Builder> aClass = instance.toBuilder().getClass();
116 195
117 - Message.Builder builder = beanToBuilder(bean, aClass); 196 + Message.Builder builder = beanToBuilder(bean, aClass, ignoreFields);
118 197
119 resultList.add((T) builder.build()); 198 resultList.add((T) builder.build());
120 } 199 }
......
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>