feat: All needed DTO added

This commit is contained in:
SunZar 2025-02-19 12:38:25 +03:00
parent 7802d39417
commit 148df734a9
8 changed files with 205 additions and 5 deletions

View File

@ -0,0 +1,28 @@
package ru.myitschool.work.dto;
import androidx.annotation.Nullable;
import com.google.gson.annotations.SerializedName;
public class HistoryDto {
@Nullable
@SerializedName("id")
public Integer id;
@Nullable
@SerializedName("idUser")
public Integer idUser;
@Nullable
@SerializedName("time")
public Long time;
@Nullable
@SerializedName("nameReader")
public String nameReader;
@Nullable
@SerializedName("type")
public String type;
}

View File

@ -0,0 +1,17 @@
package ru.myitschool.work.dto;
import androidx.annotation.Nullable;
import com.google.gson.annotations.SerializedName;
public class RoleDto {
@Nullable
@SerializedName("idUser")
public Integer idUser;
@Nullable
@SerializedName("status")
public int status;
}

View File

@ -0,0 +1,115 @@
package ru.myitschool.work.dto;
import androidx.annotation.Nullable;
import com.google.gson.annotations.SerializedName;
public class UserDto {
@Nullable
@SerializedName("username")
public String username;
@Nullable
@SerializedName("password")
public String password;
@Nullable
@SerializedName("photo")
public String photo;
@Nullable
@SerializedName("lastVisit")
public Long lastVisit;
@Nullable
@SerializedName("idUser")
public Integer idUser;
@Nullable
@SerializedName("status")
public int status;
@Nullable
@SerializedName("position")
public String position;
public UserDto(@Nullable String username, @Nullable String password, @Nullable String photo, @Nullable Long lastVisit, @Nullable Integer idUser, int status, @Nullable String position) {
this.username = username;
this.password = password;
this.photo = photo;
this.lastVisit = lastVisit;
this.idUser = idUser;
this.status = status;
this.position = position;
}
@Nullable
public String getPosition() {
return position;
}
public void setPosition(@Nullable String position) {
this.position = position;
}
@Nullable
public String getUsername() {
return username;
}
public void setUsername(@Nullable String username) {
this.username = username;
}
@Nullable
public String getPassword() {
return password;
}
public void setPassword(@Nullable String password) {
this.password = password;
}
@Nullable
public String getPhoto() {
return photo;
}
public void setPhoto(@Nullable String photo) {
this.photo = photo;
}
@Nullable
public Long getLastVisit() {
return lastVisit;
}
public void setLastVisit(@Nullable Long lastVisit) {
this.lastVisit = lastVisit;
}
@Nullable
public Integer getIdUser() {
return idUser;
}
public void setIdUser(@Nullable Integer idUser) {
this.idUser = idUser;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}

View File

@ -1,5 +1,6 @@
package ru.myitschool.work.ui;
import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -52,8 +53,10 @@ public class HistoryAdapter extends RecyclerView.Adapter<HistoryAdapter.ViewHold
super(itemView);
binding = ItemHistoryBinding.bind(itemView);
}
public void bind(History item) {
binding.time.setText(item.getTime().toString());
binding.time.setText(item.getTime().toString().substring(0, 10) + " "
+ item.getTime().toString().substring(11, 16));
binding.nameReader.setText(item.getNameReader());
if (item.getPassageType() == 1){
binding.type.setText("QR-code");

View File

@ -58,7 +58,7 @@ public class InformationFragment extends Fragment {
binding.logout.setOnClickListener(view3 -> {
onClickLogout();
});
//TODO: SERVER ZAGUZKA LISTAAAAAAAAAAAAAAA
//TODO: SERVER ZAGRUZKA LISTAAAAAAAAAAAAAAA
HistoryAdapter adapter = new HistoryAdapter();
binding.historylist.setAdapter(adapter);
adapter.updateData(history);

View File

@ -49,6 +49,7 @@ public class LoginFragment extends Fragment {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (binding.username.getText().length() >= 3 && binding.username.getText().toString().matches("[0-9a-zA-Z]+") && (binding.username.getText().toString().charAt(0) + "").matches("[0-9]+")) {
@ -69,14 +70,37 @@ public class LoginFragment extends Fragment {
}
});
binding.password.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (binding.password.getText().length() >= 5) {
binding.login.setEnabled(true);
} else {
binding.login.setEnabled(false);
}
if (binding.error.getVisibility() == View.VISIBLE) {
binding.error.setVisibility(View.GONE);
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});
binding.login.setOnClickListener(view1 -> {
if (binding.login.isEnabled()) {
if (binding.error.getVisibility() == View.VISIBLE) {
binding.error.setVisibility(View.GONE);
//binding.log.setText("click enabled");
}
//binding.log.setText("click");
onClickLogin();
}
});

View File

@ -9,14 +9,16 @@ User {
private String photo;
private String position;
private String lastVisit;
private int role; // 1 - сотрудник 2 - админ
public User(int id, String login, String name, String photo, String position, String lastVisit) {
public User(int id, String login, String name, String photo, String position, String lastVisit, int role) {
this.id = id;
this.login = login;
this.name = name;
this.photo = photo;
this.position = position;
this.lastVisit = lastVisit;
this.role = role;
}
public int getId() {
@ -66,4 +68,8 @@ User {
public void setLastVisit(String lastVisit) {
this.lastVisit = lastVisit;
}
public int getRole(int role){return role;}
public void setRole(int role){this.role = role;}
}

View File

@ -11,6 +11,13 @@
android:layout_height="wrap_content"
android:hint="@string/username"/>
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Пароль"/>
<Button
android:id="@+id/login"
android:text="@string/login"