zhuyifan

农信点餐小程序

Showing 39 changed files with 2964 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.DeleteGradeClassesAndDinersByClassIdsRpcRequest;
30 +import com.infoloop.tianting.mealorderservice.DeleteGradeClassesAndDinersByClassIdsRpcResponse;
31 +import com.infoloop.tianting.mealorderservice.DeleteGradeClassesAndDinersByClientIdsRpcRequest;
32 +import com.infoloop.tianting.mealorderservice.DeleteGradeClassesAndDinersByClientIdsRpcResponse;
33 +import com.infoloop.tianting.mealorderservice.DeleteGradeClassesByIdsRpcRequest;
34 +import com.infoloop.tianting.mealorderservice.DeleteGradeClassesRpcResponse;
35 +import com.infoloop.tianting.mealorderservice.DeleteMealOrdersByIdsRpcRequest;
36 +import com.infoloop.tianting.mealorderservice.DeleteMealOrdersRpcResponse;
37 +import com.infoloop.tianting.mealorderservice.DeleteMpAccountDinerRefsByIdsRpcRequest;
38 +import com.infoloop.tianting.mealorderservice.DeleteMpAccountDinerRefsRpcResponse;
39 +import com.infoloop.tianting.mealorderservice.DeleteMpAccountsByIdsRpcRequest;
40 +import com.infoloop.tianting.mealorderservice.DeleteMpAccountsRpcResponse;
41 +import com.infoloop.tianting.mealorderservice.DinerModification;
42 +import com.infoloop.tianting.mealorderservice.GetDinerByIdRpcRequest;
43 +import com.infoloop.tianting.mealorderservice.GetDinerByIdRpcResponse;
44 +import com.infoloop.tianting.mealorderservice.GetDinersByIdsRpcRequest;
45 +import com.infoloop.tianting.mealorderservice.GetDinersByIdsRpcResponse;
46 +import com.infoloop.tianting.mealorderservice.GetGradeClassByIdRpcRequest;
47 +import com.infoloop.tianting.mealorderservice.GetGradeClassByIdRpcResponse;
48 +import com.infoloop.tianting.mealorderservice.GetGradeClassesByIdsRpcRequest;
49 +import com.infoloop.tianting.mealorderservice.GetGradeClassesByIdsRpcResponse;
50 +import com.infoloop.tianting.mealorderservice.GetMealMenuRecordByIdRpcRequest;
51 +import com.infoloop.tianting.mealorderservice.GetMealMenuRecordByIdRpcResponse;
52 +import com.infoloop.tianting.mealorderservice.GetMealMenuRecordsByIdsRpcRequest;
53 +import com.infoloop.tianting.mealorderservice.GetMealMenuRecordsByIdsRpcResponse;
54 +import com.infoloop.tianting.mealorderservice.GetMealOrderByIdRpcRequest;
55 +import com.infoloop.tianting.mealorderservice.GetMealOrderByIdRpcResponse;
56 +import com.infoloop.tianting.mealorderservice.GetMealOrdersByIdsRpcRequest;
57 +import com.infoloop.tianting.mealorderservice.GetMealOrdersByIdsRpcResponse;
58 +import com.infoloop.tianting.mealorderservice.GetMpAccountByIdRpcRequest;
59 +import com.infoloop.tianting.mealorderservice.GetMpAccountByIdRpcResponse;
60 +import com.infoloop.tianting.mealorderservice.GetMpAccountByOpenIdRpcRequest;
61 +import com.infoloop.tianting.mealorderservice.GetMpAccountByOpenIdRpcResponse;
62 +import com.infoloop.tianting.mealorderservice.GetMpAccountDinerRefsByIdsRpcRequest;
63 +import com.infoloop.tianting.mealorderservice.GetMpAccountDinerRefsByIdsRpcResponse;
64 +import com.infoloop.tianting.mealorderservice.GetMpAccountsByIdsRpcRequest;
65 +import com.infoloop.tianting.mealorderservice.GetMpAccountsByIdsRpcResponse;
66 +import com.infoloop.tianting.mealorderservice.MealOrderServiceRpcGrpc;
67 +import com.infoloop.tianting.mealorderservice.MenuSchedule;
68 +import com.infoloop.tianting.mealorderservice.QueryDinersByConditionRpcRequest;
69 +import com.infoloop.tianting.mealorderservice.QueryDinersByConditionRpcResponse;
70 +import com.infoloop.tianting.mealorderservice.QueryGradeClassesByConditionRpcRequest;
71 +import com.infoloop.tianting.mealorderservice.QueryGradeClassesByConditionRpcResponse;
72 +import com.infoloop.tianting.mealorderservice.QueryLatestMealMenuRecordsByClientIdsRpcRequest;
73 +import com.infoloop.tianting.mealorderservice.QueryLatestMealMenuRecordsByClientIdsRpcResponse;
74 +import com.infoloop.tianting.mealorderservice.QueryMealMenuRecordsByConditionRpcRequest;
75 +import com.infoloop.tianting.mealorderservice.QueryMealMenuRecordsByConditionRpcResponse;
76 +import com.infoloop.tianting.mealorderservice.QueryMealOrdersByConditionRpcRequest;
77 +import com.infoloop.tianting.mealorderservice.QueryMealOrdersByConditionRpcResponse;
78 +import com.infoloop.tianting.mealorderservice.QueryMpAccountDinerRefsByConditionRpcRequest;
79 +import com.infoloop.tianting.mealorderservice.QueryMpAccountDinerRefsByConditionRpcResponse;
80 +import com.infoloop.tianting.mealorderservice.QueryMpAccountsByConditionRpcRequest;
81 +import com.infoloop.tianting.mealorderservice.QueryMpAccountsByConditionRpcResponse;
82 +import com.infoloop.tianting.mealorderservice.QueryReserveMealOrdersByDinerIdsRpcRequest;
83 +import com.infoloop.tianting.mealorderservice.QueryReserveMealOrdersByDinerIdsRpcResponse;
84 +import com.infoloop.tianting.mealorderservice.SingleDinerRpcResponse;
85 +import com.infoloop.tianting.mealorderservice.SingleGradeClassRpcResponse;
86 +import com.infoloop.tianting.mealorderservice.SingleMealMenuRecordRpcResponse;
87 +import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse;
88 +import com.infoloop.tianting.mealorderservice.SingleMpAccountDinerRefRpcResponse;
89 +import com.infoloop.tianting.mealorderservice.SingleMpAccountRpcResponse;
90 +import com.infoloop.tianting.mealorderservice.UpdateDinerRpcRequest;
91 +import com.infoloop.tianting.mealorderservice.UpdateDinerRpcResponse;
92 +import com.infoloop.tianting.mealorderservice.UpdateGradeClassRpcRequest;
93 +import com.infoloop.tianting.mealorderservice.UpdateGradeClassRpcResponse;
94 +import com.infoloop.tianting.mealorderservice.UpdateMpAccountRpcRequest;
95 +import com.infoloop.tianting.mealorderservice.UpdateMpAccountRpcResponse;
96 +import com.tianting.infoloop.model.db.Diner;
97 +import com.tianting.infoloop.model.db.GradeClass;
98 +import com.tianting.infoloop.model.db.MealMenuRecord;
99 +import com.tianting.infoloop.model.db.MealOrder;
100 +import com.tianting.infoloop.model.db.MpAccount;
101 +import com.tianting.infoloop.model.db.MpAccountDinerRef;
102 +import com.tianting.infoloop.service.DinerService;
103 +import com.tianting.infoloop.service.GradeClassService;
104 +import com.tianting.infoloop.service.MealMenuRecordService;
105 +import com.tianting.infoloop.service.MealOrderService;
106 +import com.tianting.infoloop.service.MpAccountDinerRefService;
107 +import com.tianting.infoloop.service.MpAccountService;
108 +import com.tianting.infoloop.utils.ProtoBeanUtil;
109 +import io.grpc.Status;
110 +import io.grpc.stub.StreamObserver;
111 +import lombok.RequiredArgsConstructor;
112 +import lombok.extern.slf4j.Slf4j;
113 +import org.springframework.beans.factory.annotation.Autowired;
114 +import org.springframework.stereotype.Service;
115 +import org.springframework.transaction.annotation.Transactional;
116 +
117 +import java.time.DayOfWeek;
118 +import java.time.LocalDate;
119 +import java.time.LocalDateTime;
120 +import java.time.LocalTime;
121 +import java.time.temporal.TemporalAdjusters;
122 +import java.util.ArrayList;
123 +import java.util.List;
124 +import java.util.function.Function;
125 +import java.util.stream.Collectors;
126 +
127 +import static com.tianting.infoloop.constants.ConfigConstants.DATA_SOURCE_MASTER;
128 +import static com.tianting.infoloop.constants.ConfigConstants.DATA_SOURCE_SLAVE;
129 +
130 +@Slf4j
131 +@Service
132 +@RequiredArgsConstructor(onConstructor_ = @Autowired)
133 +public class MealOrderGrpcService extends MealOrderServiceRpcGrpc.MealOrderServiceRpcImplBase {
134 +
135 + private final DinerService dinerService;
136 +
137 + private final GradeClassService gradeClassService;
138 +
139 + private final MealMenuRecordService mealMenuRecordService;
140 +
141 + private final MealOrderService mealOrderService;
142 +
143 + private final MpAccountDinerRefService mpAccountDinerRefService;
144 +
145 + private final MpAccountService mpAccountService;
146 +
147 + @Override
148 + @DS(DATA_SOURCE_SLAVE)
149 + public void getMealOrderById(final GetMealOrderByIdRpcRequest request,
150 + final StreamObserver<GetMealOrderByIdRpcResponse> responseObserver) {
151 + final var builder = GetMealOrderByIdRpcResponse.newBuilder();
152 + try {
153 + final var mealOrder = mealOrderService.getById(request.getId());
154 + if (mealOrder != null) {
155 + final var mealOrderRpcResponse = ProtoBeanUtil.beanToProto(mealOrder, SingleMealOrderRpcResponse.class, "meals");
156 + final var build = mealOrderRpcResponse.toBuilder().addAllMeals(ProtoBeanUtil.jsonToProtoList(mealOrder.getMeals(), MenuSchedule.class)).build();
157 + builder.setResponse(build);
158 + }
159 + } catch (final Exception e) {
160 + log.error("getMealOrderById error;", e);
161 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
162 + }
163 + responseObserver.onNext(builder.build());
164 + responseObserver.onCompleted();
165 + }
166 +
167 + @Override
168 + @DS(DATA_SOURCE_SLAVE)
169 + public void getMealOrdersByIds(final GetMealOrdersByIdsRpcRequest request,
170 + final StreamObserver<GetMealOrdersByIdsRpcResponse> responseObserver) {
171 + final var builder = GetMealOrdersByIdsRpcResponse.newBuilder();
172 + try {
173 + final var mealOrders = mealOrderService.listByIds(request.getIdsList());
174 + if (!mealOrders.isEmpty()) {
175 + for (final var mealOrder : mealOrders) {
176 + final var mealOrderRpcResponse = ProtoBeanUtil.beanToProto(mealOrder, SingleMealOrderRpcResponse.class, "meals");
177 + final var build = mealOrderRpcResponse.toBuilder().addAllMeals(ProtoBeanUtil.jsonToProtoList(mealOrder.getMeals(), MenuSchedule.class)).build();
178 + builder.addResponses(build);
179 + }
180 + }
181 + } catch (final Exception e) {
182 + log.error("getMealOrdersByIds error;", e);
183 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
184 + }
185 + responseObserver.onNext(builder.build());
186 + responseObserver.onCompleted();
187 + }
188 +
189 + @Override
190 + @DS(DATA_SOURCE_SLAVE)
191 + public void queryMealOrdersByCondition(final QueryMealOrdersByConditionRpcRequest request,
192 + final StreamObserver<QueryMealOrdersByConditionRpcResponse> responseObserver) {
193 + final var builder = QueryMealOrdersByConditionRpcResponse.newBuilder();
194 + try {
195 + LambdaQueryWrapper<MealOrder> queryWrapper = new LambdaQueryWrapper<>();
196 + queryWrapper.eq(MealOrder::getEnterpriseId, request.getEnterpriseId());
197 + if (request.getShouldFilterClientIds()) {
198 + queryWrapper.in(!request.getClientIdsList().isEmpty(), MealOrder::getClientId, request.getClientIdsList());
199 + }
200 + if (request.getShouldFilterMenuIds()) {
201 + queryWrapper.in(!request.getMenuIdsList().isEmpty(), MealOrder::getMenuId, request.getMenuIdsList());
202 + }
203 + if (request.getShouldFilterAccountIds()) {
204 + queryWrapper.in(!request.getAccountIdsList().isEmpty(), MealOrder::getAccountId, request.getAccountIdsList());
205 + }
206 + if (request.getShouldFilterOrderMethod()) {
207 + queryWrapper.eq(MealOrder::getOrderMethod, request.getOrderMethodValue());
208 + }
209 + if (request.getShouldFilterDinerIds()) {
210 + queryWrapper.in(!request.getDinerIdsList().isEmpty(), MealOrder::getDinerId, request.getDinerIdsList());
211 + }
212 + if (request.getShouldFilterReserveDateStart()) {
213 + queryWrapper.ge(MealOrder::getReserveDate, LocalDateTimeUtil.of(request.getReserveDateStart()));
214 + }
215 + if (request.getShouldFilterReserveDateEnd()) {
216 + queryWrapper.lt(MealOrder::getReserveDate, LocalDateTimeUtil.of(request.getReserveDateEnd()));
217 + }
218 + queryWrapper.orderByDesc(MealOrder::getReserveDate);
219 + final var mealOrders = mealOrderService.list(queryWrapper);
220 + if (!mealOrders.isEmpty()) {
221 + for (final var mealOrder : mealOrders) {
222 + final var mealOrderRpcResponse = ProtoBeanUtil.beanToProto(mealOrder, SingleMealOrderRpcResponse.class, "meals");
223 + final var build = mealOrderRpcResponse.toBuilder().addAllMeals(ProtoBeanUtil.jsonToProtoList(mealOrder.getMeals(), MenuSchedule.class)).build();
224 + builder.addResponses(build);
225 + }
226 + }
227 + } catch (final Exception e) {
228 + log.error("queryMealOrdersByCondition error;", e);
229 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
230 + }
231 + responseObserver.onNext(builder.build());
232 + responseObserver.onCompleted();
233 + }
234 +
235 + @Override
236 + @DS(DATA_SOURCE_SLAVE)
237 + public void queryReserveMealOrdersByDinerIds(final QueryReserveMealOrdersByDinerIdsRpcRequest request,
238 + final StreamObserver<QueryReserveMealOrdersByDinerIdsRpcResponse> responseObserver) {
239 + final var builder = QueryReserveMealOrdersByDinerIdsRpcResponse.newBuilder();
240 + try {
241 + LambdaQueryWrapper<MealOrder> queryWrapper = new LambdaQueryWrapper<>();
242 + queryWrapper.eq(MealOrder::getEnterpriseId, request.getEnterpriseId());
243 + queryWrapper.in(!request.getDinerIdsList().isEmpty(), MealOrder::getDinerId, request.getDinerIdsList());
244 + LocalDate today = LocalDate.now();
245 + LocalDate thisMonday = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
246 + LocalDateTime thisMondayStart = LocalDateTime.of(thisMonday, LocalTime.MIN);
247 + LocalDate thisSunday = today.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
248 + LocalDateTime thisSundayEnd = LocalDateTime.of(thisSunday, LocalTime.MAX);
249 + queryWrapper.ge(MealOrder::getReserveDate, thisMondayStart);
250 + queryWrapper.lt(MealOrder::getReserveDate, thisSundayEnd);
251 + final var mealOrders = mealOrderService.list(queryWrapper);
252 + if (!mealOrders.isEmpty()) {
253 + for (final var mealOrder : mealOrders) {
254 + final var mealOrderRpcResponse = ProtoBeanUtil.beanToProto(mealOrder, SingleMealOrderRpcResponse.class, "meals");
255 + final var build = mealOrderRpcResponse.toBuilder().addAllMeals(ProtoBeanUtil.jsonToProtoList(mealOrder.getMeals(), MenuSchedule.class)).build();
256 + builder.addResponses(build);
257 + }
258 + }
259 + } catch (final Exception e) {
260 + log.error("queryReserveMealOrdersByDinerIds error;", e);
261 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
262 + }
263 + responseObserver.onNext(builder.build());
264 + responseObserver.onCompleted();
265 + }
266 +
267 + @Override
268 + @DS(DATA_SOURCE_MASTER)
269 + public void createMealOrder(final CreateMealOrderRpcRequest request,
270 + final StreamObserver<CreateMealOrderRpcResponse> responseObserver) {
271 + final var builder = CreateMealOrderRpcResponse.newBuilder();
272 + try {
273 + MealOrder mealOrder = new MealOrder();
274 + mealOrder.setEnterpriseId(request.getEnterpriseId());
275 + mealOrder.setCreatedBy(request.getCreatedBy());
276 + mealOrder.setCreationSource(request.getCreationSource());
277 + mealOrder.setUpdatedBy(request.getCreatedBy());
278 + mealOrder.setUpdateSource(request.getCreationSource());
279 + mealOrder.setClientId(request.getCreation().getClientId());
280 + mealOrder.setMenuId(request.getCreation().getMenuId());
281 + mealOrder.setAccountId(request.getCreation().getAccountId());
282 + mealOrder.setOrderMethod(request.getCreation().getOrderMethodValue());
283 + mealOrder.setDinerId(request.getCreation().getDinerId());
284 + mealOrder.setDinerName(request.getCreation().getDinerName());
285 + mealOrder.setClientName(request.getCreation().getClientName());
286 + mealOrder.setGradeName(request.getCreation().getGradeName());
287 + mealOrder.setClassName(request.getCreation().getClassName());
288 + mealOrder.setStudentNo(request.getCreation().getStudentNo());
289 + mealOrder.setReserveDate(LocalDateTimeUtil.of(request.getCreation().getReserveDate()));
290 + mealOrder.setMeals(ProtoBeanUtil.protoListToJson(request.getCreation().getMealsList()));
291 + builder.setIsCreated(mealOrderService.save(mealOrder)).setId(mealOrder.getId());
292 + } catch (final Exception e) {
293 + log.error("createMealOrder error;", e);
294 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
295 + }
296 + responseObserver.onNext(builder.build());
297 + responseObserver.onCompleted();
298 + }
299 +
300 + @Override
301 + @DS(DATA_SOURCE_MASTER)
302 + public void batchCreateMealOrders(final BatchCreateMealOrdersRpcRequest request,
303 + final StreamObserver<BatchCreateMealOrdersRpcResponse> responseObserver) {
304 + final var builder = BatchCreateMealOrdersRpcResponse.newBuilder();
305 + try {
306 + final var mealOrders = new ArrayList<MealOrder>();
307 + for (final var creation : request.getCreationsList()) {
308 + MealOrder mealOrder = new MealOrder();
309 + mealOrder.setEnterpriseId(request.getEnterpriseId());
310 + mealOrder.setCreatedBy(request.getCreatedBy());
311 + mealOrder.setCreationSource(request.getCreationSource());
312 + mealOrder.setUpdatedBy(request.getCreatedBy());
313 + mealOrder.setUpdateSource(request.getCreationSource());
314 + mealOrder.setClientId(creation.getClientId());
315 + mealOrder.setMenuId(creation.getMenuId());
316 + mealOrder.setAccountId(creation.getAccountId());
317 + mealOrder.setOrderMethod(creation.getOrderMethodValue());
318 + mealOrder.setDinerId(creation.getDinerId());
319 + mealOrder.setDinerName(creation.getDinerName());
320 + mealOrder.setClientName(creation.getClientName());
321 + mealOrder.setGradeName(creation.getGradeName());
322 + mealOrder.setClassName(creation.getClassName());
323 + mealOrder.setStudentNo(creation.getStudentNo());
324 + mealOrder.setReserveDate(LocalDateTimeUtil.of(creation.getReserveDate()));
325 + mealOrder.setMeals(ProtoBeanUtil.protoListToJson(creation.getMealsList()));
326 + mealOrders.add(mealOrder);
327 + }
328 + builder.setIsCreated(mealOrderService.saveBatch(mealOrders)).addAllIds(mealOrders.stream().map(MealOrder::getId).toList());
329 + } catch (final Exception e) {
330 + log.error("batchCreateMealOrders error;", e);
331 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
332 + }
333 + responseObserver.onNext(builder.build());
334 + responseObserver.onCompleted();
335 + }
336 +
337 + @Override
338 + @DS(DATA_SOURCE_MASTER)
339 + public void deleteMealOrdersByIds(final DeleteMealOrdersByIdsRpcRequest request,
340 + final StreamObserver<DeleteMealOrdersRpcResponse> responseObserver) {
341 + final var builder = DeleteMealOrdersRpcResponse.newBuilder();
342 + try {
343 + builder.setIsDeleted(mealOrderService.removeBatchByIds(request.getIdsList()));
344 + } catch (final Exception e) {
345 + log.error("deleteMealOrdersByIds error;", e);
346 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
347 + }
348 + responseObserver.onNext(builder.build());
349 + responseObserver.onCompleted();
350 + }
351 +
352 + @Override
353 + @DS(DATA_SOURCE_SLAVE)
354 + public void getMpAccountById(final GetMpAccountByIdRpcRequest request,
355 + final StreamObserver<GetMpAccountByIdRpcResponse> responseObserver) {
356 + final var builder = GetMpAccountByIdRpcResponse.newBuilder();
357 + try {
358 + final var mealOrder = mpAccountService.getById(request.getId());
359 + if (mealOrder != null) {
360 + builder.setResponse(ProtoBeanUtil.beanToProto(mealOrder, SingleMpAccountRpcResponse.class));
361 + }
362 + } catch (final Exception e) {
363 + log.error("getMpAccountById error;", e);
364 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
365 + }
366 + responseObserver.onNext(builder.build());
367 + responseObserver.onCompleted();
368 + }
369 +
370 + @Override
371 + @DS(DATA_SOURCE_SLAVE)
372 + public void getMpAccountByOpenId(final GetMpAccountByOpenIdRpcRequest request,
373 + final StreamObserver<GetMpAccountByOpenIdRpcResponse> responseObserver) {
374 + final var builder = GetMpAccountByOpenIdRpcResponse.newBuilder();
375 + try {
376 + LambdaQueryWrapper<MpAccount> queryWrapper = Wrappers.lambdaQuery();
377 + queryWrapper.eq(MpAccount::getOpenId, request.getOpenId());
378 + final var mpAccount = mpAccountService.getOne(queryWrapper);
379 + if (mpAccount != null) {
380 + builder.setResponse(ProtoBeanUtil.beanToProto(mpAccount, SingleMpAccountRpcResponse.class));
381 + }
382 + } catch (final Exception e) {
383 + log.error("getMpAccountByOpenId error;", e);
384 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
385 + }
386 + responseObserver.onNext(builder.build());
387 + responseObserver.onCompleted();
388 + }
389 +
390 + @Override
391 + @DS(DATA_SOURCE_SLAVE)
392 + public void getMpAccountsByIds(final GetMpAccountsByIdsRpcRequest request,
393 + final StreamObserver<GetMpAccountsByIdsRpcResponse> responseObserver) {
394 + final var builder = GetMpAccountsByIdsRpcResponse.newBuilder();
395 + try {
396 + final var mealOrders = mpAccountService.listByIds(request.getIdsList());
397 + if (!mealOrders.isEmpty()) {
398 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealOrders, SingleMpAccountRpcResponse.class));
399 + }
400 + } catch (final Exception e) {
401 + log.error("getMpAccountsByIds error;", e);
402 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
403 + }
404 + responseObserver.onNext(builder.build());
405 + responseObserver.onCompleted();
406 + }
407 +
408 + @Override
409 + @DS(DATA_SOURCE_SLAVE)
410 + public void queryMpAccountsByCondition(final QueryMpAccountsByConditionRpcRequest request,
411 + final StreamObserver<QueryMpAccountsByConditionRpcResponse> responseObserver) {
412 + final var builder = QueryMpAccountsByConditionRpcResponse.newBuilder();
413 + try {
414 + LambdaQueryWrapper<MpAccount> queryWrapper = new LambdaQueryWrapper<>();
415 + queryWrapper.eq(MpAccount::getEnterpriseId, request.getEnterpriseId());
416 + if (request.getShouldFilterOpenId()) {
417 + queryWrapper.eq(MpAccount::getOpenId, request.getOpenId());
418 + }
419 + if (request.getShouldFilterUnionId()) {
420 + queryWrapper.eq(MpAccount::getUnionId, request.getUnionId());
421 + }
422 + if (request.getShouldFilterPhoneNumber()) {
423 + queryWrapper.eq(MpAccount::getPhoneNumber, request.getPhoneNumber());
424 + }
425 + if (request.getShouldFilterStatus()) {
426 + queryWrapper.eq(MpAccount::getStatus, request.getStatusValue());
427 + }
428 + final var mealOrders = mpAccountService.list(queryWrapper);
429 + if (!mealOrders.isEmpty()) {
430 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealOrders, SingleMpAccountRpcResponse.class));
431 + }
432 + } catch (final Exception e) {
433 + log.error("queryMpAccountsByCondition error;", e);
434 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
435 + }
436 + responseObserver.onNext(builder.build());
437 + responseObserver.onCompleted();
438 + }
439 +
440 + @Override
441 + @DS(DATA_SOURCE_MASTER)
442 + public void createMpAccount(final CreateMpAccountRpcRequest request,
443 + final StreamObserver<CreateMpAccountRpcResponse> responseObserver) {
444 + final var builder = CreateMpAccountRpcResponse.newBuilder();
445 + try {
446 + MpAccount mpAccount = new MpAccount();
447 + mpAccount.setEnterpriseId(request.getEnterpriseId());
448 + mpAccount.setCreatedBy(request.getCreatedBy());
449 + mpAccount.setCreationSource(request.getCreationSource());
450 + mpAccount.setUpdatedBy(request.getCreatedBy());
451 + mpAccount.setUpdateSource(request.getCreationSource());
452 + mpAccount.setOpenId(request.getCreation().getOpenId());
453 + if (request.getCreation().getShouldCreateUnionId()) {
454 + mpAccount.setUnionId(request.getCreation().getUnionId());
455 + }
456 + if (request.getCreation().getShouldCreateNickname()) {
457 + mpAccount.setNickname(request.getCreation().getNickname());
458 + }
459 + if (request.getCreation().getShouldCreateAvatarUrl()) {
460 + mpAccount.setAvatarUrl(request.getCreation().getAvatarUrl());
461 + }
462 + mpAccount.setGender(request.getCreation().getGenderValue());
463 + mpAccount.setPhoneNumber(request.getCreation().getPhoneNumber());
464 + mpAccount.setStatus(request.getCreation().getStatusValue());
465 + builder.setIsCreated(mpAccountService.save(mpAccount)).setId(mpAccount.getId());
466 + } catch (final Exception e) {
467 + log.error("createMpAccount error;", e);
468 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
469 + }
470 + responseObserver.onNext(builder.build());
471 + responseObserver.onCompleted();
472 + }
473 +
474 + @Override
475 + @DS(DATA_SOURCE_MASTER)
476 + public void updateMpAccount(final UpdateMpAccountRpcRequest request,
477 + final StreamObserver<UpdateMpAccountRpcResponse> responseObserver) {
478 + final var builder = UpdateMpAccountRpcResponse.newBuilder();
479 + try {
480 + MpAccount mpAccount = new MpAccount();
481 + mpAccount.setId(request.getModification().getId());
482 + mpAccount.setEnterpriseId(request.getEnterpriseId());
483 + mpAccount.setUpdatedBy(request.getUpdatedBy());
484 + mpAccount.setUpdateSource(request.getUpdateSource());
485 + if (request.getModification().getShouldUpdateNickname()) {
486 + mpAccount.setNickname(request.getModification().getNickname());
487 + }
488 + if (request.getModification().getShouldUpdateAvatarUrl()) {
489 + mpAccount.setAvatarUrl(request.getModification().getAvatarUrl());
490 + }
491 + if (request.getModification().getShouldUpdateGender()) {
492 + mpAccount.setGender(request.getModification().getGenderValue());
493 + }
494 + if (request.getModification().getShouldUpdatePhoneNumber()) {
495 + mpAccount.setPhoneNumber(request.getModification().getPhoneNumber());
496 + }
497 + if (request.getModification().getShouldUpdateStatus()) {
498 + mpAccount.setStatus(request.getModification().getStatusValue());
499 + }
500 + builder.setIsUpdated(mpAccountService.updateById(mpAccount));
501 + } catch (final Exception e) {
502 + log.error("updateMpAccount error;", e);
503 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
504 + }
505 + responseObserver.onNext(builder.build());
506 + responseObserver.onCompleted();
507 + }
508 +
509 + @Override
510 + @DS(DATA_SOURCE_MASTER)
511 + public void deleteMpAccountsByIds(final DeleteMpAccountsByIdsRpcRequest request,
512 + final StreamObserver<DeleteMpAccountsRpcResponse> responseObserver) {
513 + final var builder = DeleteMpAccountsRpcResponse.newBuilder();
514 + try {
515 + builder.setIsDeleted(mpAccountService.removeBatchByIds(request.getIdsList()));
516 + } catch (final Exception e) {
517 + log.error("deleteMpAccountsByIds error;", e);
518 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
519 + }
520 + responseObserver.onNext(builder.build());
521 + responseObserver.onCompleted();
522 + }
523 +
524 + @Override
525 + @DS(DATA_SOURCE_SLAVE)
526 + public void getDinerById(final GetDinerByIdRpcRequest request,
527 + final StreamObserver<GetDinerByIdRpcResponse> responseObserver) {
528 + final var builder = GetDinerByIdRpcResponse.newBuilder();
529 + try {
530 + final var mealOrder = dinerService.getById(request.getId());
531 + if (mealOrder != null) {
532 + builder.setResponse(ProtoBeanUtil.beanToProto(mealOrder, SingleDinerRpcResponse.class));
533 + }
534 + } catch (final Exception e) {
535 + log.error("getDinerById error;", e);
536 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
537 + }
538 + responseObserver.onNext(builder.build());
539 + responseObserver.onCompleted();
540 + }
541 +
542 + @Override
543 + @DS(DATA_SOURCE_SLAVE)
544 + public void getDinersByIds(final GetDinersByIdsRpcRequest request,
545 + final StreamObserver<GetDinersByIdsRpcResponse> responseObserver) {
546 + final var builder = GetDinersByIdsRpcResponse.newBuilder();
547 + try {
548 + final var mealOrders = dinerService.listByIds(request.getIdsList());
549 + if (!mealOrders.isEmpty()) {
550 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealOrders, SingleDinerRpcResponse.class));
551 + }
552 + } catch (final Exception e) {
553 + log.error("getDinersByIds error;", e);
554 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
555 + }
556 + responseObserver.onNext(builder.build());
557 + responseObserver.onCompleted();
558 + }
559 +
560 + @Override
561 + @DS(DATA_SOURCE_SLAVE)
562 + public void queryDinersByCondition(final QueryDinersByConditionRpcRequest request,
563 + final StreamObserver<QueryDinersByConditionRpcResponse> responseObserver) {
564 + final var builder = QueryDinersByConditionRpcResponse.newBuilder();
565 + try {
566 + LambdaQueryWrapper<Diner> queryWrapper = new LambdaQueryWrapper<>();
567 + queryWrapper.eq(Diner::getEnterpriseId, request.getEnterpriseId());
568 + if (request.getShouldFilterClientIds()) {
569 + queryWrapper.in(!request.getClientIdsList().isEmpty(), Diner::getClientId, request.getClientIdsList());
570 + }
571 + if (request.getShouldFilterClassIds()) {
572 + queryWrapper.in(!request.getClassIdsList().isEmpty(), Diner::getClassId, request.getClassIdsList());
573 + }
574 + if (request.getShouldFilterStudentNo()) {
575 + queryWrapper.eq(Diner::getStudentNo, request.getStudentNo());
576 + }
577 + if (request.getShouldFilterName()) {
578 + queryWrapper.eq(Diner::getName, request.getName());
579 + }
580 + final var diners = dinerService.list(queryWrapper);
581 + if (!diners.isEmpty()) {
582 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(diners, SingleDinerRpcResponse.class));
583 + }
584 + } catch (final Exception e) {
585 + log.error("queryDinersByCondition error;", e);
586 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
587 + }
588 + responseObserver.onNext(builder.build());
589 + responseObserver.onCompleted();
590 + }
591 +
592 + @Override
593 + @DS(DATA_SOURCE_MASTER)
594 + public void createDiner(final CreateDinerRpcRequest request,
595 + final StreamObserver<CreateDinerRpcResponse> responseObserver) {
596 + final var builder = CreateDinerRpcResponse.newBuilder();
597 + try {
598 + Diner diner = new Diner();
599 + diner.setEnterpriseId(request.getEnterpriseId());
600 + diner.setCreatedBy(request.getCreatedBy());
601 + diner.setCreationSource(request.getCreationSource());
602 + diner.setUpdatedBy(request.getCreatedBy());
603 + diner.setUpdateSource(request.getCreationSource());
604 + diner.setClientId(request.getCreation().getClientId());
605 + diner.setClassId(request.getCreation().getClassId());
606 + diner.setStudentNo(request.getCreation().getStudentNo());
607 + diner.setName(request.getCreation().getName());
608 + builder.setIsCreated(dinerService.save(diner)).setId(diner.getId());
609 + } catch (final Exception e) {
610 + log.error("createDiner error;", e);
611 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
612 + }
613 + responseObserver.onNext(builder.build());
614 + responseObserver.onCompleted();
615 + }
616 +
617 + @Override
618 + @DS(DATA_SOURCE_MASTER)
619 + public void updateDiner(final UpdateDinerRpcRequest request,
620 + final StreamObserver<UpdateDinerRpcResponse> responseObserver) {
621 + final var builder = UpdateDinerRpcResponse.newBuilder();
622 + try {
623 + Diner diner = new Diner();
624 + diner.setId(request.getModification().getId());
625 + diner.setEnterpriseId(request.getEnterpriseId());
626 + diner.setUpdatedBy(request.getUpdatedBy());
627 + diner.setUpdateSource(request.getUpdateSource());
628 + if (request.getModification().getShouldUpdateClientId()) {
629 + diner.setClientId(request.getModification().getClientId());
630 + }
631 + if (request.getModification().getShouldUpdateClassId()) {
632 + diner.setClassId(request.getModification().getClassId());
633 + }
634 + if (request.getModification().getShouldUpdateStudentNo()) {
635 + diner.setStudentNo(request.getModification().getStudentNo());
636 + }
637 + if (request.getModification().getShouldUpdateName()) {
638 + diner.setName(request.getModification().getName());
639 + }
640 + builder.setIsUpdated(dinerService.updateById(diner));
641 + } catch (final Exception e) {
642 + log.error("updateDiner error;", e);
643 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
644 + }
645 + responseObserver.onNext(builder.build());
646 + responseObserver.onCompleted();
647 + }
648 +
649 + @Override
650 + @DS(DATA_SOURCE_MASTER)
651 + public void batchSaveOrUpdateDiners(final BatchSaveOrUpdateDinersRpcRequest request,
652 + final StreamObserver<BatchSaveOrUpdateDinersRpcResponse> responseObserver) {
653 + final var builder = BatchSaveOrUpdateDinersRpcResponse.newBuilder();
654 + try {
655 + final var diners = new ArrayList<Diner>();
656 + for (DinerModification modification : request.getModificationsList()) {
657 + Diner diner = new Diner();
658 + diner.setId(modification.getId() == 0 ? null : modification.getId());
659 + diner.setEnterpriseId(request.getEnterpriseId());
660 + if (modification.getId() == 0) {
661 + diner.setCreatedBy(request.getUpdatedBy());
662 + diner.setCreationSource(request.getUpdateSource());
663 + }
664 + diner.setUpdatedBy(request.getUpdatedBy());
665 + diner.setUpdateSource(request.getUpdateSource());
666 + if (modification.getShouldUpdateClientId()) {
667 + diner.setClientId(modification.getClientId());
668 + }
669 + if (modification.getShouldUpdateClassId()) {
670 + diner.setClassId(modification.getClassId());
671 + }
672 + if (modification.getShouldUpdateStudentNo()) {
673 + diner.setStudentNo(modification.getStudentNo());
674 + }
675 + if (modification.getShouldUpdateName()) {
676 + diner.setName(modification.getName());
677 + }
678 + diners.add(diner);
679 + }
680 + builder.setIsUpdated(dinerService.saveOrUpdateBatch(diners));
681 + } catch (final Exception e) {
682 + log.error("batchSaveOrUpdateDiners error;", e);
683 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
684 + }
685 + responseObserver.onNext(builder.build());
686 + responseObserver.onCompleted();
687 + }
688 +
689 + @Override
690 + @DS(DATA_SOURCE_MASTER)
691 + public void deleteDinersByIds(final DeleteDinersByIdsRpcRequest request,
692 + final StreamObserver<DeleteDinersRpcResponse> responseObserver) {
693 + final var builder = DeleteDinersRpcResponse.newBuilder();
694 + try {
695 + builder.setIsDeleted(dinerService.removeBatchByIds(request.getIdsList()));
696 + } catch (final Exception e) {
697 + log.error("deleteDinersByIds error;", e);
698 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
699 + }
700 + responseObserver.onNext(builder.build());
701 + responseObserver.onCompleted();
702 + }
703 +
704 + @Override
705 + @DS(DATA_SOURCE_SLAVE)
706 + public void getMpAccountDinerRefsByIds(final GetMpAccountDinerRefsByIdsRpcRequest request,
707 + final StreamObserver<GetMpAccountDinerRefsByIdsRpcResponse> responseObserver) {
708 + final var builder = GetMpAccountDinerRefsByIdsRpcResponse.newBuilder();
709 + try {
710 + final var mpAccountDinerRefs = mpAccountDinerRefService.listByIds(request.getIdsList());
711 + if (!mpAccountDinerRefs.isEmpty()) {
712 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mpAccountDinerRefs, SingleMpAccountDinerRefRpcResponse.class));
713 + }
714 + } catch (final Exception e) {
715 + log.error("getMpAccountDinerRefsByIds error;", e);
716 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
717 + }
718 + responseObserver.onNext(builder.build());
719 + responseObserver.onCompleted();
720 + }
721 +
722 + @Override
723 + @DS(DATA_SOURCE_SLAVE)
724 + public void queryMpAccountDinerRefsByCondition(final QueryMpAccountDinerRefsByConditionRpcRequest request,
725 + final StreamObserver<QueryMpAccountDinerRefsByConditionRpcResponse> responseObserver) {
726 + final var builder = QueryMpAccountDinerRefsByConditionRpcResponse.newBuilder();
727 + try {
728 + LambdaQueryWrapper<MpAccountDinerRef> queryWrapper = new LambdaQueryWrapper<>();
729 + queryWrapper.eq(MpAccountDinerRef::getEnterpriseId, request.getEnterpriseId());
730 + if (request.getShouldFilterAccountIds()) {
731 + queryWrapper.in(!request.getAccountIdsList().isEmpty(), MpAccountDinerRef::getAccountId, request.getAccountIdsList());
732 + }
733 + if (request.getShouldFilterDinerIds()) {
734 + queryWrapper.in(!request.getDinerIdsList().isEmpty(), MpAccountDinerRef::getDinerId, request.getDinerIdsList());
735 + }
736 + final var diners = mpAccountDinerRefService.list(queryWrapper);
737 + if (!diners.isEmpty()) {
738 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(diners, SingleMpAccountDinerRefRpcResponse.class));
739 + }
740 + } catch (final Exception e) {
741 + log.error("queryMpAccountDinerRefsByCondition error;", e);
742 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
743 + }
744 + responseObserver.onNext(builder.build());
745 + responseObserver.onCompleted();
746 + }
747 +
748 + @Override
749 + @DS(DATA_SOURCE_MASTER)
750 + public void createMpAccountDinerRef(final CreateMpAccountDinerRefRpcRequest request,
751 + final StreamObserver<CreateMpAccountDinerRefRpcResponse> responseObserver) {
752 + final var builder = CreateMpAccountDinerRefRpcResponse.newBuilder();
753 + try {
754 + MpAccountDinerRef mpAccountDinerRef = new MpAccountDinerRef();
755 + mpAccountDinerRef.setEnterpriseId(request.getEnterpriseId());
756 + mpAccountDinerRef.setCreatedBy(request.getCreatedBy());
757 + mpAccountDinerRef.setCreationSource(request.getCreationSource());
758 + mpAccountDinerRef.setAccountId(request.getCreation().getAccountId());
759 + mpAccountDinerRef.setDinerId(request.getCreation().getDinerId());
760 + builder.setIsCreated(mpAccountDinerRefService.save(mpAccountDinerRef)).setId(mpAccountDinerRef.getId());
761 + } catch (final Exception e) {
762 + log.error("createMpAccountDinerRef error;", e);
763 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
764 + }
765 + responseObserver.onNext(builder.build());
766 + responseObserver.onCompleted();
767 + }
768 +
769 + @Override
770 + @DS(DATA_SOURCE_MASTER)
771 + public void deleteMpAccountDinerRefsByIds(final DeleteMpAccountDinerRefsByIdsRpcRequest request,
772 + final StreamObserver<DeleteMpAccountDinerRefsRpcResponse> responseObserver) {
773 + final var builder = DeleteMpAccountDinerRefsRpcResponse.newBuilder();
774 + try {
775 + builder.setIsDeleted(mpAccountDinerRefService.removeBatchByIds(request.getIdsList()));
776 + } catch (final Exception e) {
777 + log.error("deleteMpAccountDinerRefsByIds error;", e);
778 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
779 + }
780 + responseObserver.onNext(builder.build());
781 + responseObserver.onCompleted();
782 + }
783 +
784 + @Override
785 + @DS(DATA_SOURCE_SLAVE)
786 + public void getGradeClassById(final GetGradeClassByIdRpcRequest request,
787 + final StreamObserver<GetGradeClassByIdRpcResponse> responseObserver) {
788 + final var builder = GetGradeClassByIdRpcResponse.newBuilder();
789 + try {
790 + final var gradeClass = gradeClassService.getById(request.getId());
791 + if (gradeClass != null) {
792 + builder.setResponse(ProtoBeanUtil.beanToProto(gradeClass, SingleGradeClassRpcResponse.class));
793 + }
794 + } catch (final Exception e) {
795 + log.error("getGradeClassById error;", e);
796 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
797 + }
798 + responseObserver.onNext(builder.build());
799 + responseObserver.onCompleted();
800 + }
801 +
802 + @Override
803 + @DS(DATA_SOURCE_SLAVE)
804 + public void getGradeClassesByIds(final GetGradeClassesByIdsRpcRequest request,
805 + final StreamObserver<GetGradeClassesByIdsRpcResponse> responseObserver) {
806 + final var builder = GetGradeClassesByIdsRpcResponse.newBuilder();
807 + try {
808 + final var gradeClasses = gradeClassService.listByIds(request.getIdsList());
809 + if (!gradeClasses.isEmpty()) {
810 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(gradeClasses, SingleGradeClassRpcResponse.class));
811 + }
812 + } catch (final Exception e) {
813 + log.error("getGradeClassesByIds error;", e);
814 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
815 + }
816 + responseObserver.onNext(builder.build());
817 + responseObserver.onCompleted();
818 + }
819 +
820 + @Override
821 + @DS(DATA_SOURCE_SLAVE)
822 + public void queryGradeClassesByCondition(final QueryGradeClassesByConditionRpcRequest request,
823 + final StreamObserver<QueryGradeClassesByConditionRpcResponse> responseObserver) {
824 + final var builder = QueryGradeClassesByConditionRpcResponse.newBuilder();
825 + try {
826 + LambdaQueryWrapper<GradeClass> queryWrapper = new LambdaQueryWrapper<>();
827 + queryWrapper.eq(GradeClass::getEnterpriseId, request.getEnterpriseId());
828 + if (request.getShouldFilterClientIds()) {
829 + queryWrapper.in(!request.getClientIdsList().isEmpty(), GradeClass::getClientId, request.getClientIdsList());
830 + }
831 + if (request.getShouldFilterGradeNames()) {
832 + queryWrapper.in(GradeClass::getGradeName, request.getGradeNameList());
833 + }
834 + final var gradeClasses = gradeClassService.list(queryWrapper);
835 + if (!gradeClasses.isEmpty()) {
836 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(gradeClasses, SingleGradeClassRpcResponse.class));
837 + }
838 + } catch (final Exception e) {
839 + log.error("queryGradeClassesByCondition error;", e);
840 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
841 + }
842 + responseObserver.onNext(builder.build());
843 + responseObserver.onCompleted();
844 + }
845 +
846 + @Override
847 + @DS(DATA_SOURCE_MASTER)
848 + public void createGradeClass(final CreateGradeClassRpcRequest request,
849 + final StreamObserver<CreateGradeClassRpcResponse> responseObserver) {
850 + final var builder = CreateGradeClassRpcResponse.newBuilder();
851 + try {
852 + GradeClass gradeClass = new GradeClass();
853 + gradeClass.setEnterpriseId(request.getEnterpriseId());
854 + gradeClass.setCreatedBy(request.getCreatedBy());
855 + gradeClass.setCreationSource(request.getCreationSource());
856 + gradeClass.setUpdatedBy(request.getCreatedBy());
857 + gradeClass.setUpdateSource(request.getCreationSource());
858 + gradeClass.setClientId(request.getCreation().getClientId());
859 + gradeClass.setGradeName(request.getCreation().getGradeName());
860 + gradeClass.setClassName(request.getCreation().getClassName());
861 + builder.setIsCreated(gradeClassService.save(gradeClass)).setId(gradeClass.getId());
862 + } catch (final Exception e) {
863 + log.error("createGradeClass error;", e);
864 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
865 + }
866 + responseObserver.onNext(builder.build());
867 + responseObserver.onCompleted();
868 + }
869 +
870 + @Override
871 + @DS(DATA_SOURCE_MASTER)
872 + public void batchCreateGradeClasses(final BatchCreateGradeClassesRpcRequest request,
873 + final StreamObserver<BatchCreateGradeClassesRpcResponse> responseObserver) {
874 + final var builder = BatchCreateGradeClassesRpcResponse.newBuilder();
875 + try {
876 + final var gradeClasses = new ArrayList<GradeClass>();
877 + for (final var creation : request.getCreationsList()) {
878 + final var gradeClass = new GradeClass();
879 + gradeClass.setEnterpriseId(request.getEnterpriseId());
880 + gradeClass.setCreatedBy(request.getCreatedBy());
881 + gradeClass.setCreationSource(request.getCreationSource());
882 + gradeClass.setUpdatedBy(request.getCreatedBy());
883 + gradeClass.setUpdateSource(request.getCreationSource());
884 + gradeClass.setClientId(creation.getClientId());
885 + gradeClass.setGradeName(creation.getGradeName());
886 + gradeClass.setClassName(creation.getClassName());
887 + gradeClasses.add(gradeClass);
888 + }
889 + builder.setIsCreated(gradeClassService.saveBatch(gradeClasses)).addAllIds(gradeClasses.stream().map(GradeClass::getId).collect(Collectors.toList()));
890 + } catch (final Exception e) {
891 + log.error("batchCreateGradeClasses error;", e);
892 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
893 + }
894 + responseObserver.onNext(builder.build());
895 + responseObserver.onCompleted();
896 + }
897 +
898 + @Override
899 + @DS(DATA_SOURCE_MASTER)
900 + public void updateGradeClass(final UpdateGradeClassRpcRequest request,
901 + final StreamObserver<UpdateGradeClassRpcResponse> responseObserver) {
902 + final var builder = UpdateGradeClassRpcResponse.newBuilder();
903 + try {
904 + GradeClass gradeClass = new GradeClass();
905 + gradeClass.setId(request.getModification().getId());
906 + gradeClass.setEnterpriseId(request.getEnterpriseId());
907 + gradeClass.setUpdatedBy(request.getUpdatedBy());
908 + gradeClass.setUpdateSource(request.getUpdateSource());
909 + if (request.getModification().getShouldUpdateClientId()) {
910 + gradeClass.setClientId(request.getModification().getClientId());
911 + }
912 + if (request.getModification().getShouldUpdateClassName()) {
913 + gradeClass.setClassName(request.getModification().getClassName());
914 + }
915 + if (request.getModification().getShouldUpdateGradeName()) {
916 + gradeClass.setGradeName(request.getModification().getGradeName());
917 + }
918 + builder.setIsUpdated(gradeClassService.updateById(gradeClass));
919 + } catch (final Exception e) {
920 + log.error("updateGradeClass error;", e);
921 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
922 + }
923 + responseObserver.onNext(builder.build());
924 + responseObserver.onCompleted();
925 + }
926 +
927 + @Override
928 + @DS(DATA_SOURCE_MASTER)
929 + public void batchSaveOrUpdateGradeClasses(final BatchSaveOrUpdateGradeClassesRpcRequest request,
930 + final StreamObserver<BatchSaveOrUpdateGradeClassesRpcResponse> responseObserver) {
931 + final var builder = BatchSaveOrUpdateGradeClassesRpcResponse.newBuilder();
932 + try {
933 + List<GradeClass> gradeClasses = new ArrayList<>();
934 + for (final var modification : request.getModificationsList()) {
935 + GradeClass gradeClass = new GradeClass();
936 + gradeClass.setId(modification.getId() == 0 ? null : modification.getId());
937 + gradeClass.setEnterpriseId(request.getEnterpriseId());
938 + if (modification.getId() == 0) {
939 + gradeClass.setCreatedBy(request.getUpdatedBy());
940 + gradeClass.setCreationSource(request.getUpdateSource());
941 + }
942 + gradeClass.setUpdatedBy(request.getUpdatedBy());
943 + gradeClass.setUpdateSource(request.getUpdateSource());
944 + if (modification.getShouldUpdateClientId()) {
945 + gradeClass.setClientId(modification.getClientId());
946 + }
947 + if (modification.getShouldUpdateClassName()) {
948 + gradeClass.setClassName(modification.getClassName());
949 + }
950 + if (modification.getShouldUpdateGradeName()) {
951 + gradeClass.setGradeName(modification.getGradeName());
952 + }
953 + gradeClasses.add(gradeClass);
954 + }
955 + builder.setIsUpdated(gradeClassService.saveOrUpdateBatch(gradeClasses));
956 + } catch (final Exception e) {
957 + log.error("updateGradeClass error;", e);
958 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
959 + }
960 + responseObserver.onNext(builder.build());
961 + responseObserver.onCompleted();
962 + }
963 +
964 + @Override
965 + @DS(DATA_SOURCE_MASTER)
966 + public void deleteGradeClassesByIds(final DeleteGradeClassesByIdsRpcRequest request,
967 + final StreamObserver<DeleteGradeClassesRpcResponse> responseObserver) {
968 + final var builder = DeleteGradeClassesRpcResponse.newBuilder();
969 + try {
970 + builder.setIsDeleted(gradeClassService.removeBatchByIds(request.getIdsList()));
971 + } catch (final Exception e) {
972 + log.error("deleteGradeClassesByIds error;", e);
973 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
974 + }
975 + responseObserver.onNext(builder.build());
976 + responseObserver.onCompleted();
977 + }
978 +
979 + @Override
980 + @DS(DATA_SOURCE_MASTER)
981 + @Transactional(rollbackFor = Exception.class)
982 + public void deleteGradeClassesAndDinersByClientIds(final DeleteGradeClassesAndDinersByClientIdsRpcRequest request,
983 + final StreamObserver<DeleteGradeClassesAndDinersByClientIdsRpcResponse> responseObserver) {
984 + final var builder = DeleteGradeClassesAndDinersByClientIdsRpcResponse.newBuilder();
985 + try {
986 + final var enterpriseId = request.getEnterpriseId();
987 + final var clientIds = request.getClientIdsList();
988 + if (clientIds.isEmpty()) {
989 + builder.setIsDeleted(false);
990 + responseObserver.onNext(builder.build());
991 + responseObserver.onCompleted();
992 + return;
993 + }
994 + final var gradeClassDeleted = gradeClassService.remove(Wrappers.<GradeClass>lambdaQuery().eq(GradeClass::getEnterpriseId, enterpriseId).in(!clientIds.isEmpty(), GradeClass::getClientId, clientIds));
995 + final var diners = dinerService.list(Wrappers.<Diner>lambdaQuery().eq(Diner::getEnterpriseId, enterpriseId).in(!clientIds.isEmpty(), Diner::getClientId, clientIds));
996 + final var dinerDeleted = dinerService.remove(Wrappers.<Diner>lambdaQuery().eq(Diner::getEnterpriseId, enterpriseId).in(!clientIds.isEmpty(), Diner::getClientId, clientIds));
997 + boolean mpAccountDinerRefDeleted = true;
998 + if (!diners.isEmpty()) {
999 + final var dinerIds = diners.stream().map(Diner::getId).collect(Collectors.toList());
1000 + mpAccountDinerRefDeleted = mpAccountDinerRefService.remove(Wrappers.<MpAccountDinerRef>lambdaQuery().eq(MpAccountDinerRef::getEnterpriseId, enterpriseId).in(!dinerIds.isEmpty(), MpAccountDinerRef::getDinerId, dinerIds));
1001 + }
1002 + builder.setIsDeleted(gradeClassDeleted && dinerDeleted && mpAccountDinerRefDeleted);
1003 + } catch (final Exception e) {
1004 + log.error("deleteGradeClassesAndDinersByClientIds error;", e);
1005 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1006 + }
1007 + responseObserver.onNext(builder.build());
1008 + responseObserver.onCompleted();
1009 + }
1010 +
1011 + @Override
1012 + @DS(DATA_SOURCE_MASTER)
1013 + @Transactional(rollbackFor = Exception.class)
1014 + public void deleteGradeClassesAndDinersByClassIds(final DeleteGradeClassesAndDinersByClassIdsRpcRequest request,
1015 + final StreamObserver<DeleteGradeClassesAndDinersByClassIdsRpcResponse> responseObserver) {
1016 + final var builder = DeleteGradeClassesAndDinersByClassIdsRpcResponse.newBuilder();
1017 + try {
1018 + final var enterpriseId = request.getEnterpriseId();
1019 + final var classIds = request.getClassIdsList();
1020 + if (classIds.isEmpty()) {
1021 + builder.setIsDeleted(false);
1022 + responseObserver.onNext(builder.build());
1023 + responseObserver.onCompleted();
1024 + return;
1025 + }
1026 + final var gradeClassRemoved = gradeClassService.remove(Wrappers.<GradeClass>lambdaQuery().eq(GradeClass::getEnterpriseId, enterpriseId).in(GradeClass::getId, classIds));
1027 + final var diners = dinerService.list(Wrappers.<Diner>lambdaQuery().eq(Diner::getEnterpriseId, enterpriseId).in(!classIds.isEmpty(), Diner::getClassId, classIds));
1028 + boolean dinerRemoved = dinerService.remove(Wrappers.<Diner>lambdaQuery().eq(Diner::getEnterpriseId, enterpriseId).in(!classIds.isEmpty(), Diner::getClassId, classIds));
1029 + boolean refRemoved = diners.isEmpty() || mpAccountDinerRefService.remove(Wrappers.<MpAccountDinerRef>lambdaQuery().eq(MpAccountDinerRef::getEnterpriseId, enterpriseId).in(MpAccountDinerRef::getDinerId, diners.stream().map(Diner::getId).collect(Collectors.toList())));
1030 + builder.setIsDeleted(gradeClassRemoved && dinerRemoved && refRemoved);
1031 + } catch (final Exception e) {
1032 + log.error("deleteGradeClassesAndDinersByClassIds error;", e);
1033 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1034 + }
1035 + responseObserver.onNext(builder.build());
1036 + responseObserver.onCompleted();
1037 + }
1038 +
1039 + @Override
1040 + @DS(DATA_SOURCE_SLAVE)
1041 + public void getMealMenuRecordById(final GetMealMenuRecordByIdRpcRequest request,
1042 + final StreamObserver<GetMealMenuRecordByIdRpcResponse> responseObserver) {
1043 + final var builder = GetMealMenuRecordByIdRpcResponse.newBuilder();
1044 + try {
1045 + final var mealMenuRecord = mealMenuRecordService.getById(request.getId());
1046 + if (mealMenuRecord != null) {
1047 + builder.setResponse(ProtoBeanUtil.beanToProto(mealMenuRecord, SingleMealMenuRecordRpcResponse.class));
1048 + }
1049 + } catch (final Exception e) {
1050 + log.error("getMealMenuRecordById error;", e);
1051 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1052 + }
1053 + responseObserver.onNext(builder.build());
1054 + responseObserver.onCompleted();
1055 + }
1056 +
1057 + @Override
1058 + @DS(DATA_SOURCE_SLAVE)
1059 + public void getMealMenuRecordsByIds(final GetMealMenuRecordsByIdsRpcRequest request,
1060 + final StreamObserver<GetMealMenuRecordsByIdsRpcResponse> responseObserver) {
1061 + final var builder = GetMealMenuRecordsByIdsRpcResponse.newBuilder();
1062 + try {
1063 + final var mealMenuRecords = mealMenuRecordService.listByIds(request.getIdsList());
1064 + if (!mealMenuRecords.isEmpty()) {
1065 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(mealMenuRecords, SingleMealMenuRecordRpcResponse.class));
1066 + }
1067 + } catch (final Exception e) {
1068 + log.error("getMealMenuRecordsByIds error;", e);
1069 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1070 + }
1071 + responseObserver.onNext(builder.build());
1072 + responseObserver.onCompleted();
1073 + }
1074 +
1075 + @Override
1076 + @DS(DATA_SOURCE_SLAVE)
1077 + public void queryMealMenuRecordsByCondition(final QueryMealMenuRecordsByConditionRpcRequest request,
1078 + final StreamObserver<QueryMealMenuRecordsByConditionRpcResponse> responseObserver) {
1079 + final var builder = QueryMealMenuRecordsByConditionRpcResponse.newBuilder();
1080 + try {
1081 + LambdaQueryWrapper<MealMenuRecord> queryWrapper = new LambdaQueryWrapper<>();
1082 + queryWrapper.eq(MealMenuRecord::getEnterpriseId, request.getEnterpriseId());
1083 + if (request.getShouldFilterClientIds()) {
1084 + queryWrapper.in(!request.getClientIdsList().isEmpty(), MealMenuRecord::getClientId, request.getClientIdsList());
1085 + }
1086 + if (request.getShouldFilterName()) {
1087 + queryWrapper.eq(MealMenuRecord::getName, request.getName());
1088 + }
1089 + final var diners = mealMenuRecordService.list(queryWrapper);
1090 + if (!diners.isEmpty()) {
1091 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(diners, SingleMealMenuRecordRpcResponse.class));
1092 + }
1093 + } catch (final Exception e) {
1094 + log.error("queryMealMenuRecordsByCondition error;", e);
1095 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1096 + }
1097 + responseObserver.onNext(builder.build());
1098 + responseObserver.onCompleted();
1099 + }
1100 +
1101 + @Override
1102 + @DS(DATA_SOURCE_SLAVE)
1103 + public void queryLatestMealMenuRecordsByClientIds(final QueryLatestMealMenuRecordsByClientIdsRpcRequest request,
1104 + final StreamObserver<QueryLatestMealMenuRecordsByClientIdsRpcResponse> responseObserver) {
1105 + final var builder = QueryLatestMealMenuRecordsByClientIdsRpcResponse.newBuilder();
1106 + try {
1107 + final var queryWrapper = new LambdaQueryWrapper<MealMenuRecord>();
1108 + queryWrapper.eq(MealMenuRecord::getEnterpriseId, request.getEnterpriseId());
1109 + queryWrapper.in(MealMenuRecord::getClientId, request.getClientIdList());
1110 + queryWrapper.orderByDesc(MealMenuRecord::getCreatedAt);
1111 + final var allRecords = mealMenuRecordService.list(queryWrapper);
1112 + final var latestRecordsMap = allRecords.stream().collect(Collectors.toMap(MealMenuRecord::getClientId, Function.identity(), (existing, replacement) -> existing));
1113 + if (!latestRecordsMap.isEmpty()) {
1114 + builder.addAllResponses(ProtoBeanUtil.beanListToProtoList(new ArrayList<>(latestRecordsMap.values()), SingleMealMenuRecordRpcResponse.class));
1115 + }
1116 + } catch (final Exception e) {
1117 + log.error("queryLatestMealMenuRecordsByClientIds error;", e);
1118 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1119 + }
1120 + responseObserver.onNext(builder.build());
1121 + responseObserver.onCompleted();
1122 + }
1123 +
1124 + @Override
1125 + @DS(DATA_SOURCE_MASTER)
1126 + public void createMealMenuRecord(final CreateMealMenuRecordRpcRequest request,
1127 + final StreamObserver<CreateMealMenuRecordRpcResponse> responseObserver) {
1128 + final var builder = CreateMealMenuRecordRpcResponse.newBuilder();
1129 + try {
1130 + MealMenuRecord mealMenuRecord = new MealMenuRecord();
1131 + mealMenuRecord.setEnterpriseId(request.getEnterpriseId());
1132 + mealMenuRecord.setCreatedBy(request.getCreatedBy());
1133 + mealMenuRecord.setCreationSource(request.getCreationSource());
1134 + mealMenuRecord.setUpdatedBy(request.getCreatedBy());
1135 + mealMenuRecord.setUpdateSource(request.getCreationSource());
1136 + mealMenuRecord.setClientId(request.getCreation().getClientId());
1137 + mealMenuRecord.setName(request.getCreation().getName());
1138 + mealMenuRecord.setImageUrl(request.getCreation().getImageUrl());
1139 + builder.setIsCreated(mealMenuRecordService.save(mealMenuRecord)).setId(mealMenuRecord.getId());
1140 + } catch (final Exception e) {
1141 + log.error("createMealMenuRecord error;", e);
1142 + responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
1143 + }
1144 + responseObserver.onNext(builder.build());
1145 + responseObserver.onCompleted();
1146 + }
1147 +}
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 + rpc DeleteGradeClassesAndDinersByClassIds (DeleteGradeClassesAndDinersByClassIdsRpcRequest) returns (DeleteGradeClassesAndDinersByClassIdsRpcResponse) {}
50 +
51 + rpc GetMealMenuRecordById (GetMealMenuRecordByIdRpcRequest) returns (GetMealMenuRecordByIdRpcResponse) {}
52 + rpc GetMealMenuRecordsByIds (GetMealMenuRecordsByIdsRpcRequest) returns (GetMealMenuRecordsByIdsRpcResponse) {}
53 + rpc QueryMealMenuRecordsByCondition (QueryMealMenuRecordsByConditionRpcRequest) returns (QueryMealMenuRecordsByConditionRpcResponse) {}
54 + rpc CreateMealMenuRecord (CreateMealMenuRecordRpcRequest) returns (CreateMealMenuRecordRpcResponse) {}
55 + rpc QueryLatestMealMenuRecordsByClientIds (QueryLatestMealMenuRecordsByClientIdsRpcRequest) returns (QueryLatestMealMenuRecordsByClientIdsRpcResponse) {}
56 +}
57 +
58 +enum MealOrderOrderMethodEnum {
59 + MEAL_ORDER_METHOD_SYSTEM = 0;
60 + MEAL_ORDER_METHOD_MICRO = 1;
61 +}
62 +
63 +message SingleMealOrderRpcResponse {
64 + int32 id = 1;
65 + int32 enterpriseId = 2;
66 + int32 clientId = 3;
67 + int32 menuId = 4;
68 + int32 accountId = 5;
69 + MealOrderOrderMethodEnum orderMethod = 6;
70 + int32 dinerId = 7;
71 + string dinerName = 8;
72 + string clientName = 9;
73 + string gradeName = 10;
74 + string className = 11;
75 + string studentNo = 12;
76 + int64 reserveDate = 13;
77 + repeated MenuSchedule meals = 14;
78 + int32 createdBy = 15;
79 + int64 createdAt = 16;
80 + int32 creationSource = 17;
81 + int32 updatedBy = 18;
82 + int64 updatedAt = 19;
83 + int32 updateSource = 20;
84 + bool isDeleted = 21;
85 +}
86 +
87 +message GetMealOrderByIdRpcRequest {
88 + int32 id = 1;
89 + int32 enterpriseId = 2;
90 + bool includeDeleted = 3;
91 +}
92 +
93 +message GetMealOrderByIdRpcResponse {
94 + SingleMealOrderRpcResponse response = 1;
95 +}
96 +
97 +message GetMealOrdersByIdsRpcRequest {
98 + repeated int32 ids = 1;
99 + int32 enterpriseId = 2;
100 + bool includeDeleted = 3;
101 +}
102 +
103 +message GetMealOrdersByIdsRpcResponse {
104 + repeated SingleMealOrderRpcResponse responses = 1;
105 +}
106 +
107 +message QueryMealOrdersByConditionRpcRequest {
108 + int32 enterpriseId = 1;
109 + bool shouldFilterClientIds = 2;
110 + repeated int32 clientIds = 3;
111 + bool shouldFilterMenuIds = 4;
112 + repeated int32 menuIds = 5;
113 + bool shouldFilterAccountIds = 6;
114 + repeated int32 accountIds = 7;
115 + bool shouldFilterOrderMethod = 8;
116 + MealOrderOrderMethodEnum orderMethod = 9;
117 + bool shouldFilterDinerIds = 10;
118 + repeated int32 dinerIds = 11;
119 + bool shouldFilterReserveDateStart = 12;
120 + int64 reserveDateStart = 13;
121 + bool shouldFilterReserveDateEnd = 14;
122 + int64 reserveDateEnd = 15;
123 + bool includeDeleted = 16;
124 +}
125 +
126 +message QueryMealOrdersByConditionRpcResponse {
127 + repeated SingleMealOrderRpcResponse responses = 1;
128 +}
129 +
130 +message QueryReserveMealOrdersByDinerIdsRpcRequest {
131 + int32 enterpriseId = 1;
132 + repeated int32 dinerIds = 2;
133 +}
134 +
135 +message QueryReserveMealOrdersByDinerIdsRpcResponse {
136 + repeated SingleMealOrderRpcResponse responses = 1;
137 +}
138 +
139 +message MealOrderCreation{
140 + int32 clientId = 1;
141 + int32 menuId = 2;
142 + int32 accountId = 3;
143 + MealOrderOrderMethodEnum orderMethod = 4;
144 + int32 dinerId = 5;
145 + string dinerName = 6;
146 + string clientName = 7;
147 + string gradeName = 8;
148 + string className = 9;
149 + string studentNo = 10;
150 + int64 reserveDate = 11;
151 + repeated MenuSchedule meals = 12;
152 +}
153 +
154 +message MenuSchedule {
155 + string date = 1; // 日期字段,类型是 string
156 + string menu = 2; // 菜单字段,类型是 string
157 +}
158 +
159 +message CreateMealOrderRpcRequest {
160 + MealOrderCreation creation = 1;
161 + int32 enterpriseId = 2;
162 + int32 createdBy = 3;
163 + int32 creationSource = 4;
164 +}
165 +
166 +message CreateMealOrderRpcResponse {
167 + int32 id = 1;
168 + bool isCreated = 2;
169 +}
170 +
171 +message BatchCreateMealOrdersRpcRequest {
172 + repeated MealOrderCreation creations = 1;
173 + int32 enterpriseId = 2;
174 + int32 createdBy = 3;
175 + int32 creationSource = 4;
176 +}
177 +
178 +message BatchCreateMealOrdersRpcResponse {
179 + repeated int32 ids = 1;
180 + bool isCreated = 2;
181 +}
182 +
183 +message MealOrderModification {
184 + int32 id = 1;
185 + bool shouldUpdateClientId = 2;
186 + int32 clientId = 3;
187 + bool shouldUpdateMenuId = 4;
188 + int32 menuId = 5;
189 + bool shouldUpdateAccountId = 6;
190 + int32 accountId = 7;
191 + bool shouldUpdateOrderMethod = 8;
192 + MealOrderOrderMethodEnum orderMethod = 9;
193 + bool shouldUpdateDinerId = 10;
194 + int32 dinerId = 11;
195 + bool shouldUpdateDinerName = 12;
196 + string dinerName = 13;
197 + bool shouldUpdateClientName = 14;
198 + string clientName = 15;
199 + bool shouldUpdateGradeName = 16;
200 + string gradeName = 17;
201 + bool shouldUpdateClassName = 18;
202 + string className = 19;
203 + bool shouldUpdateStudentNo = 20;
204 + string studentNo = 21;
205 + bool shouldUpdateReserveDate = 22;
206 + int64 reserveDate = 23;
207 + bool shouldUpdateMeals = 24;
208 + repeated MenuSchedule meals = 25;
209 +}
210 +
211 +message UpdateMealOrderRpcRequest {
212 + MealOrderModification modification = 1;
213 + int32 enterpriseId = 2;
214 + int32 updatedBy = 3;
215 + int32 updateSource = 4;
216 +}
217 +
218 +message UpdateMealOrderRpcResponse {
219 + bool isUpdated = 1;
220 +}
221 +
222 +message BatchUpdateMealOrdersRpcRequest {
223 + repeated MealOrderModification modifications = 1;
224 + int32 enterpriseId = 2;
225 + int32 updatedBy = 3;
226 + int32 updateSource = 4;
227 +}
228 +
229 +message BatchUpdateMealOrdersRpcResponse {
230 + bool isUpdated = 1;
231 +}
232 +
233 +message DeleteMealOrdersByIdsRpcRequest {
234 + repeated int32 ids = 1;
235 + int32 enterpriseId = 2;
236 + int32 updatedBy = 3;
237 + int32 updateSource = 4;
238 +}
239 +
240 +message DeleteMealOrdersRpcResponse {
241 + bool isDeleted = 1;
242 +}
243 +
244 +message SingleDinerRpcResponse {
245 + int32 id = 1;
246 + int32 enterpriseId = 2;
247 + int32 clientId = 3;
248 + int32 classId = 4;
249 + string studentNo = 5;
250 + string name = 6;
251 + int32 createdBy = 7;
252 + int64 createdAt = 8;
253 + int32 creationSource = 9;
254 + int32 updatedBy = 10;
255 + int64 updatedAt = 11;
256 + int32 updateSource = 12;
257 + bool isDeleted = 13;
258 +}
259 +
260 +message GetDinerByIdRpcRequest {
261 + int32 id = 1;
262 + int32 enterpriseId = 2;
263 + bool includeDeleted = 3;
264 +}
265 +
266 +message GetDinerByIdRpcResponse {
267 + SingleDinerRpcResponse response = 1;
268 +}
269 +
270 +message GetDinersByIdsRpcRequest {
271 + repeated int32 ids = 1;
272 + int32 enterpriseId = 2;
273 + bool includeDeleted = 3;
274 +}
275 +
276 +message GetDinersByIdsRpcResponse {
277 + repeated SingleDinerRpcResponse responses = 1;
278 +}
279 +
280 +message QueryDinersByConditionRpcRequest {
281 + int32 enterpriseId = 1;
282 + bool shouldFilterClientIds = 2;
283 + repeated int32 clientIds = 3;
284 + bool shouldFilterClassIds = 4;
285 + repeated int32 classIds = 5;
286 + bool shouldFilterStudentNo = 6;
287 + string studentNo = 7;
288 + bool shouldFilterName = 8;
289 + string name = 9;
290 + bool includeDeleted = 10;
291 +}
292 +
293 +message QueryDinersByConditionRpcResponse {
294 + repeated SingleDinerRpcResponse responses = 1;
295 +}
296 +
297 +message DinerCreation{
298 + int32 clientId = 1;
299 + int32 classId = 2;
300 + string studentNo = 3;
301 + string name = 4;
302 +}
303 +
304 +message CreateDinerRpcRequest {
305 + DinerCreation creation = 1;
306 + int32 enterpriseId = 2;
307 + int32 createdBy = 3;
308 + int32 creationSource = 4;
309 +}
310 +
311 +message CreateDinerRpcResponse {
312 + int32 id = 1;
313 + bool isCreated = 2;
314 +}
315 +
316 +message DinerModification {
317 + int32 id = 1;
318 + bool shouldUpdateClientId = 2;
319 + int32 clientId = 3;
320 + bool shouldUpdateClassId = 4;
321 + int32 classId = 5;
322 + bool shouldUpdateStudentNo = 6;
323 + string studentNo = 7;
324 + bool shouldUpdateName = 8;
325 + string name = 9;
326 +}
327 +
328 +message UpdateDinerRpcRequest {
329 + DinerModification modification = 1;
330 + int32 enterpriseId = 2;
331 + int32 updatedBy = 3;
332 + int32 updateSource = 4;
333 +}
334 +
335 +message UpdateDinerRpcResponse {
336 + bool isUpdated = 1;
337 +}
338 +
339 +message BatchSaveOrUpdateDinersRpcRequest {
340 + repeated DinerModification modifications = 1;
341 + int32 enterpriseId = 2;
342 + int32 updatedBy = 3;
343 + int32 updateSource = 4;
344 +}
345 +
346 +message BatchSaveOrUpdateDinersRpcResponse {
347 + bool isUpdated = 1;
348 +}
349 +
350 +message DeleteDinersByIdsRpcRequest {
351 + repeated int32 ids = 1;
352 + int32 enterpriseId = 2;
353 + int32 updatedBy = 3;
354 + int32 updateSource = 4;
355 +}
356 +
357 +message DeleteDinersRpcResponse {
358 + bool isDeleted = 1;
359 +}
360 +
361 +enum MpAccountGenderEnum {
362 + MP_ACCOUNT_GENDER_MAN = 0;
363 + MP_ACCOUNT_GENDER_WOMAN = 1;
364 +}
365 +enum MpAccountStatusEnum {
366 + MP_ACCOUNT_STATUS_ENABLE = 0;
367 + MP_ACCOUNT_STATUS_DISABLE = 1;
368 +}
369 +
370 +message SingleMpAccountRpcResponse {
371 + int32 id = 1;
372 + int32 enterpriseId = 2;
373 + string openId = 3;
374 + string unionId = 4;
375 + string nickname = 5;
376 + string avatarUrl = 6;
377 + MpAccountGenderEnum gender = 7;
378 + string phoneNumber = 8;
379 + MpAccountStatusEnum status = 9;
380 + int32 createdBy = 10;
381 + int64 createdAt = 11;
382 + int32 creationSource = 12;
383 + int32 updatedBy = 13;
384 + int64 updatedAt = 14;
385 + int32 updateSource = 15;
386 + bool isDeleted = 16;
387 +}
388 +
389 +message GetMpAccountByIdRpcRequest {
390 + int32 id = 1;
391 + int32 enterpriseId = 2;
392 + bool includeDeleted = 3;
393 +}
394 +
395 +message GetMpAccountByIdRpcResponse {
396 + SingleMpAccountRpcResponse response = 1;
397 +}
398 +
399 +message GetMpAccountByOpenIdRpcRequest {
400 + string openId = 1;
401 +}
402 +
403 +message GetMpAccountByOpenIdRpcResponse {
404 + SingleMpAccountRpcResponse response = 1;
405 +}
406 +
407 +message GetMpAccountsByIdsRpcRequest {
408 + repeated int32 ids = 1;
409 + int32 enterpriseId = 2;
410 + bool includeDeleted = 3;
411 +}
412 +
413 +message GetMpAccountsByIdsRpcResponse {
414 + repeated SingleMpAccountRpcResponse responses = 1;
415 +}
416 +
417 +message QueryMpAccountsByConditionRpcRequest {
418 + int32 enterpriseId = 1;
419 + bool shouldFilterOpenId = 2;
420 + string openId = 3;
421 + bool shouldFilterUnionId = 4;
422 + string unionId = 5;
423 + bool shouldFilterPhoneNumber = 6;
424 + string phoneNumber = 7;
425 + bool shouldFilterStatus = 8;
426 + MpAccountStatusEnum status = 9;
427 + bool includeDeleted = 10;
428 +}
429 +
430 +message QueryMpAccountsByConditionRpcResponse {
431 + repeated SingleMpAccountRpcResponse responses = 1;
432 +}
433 +
434 +message MpAccountCreation{
435 + string openId = 1;
436 + bool shouldCreateUnionId = 2;
437 + string unionId = 3;
438 + bool shouldCreateNickname = 4;
439 + string nickname = 5;
440 + bool shouldCreateAvatarUrl = 6;
441 + string avatarUrl = 7;
442 + MpAccountGenderEnum gender = 8;
443 + string phoneNumber = 9;
444 + MpAccountStatusEnum status = 10;
445 +}
446 +
447 +message CreateMpAccountRpcRequest {
448 + MpAccountCreation creation = 1;
449 + int32 enterpriseId = 2;
450 + int32 createdBy = 3;
451 + int32 creationSource = 4;
452 +}
453 +
454 +message CreateMpAccountRpcResponse {
455 + int32 id = 1;
456 + bool isCreated = 2;
457 +}
458 +
459 +message MpAccountModification {
460 + int32 id = 1;
461 + bool shouldUpdateOpenId = 2;
462 + string openId = 3;
463 + bool shouldUpdateUnionId = 4;
464 + string unionId = 5;
465 + bool shouldUpdateNickname = 6;
466 + string nickname = 7;
467 + bool shouldUpdateAvatarUrl = 8;
468 + string avatarUrl = 9;
469 + bool shouldUpdateGender = 10;
470 + MpAccountGenderEnum gender = 11;
471 + bool shouldUpdatePhoneNumber = 12;
472 + string phoneNumber = 13;
473 + bool shouldUpdateStatus = 14;
474 + MpAccountStatusEnum status = 15;
475 +}
476 +
477 +message UpdateMpAccountRpcRequest {
478 + MpAccountModification modification = 1;
479 + int32 enterpriseId = 2;
480 + int32 updatedBy = 3;
481 + int32 updateSource = 4;
482 +}
483 +
484 +message UpdateMpAccountRpcResponse {
485 + bool isUpdated = 1;
486 +}
487 +
488 +message DeleteMpAccountsByIdsRpcRequest {
489 + repeated int32 ids = 1;
490 + int32 enterpriseId = 2;
491 + int32 updatedBy = 3;
492 + int32 updateSource = 4;
493 +}
494 +
495 +message DeleteMpAccountsRpcResponse {
496 + bool isDeleted = 1;
497 +}
498 +
499 +message SingleMpAccountDinerRefRpcResponse {
500 + int32 id = 1;
501 + int32 enterpriseId = 2;
502 + int32 accountId = 3;
503 + int32 dinerId = 4;
504 + int32 createdBy = 5;
505 + int64 createdAt = 6;
506 + int32 creationSource = 7;
507 +}
508 +
509 +message GetMpAccountDinerRefsByIdsRpcRequest {
510 + repeated int32 ids = 1;
511 + int32 enterpriseId = 2;
512 +}
513 +
514 +message GetMpAccountDinerRefsByIdsRpcResponse {
515 + repeated SingleMpAccountDinerRefRpcResponse responses = 1;
516 +}
517 +
518 +message QueryMpAccountDinerRefsByConditionRpcRequest {
519 + int32 enterpriseId = 1;
520 + bool shouldFilterAccountIds = 2;
521 + repeated int32 accountIds = 3;
522 + bool shouldFilterDinerIds = 4;
523 + repeated int32 dinerIds = 5;
524 +}
525 +
526 +message QueryMpAccountDinerRefsByConditionRpcResponse {
527 + repeated SingleMpAccountDinerRefRpcResponse responses = 1;
528 +}
529 +
530 +message MpAccountDinerRefCreation{
531 + int32 accountId = 1;
532 + int32 dinerId = 2;
533 +}
534 +
535 +message CreateMpAccountDinerRefRpcRequest {
536 + MpAccountDinerRefCreation creation = 1;
537 + int32 enterpriseId = 2;
538 + int32 createdBy = 3;
539 + int32 creationSource = 4;
540 +}
541 +
542 +message CreateMpAccountDinerRefRpcResponse {
543 + int32 id = 1;
544 + bool isCreated = 2;
545 +}
546 +
547 +message BatchCreateMpAccountDinerRefsRpcRequest {
548 + repeated MpAccountDinerRefCreation creations = 1;
549 + int32 enterpriseId = 2;
550 + int32 createdBy = 3;
551 + int32 creationSource = 4;
552 +}
553 +
554 +message BatchCreateMpAccountDinerRefsRpcResponse {
555 + repeated int32 ids = 1;
556 + bool isCreated = 2;
557 +}
558 +
559 +message DeleteMpAccountDinerRefsByIdsRpcRequest {
560 + repeated int32 ids = 1;
561 + int32 enterpriseId = 2;
562 +}
563 +
564 +message DeleteMpAccountDinerRefsRpcResponse {
565 + bool isDeleted = 1;
566 +}
567 +
568 +message SingleGradeClassRpcResponse {
569 + int32 id = 1;
570 + int32 enterpriseId = 2;
571 + int32 clientId = 3;
572 + string gradeName = 4;
573 + string className = 5;
574 + string fullName = 6;
575 + int32 createdBy = 7;
576 + int64 createdAt = 8;
577 + int32 creationSource = 9;
578 + int32 updatedBy = 10;
579 + int64 updatedAt = 11;
580 + int32 updateSource = 12;
581 + bool isDeleted = 13;
582 +}
583 +
584 +message GetGradeClassByIdRpcRequest {
585 + int32 id = 1;
586 + int32 enterpriseId = 2;
587 + bool includeDeleted = 3;
588 +}
589 +
590 +message GetGradeClassByIdRpcResponse {
591 + SingleGradeClassRpcResponse response = 1;
592 +}
593 +
594 +message GetGradeClassesByIdsRpcRequest {
595 + repeated int32 ids = 1;
596 + int32 enterpriseId = 2;
597 + bool includeDeleted = 3;
598 +}
599 +
600 +message GetGradeClassesByIdsRpcResponse {
601 + repeated SingleGradeClassRpcResponse responses = 1;
602 +}
603 +
604 +message GetAllGradeClassesRpcRequest {
605 + int32 enterpriseId = 1;
606 + bool includeDeleted = 2;
607 +}
608 +
609 +message GetAllGradeClassesRpcResponse {
610 + repeated SingleGradeClassRpcResponse responses = 1;
611 +}
612 +
613 +message QueryGradeClassesByConditionRpcRequest {
614 + int32 enterpriseId = 1;
615 + bool shouldFilterClientIds = 2;
616 + repeated int32 clientIds = 3;
617 + bool shouldFilterGradeNames = 4;
618 + repeated string gradeName = 5;
619 + bool includeDeleted = 6;
620 +}
621 +
622 +message QueryGradeClassesByConditionRpcResponse {
623 + repeated SingleGradeClassRpcResponse responses = 1;
624 +}
625 +
626 +message GradeClassCreation{
627 + int32 clientId = 1;
628 + string gradeName = 2;
629 + string className = 3;
630 + bool shouldCreateFullName = 4;
631 + string fullName = 5;
632 +}
633 +
634 +message CreateGradeClassRpcRequest {
635 + GradeClassCreation creation = 1;
636 + int32 enterpriseId = 2;
637 + int32 createdBy = 3;
638 + int32 creationSource = 4;
639 +}
640 +
641 +message CreateGradeClassRpcResponse {
642 + int32 id = 1;
643 + bool isCreated = 2;
644 +}
645 +
646 +message BatchCreateGradeClassesRpcRequest {
647 + repeated GradeClassCreation creations = 1;
648 + int32 enterpriseId = 2;
649 + int32 createdBy = 3;
650 + int32 creationSource = 4;
651 +}
652 +
653 +message BatchCreateGradeClassesRpcResponse {
654 + repeated int32 ids = 1;
655 + bool isCreated = 2;
656 +}
657 +
658 +message GradeClassModification {
659 + int32 id = 1;
660 + bool shouldUpdateClientId = 2;
661 + int32 clientId = 3;
662 + bool shouldUpdateGradeName = 4;
663 + string gradeName = 5;
664 + bool shouldUpdateClassName = 6;
665 + string className = 7;
666 + bool shouldUpdateFullName = 8;
667 + string fullName = 9;
668 +}
669 +
670 +message UpdateGradeClassRpcRequest {
671 + GradeClassModification modification = 1;
672 + int32 enterpriseId = 2;
673 + int32 updatedBy = 3;
674 + int32 updateSource = 4;
675 +}
676 +
677 +message UpdateGradeClassRpcResponse {
678 + bool isUpdated = 1;
679 +}
680 +
681 +message BatchSaveOrUpdateGradeClassesRpcRequest {
682 + repeated GradeClassModification modifications = 1;
683 + int32 enterpriseId = 2;
684 + int32 updatedBy = 3;
685 + int32 updateSource = 4;
686 +}
687 +
688 +message BatchSaveOrUpdateGradeClassesRpcResponse {
689 + bool isUpdated = 1;
690 +}
691 +
692 +message BatchUpdateGradeClassesRpcRequest {
693 + repeated GradeClassModification modifications = 1;
694 + int32 enterpriseId = 2;
695 + int32 updatedBy = 3;
696 + int32 updateSource = 4;
697 +}
698 +
699 +message BatchUpdateGradeClassesRpcResponse {
700 + bool isUpdated = 1;
701 +}
702 +
703 +message DeleteGradeClassesByIdsRpcRequest {
704 + repeated int32 ids = 1;
705 + int32 enterpriseId = 2;
706 + int32 updatedBy = 3;
707 + int32 updateSource = 4;
708 +}
709 +
710 +message DeleteGradeClassesRpcResponse {
711 + bool isDeleted = 1;
712 +}
713 +
714 +message DeleteGradeClassesAndDinersByClientIdsRpcRequest {
715 + repeated int32 clientIds = 1;
716 + int32 enterpriseId = 2;
717 + int32 updatedBy = 3;
718 + int32 updateSource = 4;
719 +}
720 +
721 +message DeleteGradeClassesAndDinersByClientIdsRpcResponse {
722 + bool isDeleted = 1;
723 +}
724 +
725 +message DeleteGradeClassesAndDinersByClassIdsRpcRequest {
726 + repeated int32 classIds = 1;
727 + int32 enterpriseId = 2;
728 + int32 updatedBy = 3;
729 + int32 updateSource = 4;
730 +}
731 +
732 +message DeleteGradeClassesAndDinersByClassIdsRpcResponse {
733 + bool isDeleted = 1;
734 +}
735 +
736 +
737 +message SingleMealMenuRecordRpcResponse {
738 + int32 id = 1;
739 + int32 enterpriseId = 2;
740 + int32 clientId = 3;
741 + string name = 4;
742 + string imageUrl = 5;
743 + int32 createdBy = 6;
744 + int64 createdAt = 7;
745 + int32 creationSource = 8;
746 + int32 updatedBy = 9;
747 + int64 updatedAt = 10;
748 + int32 updateSource = 11;
749 + bool isDeleted = 12;
750 +}
751 +
752 +message GetMealMenuRecordByIdRpcRequest {
753 + int32 id = 1;
754 + int32 enterpriseId = 2;
755 + bool includeDeleted = 3;
756 +}
757 +
758 +message GetMealMenuRecordByIdRpcResponse {
759 + SingleMealMenuRecordRpcResponse response = 1;
760 +}
761 +
762 +message GetMealMenuRecordsByIdsRpcRequest {
763 + repeated int32 ids = 1;
764 + int32 enterpriseId = 2;
765 + bool includeDeleted = 3;
766 +}
767 +
768 +message GetMealMenuRecordsByIdsRpcResponse {
769 + repeated SingleMealMenuRecordRpcResponse responses = 1;
770 +}
771 +
772 +message QueryMealMenuRecordsByConditionRpcRequest {
773 + int32 enterpriseId = 1;
774 + bool shouldFilterClientIds = 2;
775 + repeated int32 clientIds = 3;
776 + bool shouldFilterName = 4;
777 + string name = 5;
778 + bool includeDeleted = 6;
779 +}
780 +
781 +message QueryMealMenuRecordsByConditionRpcResponse {
782 + repeated SingleMealMenuRecordRpcResponse responses = 1;
783 +}
784 +
785 +message MealMenuRecordCreation{
786 + int32 clientId = 1;
787 + string name = 2;
788 + bool shouldCreateImageUrl = 3;
789 + string imageUrl = 4;
790 +}
791 +
792 +message CreateMealMenuRecordRpcRequest {
793 + MealMenuRecordCreation creation = 1;
794 + int32 enterpriseId = 2;
795 + int32 createdBy = 3;
796 + int32 creationSource = 4;
797 +}
798 +
799 +message CreateMealMenuRecordRpcResponse {
800 + int32 id = 1;
801 + bool isCreated = 2;
802 +}
803 +
804 +message QueryLatestMealMenuRecordsByClientIdsRpcRequest {
805 + int32 enterpriseId = 1;
806 + repeated int32 clientId = 2;
807 +}
808 +
809 +message QueryLatestMealMenuRecordsByClientIdsRpcResponse {
810 + repeated SingleMealMenuRecordRpcResponse responses = 1;
811 +}
...@@ -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>