sawa 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.project +11 -0
- data/README.md +59 -36
- data/bin/sawa +82 -82
- data/lib/sawa/MiniProperty.rb +78 -78
- data/lib/sawa/MiniResource.rb +100 -100
- data/lib/sawa/MiniSheet.rb +191 -191
- data/lib/sawa/MiniWork.rb +31 -31
- data/lib/sawa/tpl/api.mustache +40 -40
- data/lib/sawa/tpl/app.js.mustache +2 -3
- data/lib/sawa/tpl/crud.mustache +30 -30
- data/lib/sawa/tpl/dao.mustache +13 -13
- data/lib/sawa/tpl/model.mustache +56 -56
- data/lib/sawa/tpl/property.mustache +10 -10
- data/lib/sawa/tpl/resource.mustache +47 -47
- data/lib/sawa/version.rb +1 -1
- data/sawa-0.0.4.gem +0 -0
- metadata +5 -4
- data/sawa-0.0.3.gem +0 -0
data/lib/sawa/MiniSheet.rb
CHANGED
|
@@ -1,192 +1,192 @@
|
|
|
1
|
-
require 'mustache'
|
|
2
|
-
require 'spreadsheet'
|
|
3
|
-
require 'sawa/MiniProperty.rb'
|
|
4
|
-
require 'sawa/MiniResource.rb'
|
|
5
|
-
|
|
6
|
-
class MiniSheet < Mustache
|
|
7
|
-
|
|
8
|
-
def initialize(sheet, config)
|
|
9
|
-
@sheet = sheet
|
|
10
|
-
@config = config
|
|
11
|
-
@idx_path = 2
|
|
12
|
-
@idx_title = 3
|
|
13
|
-
@idx_method = 1
|
|
14
|
-
@idx_process = 2
|
|
15
|
-
@idx_role = 3
|
|
16
|
-
@idx_type = 1
|
|
17
|
-
@idx_name = 2
|
|
18
|
-
@idx_unique = 3
|
|
19
|
-
@idx_nullable = 4
|
|
20
|
-
@idx_jsonignore = 5
|
|
21
|
-
@idx_mtitle = 6
|
|
22
|
-
@idx_mappedBy = 7
|
|
23
|
-
@idx_refColumn = 8
|
|
24
|
-
@idx_isList = 5
|
|
25
|
-
@idx_param = 6
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def name
|
|
29
|
-
@sheet.name
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def rows_model
|
|
33
|
-
get_model_rows(@sheet)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def rows_path
|
|
37
|
-
get_path_rows(@sheet)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def package_api
|
|
41
|
-
@config['packageApi']
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def package_dao
|
|
45
|
-
@config['packageDao']
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def package_model
|
|
49
|
-
@config['packageModel']
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def package_resource
|
|
53
|
-
@config['packageResource']
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def table_name
|
|
57
|
-
@sheet.name
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def model_name
|
|
61
|
-
getName("model", @sheet.name)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def resource_path
|
|
65
|
-
@sheet.row(0)[@idx_path]
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def model_title
|
|
69
|
-
@sheet.row(0)[@idx_title]
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def dao_name
|
|
73
|
-
getName("dao", @sheet.name)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def resource_name
|
|
77
|
-
getName("resource", @sheet.name)
|
|
78
|
-
end
|
|
79
|
-
def page_name
|
|
80
|
-
getName("page", @sheet.name)
|
|
81
|
-
end
|
|
82
|
-
def api_name
|
|
83
|
-
getName("if", @sheet.name)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def model_property_metas
|
|
87
|
-
arr = []
|
|
88
|
-
@sheet.each do |row|
|
|
89
|
-
if row[0] == "m" and row[@idx_jsonignore] == "1"
|
|
90
|
-
arr.push "#{@sheet.row(0)[@idx_path]}.#{row[@idx_name]}=#{row[@idx_type]},#{row[@idx_nullable]},#{row[@idx_mtitle]}"
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
arr
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def model_imports
|
|
97
|
-
arr = []
|
|
98
|
-
@sheet.each do |row|
|
|
99
|
-
if row[0] != "m"
|
|
100
|
-
next
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
if row[@idx_jsonignore] == "1" and !arr.include?("import com.fasterxml.jackson.annotation.JsonIgnore;")
|
|
104
|
-
arr.push "import com.fasterxml.jackson.annotation.JsonIgnore;"
|
|
105
|
-
end
|
|
106
|
-
if row[@idx_mappedBy] == "1:n" and !arr.include?("import javax.persistence.OneToMany;")
|
|
107
|
-
arr.push "import javax.persistence.OneToMany;"
|
|
108
|
-
end
|
|
109
|
-
if row[@idx_mappedBy] == "1:n" and !arr.include?("import com.fasterxml.jackson.annotation.JsonManagedReference;")
|
|
110
|
-
arr.push "import com.fasterxml.jackson.annotation.JsonManagedReference;"
|
|
111
|
-
end
|
|
112
|
-
if row[@idx_mappedBy] == "1:n" and !arr.include?("import org.hibernate.annotations.Where;")
|
|
113
|
-
arr.push "import org.hibernate.annotations.Where;"
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
if row[@idx_mappedBy] == "n:1" and !arr.include?("import javax.persistence.ManyToOne;")
|
|
117
|
-
arr.push "import javax.persistence.ManyToOne;"
|
|
118
|
-
end
|
|
119
|
-
if row[@idx_mappedBy] == "n:1" and !arr.include?("import com.fasterxml.jackson.annotation.JsonBackReference;")
|
|
120
|
-
arr.push "import com.fasterxml.jackson.annotation.JsonBackReference;"
|
|
121
|
-
end
|
|
122
|
-
if row[@idx_mappedBy] == "n:1" and !arr.include?("import javax.persistence.JoinColumn;")
|
|
123
|
-
arr.push "import javax.persistence.JoinColumn;"
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
if row[@idx_mappedBy] == "1:1" and !arr.include?("import javax.persistence.OneToOne;")
|
|
127
|
-
arr.push "import javax.persistence.OneToOne;"
|
|
128
|
-
end
|
|
129
|
-
if row[@idx_mappedBy] == "1:1" and !arr.include?("import javax.persistence.JoinColumn;")
|
|
130
|
-
arr.push "import javax.persistence.JoinColumn;"
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
arr
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def resource_imports
|
|
137
|
-
arr = []
|
|
138
|
-
@sheet.each do |row|
|
|
139
|
-
if row[0] != "p"
|
|
140
|
-
next
|
|
141
|
-
end
|
|
142
|
-
if row[@idx_jsonignore] == "1" and !arr.include?("import java.util.List;")
|
|
143
|
-
arr.push "import java.util.List;"
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
arr
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def api_imports
|
|
150
|
-
arr = []
|
|
151
|
-
@sheet.each do |row|
|
|
152
|
-
if row[0] != "p"
|
|
153
|
-
next
|
|
154
|
-
end
|
|
155
|
-
if row[@idx_isList] == "1" and !arr.include?("import java.util.List;")
|
|
156
|
-
arr.push "import java.util.List;"
|
|
157
|
-
end
|
|
158
|
-
if row[@idx_param].include?("@role") and !arr.include?("import io.dropwizard.auth.Auth;")
|
|
159
|
-
arr.push "import io.dropwizard.auth.Auth;"
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
arr
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
private
|
|
166
|
-
def getName(type, sheetName)
|
|
167
|
-
perfix = sheetName.split("_")
|
|
168
|
-
perfix[0].capitalize + perfix[1].capitalize + type.capitalize
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
private
|
|
172
|
-
def get_model_rows(sheet)
|
|
173
|
-
rows_model = []
|
|
174
|
-
sheet.each do |row|
|
|
175
|
-
if row[0] == "m"
|
|
176
|
-
rows_model.push(MiniProperty.new(row, self))
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
rows_model
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
private
|
|
183
|
-
def get_path_rows(sheet)
|
|
184
|
-
rows_path = []
|
|
185
|
-
sheet.each do |row|
|
|
186
|
-
if row[0] == "p"
|
|
187
|
-
rows_path.push(MiniResource.new(row, self))
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
rows_path
|
|
191
|
-
end
|
|
1
|
+
require 'mustache'
|
|
2
|
+
require 'spreadsheet'
|
|
3
|
+
require 'sawa/MiniProperty.rb'
|
|
4
|
+
require 'sawa/MiniResource.rb'
|
|
5
|
+
|
|
6
|
+
class MiniSheet < Mustache
|
|
7
|
+
|
|
8
|
+
def initialize(sheet, config)
|
|
9
|
+
@sheet = sheet
|
|
10
|
+
@config = config
|
|
11
|
+
@idx_path = 2
|
|
12
|
+
@idx_title = 3
|
|
13
|
+
@idx_method = 1
|
|
14
|
+
@idx_process = 2
|
|
15
|
+
@idx_role = 3
|
|
16
|
+
@idx_type = 1
|
|
17
|
+
@idx_name = 2
|
|
18
|
+
@idx_unique = 3
|
|
19
|
+
@idx_nullable = 4
|
|
20
|
+
@idx_jsonignore = 5
|
|
21
|
+
@idx_mtitle = 6
|
|
22
|
+
@idx_mappedBy = 7
|
|
23
|
+
@idx_refColumn = 8
|
|
24
|
+
@idx_isList = 5
|
|
25
|
+
@idx_param = 6
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def name
|
|
29
|
+
@sheet.name
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def rows_model
|
|
33
|
+
get_model_rows(@sheet)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def rows_path
|
|
37
|
+
get_path_rows(@sheet)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def package_api
|
|
41
|
+
@config['packageApi']
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def package_dao
|
|
45
|
+
@config['packageDao']
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def package_model
|
|
49
|
+
@config['packageModel']
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def package_resource
|
|
53
|
+
@config['packageResource']
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def table_name
|
|
57
|
+
@sheet.name
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def model_name
|
|
61
|
+
getName("model", @sheet.name)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def resource_path
|
|
65
|
+
@sheet.row(0)[@idx_path]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def model_title
|
|
69
|
+
@sheet.row(0)[@idx_title]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def dao_name
|
|
73
|
+
getName("dao", @sheet.name)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def resource_name
|
|
77
|
+
getName("resource", @sheet.name)
|
|
78
|
+
end
|
|
79
|
+
def page_name
|
|
80
|
+
getName("page", @sheet.name)
|
|
81
|
+
end
|
|
82
|
+
def api_name
|
|
83
|
+
getName("if", @sheet.name)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def model_property_metas
|
|
87
|
+
arr = []
|
|
88
|
+
@sheet.each do |row|
|
|
89
|
+
if row[0] == "m" and row[@idx_jsonignore] == "1"
|
|
90
|
+
arr.push "#{@sheet.row(0)[@idx_path]}.#{row[@idx_name]}=#{row[@idx_type]},#{row[@idx_nullable]},#{row[@idx_mtitle]}"
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
arr
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def model_imports
|
|
97
|
+
arr = []
|
|
98
|
+
@sheet.each do |row|
|
|
99
|
+
if row[0] != "m"
|
|
100
|
+
next
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
if row[@idx_jsonignore] == "1" and !arr.include?("import com.fasterxml.jackson.annotation.JsonIgnore;")
|
|
104
|
+
arr.push "import com.fasterxml.jackson.annotation.JsonIgnore;"
|
|
105
|
+
end
|
|
106
|
+
if row[@idx_mappedBy] == "1:n" and !arr.include?("import javax.persistence.OneToMany;")
|
|
107
|
+
arr.push "import javax.persistence.OneToMany;"
|
|
108
|
+
end
|
|
109
|
+
if row[@idx_mappedBy] == "1:n" and !arr.include?("import com.fasterxml.jackson.annotation.JsonManagedReference;")
|
|
110
|
+
arr.push "import com.fasterxml.jackson.annotation.JsonManagedReference;"
|
|
111
|
+
end
|
|
112
|
+
if row[@idx_mappedBy] == "1:n" and !arr.include?("import org.hibernate.annotations.Where;")
|
|
113
|
+
arr.push "import org.hibernate.annotations.Where;"
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
if row[@idx_mappedBy] == "n:1" and !arr.include?("import javax.persistence.ManyToOne;")
|
|
117
|
+
arr.push "import javax.persistence.ManyToOne;"
|
|
118
|
+
end
|
|
119
|
+
if row[@idx_mappedBy] == "n:1" and !arr.include?("import com.fasterxml.jackson.annotation.JsonBackReference;")
|
|
120
|
+
arr.push "import com.fasterxml.jackson.annotation.JsonBackReference;"
|
|
121
|
+
end
|
|
122
|
+
if row[@idx_mappedBy] == "n:1" and !arr.include?("import javax.persistence.JoinColumn;")
|
|
123
|
+
arr.push "import javax.persistence.JoinColumn;"
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
if row[@idx_mappedBy] == "1:1" and !arr.include?("import javax.persistence.OneToOne;")
|
|
127
|
+
arr.push "import javax.persistence.OneToOne;"
|
|
128
|
+
end
|
|
129
|
+
if row[@idx_mappedBy] == "1:1" and !arr.include?("import javax.persistence.JoinColumn;")
|
|
130
|
+
arr.push "import javax.persistence.JoinColumn;"
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
arr
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def resource_imports
|
|
137
|
+
arr = []
|
|
138
|
+
@sheet.each do |row|
|
|
139
|
+
if row[0] != "p"
|
|
140
|
+
next
|
|
141
|
+
end
|
|
142
|
+
if row[@idx_jsonignore] == "1" and !arr.include?("import java.util.List;")
|
|
143
|
+
arr.push "import java.util.List;"
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
arr
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def api_imports
|
|
150
|
+
arr = []
|
|
151
|
+
@sheet.each do |row|
|
|
152
|
+
if row[0] != "p"
|
|
153
|
+
next
|
|
154
|
+
end
|
|
155
|
+
if row[@idx_isList] == "1" and !arr.include?("import java.util.List;")
|
|
156
|
+
arr.push "import java.util.List;"
|
|
157
|
+
end
|
|
158
|
+
if row[@idx_param].include?("@role") and !arr.include?("import io.dropwizard.auth.Auth;")
|
|
159
|
+
arr.push "import io.dropwizard.auth.Auth;"
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
arr
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
private
|
|
166
|
+
def getName(type, sheetName)
|
|
167
|
+
perfix = sheetName.split("_")
|
|
168
|
+
perfix[0].capitalize + perfix[1].capitalize + type.capitalize
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
private
|
|
172
|
+
def get_model_rows(sheet)
|
|
173
|
+
rows_model = []
|
|
174
|
+
sheet.each do |row|
|
|
175
|
+
if row[0] == "m"
|
|
176
|
+
rows_model.push(MiniProperty.new(row, self))
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
rows_model
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
private
|
|
183
|
+
def get_path_rows(sheet)
|
|
184
|
+
rows_path = []
|
|
185
|
+
sheet.each do |row|
|
|
186
|
+
if row[0] == "p"
|
|
187
|
+
rows_path.push(MiniResource.new(row, self))
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
rows_path
|
|
191
|
+
end
|
|
192
192
|
end
|
data/lib/sawa/MiniWork.rb
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
# coding: UTF-8
|
|
2
|
-
require 'spreadsheet'
|
|
3
|
-
require 'mustache'
|
|
4
|
-
require 'sawa/MiniSheet.rb'
|
|
5
|
-
|
|
6
|
-
class MiniWork < Mustache
|
|
7
|
-
|
|
8
|
-
def initialize(file, config)
|
|
9
|
-
@book = Spreadsheet.open(file, 'r')
|
|
10
|
-
@sheets = Hash.new()
|
|
11
|
-
@book.worksheets.each do |sheet|
|
|
12
|
-
@sheets[sheet.name] = MiniSheet.new(sheet, config)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def sheets
|
|
17
|
-
@sheets
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def sheet_arr
|
|
21
|
-
arr = []
|
|
22
|
-
@sheets.each do |name, sheet|
|
|
23
|
-
arr.push(sheet)
|
|
24
|
-
end
|
|
25
|
-
arr
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def sheet(name)
|
|
29
|
-
@sheets[name]
|
|
30
|
-
end
|
|
31
|
-
|
|
1
|
+
# coding: UTF-8
|
|
2
|
+
require 'spreadsheet'
|
|
3
|
+
require 'mustache'
|
|
4
|
+
require 'sawa/MiniSheet.rb'
|
|
5
|
+
|
|
6
|
+
class MiniWork < Mustache
|
|
7
|
+
|
|
8
|
+
def initialize(file, config)
|
|
9
|
+
@book = Spreadsheet.open(file, 'r')
|
|
10
|
+
@sheets = Hash.new()
|
|
11
|
+
@book.worksheets.each do |sheet|
|
|
12
|
+
@sheets[sheet.name] = MiniSheet.new(sheet, config)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def sheets
|
|
17
|
+
@sheets
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def sheet_arr
|
|
21
|
+
arr = []
|
|
22
|
+
@sheets.each do |name, sheet|
|
|
23
|
+
arr.push(sheet)
|
|
24
|
+
end
|
|
25
|
+
arr
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def sheet(name)
|
|
29
|
+
@sheets[name]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
32
|
end
|
data/lib/sawa/tpl/api.mustache
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
package {{package_api}};
|
|
2
|
-
|
|
3
|
-
import javax.ws.rs.*;
|
|
4
|
-
import javax.ws.rs.core.MediaType;
|
|
5
|
-
|
|
6
|
-
import javax.annotation.security.RolesAllowed;
|
|
7
|
-
import {{package_model}}.{{model_name}};
|
|
8
|
-
import com.jialu.sawa.vo.*;
|
|
9
|
-
|
|
10
|
-
{{# api_imports}}
|
|
11
|
-
{{.}}
|
|
12
|
-
{{/ api_imports}}
|
|
13
|
-
|
|
14
|
-
import io.dropwizard.hibernate.UnitOfWork;
|
|
15
|
-
|
|
16
|
-
@Path("{{resource_path}}")
|
|
17
|
-
public interface {{api_name}} {
|
|
18
|
-
|
|
19
|
-
{{# rows_path}}
|
|
20
|
-
/**
|
|
21
|
-
* {{resource_desc}}
|
|
22
|
-
*/
|
|
23
|
-
@{{resource_httpM}}
|
|
24
|
-
@UnitOfWork
|
|
25
|
-
@Path("{{{resource_path}}}")
|
|
26
|
-
@Consumes(MediaType.APPLICATION_JSON)
|
|
27
|
-
@Produces(MediaType.APPLICATION_JSON)
|
|
28
|
-
{{# resource_role}}
|
|
29
|
-
@RolesAllowed({ {{{.}}} })
|
|
30
|
-
{{/ resource_role}}
|
|
31
|
-
{{# resource_islist}}
|
|
32
|
-
public abstract OperatorResult<List<{{model_name}}>> {{resource_method}}({{{resource_param_full}}});
|
|
33
|
-
{{/ resource_islist}}
|
|
34
|
-
{{^ resource_islist}}
|
|
35
|
-
public abstract OperatorResult<{{model_name}}> {{resource_method}}({{{resource_param_full}}});
|
|
36
|
-
{{/ resource_islist}}
|
|
37
|
-
{{/ rows_path}}
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
1
|
+
package {{package_api}};
|
|
2
|
+
|
|
3
|
+
import javax.ws.rs.*;
|
|
4
|
+
import javax.ws.rs.core.MediaType;
|
|
5
|
+
|
|
6
|
+
import javax.annotation.security.RolesAllowed;
|
|
7
|
+
import {{package_model}}.{{model_name}};
|
|
8
|
+
import com.jialu.sawa.vo.*;
|
|
9
|
+
|
|
10
|
+
{{# api_imports}}
|
|
11
|
+
{{.}}
|
|
12
|
+
{{/ api_imports}}
|
|
13
|
+
|
|
14
|
+
import io.dropwizard.hibernate.UnitOfWork;
|
|
15
|
+
|
|
16
|
+
@Path("{{resource_path}}")
|
|
17
|
+
public interface {{api_name}} {
|
|
18
|
+
|
|
19
|
+
{{# rows_path}}
|
|
20
|
+
/**
|
|
21
|
+
* {{resource_desc}}
|
|
22
|
+
*/
|
|
23
|
+
@{{resource_httpM}}
|
|
24
|
+
@UnitOfWork
|
|
25
|
+
@Path("{{{resource_path}}}")
|
|
26
|
+
@Consumes(MediaType.APPLICATION_JSON)
|
|
27
|
+
@Produces(MediaType.APPLICATION_JSON)
|
|
28
|
+
{{# resource_role}}
|
|
29
|
+
@RolesAllowed({ {{{.}}} })
|
|
30
|
+
{{/ resource_role}}
|
|
31
|
+
{{# resource_islist}}
|
|
32
|
+
public abstract OperatorResult<List<{{model_name}}>> {{resource_method}}({{{resource_param_full}}});
|
|
33
|
+
{{/ resource_islist}}
|
|
34
|
+
{{^ resource_islist}}
|
|
35
|
+
public abstract OperatorResult<{{model_name}}> {{resource_method}}({{{resource_param_full}}});
|
|
36
|
+
{{/ resource_islist}}
|
|
37
|
+
{{/ rows_path}}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
Route,
|
|
11
11
|
Link
|
|
12
12
|
} from 'react-router-dom'
|
|
13
|
-
import { Menu, Divider, Header } from 'semantic-ui-react'
|
|
13
|
+
import { Menu, Divider, Header,Image } from 'semantic-ui-react'
|
|
14
14
|
|
|
15
15
|
class App extends Component {
|
|
16
16
|
state = {webSocket: null, user:null, users: [], login:false}
|
|
@@ -50,7 +50,7 @@ class App extends Component {
|
|
|
50
50
|
<Router>
|
|
51
51
|
<div className="body">
|
|
52
52
|
<Link to='/'>
|
|
53
|
-
<Header
|
|
53
|
+
<Header><Image src='https://s3-ap-northeast-1.amazonaws.com/ms17222/whale64.png' size='tiny' wrapped verticalAlign='bottom'/><span>�N�W��-�f�[�^</span></Header>
|
|
54
54
|
</Link>
|
|
55
55
|
<Menu>
|
|
56
56
|
{{# sheet_arr}}
|
|
@@ -63,7 +63,6 @@ class App extends Component {
|
|
|
63
63
|
{{# sheet_arr}}
|
|
64
64
|
<Route path='/{{resource_path}}' component={ {{page_name}} }/>
|
|
65
65
|
{{/ sheet_arr}}
|
|
66
|
-
<Route path='/online' render={() => <Online webSocket={this.state.webSocket} users={this.state.users} onlineChange={this.onlineChange.bind(this)}/>}/>
|
|
67
66
|
</div>
|
|
68
67
|
</Router>
|
|
69
68
|
);
|
data/lib/sawa/tpl/crud.mustache
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
<?xml version="1.0"?>
|
|
2
|
-
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
|
3
|
-
"http://hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
|
4
|
-
|
|
5
|
-
<hibernate-mapping>
|
|
6
|
-
{{# sheet_arr}}
|
|
7
|
-
|
|
8
|
-
<query name="{{table_name}}">
|
|
9
|
-
<![CDATA[FROM {{model_name}} e WHERE e.deleted = 0 ORDER BY e.utime DESC]]>
|
|
10
|
-
</query>
|
|
11
|
-
<query name="{{table_name}}-id">
|
|
12
|
-
<![CDATA[FROM {{model_name}} e WHERE e.deleted = 0 and e.id = :id ORDER BY e.utime DESC]]>
|
|
13
|
-
</query>
|
|
14
|
-
<query name="{{table_name}}-cuser">
|
|
15
|
-
<![CDATA[FROM {{model_name}} e WHERE e.deleted = 0 and e.cuser = :cuser ORDER BY e.utime DESC]]>
|
|
16
|
-
</query>
|
|
17
|
-
<query name="{{table_name}}-uuser">
|
|
18
|
-
<![CDATA[FROM {{model_name}} e WHERE e.deleted = 0 and e.uuser = :uuser ORDER BY e.utime DESC]]>
|
|
19
|
-
</query>
|
|
20
|
-
<query name="{{table_name}}-deleted">
|
|
21
|
-
<![CDATA[FROM {{model_name}} e WHERE e.deleted = :deleted ORDER BY e.utime DESC]]>
|
|
22
|
-
</query>
|
|
23
|
-
{{# rows_model}}
|
|
24
|
-
{{# is_column}}
|
|
25
|
-
<query name="{{table_name}}-{{name}}">
|
|
26
|
-
<![CDATA[FROM {{model_name}} e WHERE e.deleted = 0 and e.{{name}} = :{{name}} ORDER BY e.utime DESC]]>
|
|
27
|
-
</query>
|
|
28
|
-
{{/is_column}}
|
|
29
|
-
{{/ rows_model}}
|
|
30
|
-
{{/ sheet_arr}}
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
|
3
|
+
"http://hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
|
4
|
+
|
|
5
|
+
<hibernate-mapping>
|
|
6
|
+
{{# sheet_arr}}
|
|
7
|
+
|
|
8
|
+
<query name="{{table_name}}">
|
|
9
|
+
<![CDATA[FROM {{model_name}} e WHERE e.deleted = 0 ORDER BY e.utime DESC]]>
|
|
10
|
+
</query>
|
|
11
|
+
<query name="{{table_name}}-id">
|
|
12
|
+
<![CDATA[FROM {{model_name}} e WHERE e.deleted = 0 and e.id = :id ORDER BY e.utime DESC]]>
|
|
13
|
+
</query>
|
|
14
|
+
<query name="{{table_name}}-cuser">
|
|
15
|
+
<![CDATA[FROM {{model_name}} e WHERE e.deleted = 0 and e.cuser = :cuser ORDER BY e.utime DESC]]>
|
|
16
|
+
</query>
|
|
17
|
+
<query name="{{table_name}}-uuser">
|
|
18
|
+
<![CDATA[FROM {{model_name}} e WHERE e.deleted = 0 and e.uuser = :uuser ORDER BY e.utime DESC]]>
|
|
19
|
+
</query>
|
|
20
|
+
<query name="{{table_name}}-deleted">
|
|
21
|
+
<![CDATA[FROM {{model_name}} e WHERE e.deleted = :deleted ORDER BY e.utime DESC]]>
|
|
22
|
+
</query>
|
|
23
|
+
{{# rows_model}}
|
|
24
|
+
{{# is_column}}
|
|
25
|
+
<query name="{{table_name}}-{{name}}">
|
|
26
|
+
<![CDATA[FROM {{model_name}} e WHERE e.deleted = 0 and e.{{name}} = :{{name}} ORDER BY e.utime DESC]]>
|
|
27
|
+
</query>
|
|
28
|
+
{{/is_column}}
|
|
29
|
+
{{/ rows_model}}
|
|
30
|
+
{{/ sheet_arr}}
|
|
31
31
|
</hibernate-mapping>
|
data/lib/sawa/tpl/dao.mustache
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
package {{package_dao}};
|
|
2
|
-
|
|
3
|
-
import org.hibernate.SessionFactory;
|
|
4
|
-
|
|
5
|
-
import {{package_model}}.{{model_name}};
|
|
6
|
-
import com.jialu.sawa.utility.MiniDao;
|
|
7
|
-
|
|
8
|
-
public class {{dao_name}} extends MiniDao<{{model_name}}> {
|
|
9
|
-
|
|
10
|
-
public {{dao_name}}(SessionFactory factory) {
|
|
11
|
-
super(factory);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
package {{package_dao}};
|
|
2
|
+
|
|
3
|
+
import org.hibernate.SessionFactory;
|
|
4
|
+
|
|
5
|
+
import {{package_model}}.{{model_name}};
|
|
6
|
+
import com.jialu.sawa.utility.MiniDao;
|
|
7
|
+
|
|
8
|
+
public class {{dao_name}} extends MiniDao<{{model_name}}> {
|
|
9
|
+
|
|
10
|
+
public {{dao_name}}(SessionFactory factory) {
|
|
11
|
+
super(factory);
|
|
12
|
+
}
|
|
13
|
+
}
|