@@ -192,30 +192,26 @@ func getQueryOperator(r *http.Request, v string, tableName string) string {
192
192
if strings .HasSuffix (v , "__gt" ) {
193
193
if n {
194
194
return strings .TrimSuffix (v , "__gt" ) + "` <= ?"
195
- } else {
196
- return strings .TrimSuffix (v , "__gt" ) + "` > ?"
197
195
}
196
+ return strings .TrimSuffix (v , "__gt" ) + "` > ?"
198
197
}
199
198
if strings .HasSuffix (v , "__gte" ) {
200
199
if n {
201
200
return strings .TrimSuffix (v , "__gte" ) + "` < ?"
202
- } else {
203
- return strings .TrimSuffix (v , "__gte" ) + "` >= ?"
204
201
}
202
+ return strings .TrimSuffix (v , "__gte" ) + "` >= ?"
205
203
}
206
204
if strings .HasSuffix (v , "__lt" ) {
207
205
if n {
208
206
return strings .TrimSuffix (v , "__lt" ) + "` >= ?"
209
- } else {
210
- return strings .TrimSuffix (v , "__lt" ) + "` < ?"
211
207
}
208
+ return strings .TrimSuffix (v , "__lt" ) + "` < ?"
212
209
}
213
210
if strings .HasSuffix (v , "__lte" ) {
214
211
if n {
215
212
return strings .TrimSuffix (v , "__lte" ) + "` > ?"
216
- } else {
217
- return strings .TrimSuffix (v , "__lte" ) + "` <= ?"
218
213
}
214
+ return strings .TrimSuffix (v , "__lte" ) + "` <= ?"
219
215
}
220
216
if strings .HasSuffix (v , "__in" ) {
221
217
return strings .TrimSuffix (v , "__in" ) + nTerm + "` IN (?)"
@@ -278,9 +274,8 @@ func getQueryArg(k, v string) []interface{} {
278
274
if strings .HasSuffix (k , "__is" ) {
279
275
if strings .ToUpper (v ) == "NULL" {
280
276
return []interface {}{interface {}(nil )}
281
- } else {
282
- return []interface {}{v }
283
277
}
278
+ return []interface {}{v }
284
279
}
285
280
if strings .HasSuffix (k , "__contains" ) {
286
281
return []interface {}{"%" + v + "%" }
@@ -667,102 +662,137 @@ func returnDAPIJSON(w http.ResponseWriter, r *http.Request, a map[string]interfa
667
662
return nil
668
663
}
669
664
665
+ // APILogReader is an interface for models to control loggin their read function in dAPI
670
666
type APILogReader interface {
671
667
APILogRead (* http.Request ) bool
672
668
}
673
669
670
+ // APILogEditor is an interface for models to control loggin their edit function in dAPI
674
671
type APILogEditor interface {
675
672
APILogEdit (* http.Request ) bool
676
673
}
677
674
675
+ // APILogAdder is an interface for models to control loggin their add function in dAPI
678
676
type APILogAdder interface {
679
677
APILogAdd (* http.Request ) bool
680
678
}
681
679
680
+ // APILogDeleter is an interface for models to control loggin their delete function in dAPI
682
681
type APILogDeleter interface {
683
682
APILogDelete (* http.Request ) bool
684
683
}
685
684
685
+ // APILogSchemer is an interface for models to control loggin their schema function in dAPI
686
686
type APILogSchemer interface {
687
687
APILogSchema (* http.Request ) bool
688
688
}
689
689
690
+ // APIPublicReader is an interface for models to control public access to read function in dAPI
690
691
type APIPublicReader interface {
691
692
APIPublicRead (* http.Request ) bool
692
693
}
693
694
695
+ // APIPublicEditor is an interface for models to control public access to read function in dAPI
694
696
type APIPublicEditor interface {
695
697
APIPublicEdit (* http.Request ) bool
696
698
}
697
699
700
+ // APIPublicAdder is an interface for models to control public access to add function in dAPI
698
701
type APIPublicAdder interface {
699
702
APIPublicAdd (* http.Request ) bool
700
703
}
701
704
705
+ // APIPublicDeleter is an interface for models to control public access to delete function in dAPI
702
706
type APIPublicDeleter interface {
703
707
APIPublicDelete (* http.Request ) bool
704
708
}
705
709
710
+ // APIPublicSchemer is an interface for models to control public access to schema function in dAPI
706
711
type APIPublicSchemer interface {
707
712
APIPublicSchema (* http.Request ) bool
708
713
}
709
714
715
+ // APIDisabledReader is an interface for models to disable access to read function in dAPI
710
716
type APIDisabledReader interface {
711
717
APIDisabledRead (* http.Request ) bool
712
718
}
713
719
720
+ // APIDisabledEditor is an interface for models to disable access to edit function in dAPI
714
721
type APIDisabledEditor interface {
715
722
APIDisabledEdit (* http.Request ) bool
716
723
}
717
724
725
+ // APIDisabledAdder is an interface for models to disable access to add function in dAPI
718
726
type APIDisabledAdder interface {
719
727
APIDisabledAdd (* http.Request ) bool
720
728
}
721
729
730
+ // APIDisabledDeleter is an interface for models to disable access to delete function in dAPI
722
731
type APIDisabledDeleter interface {
723
732
APIDisabledDelete (* http.Request ) bool
724
733
}
725
734
735
+ // APIDisabledSchemer is an interface for models to disable access to schema function in dAPI
726
736
type APIDisabledSchemer interface {
727
737
APIDisabledSchema (* http.Request ) bool
728
738
}
729
739
740
+ // APIPreQueryReader is an interface for models to run before processing read function in dAPI.
741
+ // Returning false stops the rest of the process from happening
730
742
type APIPreQueryReader interface {
731
743
APIPreQueryRead (http.ResponseWriter , * http.Request ) bool
732
744
}
733
745
746
+ // APIPostQueryReader is an interface for models to run after processing read function in dAPI
747
+ // and before returning the results. Returning false stops the rest of the process from happening
734
748
type APIPostQueryReader interface {
735
749
APIPostQueryRead (http.ResponseWriter , * http.Request , map [string ]interface {}) bool
736
750
}
737
751
752
+ // APIPreQueryAdder is an interface for models to run before processing add function in dAPI.
753
+ // Returning false stops the rest of the process from happening
738
754
type APIPreQueryAdder interface {
739
755
APIPreQueryAdd (http.ResponseWriter , * http.Request ) bool
740
756
}
741
757
758
+ // APIPostQueryAdder is an interface for models to run after processing add function in dAPI
759
+ // and before returning the results. Returning false stops the rest of the process from happening
742
760
type APIPostQueryAdder interface {
743
761
APIPostQueryAdd (http.ResponseWriter , * http.Request , map [string ]interface {}) bool
744
762
}
745
763
764
+ // APIPreQueryEditor is an interface for models to run before processing edit function in dAPI.
765
+ // Returning false stops the rest of the process from happening
746
766
type APIPreQueryEditor interface {
747
767
APIPreQueryEdit (http.ResponseWriter , * http.Request ) bool
748
768
}
749
769
770
+ // APIPostQueryEditor is an interface for models to run after processing edit function in dAPI
771
+ // and before returning the results. Returning false stops the rest of the process from happening
750
772
type APIPostQueryEditor interface {
751
773
APIPostQueryEdit (http.ResponseWriter , * http.Request , map [string ]interface {}) bool
752
774
}
753
775
776
+ // APIPreQueryDeleter is an interface for models to run before processing delete function in dAPI.
777
+ // Returning false stops the rest of the process from happening
754
778
type APIPreQueryDeleter interface {
755
779
APIPreQueryDelete (http.ResponseWriter , * http.Request ) bool
756
780
}
757
781
782
+ // APIPostQueryDeleter is an interface for models to run after processing delete function in dAPI
783
+ // and before returning the results. Returning false stops the rest of the process from happening
758
784
type APIPostQueryDeleter interface {
759
785
APIPostQueryDelete (http.ResponseWriter , * http.Request , map [string ]interface {}) bool
760
786
}
761
787
788
+ // APIPreQuerySchemer is an interface for models to run before processing schema function in dAPI.
789
+ // Returning false stops the rest of the process from happening
762
790
type APIPreQuerySchemer interface {
763
791
APIPreQuerySchema (http.ResponseWriter , * http.Request ) bool
764
792
}
765
793
794
+ // APIPostQuerySchemer is an interface for models to run after processing schema function in dAPI
795
+ // and before returning the results. Returning false stops the rest of the process from happening
766
796
type APIPostQuerySchemer interface {
767
797
APIPostQuerySchema (http.ResponseWriter , * http.Request , map [string ]interface {}) bool
768
798
}
0 commit comments