added deleting locations
This commit is contained in:
parent
bd0cdd681f
commit
a0bcaeb59e
@ -142,7 +142,7 @@ public class AdminController extends CommonController {
|
|||||||
LOGGER.error("error {}: {}", error.getCode(), error.getDefaultMessage());
|
LOGGER.error("error {}: {}", error.getCode(), error.getDefaultMessage());
|
||||||
return "/admin/location_edit";
|
return "/admin/location_edit";
|
||||||
}
|
}
|
||||||
service.updateLocation(bean);
|
service.upsertLocation(bean);
|
||||||
return "redirect:/admin/location";
|
return "redirect:/admin/location";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.jooq.Condition;
|
import org.jooq.Condition;
|
||||||
@ -303,4 +305,26 @@ public class AdminRepository {
|
|||||||
return LocationBean.of(sql.fetchOne());
|
return LocationBean.of(sql.fetchOne());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete the location from the database
|
||||||
|
*
|
||||||
|
* @param id the ID of the location
|
||||||
|
* @return number of affected database rows; should be 1
|
||||||
|
*/
|
||||||
|
public Integer deleteLocation(Integer id) {
|
||||||
|
DeleteConditionStep<TLocationRecord> sql = jooq.deleteFrom(T_LOCATION).where(T_LOCATION.PK.eq(id));
|
||||||
|
LOGGER.debug(sql.toString());
|
||||||
|
return sql.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* upsert the bean; if pk is null, do an insert, an upsert else
|
||||||
|
*
|
||||||
|
* @param bean the bean
|
||||||
|
* @return number of affected database rows; should be 1
|
||||||
|
*/
|
||||||
|
public Integer upsertLocation(@Valid LocationBean bean) {
|
||||||
|
// TODO: implement; respect existing camps that fit to the current camp location.
|
||||||
|
throw new DataAccessException("not yet implemented");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,12 +99,22 @@ public class AdminService {
|
|||||||
return adminRepository.getLocation(id);
|
return adminRepository.getLocation(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLocation(@Valid LocationBean bean) {
|
/**
|
||||||
throw new DataAccessException("not yet implemented");
|
* upsert the bean
|
||||||
|
*
|
||||||
|
* @param bean the bean
|
||||||
|
*/
|
||||||
|
public void upsertLocation(@Valid LocationBean bean) {
|
||||||
|
adminRepository.upsertLocation(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete the location
|
||||||
|
*
|
||||||
|
* @param id the ID of the location
|
||||||
|
*/
|
||||||
public void deleteLocation(Integer id) {
|
public void deleteLocation(Integer id) {
|
||||||
throw new DataAccessException("not yet implemented");
|
adminRepository.deleteLocation(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user