-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
206 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AccountRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
package com.blackcompany.eeos.auth.persistence; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface AccountRepository extends JpaRepository<AccountEntity, Long> { | ||
|
||
@Query("SELECT a.memberId FROM AccountEntity a WHERE a.loginId = :loginId AND a.passWd = :passWd") | ||
List<Long> findByMemberId(@Param("loginId") String loginId, @Param("passWd") String passWd); | ||
|
||
@Query("SELECT a.passWd FROM AccountEntity a WHERE a.loginId=:loginId") | ||
Optional<String> findByLoginId(@Param("loginId") String loginId); | ||
} |
22 changes: 0 additions & 22 deletions
22
eeos/src/main/java/com/blackcompany/eeos/auth/persistence/BlackAuthenticationEntity.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 2 additions & 44 deletions
46
eeos/src/test/java/com/blackcompany/eeos/common/DatabaseCleaner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,5 @@ | ||
package com.blackcompany.eeos.common; | ||
|
||
import java.util.List; | ||
import javax.persistence.EntityManager; | ||
import javax.persistence.PersistenceContext; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Component | ||
public class DatabaseCleaner { | ||
private static final String FOREIGN_KEY_CHECK_FORMAT = "SET FOREIGN_KEY_CHECKS = %d"; | ||
private static final String TRUNCATE_FORMAT = "TRUNCATE TABLE %s"; | ||
private static final String AUTO_INCREMENT_FORMAT = "ALTER TABLE %s AUTO_INCREMENT = 1"; | ||
|
||
@PersistenceContext private EntityManager entityManager; | ||
|
||
@Transactional | ||
public void clear() { | ||
disableForeignKeyChecks(); | ||
List<String> tableNames = getTableNames(); | ||
truncate(tableNames); | ||
enableForeignKeyChecks(); | ||
} | ||
|
||
private void disableForeignKeyChecks() { | ||
entityManager.createNativeQuery(String.format(FOREIGN_KEY_CHECK_FORMAT, 0)).executeUpdate(); | ||
} | ||
|
||
private List<String> getTableNames() { | ||
String query = | ||
"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = DATABASE()"; | ||
return entityManager.createNativeQuery(query).getResultList(); | ||
} | ||
|
||
private void enableForeignKeyChecks() { | ||
entityManager.createNativeQuery(String.format(FOREIGN_KEY_CHECK_FORMAT, 1)).executeUpdate(); | ||
} | ||
|
||
private void truncate(List<String> tableNames) { | ||
for (String tableName : tableNames) { | ||
entityManager.createNativeQuery(String.format(TRUNCATE_FORMAT, tableName)).executeUpdate(); | ||
entityManager | ||
.createNativeQuery(String.format(AUTO_INCREMENT_FORMAT, tableName)) | ||
.executeUpdate(); | ||
} | ||
} | ||
public interface DatabaseCleaner { | ||
void clear(); | ||
} |
Oops, something went wrong.