finished location
This commit is contained in:
parent
00a42a35e3
commit
7ced264763
@ -21,6 +21,7 @@ import org.jooq.DeleteConditionStep;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.InsertResultStep;
|
||||
import org.jooq.InsertReturningStep;
|
||||
import org.jooq.InsertValuesStep3;
|
||||
import org.jooq.Record4;
|
||||
import org.jooq.Record5;
|
||||
import org.jooq.SelectConditionStep;
|
||||
@ -324,7 +325,32 @@ public class AdminRepository {
|
||||
* @return number of affected database rows; should be 1
|
||||
*/
|
||||
public Integer upsertLocation(@Valid LocationBean bean) {
|
||||
// TODO: implement
|
||||
throw new DataAccessException("not yet implemented");
|
||||
LambdaResultWrapper lrw = new LambdaResultWrapper();
|
||||
jooq.transaction(t -> {
|
||||
if (bean.getPk() == null) {
|
||||
InsertValuesStep3<TLocationRecord, String, Integer, String> sql = DSL.using(t)
|
||||
// @formatter:off
|
||||
.insertInto(T_LOCATION,
|
||||
T_LOCATION.NAME,
|
||||
T_LOCATION.FK_DOCUMENT,
|
||||
T_LOCATION.URL)
|
||||
.values(bean.getName(), bean.getFkDocument(), bean.getUrl());
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
lrw.add(sql.execute());
|
||||
} else {
|
||||
UpdateConditionStep<TLocationRecord> sql = DSL.using(t)
|
||||
// @formatter:off
|
||||
.update(T_LOCATION)
|
||||
.set(T_LOCATION.NAME, bean.getName())
|
||||
.set(T_LOCATION.FK_DOCUMENT, bean.getFkDocument())
|
||||
.set(T_LOCATION.URL, bean.getUrl())
|
||||
.where(T_LOCATION.PK.eq(bean.getPk()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
lrw.add(sql.execute());
|
||||
}
|
||||
});
|
||||
return lrw.getCounter();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user