This file contains hidden or 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
create database cibling_db; | |
CREATE USER cblinguser WITH PASSWORD 'cblinguser456789'; | |
ALTER ROLE cblinguser SET client_encoding TO 'utf8'; | |
ALTER ROLE cblinguser SET default_transaction_isolation TO 'read committed'; | |
ALTER ROLE cblinguser SET timezone TO 'UTC'; | |
GRANT ALL PRIVILEGES ON DATABASE cibling_db TO cblinguser; | |
This file contains hidden or 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
SET global general_log_file='/var/log/mysql/all.log'; | |
SET global log_output = 'file'; | |
SET global general_log = 1; |
This file contains hidden or 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
from functools import wraps | |
class Loggable: | |
def __init__(self, view_class, log_exception=True): | |
self.view_func = view_class | |
self.logger = self._get_logger() | |
def as_view(self, *args, **kwargs): | |
self.view_func = self.view_func.as_view(*args, **kwargs) |
This file contains hidden or 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
@Configuration | |
public class FireStoreConfig { | |
@Bean | |
public Firestore getFireStore(@Value("${firebase.credential.path}") String credentialPath) throws IOException { | |
var serviceAccount = new FileInputStream(credentialPath); | |
var credentials = GoogleCredentials.fromStream(serviceAccount); | |
var options = FirestoreOptions.newBuilder() | |
.setCredentials(credentials).build(); |
This file contains hidden or 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
@Retention(RetentionPolicy.RUNTIME) | |
@Target(ElementType.FIELD) | |
public @interface DocumentId { | |
} |
This file contains hidden or 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
@Slf4j | |
public abstract class AbstractFirestoreRepository<T> { | |
private final CollectionReference collectionReference; | |
private final String collectionName; | |
private final Class<T> parameterizedType; | |
protected AbstractFirestoreRepository(Firestore firestore, String collection) { | |
this.collectionReference = firestore.collection(collection); | |
this.collectionName = collection; | |
this.parameterizedType = getParameterizedType(); |
This file contains hidden or 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
@Repository | |
public class UserRepository extends AbstractFirestoreRepository<User> { | |
protected UserRepository(Firestore firestore) { | |
super(firestore, "User"); | |
} | |
} |
This file contains hidden or 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
public class ApplicationUser { | |
@DocumentId | |
private String id; | |
private String username; | |
private String password; | |
private String imageUrl; | |
private String bio; | |
} |
This file contains hidden or 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
@Data | |
@Entity | |
@AllArgsConstructor | |
@NoArgsConstructor | |
@Builder | |
public class KeyValuePair { | |
@Id | |
@GeneratedValue(strategy = GenerationType.IDENTITY) | |
protected Long id; | |
private String key; |
This file contains hidden or 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
@Service | |
@Slf4j | |
public class KeyValuePairServiceImpl implements KeyValuePairService { | |
private final KeyValuePairRepository keyValuePairRepository; | |
private final RedisTemplate<String, Object> redisTemplate; | |
private final ObjectMapper objectMapper; | |
public KeyValuePairServiceImpl(KeyValuePairRepository keyValuePairRepository, RedisTemplate<String, Object> redisTemplate) { | |
this.keyValuePairRepository = keyValuePairRepository; | |
this.redisTemplate = redisTemplate; |