-
Notifications
You must be signed in to change notification settings - Fork 25
/
mypatch.patch
186 lines (186 loc) · 4.72 KB
/
mypatch.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
diff --git a/avni-server-api/src/main/java/org/avni/messaging/dao/MessageRuleRepository.java b/avni-server-api/src/main/java/org/avni/messaging/dao/MessageRuleRepository.java
new file mode 100644
index 00000000..5d8e2e75
--- /dev/null
+++ b/avni-server-api/src/main/java/org/avni/messaging/dao/MessageRuleRepository.java
@@ -0,0 +1,14 @@
+package org.avni.messaging.dao;
+
+import org.avni.messaging.domain.MessageRule;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
+import org.springframework.stereotype.Repository;
+
+@Repository
+@RepositoryRestResource(collectionResourceRel = "messageRule", path = "messageRule")
+public interface MessageRuleRepository extends CrudRepository<MessageRule, Long> {
+
+ @Override
+ public <S extends MessageRule> S save(S s);
+}
diff --git a/avni-server-api/src/main/java/org/avni/messaging/domain/MessageRule.java b/avni-server-api/src/main/java/org/avni/messaging/domain/MessageRule.java
new file mode 100644
index 00000000..fd35b7b1
--- /dev/null
+++ b/avni-server-api/src/main/java/org/avni/messaging/domain/MessageRule.java
@@ -0,0 +1,133 @@
+package org.avni.messaging.domain;
+
+import org.avni.server.domain.EntityType;
+import org.avni.server.domain.OrganisationAwareEntity;
+
+import jakarta.persistence.*;
+import jakarta.validation.constraints.NotNull;
+
+@Entity
+@Table(name = "account_admin")
+public class MessageRule extends OrganisationAwareEntity {
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id", updatable = false, nullable = false)
+ @Id
+ private Long id;
+
+ @Column
+ @NotNull
+ private String uuid;
+
+ @Column
+ @NotNull
+ private String name;
+
+ @Column
+ private String messageRule;
+
+ @Column
+ private String scheduleRule;
+
+ @Column
+ private boolean isVoided;
+
+ @Column
+ @Enumerated(EnumType.STRING)
+ private EntityType entityType;
+
+ @Column
+ private Long entityId;
+
+ @Column
+ private Long messageTemplateId;
+
+ @Column
+ private int version;
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Id
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ public String getUuid() {
+ return uuid;
+ }
+
+ @Override
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getMessageRule() {
+ return messageRule;
+ }
+
+ public void setMessageRule(String messageRule) {
+ this.messageRule = messageRule;
+ }
+
+ public String getScheduleRule() {
+ return scheduleRule;
+ }
+
+ public void setScheduleRule(String scheduleRule) {
+ this.scheduleRule = scheduleRule;
+ }
+
+ @Override
+ public boolean isVoided() {
+ return isVoided;
+ }
+
+ @Override
+ public void setVoided(boolean voided) {
+ isVoided = voided;
+ }
+
+ public EntityType getEntityType() {
+ return entityType;
+ }
+
+ public void setEntityType(EntityType entityType) {
+ this.entityType = entityType;
+ }
+
+ public Long getEntityId() {
+ return entityId;
+ }
+
+ public void setEntityId(Long entityId) {
+ this.entityId = entityId;
+ }
+
+ public Long getMessageTemplateId() {
+ return messageTemplateId;
+ }
+
+ public void setMessageTemplateId(Long messageTemplateId) {
+ this.messageTemplateId = messageTemplateId;
+ }
+
+ @Override
+ public int getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(int version) {
+ this.version = version;
+ }
+}
diff --git a/avni-server-api/src/main/java/org/avni/messaging/service/MessagingService.java b/avni-server-api/src/main/java/org/avni/messaging/service/MessagingService.java
new file mode 100644
index 00000000..637eeca8
--- /dev/null
+++ b/avni-server-api/src/main/java/org/avni/messaging/service/MessagingService.java
@@ -0,0 +1,21 @@
+package org.avni.messaging.service;
+
+import org.avni.messaging.dao.MessageRuleRepository;
+import org.avni.messaging.domain.MessageRule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MessagingService {
+ private final Logger logger;
+
+ private final MessageRuleRepository messageRuleRepository;
+
+ public MessagingService(MessageRuleRepository messageRuleRepository) {
+ this.messageRuleRepository = messageRuleRepository;
+ logger = LoggerFactory.getLogger(this.getClass());
+ }
+
+ public void saveRule(MessageRule messageRule) {
+ messageRuleRepository.save(messageRule);
+ }
+}