Exemplo n.º 1
0
 @Override
 public ResponseEntity<Licences> onCreate(
     int idUsuario, String token, long idSchool, int quantity, long idLicenceType)
     throws EntidadNoEncontradaException {
   School school = repoSchool.findOne(idSchool);
   if (school == null) {
     throw new EntidadNoEncontradaException("Entity School");
   }
   Profile lt = repoLicType.findOne(idLicenceType);
   if (lt == null) {
     throw new EntidadNoEncontradaException("Entity LicenceType");
   }
   List<Licences> licences = new ArrayList<>();
   for (int i = 0; i < quantity; i++) {
     Licences lic = new Licences();
     lic.setDates(new Date());
     lic.setProfile(lt);
     lic.setSchool(school);
     lic.setSnActive(true);
     lic.setStatus(Status.A);
     lic.setTxtLicence(Common.getToken());
     licences.add(lic);
   }
   return new ResponseEntity(repoLic.save(licences), HttpStatus.OK);
 }
Exemplo n.º 2
0
  @Override
  public ResponseEntity<Licences> findBySchool(int idUsuario, String token, long idSchool)
      throws EntidadNoEncontradaException {
    School school = repoSchool.findOne(idSchool);

    if (school == null) {
      throw new EntidadNoEncontradaException("Entity School");
    }
    return new ResponseEntity(repoLic.findBySchool(school), HttpStatus.OK);
  }
Exemplo n.º 3
0
  @Override
  public ResponseEntity<Licences> findById(int idUsuario, String token, Long id)
      throws EntidadNoEncontradaException {
    Licences p = repoLic.findOne(id);

    if (p != null) {
      return new ResponseEntity(p, HttpStatus.OK);
    } else {
      throw new EntidadNoEncontradaException("Entity User");
    }
  }