gestion des formats de tickets!
This commit is contained in:
28
app/src/main/java/com/example/quiz/data/ActivityLogger.java
Normal file
28
app/src/main/java/com/example/quiz/data/ActivityLogger.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.example.quiz.data;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.example.quiz.data.dao.UserActivityLogDao;
|
||||
import com.example.quiz.data.entity.Logs;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class ActivityLogger {
|
||||
public static UserActivityLogDao dao;
|
||||
|
||||
public static void init(UserActivityLogDao iDao){
|
||||
dao = iDao;
|
||||
}
|
||||
|
||||
public static void log(String userId, String activity, String description, Long timestamp){
|
||||
Executors.newSingleThreadExecutor().execute(()->{
|
||||
Logs userLog = new Logs();
|
||||
userLog.setUserId(userId);
|
||||
userLog.setAction(activity);
|
||||
userLog.setDescription(description);
|
||||
userLog.setTimestamp(timestamp);
|
||||
dao.insertLog(userLog);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,9 @@ import com.example.quiz.data.model.Course;
|
||||
import com.example.quiz.viewModel.SharedViewModel;
|
||||
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -22,10 +24,8 @@ public class BetsAdapter extends RecyclerView.Adapter<BetsAdapter.BetViewHolder>
|
||||
|
||||
private List<Course> bets = new ArrayList<>();
|
||||
private onItemClickListener listener;
|
||||
private SharedViewModel shared;
|
||||
|
||||
public BetsAdapter(SharedViewModel shared) {
|
||||
this.shared = shared;
|
||||
public BetsAdapter() {
|
||||
}
|
||||
|
||||
public interface onItemClickListener {
|
||||
@@ -52,18 +52,14 @@ public class BetsAdapter extends RecyclerView.Adapter<BetsAdapter.BetViewHolder>
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull BetViewHolder holder, int position) {
|
||||
Course bet = bets.get(position);
|
||||
|
||||
holder.tvDate.setText(LocalDateTime.parse(
|
||||
bet.getDateDepartCourse(),
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")
|
||||
).format(
|
||||
DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss")
|
||||
));
|
||||
OffsetDateTime dateTime = OffsetDateTime.parse(bet.getHeureDepartPrevue());
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
|
||||
String formattedDate = dateTime.format(formatter);
|
||||
holder.tvDate.setText(formattedDate);
|
||||
holder.tvName.setText(bet.getNom());
|
||||
|
||||
if (shared != null && shared.selectedReunion.getValue() != null) {
|
||||
holder.tvReunion.setText(shared.selectedReunion.getValue().getNom());
|
||||
}
|
||||
String reunion = "Reunion "+bet.getReunionNumero();
|
||||
holder.tvReunion.setText(reunion);
|
||||
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
if (listener != null) listener.onItemClick(bet);
|
||||
|
||||
@@ -9,19 +9,21 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.example.quiz.R;
|
||||
import com.example.quiz.data.model.Pari;
|
||||
import com.example.quiz.data.model.ParisResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LastBetsAdapter extends RecyclerView.Adapter<LastBetsAdapter.LastBetsViewHolder> {
|
||||
|
||||
private List<Pari> listeParis = new ArrayList<>(); // évite les NPE
|
||||
private List<ParisResponse> listeParis = new ArrayList<>(); // évite les NPE
|
||||
private OnBetClick onBetClick; // peut être null si tu veux
|
||||
|
||||
public interface OnBetClick {
|
||||
void onItemClick(Pari pari);
|
||||
void onItemClick(ParisResponse pari);
|
||||
}
|
||||
|
||||
public LastBetsAdapter(List<Pari> listeParis, OnBetClick onBetClick) {
|
||||
public LastBetsAdapter(List<ParisResponse> listeParis, OnBetClick onBetClick) {
|
||||
if (listeParis != null) this.listeParis = listeParis;
|
||||
this.onBetClick = onBetClick;
|
||||
}
|
||||
@@ -31,7 +33,7 @@ public class LastBetsAdapter extends RecyclerView.Adapter<LastBetsAdapter.LastBe
|
||||
this.onBetClick = onBetClick;
|
||||
}
|
||||
|
||||
public void setData(List<Pari> newList) {
|
||||
public void setData(List<ParisResponse> newList) {
|
||||
if (newList == null) {
|
||||
this.listeParis = new ArrayList<>();
|
||||
} else {
|
||||
@@ -40,7 +42,7 @@ public class LastBetsAdapter extends RecyclerView.Adapter<LastBetsAdapter.LastBe
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void addItem(Pari pari) {
|
||||
public void addItem(ParisResponse pari) {
|
||||
if (pari == null) return;
|
||||
this.listeParis.add(pari);
|
||||
notifyItemInserted(listeParis.size() - 1);
|
||||
@@ -60,38 +62,21 @@ public class LastBetsAdapter extends RecyclerView.Adapter<LastBetsAdapter.LastBe
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LastBetsViewHolder holder, int position) {
|
||||
Pari pari = listeParis.get(position);
|
||||
ParisResponse pari = listeParis.get(position);
|
||||
if (pari == null) return;
|
||||
|
||||
holder.typeOfCourse.setText(pari.getCourse().getType());
|
||||
holder.typeOfCourse.setText(pari.getCourseNom());
|
||||
holder.refenceTicket.setText(pari.getNumeroTicket());
|
||||
|
||||
// Type (défensif : vérifie null)
|
||||
holder.betType.setText(pari.getTypePari() != null ? pari.getTypePari() : "-");
|
||||
holder.betType.setText(pari.getFormules().size()>0 ? pari.getFormules().get(0):"Pas de formule");
|
||||
|
||||
// Course (défensif : course peut être null)
|
||||
if (pari.getCourse() != null) {
|
||||
holder.course.setText("Course: " + pari.getCourse().getId());
|
||||
} else {
|
||||
holder.course.setText("Course: -");
|
||||
}
|
||||
holder.course.setText("Course: " + pari.getCourseId());
|
||||
|
||||
// Chevaux : join en toute sécurité (gère Integer list ou String list)
|
||||
List<?> chevaux = pari.getChevauxSelectionnes();
|
||||
if (chevaux != null && !chevaux.isEmpty()) {
|
||||
// convertir en strings
|
||||
List<String> str = new ArrayList<>(chevaux.size());
|
||||
for (Object o : chevaux) {
|
||||
str.add(String.valueOf(o));
|
||||
}
|
||||
// TextUtils.join est compatible avec tous les niveaux API
|
||||
holder.horses.setText("Chevaux : " + TextUtils.join("-", str));
|
||||
} else {
|
||||
holder.horses.setText("Chevaux : -");
|
||||
}
|
||||
holder.horses.setText(pari.getCombinaison());
|
||||
|
||||
// Mise (défensif)
|
||||
holder.mise.setText("Mise: " + pari.getMise() + " CFA");
|
||||
holder.mise.setText("Mise: " + pari.getMiseTotale() + " CFA");
|
||||
|
||||
// click listener défensif
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.example.quiz.data.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.quiz.R;
|
||||
import com.example.quiz.data.entity.Logs;
|
||||
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LogsAdapter extends RecyclerView.Adapter<LogsAdapter.LogViewHolder> {
|
||||
|
||||
private List<Logs> logs = new ArrayList<>();
|
||||
|
||||
public void setLogs(List<Logs> logs) {
|
||||
this.logs = logs;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LogViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_log, parent, false);
|
||||
return new LogViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LogViewHolder holder, int position) {
|
||||
Logs log = logs.get(position);
|
||||
|
||||
holder.textAction.setText(log.getAction());
|
||||
holder.textDescription.setText(log.getDescription());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy • HH:mm", Locale.getDefault());
|
||||
holder.textDate.setText(sdf.format(new Date(log.getTimestamp())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return logs.size();
|
||||
}
|
||||
|
||||
static class LogViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView textAction, textDescription, textDate;
|
||||
|
||||
public LogViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
textAction = itemView.findViewById(R.id.textAction);
|
||||
textDescription = itemView.findViewById(R.id.textDescription);
|
||||
textDate = itemView.findViewById(R.id.textDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.example.quiz.data.adapter;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.quiz.R;
|
||||
import com.example.quiz.data.model.PointDeVente;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PointDeVenteAdapter extends RecyclerView.Adapter<PointDeVenteAdapter.ViewHolder> {
|
||||
|
||||
private List<PointDeVente> points = new ArrayList<>();
|
||||
private OnItemClickListener listener;
|
||||
|
||||
|
||||
|
||||
public PointDeVenteAdapter(){
|
||||
|
||||
}
|
||||
// Interface pour gérer le clic sur un item
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(PointDeVente point);
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setPoints(List<PointDeVente> points) {
|
||||
this.points = points;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_point_de_vente, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
PointDeVente point = points.get(position);
|
||||
holder.txtNom.setText(point.getNom());
|
||||
String adresse = point.getVille()+", "+point.getAdresse();
|
||||
holder.txtAdresse.setText(adresse);
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
if (listener != null) listener.onItemClick(point);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return points.size();
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView txtNom;
|
||||
|
||||
TextView txtAdresse;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
txtNom = itemView.findViewById(R.id.txtNom);
|
||||
txtAdresse = itemView.findViewById(R.id.txtAdresse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.example.quiz.data.dao;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
|
||||
import com.example.quiz.data.entity.Logs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface UserActivityLogDao {
|
||||
|
||||
@Insert
|
||||
void insertLog(Logs log);
|
||||
|
||||
@Query(" SELECT * FROM user_activity_logs WHERE date(timestamp / 1000, 'unixepoch', 'localtime') = date('now', 'localtime') ORDER BY timestamp DESC ")
|
||||
LiveData<List<Logs>> getTodayLogs();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.example.quiz.data.database;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import com.example.quiz.data.dao.UserActivityLogDao;
|
||||
import com.example.quiz.data.entity.Logs;
|
||||
|
||||
@Database(entities = {Logs.class}, version = 3, exportSchema = false)
|
||||
public abstract class AppDataBase extends RoomDatabase {
|
||||
|
||||
private static AppDataBase instance;
|
||||
|
||||
public abstract UserActivityLogDao logsDao();
|
||||
|
||||
public static synchronized AppDataBase getInstance(Context context) {
|
||||
if (instance == null) {
|
||||
instance = Room.databaseBuilder(
|
||||
context.getApplicationContext(),
|
||||
AppDataBase.class,
|
||||
"app-db"
|
||||
).fallbackToDestructiveMigration() // optionnel
|
||||
.build();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.example.quiz.data.database;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.room.Room;
|
||||
|
||||
|
||||
|
||||
public class DatabaseClient {
|
||||
|
||||
private static DatabaseClient instance;
|
||||
private AppDataBase appDatabase;
|
||||
private Context context;
|
||||
|
||||
private DatabaseClient(Context context) {
|
||||
this.context = context;
|
||||
appDatabase = Room.databaseBuilder(context,
|
||||
AppDataBase.class, "QuizDB")
|
||||
.fallbackToDestructiveMigration()
|
||||
.build();
|
||||
}
|
||||
|
||||
public static synchronized DatabaseClient getInstance(Context context) {
|
||||
if (instance == null) {
|
||||
instance = new DatabaseClient(context);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public AppDataBase getAppDatabase() {
|
||||
return appDatabase;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.example.quiz.data.database;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.room.Room;
|
||||
|
||||
import com.example.quiz.data.dao.UserActivityLogDao;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import dagger.hilt.InstallIn;
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext;
|
||||
import dagger.hilt.components.SingletonComponent;
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent.class)
|
||||
public class DatabaseModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public static AppDataBase provideDatabase(@ApplicationContext Context context) {
|
||||
return Room.databaseBuilder(context, AppDataBase.class, "QuizDB")
|
||||
.fallbackToDestructiveMigration()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Provides
|
||||
public static UserActivityLogDao provideUserActivityLogDao(AppDataBase db) {
|
||||
return db.logsDao(); // ton DAO
|
||||
}
|
||||
}
|
||||
59
app/src/main/java/com/example/quiz/data/entity/Logs.java
Normal file
59
app/src/main/java/com/example/quiz/data/entity/Logs.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.example.quiz.data.entity;
|
||||
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity(tableName = "user_activity_logs")
|
||||
public class Logs {
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int id;
|
||||
|
||||
private String userId;
|
||||
private String action;
|
||||
|
||||
private String description;
|
||||
private Long timestamp;
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
@@ -8,117 +8,75 @@ import java.util.List;
|
||||
|
||||
|
||||
public class Course {
|
||||
private int id;
|
||||
private String type;
|
||||
private String numero;
|
||||
private long id;
|
||||
private long hippodromeId;
|
||||
private long reunionNumero;
|
||||
|
||||
private String reunionDate;
|
||||
private String nom;
|
||||
private String lieu;
|
||||
private String dateDepartCourse;
|
||||
private int reunionId;
|
||||
private String particularite;
|
||||
private int partants;
|
||||
private String statut;
|
||||
private int nombreChevauxInscrits;
|
||||
|
||||
public Course(int id, String type, String numero, String nom, String lieu, String dateDepartCourse, int reunionId, String particularite, int partants, String statut, int nombreChevauxInscrits) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.numero = numero;
|
||||
this.nom = nom;
|
||||
this.lieu = lieu;
|
||||
this.dateDepartCourse = dateDepartCourse;
|
||||
this.reunionId = reunionId;
|
||||
this.particularite = particularite;
|
||||
this.partants = partants;
|
||||
this.statut = statut;
|
||||
this.nombreChevauxInscrits = nombreChevauxInscrits;
|
||||
private int numero;
|
||||
private String heureDepartPrevue;
|
||||
|
||||
private boolean bettingOpen;
|
||||
private String bettingClosedAt;
|
||||
|
||||
private String discipline;
|
||||
private int distanceMetres;
|
||||
private String categorie;
|
||||
private int nombrePartants;
|
||||
|
||||
private Statut statut;
|
||||
|
||||
private boolean annulee;
|
||||
private boolean reporteeMemeJour;
|
||||
private boolean reporteeAutreJour;
|
||||
private boolean incidentTechnique;
|
||||
|
||||
private List<Integer> nonPartants;
|
||||
private List<TypeParis> typesParisOuverts;
|
||||
|
||||
// ===== ENUMS =====
|
||||
|
||||
public enum Statut {
|
||||
BROUILLON,
|
||||
VALIDE,
|
||||
OUVERT,
|
||||
FERME,
|
||||
RESULTAT_PROVISOIRE,
|
||||
RESULTAT_OFFICIEL,
|
||||
REGLEE,
|
||||
ANNULEE
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
public enum TypeParis {
|
||||
COUPLE_GAGNANT,
|
||||
COUPLE_PLACE,
|
||||
TIERCE,
|
||||
QUARTE,
|
||||
QUINTE
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
// ===== GETTERS & SETTERS =====
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String stype) {
|
||||
this.type = stype;
|
||||
}
|
||||
|
||||
public String getNumero() {
|
||||
return numero;
|
||||
}
|
||||
|
||||
public void setNumero(String numero) {
|
||||
this.numero = numero;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
public String getLieu() {
|
||||
return lieu;
|
||||
}
|
||||
|
||||
public void setLieu(String lieu) {
|
||||
this.lieu = lieu;
|
||||
}
|
||||
|
||||
public String getDateDepartCourse() {
|
||||
return dateDepartCourse;
|
||||
}
|
||||
|
||||
public void setDateDepartCourse(String dateDepartCourse) {
|
||||
this.dateDepartCourse = dateDepartCourse;
|
||||
}
|
||||
|
||||
public int getReunionId() {
|
||||
return reunionId;
|
||||
}
|
||||
|
||||
public void setReunionId(int reunionId) {
|
||||
this.reunionId = reunionId;
|
||||
}
|
||||
|
||||
public String getParticularite() {
|
||||
return particularite;
|
||||
}
|
||||
|
||||
public void setParticularite(String particularite) {
|
||||
this.particularite = particularite;
|
||||
}
|
||||
|
||||
public int getPartants() {
|
||||
return partants;
|
||||
}
|
||||
|
||||
public void setPartants(int partants) {
|
||||
this.partants = partants;
|
||||
}
|
||||
|
||||
public String getStatut() {
|
||||
return statut;
|
||||
}
|
||||
|
||||
public void setStatut(String statut) {
|
||||
this.statut = statut;
|
||||
}
|
||||
|
||||
public int getNombreChevauxInscrits() {
|
||||
return nombreChevauxInscrits;
|
||||
}
|
||||
|
||||
public void setNombreChevauxInscrits(int nombreChevauxInscrits) {
|
||||
this.nombreChevauxInscrits = nombreChevauxInscrits;
|
||||
}
|
||||
public long getId() { return id; }
|
||||
public long getHippodromeId() { return hippodromeId; }
|
||||
public long getReunionNumero() { return reunionNumero; }
|
||||
public String getReunionDate() { return reunionDate; }
|
||||
public String getNom() { return nom; }
|
||||
public int getNumero() { return numero; }
|
||||
public String getHeureDepartPrevue() { return heureDepartPrevue; }
|
||||
public boolean isBettingOpen() { return bettingOpen; }
|
||||
public String getBettingClosedAt() { return bettingClosedAt; }
|
||||
public String getDiscipline() { return discipline; }
|
||||
public int getDistanceMetres() { return distanceMetres; }
|
||||
public String getCategorie() { return categorie; }
|
||||
public int getNombrePartants() { return nombrePartants; }
|
||||
public Statut getStatut() { return statut; }
|
||||
public boolean isAnnulee() { return annulee; }
|
||||
public boolean isReporteeMemeJour() { return reporteeMemeJour; }
|
||||
public boolean isReporteeAutreJour() { return reporteeAutreJour; }
|
||||
public boolean isIncidentTechnique() { return incidentTechnique; }
|
||||
public List<Integer> getNonPartants() { return nonPartants; }
|
||||
public List<TypeParis> getTypesParisOuverts() { return typesParisOuverts; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.example.quiz.data.model;
|
||||
|
||||
import com.example.quiz.data.model.enums.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PagedModel<T> {
|
||||
private Long totalPages;
|
||||
private Long totalElements;
|
||||
private Pageable pageable;
|
||||
private Long numberOfElements;
|
||||
private Long size;
|
||||
private List<T> content;
|
||||
|
||||
public Long getTotalPages() {
|
||||
return totalPages;
|
||||
}
|
||||
|
||||
public void setTotalPages(Long totalPages) {
|
||||
this.totalPages = totalPages;
|
||||
}
|
||||
|
||||
public Long getTotalElements() {
|
||||
return totalElements;
|
||||
}
|
||||
|
||||
public void setTotalElements(Long totalElements) {
|
||||
this.totalElements = totalElements;
|
||||
}
|
||||
|
||||
public Pageable getPageable() {
|
||||
return pageable;
|
||||
}
|
||||
|
||||
public void setPageable(Pageable pageable) {
|
||||
this.pageable = pageable;
|
||||
}
|
||||
|
||||
public Long getNumberOfElements() {
|
||||
return numberOfElements;
|
||||
}
|
||||
|
||||
public void setNumberOfElements(Long numberOfElements) {
|
||||
this.numberOfElements = numberOfElements;
|
||||
}
|
||||
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public List<T> getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(List<T> content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
@@ -4,129 +4,51 @@ import com.example.quiz.data.model.enums.PariStatut;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Pari {
|
||||
private String numeroTicket;
|
||||
private String typePari;
|
||||
private double mise;
|
||||
private String datePari;
|
||||
private boolean estPaye;
|
||||
private boolean estRembourse;
|
||||
private PariCourseDto course;
|
||||
private List<String> chevauxSelectionnes;
|
||||
private List<String> ordrePredit;
|
||||
private boolean validationOrdreExact;
|
||||
private String typeMulti;
|
||||
|
||||
private String createdBy;
|
||||
private String dateHeurePrise; // ISO String
|
||||
private long courseId;
|
||||
private long agentId;
|
||||
private long terminalId;
|
||||
private long pointDeVenteId;
|
||||
|
||||
public Pari(String numeroTicket, String typePari, double mise, String datePari, boolean estPaye, boolean estRembourse, PariCourseDto course, List<String> chevauxSelectionnes, List<String> ordrePredit, boolean validationOrdreExact, String typeMulti, String createdBy) {
|
||||
this.numeroTicket = numeroTicket;
|
||||
this.typePari = typePari;
|
||||
this.mise = mise;
|
||||
this.datePari = datePari;
|
||||
this.estPaye = estPaye;
|
||||
this.estRembourse = estRembourse;
|
||||
this.course = course;
|
||||
this.chevauxSelectionnes = chevauxSelectionnes;
|
||||
this.ordrePredit = ordrePredit;
|
||||
this.validationOrdreExact = validationOrdreExact;
|
||||
this.typeMulti = typeMulti;
|
||||
this.createdBy = createdBy;
|
||||
private List<PariMise> typesParisMises;
|
||||
private List<String> formules;
|
||||
|
||||
private String combinaison;
|
||||
private double coefficient;
|
||||
private String devise;
|
||||
private String notes;
|
||||
|
||||
public Pari(String dateHeurePrise, long courseId, long agentId, long terminalId, long pointDeVenteId, List<PariMise> typesParisMises, List<String> formules, String combinaison, double coefficient, String devise, String notes) {
|
||||
this.dateHeurePrise = dateHeurePrise;
|
||||
this.courseId = courseId;
|
||||
this.agentId = agentId;
|
||||
this.terminalId = terminalId;
|
||||
this.pointDeVenteId = pointDeVenteId;
|
||||
this.typesParisMises = typesParisMises;
|
||||
this.formules = formules;
|
||||
this.combinaison = combinaison;
|
||||
this.coefficient = coefficient;
|
||||
this.devise = devise;
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
public String getNumeroTicket() {
|
||||
return numeroTicket;
|
||||
}
|
||||
public String getDateHeurePrise() { return dateHeurePrise; }
|
||||
public long getCourseId() { return courseId; }
|
||||
public long getAgentId() { return agentId; }
|
||||
public long getTerminalId() { return terminalId; }
|
||||
public long getPointDeVenteId() { return pointDeVenteId; }
|
||||
public List<PariMise> getTypesParisMises() { return typesParisMises; }
|
||||
public List<String> getFormules() { return formules; }
|
||||
public String getCombinaison() { return combinaison; }
|
||||
public double getCoefficient() { return coefficient; }
|
||||
public String getDevise() { return devise; }
|
||||
public String getNotes() { return notes; }
|
||||
|
||||
public void setNumeroTicket(String numeroTicket) {
|
||||
this.numeroTicket = numeroTicket;
|
||||
}
|
||||
|
||||
public String getTypePari() {
|
||||
return typePari;
|
||||
}
|
||||
|
||||
public void setTypePari(String typePari) {
|
||||
this.typePari = typePari;
|
||||
}
|
||||
|
||||
public double getMise() {
|
||||
return mise;
|
||||
}
|
||||
|
||||
public void setMise(double mise) {
|
||||
this.mise = mise;
|
||||
}
|
||||
|
||||
public String getDatePari() {
|
||||
return datePari;
|
||||
}
|
||||
|
||||
public void setDatePari(String datePari) {
|
||||
this.datePari = datePari;
|
||||
}
|
||||
|
||||
public boolean isEstPaye() {
|
||||
return estPaye;
|
||||
}
|
||||
|
||||
public void setEstPaye(boolean estPaye) {
|
||||
this.estPaye = estPaye;
|
||||
}
|
||||
|
||||
public boolean isEstRembourse() {
|
||||
return estRembourse;
|
||||
}
|
||||
|
||||
public void setEstRembourse(boolean estRembourse) {
|
||||
this.estRembourse = estRembourse;
|
||||
}
|
||||
|
||||
public PariCourseDto getCourse() {
|
||||
return course;
|
||||
}
|
||||
|
||||
public void setCourse(PariCourseDto course) {
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public List<String> getChevauxSelectionnes() {
|
||||
return chevauxSelectionnes;
|
||||
}
|
||||
|
||||
public void setChevauxSelectionnes(List<String> chevauxSelectionnes) {
|
||||
this.chevauxSelectionnes = chevauxSelectionnes;
|
||||
}
|
||||
|
||||
public List<String> getOrdrePredit() {
|
||||
return ordrePredit;
|
||||
}
|
||||
|
||||
public void setOrdrePredit(List<String> ordrePredit) {
|
||||
this.ordrePredit = ordrePredit;
|
||||
}
|
||||
|
||||
public boolean isValidationOrdreExact() {
|
||||
return validationOrdreExact;
|
||||
}
|
||||
|
||||
public void setValidationOrdreExact(boolean validationOrdreExact) {
|
||||
this.validationOrdreExact = validationOrdreExact;
|
||||
}
|
||||
|
||||
public String getTypeMulti() {
|
||||
return typeMulti;
|
||||
}
|
||||
|
||||
public void setTypeMulti(String typeMulti) {
|
||||
this.typeMulti = typeMulti;
|
||||
}
|
||||
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedBy(String createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
// ===== INNER CLASS =====
|
||||
}
|
||||
|
||||
19
app/src/main/java/com/example/quiz/data/model/PariMise.java
Normal file
19
app/src/main/java/com/example/quiz/data/model/PariMise.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.example.quiz.data.model;
|
||||
|
||||
public class PariMise {
|
||||
private String typePari;
|
||||
private long miseTotale;
|
||||
|
||||
public PariMise(String typePari, long miseTotale) {
|
||||
this.typePari = typePari;
|
||||
this.miseTotale = miseTotale;
|
||||
}
|
||||
|
||||
public String getTypePari() {
|
||||
return typePari;
|
||||
}
|
||||
|
||||
public long getMiseTotale() {
|
||||
return miseTotale;
|
||||
}
|
||||
}
|
||||
100
app/src/main/java/com/example/quiz/data/model/ParisResponse.java
Normal file
100
app/src/main/java/com/example/quiz/data/model/ParisResponse.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package com.example.quiz.data.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class ParisResponse implements Serializable {
|
||||
private long id;
|
||||
private String numeroTicket;
|
||||
private String dateHeurePrise;
|
||||
private String qrPayload;
|
||||
|
||||
private long courseId;
|
||||
private String courseNom;
|
||||
private int courseNumero;
|
||||
|
||||
private String hippodromeNom;
|
||||
private long reunionNumero;
|
||||
private String reunionDate;
|
||||
private String heureDepartPrevue;
|
||||
|
||||
private int nombrePartants;
|
||||
private List<Integer> nonPartants;
|
||||
|
||||
private long agentId;
|
||||
private String agentCode;
|
||||
private String agentNom;
|
||||
|
||||
private long terminalId;
|
||||
private String terminalNumeroSerie;
|
||||
|
||||
private long pointDeVenteId;
|
||||
private String pointDeVenteCode;
|
||||
private String pointDeVenteNom;
|
||||
|
||||
private List<PariMise> typesParisMises;
|
||||
private long miseTotale;
|
||||
|
||||
private List<String> formules;
|
||||
|
||||
private double coefficient;
|
||||
private String combinaison;
|
||||
|
||||
private StatutPari statutPari;
|
||||
|
||||
private long gainCalcule;
|
||||
private String devise;
|
||||
|
||||
private String dateReglement;
|
||||
private String datePaiement;
|
||||
|
||||
private String notes;
|
||||
|
||||
// ================= ENUM =================
|
||||
|
||||
public enum StatutPari {
|
||||
ENREGISTRE,
|
||||
VALIDE,
|
||||
PAYE,
|
||||
ANNULE,
|
||||
PERDANT,
|
||||
GAGNANT
|
||||
}
|
||||
|
||||
// ================= INNER CLASS =================
|
||||
|
||||
// ================= GETTERS =================
|
||||
|
||||
public long getId() { return id; }
|
||||
public String getNumeroTicket() { return numeroTicket; }
|
||||
public String getDateHeurePrise() { return dateHeurePrise; }
|
||||
public String getQrPayload() { return qrPayload; }
|
||||
public long getCourseId() { return courseId; }
|
||||
public String getCourseNom() { return courseNom; }
|
||||
public int getCourseNumero() { return courseNumero; }
|
||||
public String getHippodromeNom() { return hippodromeNom; }
|
||||
public long getReunionNumero() { return reunionNumero; }
|
||||
public String getReunionDate() { return reunionDate; }
|
||||
public String getHeureDepartPrevue() { return heureDepartPrevue; }
|
||||
public int getNombrePartants() { return nombrePartants; }
|
||||
public List<Integer> getNonPartants() { return nonPartants; }
|
||||
public long getAgentId() { return agentId; }
|
||||
public String getAgentCode() { return agentCode; }
|
||||
public String getAgentNom() { return agentNom; }
|
||||
public long getTerminalId() { return terminalId; }
|
||||
public String getTerminalNumeroSerie() { return terminalNumeroSerie; }
|
||||
public long getPointDeVenteId() { return pointDeVenteId; }
|
||||
public String getPointDeVenteCode() { return pointDeVenteCode; }
|
||||
public String getPointDeVenteNom() { return pointDeVenteNom; }
|
||||
public List<PariMise> getTypesParisMises() { return typesParisMises; }
|
||||
public long getMiseTotale() { return miseTotale; }
|
||||
public List<String> getFormules() { return formules; }
|
||||
public double getCoefficient() { return coefficient; }
|
||||
public String getCombinaison() { return combinaison; }
|
||||
public StatutPari getStatutPari() { return statutPari; }
|
||||
public long getGainCalcule() { return gainCalcule; }
|
||||
public String getDevise() { return devise; }
|
||||
public String getDateReglement() { return dateReglement; }
|
||||
public String getDatePaiement() { return datePaiement; }
|
||||
public String getNotes() { return notes; }
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.example.quiz.data.model;
|
||||
|
||||
public class PointDeVente {
|
||||
private Long id;
|
||||
private String code;
|
||||
private String nom;
|
||||
private String adresse;
|
||||
private String ville;
|
||||
private String latitude;
|
||||
private String longitude;
|
||||
private PointStatus statut;
|
||||
|
||||
public PointDeVente(Long id, String code, String nom, String adresse, String ville, String latitude, String longitude, PointStatus statut) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.nom = nom;
|
||||
this.adresse = adresse;
|
||||
this.ville = ville;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.statut = statut;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
public String getAdresse() {
|
||||
return adresse;
|
||||
}
|
||||
|
||||
public void setAdresse(String adresse) {
|
||||
this.adresse = adresse;
|
||||
}
|
||||
|
||||
public String getVille() {
|
||||
return ville;
|
||||
}
|
||||
|
||||
public void setVille(String ville) {
|
||||
this.ville = ville;
|
||||
}
|
||||
|
||||
public String getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(String latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public String getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(String longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public PointStatus getStatut() {
|
||||
return statut;
|
||||
}
|
||||
|
||||
public void setStatut(PointStatus statut) {
|
||||
this.statut = statut;
|
||||
}
|
||||
|
||||
public enum PointStatus {
|
||||
ACTIF,
|
||||
INACTIF
|
||||
}
|
||||
}
|
||||
114
app/src/main/java/com/example/quiz/data/model/Tpe.java
Normal file
114
app/src/main/java/com/example/quiz/data/model/Tpe.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package com.example.quiz.data.model;
|
||||
|
||||
public class Tpe {
|
||||
private String numeroSerie;
|
||||
private long pointDeVenteId;
|
||||
private String statut;
|
||||
private String versionLogicielle;
|
||||
private String typeTerminal;
|
||||
private String plateforme;
|
||||
private String modeleAppareil;
|
||||
private String systemeExploitation;
|
||||
private String versionOs;
|
||||
private String adresseIp;
|
||||
private String adresseMac;
|
||||
private String journalSession;
|
||||
|
||||
public Tpe() {}
|
||||
|
||||
public String getNumeroSerie() {
|
||||
return numeroSerie;
|
||||
}
|
||||
|
||||
public void setNumeroSerie(String numeroSerie) {
|
||||
this.numeroSerie = numeroSerie;
|
||||
}
|
||||
|
||||
public long getPointDeVenteId() {
|
||||
return pointDeVenteId;
|
||||
}
|
||||
|
||||
public void setPointDeVenteId(long pointDeVenteId) {
|
||||
this.pointDeVenteId = pointDeVenteId;
|
||||
}
|
||||
|
||||
public String getStatut() {
|
||||
return statut;
|
||||
}
|
||||
|
||||
public void setStatut(String statut) {
|
||||
this.statut = statut;
|
||||
}
|
||||
|
||||
public String getVersionLogicielle() {
|
||||
return versionLogicielle;
|
||||
}
|
||||
|
||||
public void setVersionLogicielle(String versionLogicielle) {
|
||||
this.versionLogicielle = versionLogicielle;
|
||||
}
|
||||
|
||||
public String getTypeTerminal() {
|
||||
return typeTerminal;
|
||||
}
|
||||
|
||||
public void setTypeTerminal(String typeTerminal) {
|
||||
this.typeTerminal = typeTerminal;
|
||||
}
|
||||
|
||||
public String getPlateforme() {
|
||||
return plateforme;
|
||||
}
|
||||
|
||||
public void setPlateforme(String plateforme) {
|
||||
this.plateforme = plateforme;
|
||||
}
|
||||
|
||||
public String getModeleAppareil() {
|
||||
return modeleAppareil;
|
||||
}
|
||||
|
||||
public void setModeleAppareil(String modeleAppareil) {
|
||||
this.modeleAppareil = modeleAppareil;
|
||||
}
|
||||
|
||||
public String getSystemeExploitation() {
|
||||
return systemeExploitation;
|
||||
}
|
||||
|
||||
public void setSystemeExploitation(String systemeExploitation) {
|
||||
this.systemeExploitation = systemeExploitation;
|
||||
}
|
||||
|
||||
public String getVersionOs() {
|
||||
return versionOs;
|
||||
}
|
||||
|
||||
public void setVersionOs(String versionOs) {
|
||||
this.versionOs = versionOs;
|
||||
}
|
||||
|
||||
public String getAdresseIp() {
|
||||
return adresseIp;
|
||||
}
|
||||
|
||||
public void setAdresseIp(String adresseIp) {
|
||||
this.adresseIp = adresseIp;
|
||||
}
|
||||
|
||||
public String getAdresseMac() {
|
||||
return adresseMac;
|
||||
}
|
||||
|
||||
public void setAdresseMac(String adresseMac) {
|
||||
this.adresseMac = adresseMac;
|
||||
}
|
||||
|
||||
public String getJournalSession() {
|
||||
return journalSession;
|
||||
}
|
||||
|
||||
public void setJournalSession(String journalSession) {
|
||||
this.journalSession = journalSession;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.example.quiz.data.model;
|
||||
|
||||
public class TpeResponse extends Tpe {
|
||||
private long id;
|
||||
private String derniereConnexion;
|
||||
private String derniereConnexionAgent;
|
||||
private String derniereDeconnexionAgent;
|
||||
private boolean assigned;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getDerniereConnexion() {
|
||||
return derniereConnexion;
|
||||
}
|
||||
|
||||
public void setDerniereConnexion(String derniereConnexion) {
|
||||
this.derniereConnexion = derniereConnexion;
|
||||
}
|
||||
|
||||
public String getDerniereConnexionAgent() {
|
||||
return derniereConnexionAgent;
|
||||
}
|
||||
|
||||
public void setDerniereConnexionAgent(String derniereConnexionAgent) {
|
||||
this.derniereConnexionAgent = derniereConnexionAgent;
|
||||
}
|
||||
|
||||
public String getDerniereDeconnexionAgent() {
|
||||
return derniereDeconnexionAgent;
|
||||
}
|
||||
|
||||
public void setDerniereDeconnexionAgent(String derniereDeconnexionAgent) {
|
||||
this.derniereDeconnexionAgent = derniereDeconnexionAgent;
|
||||
}
|
||||
|
||||
public boolean isAssigned() {
|
||||
return assigned;
|
||||
}
|
||||
|
||||
public void setAssigned(boolean assigned) {
|
||||
this.assigned = assigned;
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,10 @@ package com.example.quiz.data.model;
|
||||
public class TypeOfBet {
|
||||
|
||||
private String label;
|
||||
private String name;
|
||||
private Course.TypeParis name;
|
||||
private int numberOfHorse;
|
||||
|
||||
public TypeOfBet(String label, String name, int numberOfHorse) {
|
||||
public TypeOfBet(String label, Course.TypeParis name, int numberOfHorse) {
|
||||
this.label = label;
|
||||
this.name = name;
|
||||
this.numberOfHorse = numberOfHorse;
|
||||
@@ -20,11 +20,11 @@ public class TypeOfBet {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
public Course.TypeParis getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public void setName(Course.TypeParis name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.example.quiz.data.model.dtos.auth;
|
||||
|
||||
public class Agent {
|
||||
private Long id;
|
||||
private String code;
|
||||
private String nom;
|
||||
private String prenom;
|
||||
private String phone;
|
||||
private String zone;
|
||||
private String fonction;
|
||||
public Agent(){}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
public String getPrenom() {
|
||||
return prenom;
|
||||
}
|
||||
|
||||
public void setPrenom(String prenom) {
|
||||
this.prenom = prenom;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getZone() {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public void setZone(String zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
public String getFonction() {
|
||||
return fonction;
|
||||
}
|
||||
|
||||
public void setFonction(String fonction) {
|
||||
this.fonction = fonction;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,31 @@
|
||||
package com.example.quiz.data.model.dtos.auth;
|
||||
|
||||
public class LoginPayload {
|
||||
private String pin;
|
||||
|
||||
public LoginPayload(String pin) {
|
||||
private String code;
|
||||
private String pin;
|
||||
private Long terminalId;
|
||||
|
||||
public LoginPayload(String code, String pin, Long terminalId) {
|
||||
this.code = code;
|
||||
this.pin = pin;
|
||||
this.terminalId = terminalId;
|
||||
}
|
||||
|
||||
public Long getTerminalId() {
|
||||
return terminalId;
|
||||
}
|
||||
|
||||
public void setTerminalId(Long terminalId) {
|
||||
this.terminalId = terminalId;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getPin() {
|
||||
|
||||
@@ -1,237 +1,27 @@
|
||||
package com.example.quiz.data.model.dtos.auth;
|
||||
|
||||
public class LoginResponse {
|
||||
private int id;
|
||||
private String code;
|
||||
private String profile;
|
||||
private String principalCode;
|
||||
private String caisseProfile;
|
||||
private String statut;
|
||||
private String zone;
|
||||
private String kiosk;
|
||||
private String fonction;
|
||||
private String dateEmbauche;
|
||||
private String derniereConnexion;
|
||||
private String nom;
|
||||
private String prenom;
|
||||
private String autresNom;
|
||||
private String dateNaissance;
|
||||
private String lieuNaissance;
|
||||
private String ville;
|
||||
private String adresse;
|
||||
private String cni;
|
||||
private double limiteInferieure;
|
||||
private double limiteSuperieure;
|
||||
private double limiteParTransaction;
|
||||
private String autreAdresse1;
|
||||
private String token;
|
||||
private Agent agent;
|
||||
|
||||
public LoginResponse(int id, String code, String profile, String principalCode, String caisseProfile, String statut, String zone, String kiosk, String fonction, String dateEmbauche, String derniereConnexion, String nom, String prenom, String autresNom, String dateNaissance, String lieuNaissance, String ville, String adresse, String cni, double limiteInferieure, double limiteSuperieure, double limiteParTransaction, String autreAdresse1) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.profile = profile;
|
||||
this.principalCode = principalCode;
|
||||
this.caisseProfile = caisseProfile;
|
||||
this.statut = statut;
|
||||
this.zone = zone;
|
||||
this.kiosk = kiosk;
|
||||
this.fonction = fonction;
|
||||
this.dateEmbauche = dateEmbauche;
|
||||
this.derniereConnexion = derniereConnexion;
|
||||
this.nom = nom;
|
||||
this.prenom = prenom;
|
||||
this.autresNom = autresNom;
|
||||
this.dateNaissance = dateNaissance;
|
||||
this.lieuNaissance = lieuNaissance;
|
||||
this.ville = ville;
|
||||
this.adresse = adresse;
|
||||
this.cni = cni;
|
||||
this.limiteInferieure = limiteInferieure;
|
||||
this.limiteSuperieure = limiteSuperieure;
|
||||
this.limiteParTransaction = limiteParTransaction;
|
||||
this.autreAdresse1 = autreAdresse1;
|
||||
public LoginResponse(String token, Agent agent) {
|
||||
this.token = token;
|
||||
this.agent = agent;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
public Agent getUser() {
|
||||
return agent;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
public void setUser(Agent agent) {
|
||||
this.agent = agent;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(String profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public String getPrincipalCode() {
|
||||
return principalCode;
|
||||
}
|
||||
|
||||
public void setPrincipalCode(String principalCode) {
|
||||
this.principalCode = principalCode;
|
||||
}
|
||||
|
||||
public String getCaisseProfile() {
|
||||
return caisseProfile;
|
||||
}
|
||||
|
||||
public void setCaisseProfile(String caisseProfile) {
|
||||
this.caisseProfile = caisseProfile;
|
||||
}
|
||||
|
||||
public String getStatut() {
|
||||
return statut;
|
||||
}
|
||||
|
||||
public void setStatut(String statut) {
|
||||
this.statut = statut;
|
||||
}
|
||||
|
||||
public String getZone() {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public void setZone(String zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
public String getKiosk() {
|
||||
return kiosk;
|
||||
}
|
||||
|
||||
public void setKiosk(String kiosk) {
|
||||
this.kiosk = kiosk;
|
||||
}
|
||||
|
||||
public String getFonction() {
|
||||
return fonction;
|
||||
}
|
||||
|
||||
public void setFonction(String fonction) {
|
||||
this.fonction = fonction;
|
||||
}
|
||||
|
||||
public String getDateEmbauche() {
|
||||
return dateEmbauche;
|
||||
}
|
||||
|
||||
public void setDateEmbauche(String dateEmbauche) {
|
||||
this.dateEmbauche = dateEmbauche;
|
||||
}
|
||||
|
||||
public String getDerniereConnexion() {
|
||||
return derniereConnexion;
|
||||
}
|
||||
|
||||
public void setDerniereConnexion(String derniereConnexion) {
|
||||
this.derniereConnexion = derniereConnexion;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
public String getPrenom() {
|
||||
return prenom;
|
||||
}
|
||||
|
||||
public void setPrenom(String prenom) {
|
||||
this.prenom = prenom;
|
||||
}
|
||||
|
||||
public String getAutresNom() {
|
||||
return autresNom;
|
||||
}
|
||||
|
||||
public void setAutresNom(String autresNom) {
|
||||
this.autresNom = autresNom;
|
||||
}
|
||||
|
||||
public String getDateNaissance() {
|
||||
return dateNaissance;
|
||||
}
|
||||
|
||||
public void setDateNaissance(String dateNaissance) {
|
||||
this.dateNaissance = dateNaissance;
|
||||
}
|
||||
|
||||
public String getLieuNaissance() {
|
||||
return lieuNaissance;
|
||||
}
|
||||
|
||||
public void setLieuNaissance(String lieuNaissance) {
|
||||
this.lieuNaissance = lieuNaissance;
|
||||
}
|
||||
|
||||
public String getVille() {
|
||||
return ville;
|
||||
}
|
||||
|
||||
public void setVille(String ville) {
|
||||
this.ville = ville;
|
||||
}
|
||||
|
||||
public String getAdresse() {
|
||||
return adresse;
|
||||
}
|
||||
|
||||
public void setAdresse(String adresse) {
|
||||
this.adresse = adresse;
|
||||
}
|
||||
|
||||
public String getCni() {
|
||||
return cni;
|
||||
}
|
||||
|
||||
public void setCni(String cni) {
|
||||
this.cni = cni;
|
||||
}
|
||||
|
||||
public double getLimiteInferieure() {
|
||||
return limiteInferieure;
|
||||
}
|
||||
|
||||
public void setLimiteInferieure(double limiteInferieure) {
|
||||
this.limiteInferieure = limiteInferieure;
|
||||
}
|
||||
|
||||
public double getLimiteSuperieure() {
|
||||
return limiteSuperieure;
|
||||
}
|
||||
|
||||
public void setLimiteSuperieure(double limiteSuperieure) {
|
||||
this.limiteSuperieure = limiteSuperieure;
|
||||
}
|
||||
|
||||
public double getLimiteParTransaction() {
|
||||
return limiteParTransaction;
|
||||
}
|
||||
|
||||
public void setLimiteParTransaction(double limiteParTransaction) {
|
||||
this.limiteParTransaction = limiteParTransaction;
|
||||
}
|
||||
|
||||
public String getAutreAdresse1() {
|
||||
return autreAdresse1;
|
||||
}
|
||||
|
||||
public void setAutreAdresse1(String autreAdresse1) {
|
||||
this.autreAdresse1 = autreAdresse1;
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
package com.example.quiz.data.model.dtos.auth;
|
||||
|
||||
public class User {
|
||||
private int id;
|
||||
private String code;
|
||||
private String profile;
|
||||
private String principalCode;
|
||||
private String caisseProfile;
|
||||
private String statut;
|
||||
private String zone;
|
||||
private String kiosk;
|
||||
private String fonction;
|
||||
private String dateEmbauche;
|
||||
private String derniereConnexion;
|
||||
private String nom;
|
||||
private String prenom;
|
||||
private String autresNom;
|
||||
private String dateNaissance;
|
||||
private String lieuNaissance;
|
||||
private String ville;
|
||||
private String adresse;
|
||||
private String cni;
|
||||
private double limiteInferieure;
|
||||
private double limiteSuperieure;
|
||||
private double limiteParTransaction;
|
||||
private String autreAdresse1;
|
||||
|
||||
public User(int id, String code, String profile, String principalCode, String caisseProfile, String statut, String zone, String kiosk, String fonction, String dateEmbauche, String derniereConnexion, String nom, String prenom, String autresNom, String dateNaissance, String lieuNaissance, String ville, String adresse, String cni, double limiteInferieure, double limiteSuperieure, double limiteParTransaction, String autreAdresse1){
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.profile = profile;
|
||||
this.principalCode = principalCode;
|
||||
this.caisseProfile = caisseProfile;
|
||||
this.statut = statut;
|
||||
this.zone = zone;
|
||||
this.kiosk = kiosk;
|
||||
this.fonction = fonction;
|
||||
this.dateEmbauche = dateEmbauche;
|
||||
this.derniereConnexion = derniereConnexion;
|
||||
this.nom = nom;
|
||||
this.prenom = prenom;
|
||||
this.autresNom = autresNom;
|
||||
this.dateNaissance = dateNaissance;
|
||||
this.lieuNaissance = lieuNaissance;
|
||||
this.ville = ville;
|
||||
this.adresse = adresse;
|
||||
this.cni = cni;
|
||||
this.limiteInferieure = limiteInferieure;
|
||||
this.limiteSuperieure = limiteSuperieure;
|
||||
this.limiteParTransaction = limiteParTransaction;
|
||||
this.autreAdresse1 = autreAdresse1;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(String profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public String getPrincipalCode() {
|
||||
return principalCode;
|
||||
}
|
||||
|
||||
public void setPrincipalCode(String principalCode) {
|
||||
this.principalCode = principalCode;
|
||||
}
|
||||
|
||||
public String getCaisseProfile() {
|
||||
return caisseProfile;
|
||||
}
|
||||
|
||||
public void setCaisseProfile(String caisseProfile) {
|
||||
this.caisseProfile = caisseProfile;
|
||||
}
|
||||
|
||||
public String getStatut() {
|
||||
return statut;
|
||||
}
|
||||
|
||||
public void setStatut(String statut) {
|
||||
this.statut = statut;
|
||||
}
|
||||
|
||||
public String getZone() {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public void setZone(String zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
public String getKiosk() {
|
||||
return kiosk;
|
||||
}
|
||||
|
||||
public void setKiosk(String kiosk) {
|
||||
this.kiosk = kiosk;
|
||||
}
|
||||
|
||||
public String getFonction() {
|
||||
return fonction;
|
||||
}
|
||||
|
||||
public void setFonction(String fonction) {
|
||||
this.fonction = fonction;
|
||||
}
|
||||
|
||||
public String getDateEmbauche() {
|
||||
return dateEmbauche;
|
||||
}
|
||||
|
||||
public void setDateEmbauche(String dateEmbauche) {
|
||||
this.dateEmbauche = dateEmbauche;
|
||||
}
|
||||
|
||||
public String getDerniereConnexion() {
|
||||
return derniereConnexion;
|
||||
}
|
||||
|
||||
public void setDerniereConnexion(String derniereConnexion) {
|
||||
this.derniereConnexion = derniereConnexion;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
public String getPrenom() {
|
||||
return prenom;
|
||||
}
|
||||
|
||||
public void setPrenom(String prenom) {
|
||||
this.prenom = prenom;
|
||||
}
|
||||
|
||||
public String getAutresNom() {
|
||||
return autresNom;
|
||||
}
|
||||
|
||||
public void setAutresNom(String autresNom) {
|
||||
this.autresNom = autresNom;
|
||||
}
|
||||
|
||||
public String getDateNaissance() {
|
||||
return dateNaissance;
|
||||
}
|
||||
|
||||
public void setDateNaissance(String dateNaissance) {
|
||||
this.dateNaissance = dateNaissance;
|
||||
}
|
||||
|
||||
public String getLieuNaissance() {
|
||||
return lieuNaissance;
|
||||
}
|
||||
|
||||
public void setLieuNaissance(String lieuNaissance) {
|
||||
this.lieuNaissance = lieuNaissance;
|
||||
}
|
||||
|
||||
public String getVille() {
|
||||
return ville;
|
||||
}
|
||||
|
||||
public void setVille(String ville) {
|
||||
this.ville = ville;
|
||||
}
|
||||
|
||||
public String getAdresse() {
|
||||
return adresse;
|
||||
}
|
||||
|
||||
public void setAdresse(String adresse) {
|
||||
this.adresse = adresse;
|
||||
}
|
||||
|
||||
public String getCni() {
|
||||
return cni;
|
||||
}
|
||||
|
||||
public void setCni(String cni) {
|
||||
this.cni = cni;
|
||||
}
|
||||
|
||||
public double getLimiteInferieure() {
|
||||
return limiteInferieure;
|
||||
}
|
||||
|
||||
public void setLimiteInferieure(double limiteInferieure) {
|
||||
this.limiteInferieure = limiteInferieure;
|
||||
}
|
||||
|
||||
public double getLimiteSuperieure() {
|
||||
return limiteSuperieure;
|
||||
}
|
||||
|
||||
public void setLimiteSuperieure(double limiteSuperieure) {
|
||||
this.limiteSuperieure = limiteSuperieure;
|
||||
}
|
||||
|
||||
public double getLimiteParTransaction() {
|
||||
return limiteParTransaction;
|
||||
}
|
||||
|
||||
public void setLimiteParTransaction(double limiteParTransaction) {
|
||||
this.limiteParTransaction = limiteParTransaction;
|
||||
}
|
||||
|
||||
public String getAutreAdresse1() {
|
||||
return autreAdresse1;
|
||||
}
|
||||
|
||||
public void setAutreAdresse1(String autreAdresse1) {
|
||||
this.autreAdresse1 = autreAdresse1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.example.quiz.data.model.enums;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Pageable implements Serializable {
|
||||
|
||||
private boolean unpaged;
|
||||
private boolean paged;
|
||||
private int pageNumber;
|
||||
private int pageSize;
|
||||
private long offset; // ⚠️ long obligatoire
|
||||
private Sort sort;
|
||||
|
||||
public boolean isUnpaged() {
|
||||
return unpaged;
|
||||
}
|
||||
|
||||
public boolean isPaged() {
|
||||
return paged;
|
||||
}
|
||||
|
||||
public int getPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public long getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public Sort getSort() {
|
||||
return sort;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.example.quiz.data.model.enums;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Sort implements Serializable {
|
||||
|
||||
private boolean unsorted;
|
||||
private boolean sorted;
|
||||
private boolean empty;
|
||||
|
||||
public boolean isUnsorted() {
|
||||
return unsorted;
|
||||
}
|
||||
|
||||
public boolean isSorted() {
|
||||
return sorted;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,14 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
||||
@Module
|
||||
@InstallIn(SingletonComponent.class)
|
||||
public class ApiClient {
|
||||
private static final String BASE_URL = "https://boxer-adapting-bluegill.ngrok-free.app/api/v1/";
|
||||
private static final String BASE_URL = "https://boxer-adapting-bluegill.ngrok-free.app/api/";
|
||||
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public AuthInterceptor provideInterceptor(TokenManager tokenManager){
|
||||
return new AuthInterceptor(tokenManager);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@@ -37,9 +44,10 @@ public class ApiClient {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public OkHttpClient provideOkHttpClient(HttpLoggingInterceptor loggingInterceptor){
|
||||
public OkHttpClient provideOkHttpClient(HttpLoggingInterceptor loggingInterceptor, AuthInterceptor authInterceptor){
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(loggingInterceptor)
|
||||
.addInterceptor(authInterceptor)
|
||||
.connectTimeout(240, TimeUnit.SECONDS)
|
||||
.readTimeout(240, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.example.quiz.data.remote;
|
||||
|
||||
import com.example.quiz.data.model.Course;
|
||||
import com.example.quiz.data.model.PagedModel;
|
||||
import com.example.quiz.data.model.Pari;
|
||||
import com.example.quiz.data.model.ParisResponse;
|
||||
import com.example.quiz.data.model.PointDeVente;
|
||||
import com.example.quiz.data.model.Reunion;
|
||||
import com.example.quiz.data.model.Tpe;
|
||||
import com.example.quiz.data.model.dtos.auth.LoginPayload;
|
||||
import com.example.quiz.data.model.dtos.auth.LoginResponse;
|
||||
import com.example.quiz.data.model.TpeResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,28 +22,33 @@ import retrofit2.http.Path;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ApiService {
|
||||
@GET("reunions")
|
||||
Call<List<Reunion>> getReunions();
|
||||
@GET("reunions/date/{date}")
|
||||
Call<List<Reunion>> getReunions(@Path("date") String date);
|
||||
|
||||
@GET("courses/reunion/{reunionId}")
|
||||
Call<List<Course>> getCourses(@Path("reunionId") String reunionId);
|
||||
@GET("courses")
|
||||
Call<PagedModel<Course>> getCourses(@Query("reunionDate") String reunionDate);
|
||||
|
||||
@POST("pari")
|
||||
Call<Pari> createPari(@Body Pari pari);
|
||||
@POST("paris")
|
||||
Call<ParisResponse> createPari(@Body Pari pari);
|
||||
|
||||
@POST("auth/agent/login")
|
||||
Call<LoginResponse> login(@Body LoginPayload loginPayload);
|
||||
|
||||
@GET("pari/created-by/{created-by}/today")
|
||||
Call<List<Pari>> derniersParis(@Path("created-by") String createdBy);
|
||||
@GET("paris/agent/{agentId}/today")
|
||||
Call<List<ParisResponse>> derniersParis(@Path("agentId") String agentId);
|
||||
|
||||
@PUT("pari/annuler/{numeroTicket}")
|
||||
Call<Pari> annulerPari(@Path("numeroTicket") String numeroTicket);
|
||||
Call<ParisResponse> annulerPari(@Path("numeroTicket") String numeroTicket);
|
||||
|
||||
@GET("pari/solde/{createdBy}/course/{courseId}")
|
||||
Call<Double> getSoldeByCourse(@Path("createdBy") String createdBy, @Path("courseId") String courseId);
|
||||
@GET("paris/agent/{agentId}/solde/course/{courseId}")
|
||||
Call<Double> getSoldeByCourse(@Path("agentId") String createdBy, @Path("courseId") String courseId);
|
||||
|
||||
@GET("pari/solde/{createdBy}")
|
||||
Call<Double> getSoldeByDay(@Path("createdBy") String createdBy, @Query("date") String day);
|
||||
@GET("paris/agent/{agentId}/solde")
|
||||
Call<Double> getSoldeByDay(@Path("agentId") String agentId, @Query("date") String day);
|
||||
|
||||
@POST("terminaux")
|
||||
Call<TpeResponse> createTpe(@Body Tpe tpe);
|
||||
|
||||
@GET("points-de-vente")
|
||||
Call<PagedModel<PointDeVente>> getPointsDeVente(@Query("nom") String nom);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.example.quiz.data.remote;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class AuthInterceptor implements Interceptor {
|
||||
|
||||
private final TokenManager tokenManager;
|
||||
|
||||
public AuthInterceptor(TokenManager tokenManager) {
|
||||
this.tokenManager = tokenManager;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
|
||||
Request originalRequest = chain.request();
|
||||
String token = tokenManager.getToken();
|
||||
|
||||
if (token != null) {
|
||||
Request newRequest = originalRequest.newBuilder()
|
||||
.addHeader("Authorization", "Bearer " + token)
|
||||
.build();
|
||||
return chain.proceed(newRequest);
|
||||
}
|
||||
|
||||
return chain.proceed(originalRequest);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.example.quiz.data.remote;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.WebSocket;
|
||||
import okhttp3.WebSocketListener;
|
||||
|
||||
@Singleton
|
||||
public class SocketManager {
|
||||
|
||||
private final OkHttpClient client;
|
||||
private final TokenManager tokenManager;
|
||||
private WebSocket webSocket;
|
||||
private boolean isConnected = false;
|
||||
|
||||
@Inject
|
||||
public SocketManager(OkHttpClient client, TokenManager tokenManager) {
|
||||
this.client = client;
|
||||
this.tokenManager = tokenManager;
|
||||
}
|
||||
|
||||
public synchronized void connect() {
|
||||
|
||||
String token = tokenManager.getToken();
|
||||
|
||||
if (token == null) {
|
||||
Log.d("SOCKET", "Token null → no connection");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isConnected) return;
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url("ws://boxer-adapting-bluegill.ngrok-free.app/ws")
|
||||
.addHeader("Authorization", "Bearer " + token)
|
||||
.build();
|
||||
|
||||
webSocket = client.newWebSocket(request, new WebSocketListener() {
|
||||
|
||||
@Override
|
||||
public void onOpen(WebSocket webSocket, Response response) {
|
||||
isConnected = true;
|
||||
Log.d("SOCKET", "Connected");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(WebSocket webSocket, String text) {
|
||||
Log.d("SOCKET", "Message: " + text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||
isConnected = false;
|
||||
Log.e("SOCKET", "Error: " + t.getMessage());
|
||||
|
||||
// tentative de reconnexion
|
||||
reconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(WebSocket webSocket, int code, String reason) {
|
||||
isConnected = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public synchronized void reconnect() {
|
||||
disconnect();
|
||||
connect();
|
||||
}
|
||||
|
||||
public synchronized void disconnect() {
|
||||
if (webSocket != null) {
|
||||
webSocket.close(1000, "Closing");
|
||||
webSocket = null;
|
||||
}
|
||||
isConnected = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.example.quiz.data.remote;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext;
|
||||
|
||||
public class TokenManager {
|
||||
private static final String PREF_NAME = "auth_pref";
|
||||
private static final String KEY_TOKEN = "auth_token";
|
||||
|
||||
SocketManager socketManager;
|
||||
private SharedPreferences sharedPreferences;
|
||||
@Inject
|
||||
public TokenManager(@ApplicationContext Context context, SocketManager socketManager) {
|
||||
this.sharedPreferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
|
||||
this.socketManager = socketManager;
|
||||
}
|
||||
public void saveToken(String token){
|
||||
sharedPreferences.edit().putString(KEY_TOKEN, token).apply();
|
||||
socketManager.reconnect();
|
||||
}
|
||||
|
||||
public String getToken(){
|
||||
return sharedPreferences.getString(KEY_TOKEN, null);
|
||||
}
|
||||
|
||||
public void clearToken(){
|
||||
sharedPreferences.edit().remove(KEY_TOKEN).apply();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.example.quiz.data.model.Course;
|
||||
import com.example.quiz.data.model.PagedModel;
|
||||
import com.example.quiz.data.remote.ApiService;
|
||||
import com.example.quiz.utils.Result;
|
||||
|
||||
@@ -25,12 +26,12 @@ public class CourseRepository {
|
||||
this.apiService = apiService;
|
||||
}
|
||||
|
||||
public LiveData<Result<List<Course>>> getCourses(String reunionId) {
|
||||
MutableLiveData<Result<List<Course>>> liveCourses = new MutableLiveData<Result<List<Course>>>();
|
||||
public LiveData<Result<PagedModel<Course>>> getCourses(String reunionDate) {
|
||||
MutableLiveData<Result<PagedModel<Course>>> liveCourses = new MutableLiveData<Result<PagedModel<Course>>>();
|
||||
liveCourses.setValue(Result.loading());
|
||||
apiService.getCourses(reunionId).enqueue(new Callback<List<Course>>() {
|
||||
apiService.getCourses(reunionDate).enqueue(new Callback<PagedModel<Course>>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<Course>> call, Response<List<Course>> response) {
|
||||
public void onResponse(Call<PagedModel<Course>> call, Response<PagedModel<Course>> response) {
|
||||
if(response.isSuccessful()){
|
||||
liveCourses.postValue(Result.success(response.body()));
|
||||
}else{
|
||||
@@ -39,7 +40,7 @@ public class CourseRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<Course>> call, Throwable throwable) {
|
||||
public void onFailure(Call<PagedModel<Course>> call, Throwable throwable) {
|
||||
liveCourses.postValue(Result.error(throwable.getMessage()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.example.quiz.data.repository;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.example.quiz.data.model.dtos.auth.LoginPayload;
|
||||
import com.example.quiz.data.model.dtos.auth.LoginResponse;
|
||||
import com.example.quiz.data.remote.ApiService;
|
||||
import com.example.quiz.data.remote.TokenManager;
|
||||
import com.example.quiz.utils.Result;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -16,8 +19,10 @@ import retrofit2.Response;
|
||||
|
||||
public class LoginRepository {
|
||||
private ApiService apiService;
|
||||
private TokenManager tokenManager;
|
||||
@Inject
|
||||
public LoginRepository(ApiService apiService) {
|
||||
public LoginRepository(ApiService apiService, TokenManager tokenManager) {
|
||||
this.tokenManager = tokenManager;
|
||||
this.apiService = apiService;
|
||||
}
|
||||
|
||||
@@ -29,6 +34,8 @@ public class LoginRepository {
|
||||
public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) {
|
||||
if(response.isSuccessful()){
|
||||
liveLogin.postValue(Result.success(response.body()));
|
||||
Log.d("TOKEN", response.body().getToken());
|
||||
tokenManager.saveToken(response.body().getToken());
|
||||
}else{
|
||||
liveLogin.postValue(Result.error(response.message()));
|
||||
}
|
||||
|
||||
@@ -7,10 +7,13 @@ import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.example.quiz.data.model.Pari;
|
||||
import com.example.quiz.data.model.ParisResponse;
|
||||
import com.example.quiz.data.remote.ApiService;
|
||||
import com.example.quiz.utils.Result;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -26,23 +29,25 @@ public class PariRepository {
|
||||
this.apiService = apiService;
|
||||
}
|
||||
|
||||
public LiveData<Result<Pari>> createPari(Pari pari) {
|
||||
MutableLiveData<Result<Pari>> pariResponse = new MutableLiveData<>();
|
||||
public LiveData<Result<ParisResponse>> createPari(Pari pari) {
|
||||
MutableLiveData<Result<ParisResponse>> pariResponse = new MutableLiveData<>();
|
||||
pariResponse.setValue(Result.loading());
|
||||
|
||||
apiService.createPari(pari).enqueue(new Callback<Pari>() {
|
||||
apiService.createPari(pari).enqueue(new Callback<ParisResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<Pari> call, Response<Pari> response) {
|
||||
public void onResponse(Call<ParisResponse> call, Response<ParisResponse> response) {
|
||||
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
pariResponse.postValue(Result.success(response.body()));
|
||||
} else {
|
||||
// On récupère l'erreur exacte envoyée par le backend
|
||||
try {
|
||||
String errorBody = response.errorBody() != null ?
|
||||
response.errorBody().string() : "Erreur inconnue";
|
||||
|
||||
pariResponse.postValue(Result.error(errorBody));
|
||||
Map<String, String> errorBody = Collections.emptyMap();
|
||||
if(response.errorBody() != null){
|
||||
errorBody = (Map<String, String>) response.errorBody();
|
||||
}
|
||||
Log.d("PariRepository", response.errorBody().toString());
|
||||
pariResponse.postValue(Result.error(errorBody.get("message")));
|
||||
|
||||
} catch (Exception e) {
|
||||
pariResponse.postValue(Result.error("Erreur serveur"));
|
||||
@@ -51,7 +56,7 @@ public class PariRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Pari> call, Throwable t) {
|
||||
public void onFailure(Call<ParisResponse> call, Throwable t) {
|
||||
pariResponse.postValue(Result.error(t.getMessage()));
|
||||
}
|
||||
});
|
||||
@@ -59,12 +64,12 @@ public class PariRepository {
|
||||
return pariResponse;
|
||||
}
|
||||
|
||||
public LiveData<Result<List<Pari>>> derniersParis(String createdBy){
|
||||
MutableLiveData<Result<List<Pari>>> derniersParis = new MutableLiveData<>();
|
||||
public LiveData<Result<List<ParisResponse>>> derniersParis(String agentId){
|
||||
MutableLiveData<Result<List<ParisResponse>>> derniersParis = new MutableLiveData<>();
|
||||
derniersParis.setValue(Result.loading());
|
||||
apiService.derniersParis(createdBy).enqueue(new Callback<List<Pari>>() {
|
||||
apiService.derniersParis(agentId).enqueue(new Callback<List<ParisResponse>>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<Pari>> call, Response<List<Pari>> response) {
|
||||
public void onResponse(Call<List<ParisResponse>> call, Response<List<ParisResponse>> response) {
|
||||
if(response.isSuccessful() && response.body() != null){
|
||||
derniersParis.postValue(Result.success(response.body()));
|
||||
}else{
|
||||
@@ -80,7 +85,7 @@ public class PariRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<Pari>> call, Throwable throwable) {
|
||||
public void onFailure(Call<List<ParisResponse>> call, Throwable throwable) {
|
||||
derniersParis.postValue(Result.error(throwable.getMessage()));
|
||||
}
|
||||
});
|
||||
@@ -88,12 +93,12 @@ public class PariRepository {
|
||||
return derniersParis;
|
||||
}
|
||||
|
||||
public LiveData<Result<Pari>> annulerPari(String numeroTicket){
|
||||
MutableLiveData<Result<Pari>> pariResponse = new MutableLiveData<>();
|
||||
public LiveData<Result<ParisResponse>> annulerPari(String numeroTicket){
|
||||
MutableLiveData<Result<ParisResponse>> pariResponse = new MutableLiveData<>();
|
||||
pariResponse.setValue(Result.loading());
|
||||
apiService.annulerPari(numeroTicket).enqueue(new Callback<Pari>(){
|
||||
apiService.annulerPari(numeroTicket).enqueue(new Callback<ParisResponse>(){
|
||||
@Override
|
||||
public void onResponse(Call<Pari> call, Response<Pari> response) {
|
||||
public void onResponse(Call<ParisResponse> call, Response<ParisResponse> response) {
|
||||
if(response.isSuccessful()){
|
||||
pariResponse.postValue(Result.success(response.body()));
|
||||
}else{
|
||||
@@ -109,17 +114,17 @@ public class PariRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Pari> call, Throwable throwable) {
|
||||
public void onFailure(Call<ParisResponse> call, Throwable throwable) {
|
||||
pariResponse.postValue(Result.error(throwable.getMessage()));
|
||||
}
|
||||
});
|
||||
return pariResponse;
|
||||
}
|
||||
|
||||
public LiveData<Result<Double>> getSoldeByCourse(String createdBy, String courseId){
|
||||
public LiveData<Result<Double>> getSoldeByCourse(String agentId, String courseId){
|
||||
MutableLiveData<Result<Double>> solde = new MutableLiveData<>();
|
||||
solde.setValue(Result.loading());
|
||||
apiService.getSoldeByCourse(createdBy, courseId).enqueue(new Callback<Double>() {
|
||||
apiService.getSoldeByCourse(agentId, courseId).enqueue(new Callback<Double>() {
|
||||
@Override
|
||||
public void onResponse(Call<Double> call, Response<Double> response) {
|
||||
if(response.isSuccessful()){
|
||||
@@ -141,10 +146,10 @@ public class PariRepository {
|
||||
return solde;
|
||||
}
|
||||
|
||||
public LiveData<Result<Double>> getSoldeByDay(String createdBy, String day){
|
||||
public LiveData<Result<Double>> getSoldeByDay(String agentId, String day){
|
||||
MutableLiveData<Result<Double>> solde = new MutableLiveData<>();
|
||||
solde.setValue(Result.loading());
|
||||
apiService.getSoldeByDay(createdBy, day).enqueue(new Callback<Double>() {
|
||||
apiService.getSoldeByDay(agentId, day).enqueue(new Callback<Double>() {
|
||||
@Override
|
||||
public void onResponse(Call<Double> call, Response<Double> response) {
|
||||
if(response.isSuccessful()){
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.example.quiz.data.repository;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.example.quiz.data.model.PagedModel;
|
||||
import com.example.quiz.data.model.PointDeVente;
|
||||
import com.example.quiz.data.remote.ApiService;
|
||||
import com.example.quiz.utils.Result;
|
||||
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import retrofit2.*;
|
||||
|
||||
public class PointDeVenteRepository {
|
||||
|
||||
private ApiService apiService;
|
||||
@Inject
|
||||
public PointDeVenteRepository(ApiService apiService) {
|
||||
this.apiService = apiService;
|
||||
}
|
||||
|
||||
public LiveData<Result<PagedModel<PointDeVente>>> getPointsDeVente(String nom) {
|
||||
MutableLiveData<Result<PagedModel<PointDeVente>>> result = new MutableLiveData<>();
|
||||
result.setValue(Result.loading());
|
||||
|
||||
apiService.getPointsDeVente(nom)
|
||||
.clone()
|
||||
.enqueue(new Callback<PagedModel<PointDeVente>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<PagedModel<PointDeVente>> call,
|
||||
Response<PagedModel<PointDeVente>> response) {
|
||||
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
result.postValue(Result.success(response.body()));
|
||||
} else {
|
||||
|
||||
String errorMessage = "Erreur inconnue";
|
||||
|
||||
try {
|
||||
if (response.errorBody() != null) {
|
||||
errorMessage = response.errorBody().string();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorMessage = e.getMessage();
|
||||
}
|
||||
|
||||
result.postValue(Result.error(errorMessage));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<PagedModel<PointDeVente>> call, Throwable t) {
|
||||
result.postValue(Result.error(
|
||||
t.getMessage() != null ? t.getMessage() : "Erreur réseau"
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,10 @@ import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.example.quiz.data.model.Reunion;
|
||||
import com.example.quiz.data.remote.ApiClient;
|
||||
|
||||
import com.example.quiz.data.remote.ApiService;
|
||||
import com.example.quiz.utils.Result;
|
||||
import com.google.android.gms.common.api.Api;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,10 +25,10 @@ public class ReunionRepository {
|
||||
this.apiService = apiService;
|
||||
}
|
||||
|
||||
public LiveData<Result<List<Reunion>>> getReunions(){
|
||||
public LiveData<Result<List<Reunion>>> getReunions(String date){
|
||||
MutableLiveData<Result<List<Reunion>>> liveReunionsData = new MutableLiveData<>();
|
||||
liveReunionsData.setValue(Result.loading());
|
||||
apiService.getReunions().enqueue(new Callback<List<Reunion>>() {
|
||||
apiService.getReunions(date).enqueue(new Callback<List<Reunion>>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<Reunion>> call, Response<List<Reunion>> response) {
|
||||
if(response.isSuccessful()){
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.example.quiz.data.repository;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.example.quiz.data.model.Tpe;
|
||||
import com.example.quiz.data.model.TpeResponse;
|
||||
import com.example.quiz.data.remote.ApiService;
|
||||
import com.example.quiz.utils.Result;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
|
||||
public class TpeRepository {
|
||||
|
||||
private ApiService apiService;
|
||||
|
||||
@Inject
|
||||
public TpeRepository(ApiService apiService) {
|
||||
this.apiService = apiService;
|
||||
}
|
||||
|
||||
public LiveData<Result<TpeResponse>> createTpe(Tpe tpe) {
|
||||
MutableLiveData<Result<TpeResponse>> tpeLiveData = new MutableLiveData<>();
|
||||
tpeLiveData.setValue(Result.loading());
|
||||
apiService.createTpe(tpe).enqueue(new Callback<TpeResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<TpeResponse> call, Response<TpeResponse> response) {
|
||||
if (response.isSuccessful()) {
|
||||
tpeLiveData.postValue(Result.success(response.body()));
|
||||
} else {
|
||||
tpeLiveData.postValue(Result.error(response.message()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<TpeResponse> call, Throwable throwable) {
|
||||
tpeLiveData.postValue(Result.error(throwable.getMessage()));
|
||||
}
|
||||
});
|
||||
return tpeLiveData;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user