parent
4c07bc2b90
commit
83f7d2281a
@ -1,4 +1,4 @@ |
||||
package de.kreth.clubhelperbackend.controller.abstr; |
||||
package de.kreth.clubhelper.model.controller; |
||||
|
||||
import java.util.List; |
||||
|
||||
@ -1,15 +1,15 @@ |
||||
package de.kreth.clubhelperbackend.controller; |
||||
package de.kreth.clubhelper.model.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.dao.RelativeDao; |
||||
import de.kreth.clubhelper.model.data.Relative; |
||||
import de.kreth.clubhelperbackend.controller.abstr.AbstractController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/relative") |
||||
public class RelativeController extends AbstractController<Relative> { |
||||
public class RelativeController extends AbstractController<Relative, RelativeDao> { |
||||
|
||||
@Autowired |
||||
public RelativeController() { |
||||
@ -0,0 +1,17 @@ |
||||
package de.kreth.clubhelper.model.controller; |
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import de.kreth.clubhelper.model.dao.StartpassDao; |
||||
import de.kreth.clubhelper.model.data.Startpass; |
||||
|
||||
@RestController |
||||
@RequestMapping("/startpass") |
||||
public class StartpassController extends AbstractController<Startpass, StartpassDao> { |
||||
|
||||
public StartpassController() { |
||||
super(Startpass.class); |
||||
} |
||||
|
||||
} |
||||
@ -1,12 +1,20 @@ |
||||
package de.kreth.clubhelper.model.dao; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
import de.kreth.clubhelper.model.data.Adress; |
||||
import de.kreth.clubhelper.model.data.Person; |
||||
|
||||
public interface AdressDao extends ClubhelperDao<Adress> { |
||||
public interface AdressDao extends CrudRepository<Adress, Long>, ClubhelperDao<Adress> { |
||||
|
||||
List<Adress> findByPerson(Person person); |
||||
|
||||
@Override |
||||
List<Adress> findByPersonId(long personId); |
||||
|
||||
@Override |
||||
List<Adress> findByChangedGreaterThan(Date date); |
||||
} |
||||
|
||||
@ -1,7 +1,14 @@ |
||||
package de.kreth.clubhelper.model.dao; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
import de.kreth.clubhelper.model.data.DeletedEntry; |
||||
|
||||
public interface DeletedEntriesDao extends ClubhelperDao<DeletedEntry> |
||||
public interface DeletedEntriesDao extends CrudRepository<DeletedEntry, Long> |
||||
{ |
||||
|
||||
List<DeletedEntry> findByChangedGreaterThan(Date date); |
||||
} |
||||
|
||||
@ -1,7 +1,13 @@ |
||||
package de.kreth.clubhelper.model.dao; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
import de.kreth.clubhelper.model.data.GroupDef; |
||||
|
||||
public interface GroupDao extends ClubhelperDao<GroupDef> { |
||||
public interface GroupDao extends CrudRepository<GroupDef, Long> { |
||||
|
||||
List<GroupDef> findByChangedGreaterThan(Date date); |
||||
} |
||||
|
||||
@ -1,10 +1,15 @@ |
||||
package de.kreth.clubhelper.model.dao; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
import org.springframework.stereotype.Repository; |
||||
|
||||
import de.kreth.clubhelper.model.data.Person; |
||||
|
||||
@Repository |
||||
public interface PersonDao extends ClubhelperDao<Person> { |
||||
public interface PersonDao extends CrudRepository<Person, Long> { |
||||
|
||||
List<Person> findByChangedGreaterThan(Date date); |
||||
} |
||||
|
||||
@ -0,0 +1,9 @@ |
||||
package de.kreth.clubhelper.model.dao; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
import de.kreth.clubhelper.model.data.Relative; |
||||
|
||||
public interface RelativeDao extends CrudRepository<Relative, Long> |
||||
{ |
||||
} |
||||
@ -0,0 +1,9 @@ |
||||
package de.kreth.clubhelper.model.dao; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
import de.kreth.clubhelper.model.data.Startpass; |
||||
|
||||
public interface StartpassDao extends CrudRepository<Startpass, Long> |
||||
{ |
||||
} |
||||
@ -1,27 +0,0 @@ |
||||
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>(); |
||||
} |
||||
|
||||
} |
||||
@ -1,63 +0,0 @@ |
||||
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); |
||||
} |
||||
} |
||||
@ -1,19 +0,0 @@ |
||||
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); |
||||
} |
||||
|
||||
} |
||||
@ -1,19 +0,0 @@ |
||||
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); |
||||
} |
||||
|
||||
} |
||||
@ -1,49 +0,0 @@ |
||||
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; |
||||
} |
||||
|
||||
} |
||||
@ -1,104 +0,0 @@ |
||||
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(); |
||||
} |
||||
} |
||||
} |
||||
@ -1,27 +0,0 @@ |
||||
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); |
||||
} |
||||
} |
||||
@ -1,5 +0,0 @@ |
||||
/** |
||||
* @author markus |
||||
* |
||||
*/ |
||||
package de.kreth.clubhelperbackend.controller.abstr; |
||||
Loading…
Reference in new issue