質問編集履歴
2
ソースコードの貼り付けを修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -64,12 +64,72 @@
|
|
64
64
|
|
65
65
|
|
66
66
|
|
67
|
+
|
68
|
+
|
69
|
+
```lang-java
|
70
|
+
|
71
|
+
package jp.co.system.thirdbox.action;
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
import javax.annotation.Resource;
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
import org.seasar.framework.beans.util.Beans;
|
80
|
+
|
81
|
+
import org.seasar.struts.annotation.ActionForm;
|
82
|
+
|
83
|
+
import org.seasar.struts.annotation.Execute;
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
import jp.co.system.thirdbox.dto.LoginDto;
|
88
|
+
|
89
|
+
import jp.co.system.thirdbox.entity.Diary;
|
90
|
+
|
91
|
+
import jp.co.system.thirdbox.form.DiaryForm;
|
92
|
+
|
93
|
+
import jp.co.system.thirdbox.service.DiaryService;
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
public class DiaryAction {
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
@Resource
|
102
|
+
|
67
|
-
|
103
|
+
@ActionForm
|
104
|
+
|
68
|
-
|
105
|
+
public DiaryForm diaryForm;
|
106
|
+
|
107
|
+
|
108
|
+
|
69
|
-
|
109
|
+
@Resource
|
110
|
+
|
111
|
+
public LoginDto loginDto;
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
@Resource
|
116
|
+
|
117
|
+
protected DiaryService diaryService;
|
118
|
+
|
119
|
+
|
70
120
|
|
71
121
|
@Execute(validator = false)
|
72
122
|
|
123
|
+
public String index(){
|
124
|
+
|
125
|
+
return "diary.jsp";
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
@Execute(validator = false)
|
132
|
+
|
73
133
|
public String keep(){
|
74
134
|
|
75
135
|
diaryForm.accountId = loginDto.id;
|
@@ -84,13 +144,55 @@
|
|
84
144
|
|
85
145
|
}
|
86
146
|
|
147
|
+
|
148
|
+
|
87
|
-
|
149
|
+
}
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
150
|
+
|
92
|
-
|
151
|
+
|
152
|
+
|
93
|
-
|
153
|
+
```
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
```lang-java
|
158
|
+
|
159
|
+
package jp.co.system.thirdbox.form;
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
import java.io.Serializable;
|
164
|
+
|
165
|
+
import java.sql.Timestamp;
|
166
|
+
|
167
|
+
import java.util.Date;
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
import org.seasar.framework.container.annotation.tiger.Component;
|
172
|
+
|
173
|
+
import org.seasar.framework.container.annotation.tiger.InstanceType;
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
@Component(instance = InstanceType.SESSION)
|
178
|
+
|
179
|
+
public class DiaryForm implements Serializable {
|
180
|
+
|
181
|
+
private static final long serialVersionUID = 1L;
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
/** idプロパティ */
|
186
|
+
|
187
|
+
public Integer id;
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
/** accountIdプロパティ */
|
192
|
+
|
193
|
+
public Integer accountId;
|
194
|
+
|
195
|
+
|
94
196
|
|
95
197
|
/** diaryDayプロパティ */
|
96
198
|
|
@@ -98,25 +200,219 @@
|
|
98
200
|
|
99
201
|
|
100
202
|
|
203
|
+
/** activity1プロパティ */
|
204
|
+
|
205
|
+
public String activity1;
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
/** activity2プロパティ */
|
210
|
+
|
211
|
+
public String activity2;
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
/** activity3プロパティ */
|
216
|
+
|
217
|
+
public String activity3;
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
/** createTimeプロパティ */
|
222
|
+
|
223
|
+
public Timestamp createTime;
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
/** updateTimeプロパティ */
|
228
|
+
|
229
|
+
public Timestamp updateTime;
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
/** deleteFlagプロパティ */
|
234
|
+
|
235
|
+
public Integer deleteFlag;
|
236
|
+
|
101
|
-
|
237
|
+
}
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
238
|
+
|
106
|
-
|
239
|
+
|
240
|
+
|
107
|
-
|
241
|
+
```
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
```lang-java
|
246
|
+
|
247
|
+
package jp.co.system.thirdbox.dto;
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
import java.io.Serializable;
|
252
|
+
|
253
|
+
import java.sql.Timestamp;
|
254
|
+
|
255
|
+
import java.util.Date;
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
import org.seasar.framework.container.annotation.tiger.Component;
|
260
|
+
|
261
|
+
import org.seasar.framework.container.annotation.tiger.InstanceType;
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
@Component(instance = InstanceType.SESSION)
|
266
|
+
|
267
|
+
public class DiaryDto implements Serializable {
|
268
|
+
|
269
|
+
private static final long serialVersionUID = 1L;
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
/** idプロパティ */
|
274
|
+
|
275
|
+
public Integer id;
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
/** accountIdプロパティ */
|
280
|
+
|
281
|
+
public Integer accountId;
|
282
|
+
|
283
|
+
|
108
284
|
|
109
285
|
/** diaryDayプロパティ */
|
110
286
|
|
111
287
|
public Date diaryDay;
|
112
288
|
|
289
|
+
|
290
|
+
|
291
|
+
/** activity1プロパティ */
|
292
|
+
|
293
|
+
public String activity1;
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
/** activity2プロパティ */
|
298
|
+
|
299
|
+
public String activity2;
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
/** activity3プロパティ */
|
304
|
+
|
305
|
+
public String activity3;
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
/** createTimeプロパティ */
|
310
|
+
|
311
|
+
public Timestamp createTime;
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
/** updateTimeプロパティ */
|
316
|
+
|
317
|
+
public Timestamp updateTime;
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
/** deleteFlagプロパティ */
|
322
|
+
|
323
|
+
public Integer deleteFlag;
|
324
|
+
|
325
|
+
|
326
|
+
|
113
|
-
|
327
|
+
}
|
328
|
+
|
329
|
+
|
330
|
+
|
114
|
-
|
331
|
+
```
|
332
|
+
|
333
|
+
|
334
|
+
|
115
|
-
|
335
|
+
```lang-java
|
336
|
+
|
116
|
-
|
337
|
+
package jp.co.system.thirdbox.service;
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
import static jp.co.system.thirdbox.entity.DiaryNames.*;
|
342
|
+
|
343
|
+
import static org.seasar.extension.jdbc.operation.Operations.*;
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
import java.util.List;
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
import javax.annotation.Generated;
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
import jp.co.system.thirdbox.entity.Diary;
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
/**
|
360
|
+
|
117
|
-
|
361
|
+
* {@link Diary}のサービスクラスです。
|
362
|
+
|
118
|
-
|
363
|
+
*
|
364
|
+
|
119
|
-
|
365
|
+
*/
|
366
|
+
|
367
|
+
@Generated(value = {"S2JDBC-Gen 2.4.46", "org.seasar.extension.jdbc.gen.internal.model.ServiceModelFactoryImpl"}, date = "2018/06/06 11:51:06")
|
368
|
+
|
369
|
+
public class DiaryService extends AbstractService<Diary> {
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
/**
|
374
|
+
|
375
|
+
* 識別子でエンティティを検索します。
|
376
|
+
|
377
|
+
*
|
378
|
+
|
379
|
+
* @param id
|
380
|
+
|
381
|
+
* 識別子
|
382
|
+
|
383
|
+
* @return エンティティ
|
384
|
+
|
385
|
+
*/
|
386
|
+
|
387
|
+
public Diary findById(Integer id) {
|
388
|
+
|
389
|
+
return select().id(id).getSingleResult();
|
390
|
+
|
391
|
+
}
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
/**
|
396
|
+
|
397
|
+
* 識別子の昇順ですべてのエンティティを検索します。
|
398
|
+
|
399
|
+
*
|
400
|
+
|
401
|
+
* @return エンティティのリスト
|
402
|
+
|
403
|
+
*/
|
404
|
+
|
405
|
+
public List<Diary> findAllOrderById() {
|
406
|
+
|
407
|
+
return select().orderBy(asc(id())).getResultList();
|
408
|
+
|
409
|
+
}
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
/*日記を1件挿入する*/
|
120
416
|
|
121
417
|
public int diaryInsert(Diary diary){
|
122
418
|
|
@@ -124,4 +420,18 @@
|
|
124
420
|
|
125
421
|
}
|
126
422
|
|
423
|
+
|
424
|
+
|
425
|
+
/* 全日記を取得(新しい順)
|
426
|
+
|
427
|
+
public List<Diary> findAllByaccountId(int accountId){
|
428
|
+
|
429
|
+
return jdbcManager.from(Diary.class).where("account_id = ?",accountId).orderBy(desc("diaryDay")).getResultList();
|
430
|
+
|
431
|
+
}*/
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
|
436
|
+
|
127
|
-
|
437
|
+
```
|
1
ソースコード追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -55,3 +55,73 @@
|
|
55
55
|
postgresql-9.2.24
|
56
56
|
|
57
57
|
※DB用サーバーはなく、上記全て同じサーバー上で動いています
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
### ソースコード
|
62
|
+
|
63
|
+
古いですが、seasar2のフレームワークを使っています。
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
【Actionクラス】
|
68
|
+
|
69
|
+
~抜粋
|
70
|
+
|
71
|
+
@Execute(validator = false)
|
72
|
+
|
73
|
+
public String keep(){
|
74
|
+
|
75
|
+
diaryForm.accountId = loginDto.id;
|
76
|
+
|
77
|
+
Diary diary = new Diary();
|
78
|
+
|
79
|
+
Beans.copy(diaryForm,diary).execute();
|
80
|
+
|
81
|
+
diaryService.diaryInsert(diary);
|
82
|
+
|
83
|
+
return "finish.jsp";
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
~
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
【DiaryFormクラス】
|
92
|
+
|
93
|
+
~抜粋
|
94
|
+
|
95
|
+
/** diaryDayプロパティ */
|
96
|
+
|
97
|
+
public Date diaryDay;
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
~
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
【DiaryDtoクラス】
|
106
|
+
|
107
|
+
~抜粋
|
108
|
+
|
109
|
+
/** diaryDayプロパティ */
|
110
|
+
|
111
|
+
public Date diaryDay;
|
112
|
+
|
113
|
+
~
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
【DiaryServiceクラス】
|
118
|
+
|
119
|
+
~抜粋
|
120
|
+
|
121
|
+
public int diaryInsert(Diary diary){
|
122
|
+
|
123
|
+
return jdbcManager.insert(diary).excludesNull().execute();
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
~
|