user nules
This commit is contained in:
parent
ca440a3fd5
commit
5ef7c19ade
10
README.md
10
README.md
@ -35,11 +35,11 @@ spring.profiles.active=prod
|
|||||||
Jeżeli chcemy zmienić jakieś opcję dla pordukcji to robimy to w tym sammym katalogi w pliku `application-prod.properties` i dla dev analogicznie w `application-dev.properties`.
|
Jeżeli chcemy zmienić jakieś opcję dla pordukcji to robimy to w tym sammym katalogi w pliku `application-prod.properties` i dla dev analogicznie w `application-dev.properties`.
|
||||||
W paczce dla proda w protpertiesach poufne dane odczytywane są ze zmiennych środowiskowych systemu na którym odpalana jest aplikacja. Ustawić trzeba następujące zmienne:
|
W paczce dla proda w protpertiesach poufne dane odczytywane są ze zmiennych środowiskowych systemu na którym odpalana jest aplikacja. Ustawić trzeba następujące zmienne:
|
||||||
|
|
||||||
- PLANNAPLAN_MYSQL_DB_HOST - host bazy danych np `localhost`
|
- `PLANNAPLAN_MYSQL_DB_HOST` - host bazy danych np `localhost`
|
||||||
- PLANNAPLAN_MYSQL_DB_PORT - port na którym działa baza
|
- `PLANNAPLAN_MYSQL_DB_PORT` - port na którym działa baza
|
||||||
- PLANNAPLAN_MYSQL_DB - nazwa bazy dancyh. W profilu **dev** jest to np test
|
- `PLANNAPLAN_MYSQL_DB` - nazwa bazy dancyh. W profilu **dev** jest to np test
|
||||||
- PLANNAPLAN_MYSQL_DB_USERNAME - nazwa użytkownika bazy
|
- `PLANNAPLAN_MYSQL_DB_USERNAME` - nazwa użytkownika bazy
|
||||||
- PLANNAPLAN_MYSQL_DB_PASSWORD - hasło użytkownika bazy
|
- `PLANNAPLAN_MYSQL_DB_PASSWORD` - hasło użytkownika bazy
|
||||||
|
|
||||||
## Packaging
|
## Packaging
|
||||||
|
|
||||||
|
@ -12,27 +12,23 @@ import org.springframework.data.repository.query.Param;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UserRepository.getByAuthority:
|
* UserRepository.getByAuthority: Return list of: SELECT * FROM User WHERE email
|
||||||
* Return list of:
|
* = i.
|
||||||
* SELECT * FROM User WHERE email = i.
|
|
||||||
*
|
*
|
||||||
* Where i, ?1 are equale to variables.
|
* Where i, ?1 are equale to variables.
|
||||||
*
|
*
|
||||||
* UserRepository.getByToken:
|
* UserRepository.getByToken: Return list of: SELECT * FROM User WHERE token =
|
||||||
* Return list of:
|
* i.
|
||||||
* SELECT * FROM User WHERE token = i.
|
|
||||||
*
|
*
|
||||||
* Where i, ?1 are equale to variables.
|
* Where i, ?1 are equale to variables.
|
||||||
*
|
*
|
||||||
* UserRepository.searchForUsers:
|
* UserRepository.searchForUsers: Return list of: SELECT * FROM User WHERE (name
|
||||||
* Return list of:
|
* LIKE %?1% OR surname LIKE %?1%).
|
||||||
* SELECT * FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%).
|
|
||||||
*
|
*
|
||||||
* Where i, ?1 are equale to variables.
|
* Where i, ?1 are equale to variables.
|
||||||
*
|
*
|
||||||
* UserRepository.searchForUsers with role:
|
* UserRepository.searchForUsers with role: Return list of: SELECT * FROM User
|
||||||
* Return list of:
|
* WHERE (name LIKE %?1% OR surname LIKE %?1%) AND role=?2").
|
||||||
* SELECT * FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%) AND role=?2").
|
|
||||||
*
|
*
|
||||||
* Where i, ?1 are equale to variables.
|
* Where i, ?1 are equale to variables.
|
||||||
*/
|
*/
|
||||||
@ -51,6 +47,9 @@ public interface UserRepository extends JpaRepository<User, Long> {
|
|||||||
@Query("FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%) AND role=?2")
|
@Query("FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%) AND role=?2")
|
||||||
List<User> searchForUsers(@Param("query") String query, @Param("role") UserRoles role);
|
List<User> searchForUsers(@Param("query") String query, @Param("role") UserRoles role);
|
||||||
|
|
||||||
|
@Query("FROM User WHERE role=?1")
|
||||||
|
List<User> getAllByRole(@Param("role") UserRoles role);
|
||||||
|
|
||||||
@Query("FROM User WHERE usosId = ?1")
|
@Query("FROM User WHERE usosId = ?1")
|
||||||
Optional<User> getByUsosId(@Param("usosId") String usosId);
|
Optional<User> getByUsosId(@Param("usosId") String usosId);
|
||||||
}
|
}
|
@ -77,4 +77,8 @@ public class UserService {
|
|||||||
return this.repo.findById(userId);
|
return this.repo.findById(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<User> getAllStudents() {
|
||||||
|
return this.repo.getAllByRole(UserRoles.STUDENT);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -120,6 +120,11 @@ public class App {
|
|||||||
newuser.setSurname("Sad");
|
newuser.setSurname("Sad");
|
||||||
newuser.setRole(UserRoles.STUDENT);
|
newuser.setRole(UserRoles.STUDENT);
|
||||||
this.userService.save(newuser);
|
this.userService.save(newuser);
|
||||||
|
|
||||||
|
newuser = new User();
|
||||||
|
newuser.setEmail("iamnull@st.amu.edu.pl");
|
||||||
|
newuser.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(newuser);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(Logo.getStartedInfo(isDev));
|
System.out.println(Logo.getStartedInfo(isDev));
|
||||||
|
@ -47,7 +47,7 @@ public class UsersController {
|
|||||||
@PreAuthorize("hasRole('ROLE_DEANERY')")
|
@PreAuthorize("hasRole('ROLE_DEANERY')")
|
||||||
@ApiOperation(value = "Gets all students. You need token with DEANERY role to call this")
|
@ApiOperation(value = "Gets all students. You need token with DEANERY role to call this")
|
||||||
public ResponseEntity<List<UserResponse>> getAllStudents() {
|
public ResponseEntity<List<UserResponse>> getAllStudents() {
|
||||||
final List<User> searches = this.userService.searchForStudents("");
|
final List<User> searches = this.userService.getAllStudents();
|
||||||
final List<UserResponse> response = UserResponseMappers.mapToDefaultResponse(searches);
|
final List<UserResponse> response = UserResponseMappers.mapToDefaultResponse(searches);
|
||||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user