parent
8bb9156ac5
commit
4c07bc2b90
@ -0,0 +1,14 @@ |
||||
package de.kreth.clubhelper.model.dao; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
|
||||
public interface ClubhelperDao<T> extends CrudRepository<T, Long> |
||||
{ |
||||
List<T> findByPersonId(long personId); |
||||
|
||||
List<T> findByChangedGreaterThan(Date date); |
||||
} |
||||
@ -0,0 +1,7 @@ |
||||
package de.kreth.clubhelper.model.dao; |
||||
|
||||
import de.kreth.clubhelper.model.data.DeletedEntry; |
||||
|
||||
public interface DeletedEntriesDao extends ClubhelperDao<DeletedEntry> |
||||
{ |
||||
} |
||||
@ -1,9 +1,7 @@ |
||||
package de.kreth.clubhelper.model.dao; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
import de.kreth.clubhelper.model.data.GroupDef; |
||||
|
||||
public interface GroupDao extends CrudRepository<GroupDef, Integer> { |
||||
public interface GroupDao extends ClubhelperDao<GroupDef> { |
||||
|
||||
} |
||||
|
||||
@ -1,11 +1,10 @@ |
||||
package de.kreth.clubhelper.model.dao; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
import org.springframework.stereotype.Repository; |
||||
|
||||
import de.kreth.clubhelper.model.data.Person; |
||||
|
||||
@Repository |
||||
public interface PersonDao extends CrudRepository<Person, Integer> { |
||||
public interface PersonDao extends ClubhelperDao<Person> { |
||||
|
||||
} |
||||
|
||||
@ -0,0 +1,99 @@ |
||||
package de.kreth.clubhelperbackend.aspects; |
||||
|
||||
import org.aspectj.lang.JoinPoint; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
public class AbstractLoggerAspect { |
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass()); |
||||
|
||||
public enum LogLevel { |
||||
WARN, DEBUG, INFO; |
||||
|
||||
boolean enabled(Logger logger) { |
||||
switch (this) { |
||||
case WARN : |
||||
return logger.isWarnEnabled(); |
||||
case DEBUG : |
||||
return logger.isDebugEnabled(); |
||||
case INFO : |
||||
return logger.isInfoEnabled(); |
||||
|
||||
default : |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected void log(LogLevel level, JoinPoint joinPoint) { |
||||
log(level, joinPoint, null); |
||||
} |
||||
|
||||
protected void log(LogLevel level, JoinPoint joinPoint, Object result) { |
||||
|
||||
if (level.enabled(logger)) { |
||||
|
||||
StringBuffer msg = generateLogMessage(joinPoint); |
||||
Exception exception = null; |
||||
|
||||
if (result != null) { |
||||
if (result instanceof Exception) { |
||||
exception = (Exception) result; |
||||
} else { |
||||
msg.append(" ==> ").append(result); |
||||
} |
||||
} |
||||
|
||||
switch (level) { |
||||
case WARN : |
||||
if (exception == null) { |
||||
logger.warn(msg.toString()); |
||||
} else { |
||||
logger.warn(msg.toString(), exception); |
||||
} |
||||
break; |
||||
case DEBUG : |
||||
if (exception == null) { |
||||
logger.debug(msg.toString()); |
||||
} else { |
||||
logger.debug(msg.toString(), exception); |
||||
} |
||||
break; |
||||
case INFO : |
||||
if (exception == null) { |
||||
logger.info(msg.toString()); |
||||
} else { |
||||
logger.info(msg.toString(), exception); |
||||
} |
||||
break; |
||||
default : |
||||
if (exception == null) { |
||||
logger.trace(msg.toString()); |
||||
} else { |
||||
logger.trace(msg.toString(), exception); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected StringBuffer generateLogMessage(JoinPoint joinPoint) { |
||||
StringBuffer logMessage = new StringBuffer(); |
||||
logMessage.append(joinPoint.getTarget().getClass().getName()); |
||||
logMessage.append("."); |
||||
logMessage.append(joinPoint.getSignature().getName()); |
||||
logMessage.append("("); |
||||
// append args
|
||||
Object[] args = joinPoint.getArgs(); |
||||
for (int i = 0; i < args.length; i++) { |
||||
logMessage.append(args[i]).append(","); |
||||
} |
||||
if (args.length > 0) { |
||||
logMessage.deleteCharAt(logMessage.length() - 1); |
||||
} |
||||
|
||||
logMessage.append(")"); |
||||
return logMessage; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,56 @@ |
||||
package de.kreth.clubhelperbackend.aspects; |
||||
|
||||
import static de.kreth.clubhelperbackend.aspects.AbstractLoggerAspect.LogLevel.DEBUG; |
||||
import static de.kreth.clubhelperbackend.aspects.AbstractLoggerAspect.LogLevel.INFO; |
||||
import static de.kreth.clubhelperbackend.aspects.AbstractLoggerAspect.LogLevel.WARN; |
||||
|
||||
import org.aspectj.lang.JoinPoint; |
||||
import org.aspectj.lang.annotation.AfterReturning; |
||||
import org.aspectj.lang.annotation.AfterThrowing; |
||||
import org.aspectj.lang.annotation.Aspect; |
||||
import org.aspectj.lang.annotation.Before; |
||||
import org.aspectj.lang.annotation.Pointcut; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
@Component |
||||
@Aspect |
||||
public class ControllerLoggerAspect extends AbstractLoggerAspect { |
||||
|
||||
@Pointcut("execution (public * de.kreth.clubhelperbackend.controller..*.delete(..))") |
||||
private void deleteItem() { |
||||
} |
||||
|
||||
@Pointcut("execution (public * de.kreth.clubhelperbackend.controller..*(..))") |
||||
private void callAny() { |
||||
} |
||||
|
||||
@Pointcut("callAny() && (!deleteItem())") |
||||
private void invocation() { |
||||
} |
||||
|
||||
@Before("invocation()") |
||||
public void logDao(JoinPoint joinPoint) throws Throwable { |
||||
log(INFO, joinPoint); |
||||
} |
||||
|
||||
@AfterThrowing(pointcut = "invocation()", throwing = "ex") |
||||
public void logCall(JoinPoint joinPoint, Exception ex) throws Throwable { |
||||
logger.error(generateLogMessage(joinPoint).toString(), ex); |
||||
} |
||||
|
||||
@AfterReturning(pointcut = "invocation()", returning = "result") |
||||
public void logCall(JoinPoint joinPoint, Object result) throws Throwable { |
||||
log(DEBUG, joinPoint, result); |
||||
} |
||||
|
||||
@AfterReturning(pointcut = "deleteItem()", returning = "result") |
||||
public void logDeleteSuccess(JoinPoint joinPoint, Object result) |
||||
throws Throwable { |
||||
log(WARN, joinPoint, result); |
||||
} |
||||
|
||||
@Before("deleteItem()") |
||||
public void logDeleteInvocation(JoinPoint joinPoint) throws Throwable { |
||||
log(DEBUG, joinPoint); |
||||
} |
||||
} |
||||
@ -0,0 +1,66 @@ |
||||
package de.kreth.clubhelperbackend.aspects; |
||||
|
||||
import java.lang.reflect.Modifier; |
||||
import java.util.Date; |
||||
|
||||
import org.aspectj.lang.JoinPoint; |
||||
import org.aspectj.lang.annotation.AfterReturning; |
||||
import org.aspectj.lang.annotation.Aspect; |
||||
import org.aspectj.lang.annotation.Pointcut; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import de.kreth.clubhelper.model.dao.DeletedEntriesDao; |
||||
import de.kreth.clubhelper.model.data.BaseEntity; |
||||
import de.kreth.clubhelper.model.data.DeletedEntry; |
||||
import de.kreth.clubhelperbackend.utils.TimeProvider; |
||||
|
||||
@Aspect |
||||
@Component |
||||
public class DeletedStorageAspect { |
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass()); |
||||
private DeletedEntriesDao deletedEntriesDao; |
||||
private TimeProvider time; |
||||
|
||||
@Autowired |
||||
public void setTime(TimeProvider time) { |
||||
this.time = time; |
||||
} |
||||
|
||||
@Autowired |
||||
public DeletedStorageAspect(DeletedEntriesDao deletedEntriesDao) { |
||||
super(); |
||||
this.deletedEntriesDao = deletedEntriesDao; |
||||
} |
||||
|
||||
@Pointcut("execution (public * de.kreth.clubhelperbackend.controller.abstr.AbstractController.delete(..))") |
||||
private void invocation() { |
||||
} |
||||
|
||||
@AfterReturning(pointcut = "invocation()", returning = "deleted") |
||||
public void storeDeleted(JoinPoint joinPoint, BaseEntity deleted) { |
||||
|
||||
logger.debug("Deleted: " + deleted); |
||||
Class<?> class1 = deleted.getClass(); |
||||
|
||||
while (!class1.getSuperclass().equals(Object.class) && !Modifier.isAbstract(class1.getSuperclass().getModifiers())) |
||||
class1 = class1.getSuperclass(); |
||||
|
||||
String tableName = class1.getSimpleName(); |
||||
long id = deleted.getId(); |
||||
Date now = time.getNow(); |
||||
|
||||
DeletedEntry entry = new DeletedEntry(); |
||||
entry.setTablename(tableName); |
||||
entry.setEntryId(id); |
||||
entry.setChanged(now); |
||||
entry.setCreated(now); |
||||
logger.info("Inserted Deleteentry: {}", entry); |
||||
deletedEntriesDao.save(entry); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,27 @@ |
||||
package de.kreth.clubhelperbackend.controller; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import de.kreth.clubhelper.model.data.Adress; |
||||
import de.kreth.clubhelperbackend.controller.abstr.AbstractController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/adress") |
||||
public class AdressController extends AbstractController<Adress> { |
||||
|
||||
@Autowired |
||||
public AdressController() { |
||||
super(Adress.class); |
||||
} |
||||
|
||||
@Override |
||||
public List<Adress> getByParentId(long id) { |
||||
return new ArrayList<Adress>(); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,63 @@ |
||||
package de.kreth.clubhelperbackend.controller; |
||||
|
||||
import java.sql.SQLException; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import org.springframework.format.annotation.DateTimeFormat.ISO; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import de.kreth.clubhelper.model.dao.AttendanceDao; |
||||
import de.kreth.clubhelper.model.dao.PersonDao; |
||||
import de.kreth.clubhelper.model.data.Attendance; |
||||
import de.kreth.clubhelperbackend.controller.abstr.AbstractController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/attendance") |
||||
public class AttendanceController extends AbstractController<Attendance> { |
||||
|
||||
@Autowired |
||||
private PersonDao personDao; |
||||
|
||||
public AttendanceController() { |
||||
super(Attendance.class); |
||||
} |
||||
|
||||
@RequestMapping(value = "/on", method = RequestMethod.POST, produces = "application/json") |
||||
|
||||
public List<Attendance> postListAttendencesOn(@RequestBody(required=false) Date date) |
||||
throws SQLException { |
||||
|
||||
if(date == null) { |
||||
date = new Date(); |
||||
} |
||||
AttendanceDao tmpDao = (AttendanceDao)dao; |
||||
|
||||
return tmpDao.findByOnDate(date); |
||||
} |
||||
|
||||
@RequestMapping(value = "/on/{date}", method = RequestMethod.GET, produces = "application/json") |
||||
|
||||
public List<Attendance> getAttendencesOn(@PathVariable("date") @DateTimeFormat(iso=ISO.DATE) Date date) |
||||
throws SQLException { |
||||
|
||||
AttendanceDao tmpDao = (AttendanceDao)dao; |
||||
|
||||
return tmpDao.findByOnDate(date); |
||||
} |
||||
|
||||
@RequestMapping(value = "/for/{id}", method = RequestMethod.POST, produces = "application/json") |
||||
|
||||
public Attendance post(@PathVariable("id") Long id) { |
||||
Attendance att = new Attendance(); |
||||
att.setPerson(personDao.findById(id).get()); |
||||
att.setOnDate(new Date()); |
||||
return post(att); |
||||
} |
||||
} |
||||
@ -0,0 +1,19 @@ |
||||
package de.kreth.clubhelperbackend.controller; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import de.kreth.clubhelper.model.data.Contact; |
||||
import de.kreth.clubhelperbackend.controller.abstr.AbstractController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/contact") |
||||
public class ContactController extends AbstractController<Contact> { |
||||
|
||||
@Autowired |
||||
public ContactController() { |
||||
super(Contact.class); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,26 @@ |
||||
package de.kreth.clubhelperbackend.controller; |
||||
|
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import de.kreth.clubhelper.model.data.DeletedEntry; |
||||
import de.kreth.clubhelperbackend.controller.abstr.AbstractController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/deletedentries") |
||||
public class DeletedEntriesController extends AbstractController<DeletedEntry> { |
||||
|
||||
@Autowired |
||||
public DeletedEntriesController() { |
||||
super(DeletedEntry.class); |
||||
} |
||||
|
||||
@Override |
||||
public List<DeletedEntry> getByParentId(long id) { |
||||
return Collections.emptyList(); |
||||
} |
||||
} |
||||
@ -0,0 +1,19 @@ |
||||
package de.kreth.clubhelperbackend.controller; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import de.kreth.clubhelper.model.data.GroupDef; |
||||
import de.kreth.clubhelperbackend.controller.abstr.AbstractController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/group") |
||||
public class GroupController extends AbstractController<GroupDef> { |
||||
|
||||
@Autowired() |
||||
public GroupController() { |
||||
super(GroupDef.class); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,49 @@ |
||||
package de.kreth.clubhelperbackend.controller; |
||||
|
||||
import java.text.DateFormat; |
||||
import java.util.Date; |
||||
import java.util.Locale; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* Handles requests for the application home page. |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/") |
||||
public class HomeController { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HomeController.class); |
||||
|
||||
/** |
||||
* Simply selects the home view to render by returning its name. |
||||
* |
||||
* @param response |
||||
* response Object for redirection. |
||||
* @param device |
||||
* device Type to decide redirection target. |
||||
* @param locale |
||||
* locale for language |
||||
* @param model |
||||
* model to set response data |
||||
* @return Name of View |
||||
*/ |
||||
@GetMapping(value = "/") |
||||
public String home(HttpServletResponse response, Locale locale) { |
||||
|
||||
logger.info("Welcome home! The client locale is {}.", locale); |
||||
Date date = new Date(); |
||||
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); |
||||
|
||||
String formattedDate = dateFormat.format(date); |
||||
|
||||
return "This is Clubhelper Backend at " + formattedDate; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,104 @@ |
||||
package de.kreth.clubhelperbackend.controller; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.http.ResponseEntity; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import de.kreth.clubhelper.model.data.Adress; |
||||
import de.kreth.clubhelper.model.data.Contact; |
||||
import de.kreth.clubhelper.model.data.Person; |
||||
import de.kreth.clubhelper.model.data.Relative; |
||||
import de.kreth.clubhelperbackend.controller.abstr.AbstractController; |
||||
import de.kreth.clubhelperbackend.controller.abstr.ClubController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/person") |
||||
public class PersonController extends AbstractController<Person> { |
||||
|
||||
@Autowired |
||||
private ClubController<Contact> contactController; |
||||
@Autowired |
||||
private ClubController<Relative> relativeController; |
||||
@Autowired |
||||
private ClubController<Adress> adressController; |
||||
|
||||
public PersonController() { |
||||
super(Person.class); |
||||
} |
||||
|
||||
// private static ClubhelperDao<Person> doCast(PersonDao dao) {
|
||||
// Object anonymous = dao;
|
||||
// return (ClubhelperDao<Person>) anonymous;
|
||||
// }
|
||||
|
||||
@Override |
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "application/json") |
||||
public ResponseEntity<Person> delete(@PathVariable("id") final long id) { |
||||
|
||||
for (Contact c : contactController.getByParentId(id)) { |
||||
contactController.delete(c.getId()); |
||||
} |
||||
for (Adress a : adressController.getByParentId(id)) { |
||||
adressController.delete(a.getId()); |
||||
} |
||||
for (Relative r : relativeController.getByParentId(id)) { |
||||
relativeController.delete(r.getId()); |
||||
} |
||||
|
||||
return super.delete(id); |
||||
} |
||||
|
||||
/** |
||||
* Delivers list with one Person with id. |
||||
*/ |
||||
@Override |
||||
public List<Person> getByParentId(long id) { |
||||
List<Person> all = new ArrayList<Person>(); |
||||
all.add(getById(id)); |
||||
return all; |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @author markus |
||||
* |
||||
*/ |
||||
public class PersonRelative extends Relative { |
||||
|
||||
private static final long serialVersionUID = 4828690343464403867L; |
||||
private Person toPerson; |
||||
private String relation; |
||||
|
||||
public PersonRelative(Relative r) { |
||||
super(r.getId(), |
||||
r.getToPerson2Relation(), r.getToPerson1Relation(), r.getPerson1Bean(), r.getPerson2Bean()); |
||||
setChanged(r.getChanged()); |
||||
setCreated(r.getCreated()); |
||||
toPerson = r.getPerson1Bean(); |
||||
relation = r.getToPerson1Relation(); |
||||
} |
||||
|
||||
public Person getToPerson() { |
||||
return toPerson; |
||||
} |
||||
|
||||
public String getRelation() { |
||||
return relation; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
StringBuilder bld = new StringBuilder(); |
||||
bld.append(relation).append(" ").append(toPerson.getId()) |
||||
.append(": ").append(toPerson.getPrename()).append(" ") |
||||
.append(toPerson.getSurname()); |
||||
return bld.toString(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,27 @@ |
||||
package de.kreth.clubhelperbackend.controller; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import de.kreth.clubhelper.model.data.Relative; |
||||
import de.kreth.clubhelperbackend.controller.abstr.AbstractController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/relative") |
||||
public class RelativeController extends AbstractController<Relative> { |
||||
|
||||
@Autowired |
||||
public RelativeController() { |
||||
super(Relative.class); |
||||
} |
||||
//
|
||||
// @Override
|
||||
// @RequestMapping(value = "/for/{id}", method = RequestMethod.GET)
|
||||
// public List<Relative> getByParentId(@PathVariable("id") long id) {
|
||||
// StringBuilder whereClause = new StringBuilder("person1=");
|
||||
// whereClause.append(id).append(" OR person2=").append(id);
|
||||
// return dao.getByWhere(whereClause.toString());
|
||||
// }
|
||||
|
||||
} |
||||
@ -0,0 +1,27 @@ |
||||
package de.kreth.clubhelperbackend.controller; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import de.kreth.clubhelper.model.data.Startpass; |
||||
import de.kreth.clubhelperbackend.controller.abstr.AbstractController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/startpass") |
||||
public class StartpassController extends AbstractController<Startpass> { |
||||
|
||||
@Autowired |
||||
public StartpassController() { |
||||
super(Startpass.class); |
||||
} |
||||
|
||||
@Override |
||||
// @RequestMapping(value = "/for/{id}", method = RequestMethod.GET, produces = "application/json")
|
||||
public List<Startpass> getByParentId(@PathVariable("id") long id) { |
||||
return dao.findByPersonId(id); |
||||
} |
||||
} |
||||
@ -0,0 +1,144 @@ |
||||
package de.kreth.clubhelperbackend.controller.abstr; |
||||
|
||||
import static de.kreth.clubhelperbackend.utils.BoolUtils.not; |
||||
import static java.time.temporal.ChronoUnit.MINUTES; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.http.ResponseEntity; |
||||
import org.springframework.web.bind.annotation.DeleteMapping; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.PutMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
||||
import de.kreth.clubhelper.model.dao.ClubhelperDao; |
||||
import de.kreth.clubhelper.model.data.BaseEntity; |
||||
|
||||
/** |
||||
* Default Controller implementing all functionality for all {@link Data} types. |
||||
* |
||||
* @param <T> |
||||
* Data type |
||||
*/ |
||||
|
||||
//@PreAuthorize("hasAnyRole('ROLE_ADMIN', 'STAFF')")
|
||||
public abstract class AbstractController<T extends BaseEntity> |
||||
implements |
||||
ClubController<T> { |
||||
|
||||
@Autowired |
||||
protected ClubhelperDao<T> dao; |
||||
private Class<T> elementClass; |
||||
|
||||
public AbstractController(Class<T> element) { |
||||
super(); |
||||
this.elementClass = element; |
||||
} |
||||
|
||||
@Override |
||||
@GetMapping(value = "/{id}", produces = "application/json") |
||||
public T getById(@PathVariable("id") long id) { |
||||
return dao.findById(id).orElseThrow(() -> new IllegalArgumentException(elementClass.getName() + " with id=" + id + " not found")); |
||||
} |
||||
|
||||
protected List<T> iterableToList(Iterable<T> in) { |
||||
List<T> result = new ArrayList<>(); |
||||
in.forEach(result::add); |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
@GetMapping(value = {"/", |
||||
""}, produces = "application/json") |
||||
public List<T> getAll() { |
||||
Iterable<T> findAll = dao.findAll(); |
||||
List<T> result = new ArrayList<>(); |
||||
findAll.forEach(result::add); |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
@GetMapping(value = "/for/{id}", produces = "application/json") |
||||
public List<T> getByParentId(@PathVariable("id") long id) { |
||||
return dao.findByPersonId(id); |
||||
} |
||||
|
||||
@Override |
||||
@GetMapping(value = "/changed/{changed}", produces = "application/json") |
||||
public List<T> getChangedSince(@PathVariable("changed") long changed) { |
||||
return dao.findByChangedGreaterThan(new Date(changed)); |
||||
} |
||||
|
||||
@Override |
||||
@PutMapping(value = "/{id}", produces = "application/json") |
||||
public T put(@PathVariable("id") long id, @RequestBody T toUpdate) { |
||||
|
||||
Date now = new Date(); |
||||
Date created = toUpdate.getCreated(); |
||||
Date changed = null; |
||||
|
||||
if (toUpdate.getChanged() != null) { |
||||
changed = toUpdate.getChanged(); |
||||
long minutes = MINUTES.between(created.toInstant(), changed.toInstant()); |
||||
if (minutes < 1) { |
||||
toUpdate.setChanged(now); |
||||
} |
||||
} else { |
||||
toUpdate.setChanged(now); |
||||
} |
||||
|
||||
dao.save(toUpdate); |
||||
return toUpdate; |
||||
} |
||||
|
||||
@Override |
||||
@DeleteMapping(value = "/{id}", produces = "application/json") |
||||
public ResponseEntity<T> delete(@PathVariable("id") long id) { |
||||
T byId = getById(id); |
||||
if (not(byId.isDeleted())) { |
||||
dao.delete(byId); |
||||
} |
||||
return ResponseEntity.ok(getById(id)); |
||||
} |
||||
|
||||
@Override |
||||
@PostMapping(value = "/", produces = "application/json") |
||||
public T post(@RequestBody T toCreate) { |
||||
return post(-1L, toCreate); |
||||
} |
||||
|
||||
@Override |
||||
@PostMapping(value = "/{id}", produces = "application/json") |
||||
public T post(@PathVariable("id") Long id, @RequestBody T toCreate) { |
||||
if (id == null) { |
||||
id = -1L; |
||||
} |
||||
toCreate.setId(id); |
||||
Date now = new Date(); |
||||
|
||||
toCreate.setChanged(now); |
||||
|
||||
if (toCreate.getCreated() == null |
||||
|| toCreate.getCreated().getTime() == 0) { |
||||
toCreate.setCreated(now); |
||||
} |
||||
|
||||
if (toCreate.getId() < 0) { |
||||
return dao.save(toCreate); |
||||
} else { |
||||
T byId = getById(toCreate.getId()); |
||||
if (byId != null) { |
||||
toCreate.setDeleted(null); |
||||
return dao.save(toCreate); |
||||
} else { |
||||
return dao.save(toCreate); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,101 @@ |
||||
package de.kreth.clubhelperbackend.controller.abstr; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.springframework.http.ResponseEntity; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
||||
public interface ClubController<T> { |
||||
|
||||
/* |
||||
* ************* REST Methoden ************ |
||||
*/ |
||||
|
||||
/** |
||||
* Rest: PUT - Change object (update) |
||||
* <p> |
||||
* Mapping: /{id} |
||||
* |
||||
* @param id |
||||
* Id of updated object |
||||
* @param toUpdate |
||||
* Object with updated data. |
||||
* @return updated object |
||||
*/ |
||||
T put(@PathVariable("id") long id, @RequestBody T toUpdate); |
||||
|
||||
/** |
||||
* Rest: POST - Create Object without Id. |
||||
* |
||||
* @param toCreate |
||||
* object with data to insert. |
||||
* @return created and corrected object |
||||
*/ |
||||
T post(@RequestBody T toCreate); |
||||
|
||||
/** |
||||
* Rest: POST - Create Object with or without Id. |
||||
* |
||||
* @param id |
||||
* -1 for new Id |
||||
* @param toCreate |
||||
* Object to create. |
||||
* @return created object with updated id and dates. |
||||
*/ |
||||
T post(@PathVariable("id") Long id, @RequestBody T toCreate); |
||||
|
||||
/** |
||||
* Rest: GET - return object |
||||
* <p> |
||||
* Mapping: /{id} |
||||
* |
||||
* @param id |
||||
* id to find object for. |
||||
* @return Object for matching id |
||||
*/ |
||||
T getById(@PathVariable("id") long id); |
||||
|
||||
/** |
||||
* Rest: GET - return List of all objects |
||||
* <p> |
||||
* Mapping: / |
||||
* |
||||
* @return List of all Objects - sorted if configured. |
||||
*/ |
||||
List<T> getAll(); |
||||
|
||||
/** |
||||
* Rest: GET - return List of object having the (parent object) id as |
||||
* property. <br> |
||||
* Which property is meant is implementation dependant. Most likely its |
||||
* personId |
||||
* <p> |
||||
* Mapping: /for/{id} |
||||
* |
||||
* @param id |
||||
* Id matching all objects property. |
||||
* @return List of object with certain property matching id. |
||||
*/ |
||||
List<T> getByParentId(@PathVariable("id") long id); |
||||
|
||||
/** |
||||
* Rest: DELETE - deletes object with the Id. |
||||
* <p> |
||||
* Mapping: /{id} |
||||
* |
||||
* @param id |
||||
* Id of the object to delete. |
||||
* @return deleted object. |
||||
*/ |
||||
ResponseEntity<T> delete(@PathVariable("id") long id); |
||||
|
||||
/** |
||||
* |
||||
* @param changed |
||||
* date of last change included |
||||
* @return list of objects changed since changed date. |
||||
*/ |
||||
List<T> getChangedSince(long changed); |
||||
|
||||
} |
||||
@ -0,0 +1,5 @@ |
||||
/** |
||||
* @author markus |
||||
* |
||||
*/ |
||||
package de.kreth.clubhelperbackend.controller.abstr; |
||||
@ -0,0 +1,11 @@ |
||||
package de.kreth.clubhelperbackend.utils; |
||||
|
||||
public class BoolUtils { |
||||
private BoolUtils() { |
||||
// Static Methods only.
|
||||
} |
||||
|
||||
public static final boolean not(boolean value) { |
||||
return !value; |
||||
} |
||||
} |
||||
@ -0,0 +1,18 @@ |
||||
package de.kreth.clubhelperbackend.utils; |
||||
|
||||
import java.util.regex.Matcher; |
||||
import java.util.regex.Pattern; |
||||
|
||||
public class EmailUtils { |
||||
|
||||
private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" |
||||
+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; |
||||
|
||||
private static final Pattern pattern = Pattern.compile(EMAIL_PATTERN); |
||||
|
||||
public static boolean isValidEmailadress(String email) { |
||||
Matcher matcher = pattern.matcher(email); |
||||
return matcher.matches(); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,52 @@ |
||||
package de.kreth.clubhelperbackend.utils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
import java.util.concurrent.LinkedBlockingQueue; |
||||
import java.util.concurrent.ThreadPoolExecutor; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
public class ThreadPoolErrors extends ThreadPoolExecutor { |
||||
|
||||
public final List<Throwable> exceptions = Collections |
||||
.synchronizedList(new ArrayList<>()); |
||||
|
||||
public ThreadPoolErrors(int threadCount) { |
||||
super(Math.min(3, threadCount), // core threads
|
||||
threadCount, // max threads
|
||||
30, // timeout
|
||||
TimeUnit.SECONDS, // timeout units
|
||||
new LinkedBlockingQueue<Runnable>() // work queue
|
||||
); |
||||
} |
||||
|
||||
protected void afterExecute(Runnable r, Throwable t) { |
||||
super.afterExecute(r, t); |
||||
if (t != null) { |
||||
exceptions.add(t); |
||||
} |
||||
} |
||||
|
||||
public Throwable myAwaitTermination() { |
||||
|
||||
while (isRunningWithoutException()) { |
||||
try { |
||||
Thread.sleep(100); |
||||
} catch (InterruptedException e) { |
||||
shutdownNow(); |
||||
return e; |
||||
} |
||||
} |
||||
if (exceptions.isEmpty() == false) { |
||||
return exceptions.get(0); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private boolean isRunningWithoutException() { |
||||
return isTerminated() == false && getActiveCount() > 0 |
||||
&& exceptions.isEmpty(); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,7 @@ |
||||
package de.kreth.clubhelperbackend.utils; |
||||
|
||||
import java.util.Date; |
||||
|
||||
public interface TimeProvider { |
||||
Date getNow(); |
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
package de.kreth.clubhelperbackend.utils; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import org.springframework.stereotype.Component; |
||||
|
||||
@Component |
||||
public class TimeProviderImpl implements TimeProvider { |
||||
|
||||
@Override |
||||
public Date getNow() { |
||||
return new Date(); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,282 @@ |
||||
-- MySQL dump 10.13 Distrib 8.0.20, for Win64 (x86_64) |
||||
-- |
||||
-- ------------------------------------------------------ |
||||
|
||||
-- |
||||
-- Table structure for table groupdef |
||||
-- |
||||
-- DROP TABLE IF EXISTS groupdef; |
||||
CREATE TABLE groupdef ( |
||||
id SERIAL PRIMARY KEY, |
||||
name varchar(255) NOT NULL, |
||||
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP, |
||||
created timestamp DEFAULT CURRENT_TIMESTAMP, |
||||
deleted timestamp DEFAULT NULL, |
||||
CONSTRAINT groupname_UNIQUE UNIQUE (name) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table person |
||||
-- |
||||
-- DROP TABLE IF EXISTS person; |
||||
CREATE TABLE person ( |
||||
id SERIAL PRIMARY KEY, |
||||
prename varchar(255) NOT NULL, |
||||
surname varchar(255) DEFAULT NULL, |
||||
birth timestamp DEFAULT NULL, |
||||
gender smallint DEFAULT NULL, |
||||
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP, |
||||
created timestamp DEFAULT CURRENT_TIMESTAMP, |
||||
deleted timestamp DEFAULT NULL, |
||||
username varchar(255) DEFAULT NULL, |
||||
password varchar(255) DEFAULT NULL |
||||
); |
||||
|
||||
|
||||
-- |
||||
-- Table structure for table `contact` |
||||
-- |
||||
|
||||
-- DROP TABLE IF EXISTS contact; |
||||
CREATE TABLE contact ( |
||||
id SERIAL PRIMARY KEY, |
||||
type varchar(255) NOT NULL, |
||||
value varchar(255) DEFAULT NULL, |
||||
person_id int NOT NULL, |
||||
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP, |
||||
created timestamp DEFAULT CURRENT_TIMESTAMP, |
||||
deleted timestamp DEFAULT NULL, |
||||
CONSTRAINT contact_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id) ON DELETE RESTRICT ON UPDATE RESTRICT |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table clubevent |
||||
-- |
||||
|
||||
-- DROP TABLE IF EXISTS clubevent; |
||||
CREATE TABLE clubevent ( |
||||
id varchar(250) NOT NULL, |
||||
location varchar(255) DEFAULT NULL, |
||||
ICALUID varchar(150) DEFAULT NULL, |
||||
organizerDisplayName varchar(150) DEFAULT NULL, |
||||
caption varchar(150) DEFAULT NULL, |
||||
description varchar(500) DEFAULT NULL, |
||||
start timestamp DEFAULT NULL, |
||||
ende timestamp DEFAULT NULL, |
||||
allDay smallint DEFAULT NULL, |
||||
deleted smallint NOT NULL DEFAULT 0, |
||||
PRIMARY KEY (id) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table pflichten |
||||
-- |
||||
-- DROP TABLE IF EXISTS pflichten; |
||||
CREATE TABLE pflichten ( |
||||
id SERIAL PRIMARY KEY, |
||||
name varchar(45) NOT NULL, |
||||
fixed smallint DEFAULT NULL, |
||||
ordered int NOT NULL, |
||||
comment varchar(500) DEFAULT NULL, |
||||
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP, |
||||
created timestamp DEFAULT CURRENT_TIMESTAMP, |
||||
deleted timestamp DEFAULT NULL, |
||||
CONSTRAINT name_UNIQUE UNIQUE (name) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table adress |
||||
-- |
||||
-- DROP TABLE IF EXISTS adress; |
||||
CREATE TABLE adress ( |
||||
id SERIAL PRIMARY KEY, |
||||
adress1 varchar(255) DEFAULT NULL, |
||||
adress2 varchar(255) DEFAULT NULL, |
||||
plz varchar(255) DEFAULT NULL, |
||||
city varchar(255) DEFAULT NULL, |
||||
person_id int NOT NULL, |
||||
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP, |
||||
created timestamp DEFAULT CURRENT_TIMESTAMP, |
||||
deleted timestamp DEFAULT NULL, |
||||
CONSTRAINT adress_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table altersgruppe |
||||
-- |
||||
-- DROP TABLE IF EXISTS altersgruppe; |
||||
CREATE TABLE altersgruppe ( |
||||
id SERIAL PRIMARY KEY, |
||||
event_id varchar(250) NOT NULL, |
||||
pflicht_id int DEFAULT NULL, |
||||
bezeichnung varchar(100) NOT NULL, |
||||
start int DEFAULT NULL, |
||||
ende varchar(45) DEFAULT NULL, |
||||
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP, |
||||
created timestamp DEFAULT CURRENT_TIMESTAMP, |
||||
deleted timestamp DEFAULT NULL, |
||||
CONSTRAINT fk_altersgruppe_event FOREIGN KEY (event_id) REFERENCES clubevent (id), |
||||
CONSTRAINT fk_altersgruppe_pflicht FOREIGN KEY (pflicht_id) REFERENCES pflichten (id) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table attendance |
||||
-- |
||||
-- DROP TABLE IF EXISTS attendance; |
||||
CREATE TABLE attendance ( |
||||
id SERIAL PRIMARY KEY, |
||||
on_date timestamp DEFAULT NULL, |
||||
person_id int NOT NULL, |
||||
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP, |
||||
created timestamp DEFAULT CURRENT_TIMESTAMP, |
||||
deleted timestamp DEFAULT NULL, |
||||
CONSTRAINT UNIQUE_person_id_on_date UNIQUE (person_id,on_date), |
||||
CONSTRAINT attendance_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table clubevent_addon |
||||
-- |
||||
|
||||
-- DROP TABLE IF EXISTS clubevent_addon; |
||||
CREATE TABLE clubevent_addon ( |
||||
id varchar(250) NOT NULL, |
||||
competition_type varchar(45) NOT NULL, |
||||
PRIMARY KEY (id), |
||||
CONSTRAINT fk_event_addon_id FOREIGN KEY (id) REFERENCES clubevent (id) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table clubevent_has_person |
||||
-- |
||||
|
||||
-- DROP TABLE IF EXISTS clubevent_has_person; |
||||
CREATE TABLE clubevent_has_person ( |
||||
clubevent_id varchar(250) NOT NULL, |
||||
person_id int NOT NULL, |
||||
comment varchar(250) NOT NULL, |
||||
PRIMARY KEY (clubevent_id,person_id), |
||||
CONSTRAINT fk_clubevent_has_person_clubevent1 FOREIGN KEY (clubevent_id) REFERENCES clubevent (id), |
||||
CONSTRAINT fk_clubevent_has_person_person1 FOREIGN KEY (person_id) REFERENCES person (id) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table deleted_entries |
||||
-- |
||||
|
||||
-- DROP TABLE IF EXISTS deleted_entries; |
||||
CREATE TABLE deleted_entries ( |
||||
id SERIAL PRIMARY KEY, |
||||
tablename varchar(25) NOT NULL, |
||||
entryId int NOT NULL, |
||||
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP, |
||||
created timestamp DEFAULT CURRENT_TIMESTAMP, |
||||
deleted timestamp DEFAULT NULL |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table event_has_altersgruppe |
||||
-- |
||||
|
||||
-- DROP TABLE IF EXISTS event_has_altersgruppe; |
||||
CREATE TABLE event_has_altersgruppe ( |
||||
id SERIAL PRIMARY KEY, |
||||
event_id varchar(250) NOT NULL, |
||||
altersgruppe_id int NOT NULL, |
||||
CONSTRAINT fk_event_has_altersgruppe_altersgruppe FOREIGN KEY (altersgruppe_id) REFERENCES altersgruppe (id), |
||||
CONSTRAINT fk_event_has_altersgruppe_event FOREIGN KEY (event_id) REFERENCES clubevent (id) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table notes |
||||
-- |
||||
|
||||
-- DROP TABLE IF EXISTS notes; |
||||
CREATE TABLE notes ( |
||||
id SERIAL PRIMARY KEY, |
||||
person_id int NOT NULL, |
||||
notekey varchar(25) DEFAULT NULL, |
||||
notetext varchar(2000) DEFAULT NULL, |
||||
CONSTRAINT fk_notes_person FOREIGN KEY (person_id) REFERENCES person (id) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table persongroup |
||||
-- |
||||
|
||||
-- DROP TABLE IF EXISTS persongroup; |
||||
CREATE TABLE persongroup ( |
||||
id SERIAL PRIMARY KEY, |
||||
person_id int NOT NULL, |
||||
group_id int NOT NULL, |
||||
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP, |
||||
created timestamp DEFAULT CURRENT_TIMESTAMP, |
||||
deleted timestamp DEFAULT NULL, |
||||
CONSTRAINT unique_person_group UNIQUE (person_id,group_id), |
||||
CONSTRAINT persongroup_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id), |
||||
CONSTRAINT persongroup_ibfk_2 FOREIGN KEY (group_id) REFERENCES groupdef (id) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table relative |
||||
-- |
||||
|
||||
-- DROP TABLE IF EXISTS relative; |
||||
CREATE TABLE relative ( |
||||
id SERIAL PRIMARY KEY, |
||||
person1 int NOT NULL, |
||||
person2 int NOT NULL, |
||||
TO_PERSON1_RELATION varchar(255) DEFAULT NULL, |
||||
TO_PERSON2_RELATION varchar(255) DEFAULT NULL, |
||||
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP, |
||||
created timestamp DEFAULT CURRENT_TIMESTAMP, |
||||
deleted timestamp DEFAULT NULL, |
||||
CONSTRAINT relative_ibfk_1 FOREIGN KEY (person1) REFERENCES person (id), |
||||
CONSTRAINT relative_ibfk_2 FOREIGN KEY (person2) REFERENCES person (id) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table startpaesse |
||||
-- |
||||
|
||||
-- DROP TABLE IF EXISTS startpaesse; |
||||
CREATE TABLE startpaesse ( |
||||
id SERIAL PRIMARY KEY, |
||||
person_id int NOT NULL, |
||||
startpass_nr varchar(25) NOT NULL, |
||||
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP, |
||||
created timestamp DEFAULT CURRENT_TIMESTAMP, |
||||
deleted timestamp DEFAULT NULL, |
||||
CONSTRAINT startpass_nr UNIQUE (startpass_nr), |
||||
CONSTRAINT startpaesse_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table startpass_startrechte |
||||
-- |
||||
|
||||
-- DROP TABLE IF EXISTS startpass_startrechte; |
||||
CREATE TABLE startpass_startrechte ( |
||||
id SERIAL PRIMARY KEY, |
||||
startpass_id int NOT NULL, |
||||
verein_name varchar(100) NOT NULL, |
||||
fachgebiet varchar(25) NOT NULL, |
||||
startrecht_beginn timestamp NOT NULL, |
||||
startrecht_ende timestamp NOT NULL, |
||||
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP, |
||||
created timestamp DEFAULT CURRENT_TIMESTAMP, |
||||
deleted timestamp DEFAULT NULL, |
||||
CONSTRAINT startpass_startrechte_ibfk_1 FOREIGN KEY (startpass_id) REFERENCES startpaesse (id) |
||||
); |
||||
|
||||
-- |
||||
-- Table structure for table version |
||||
-- |
||||
-- DROP TABLE IF EXISTS version; |
||||
CREATE TABLE version ( |
||||
id SERIAL PRIMARY KEY, |
||||
version int NOT NULL, |
||||
deleted timestamp DEFAULT NULL |
||||
); |
||||
|
||||
-- Dump completed |
||||
Loading…
Reference in new issue