Skip to content

Instantly share code, notes, and snippets.

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;
SET global general_log_file='/var/log/mysql/all.log';
SET global log_output = 'file';
SET global general_log = 1;
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)
@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();
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface DocumentId {
}
@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();
@Repository
public class UserRepository extends AbstractFirestoreRepository<User> {
protected UserRepository(Firestore firestore) {
super(firestore, "User");
}
}
public class ApplicationUser {
@DocumentId
private String id;
private String username;
private String password;
private String imageUrl;
private String bio;
}
@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class KeyValuePair {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Long id;
private String key;
@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;