-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
init project #1
base: main
Are you sure you want to change the base?
init project #1
Conversation
the fist StudentProject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все отлично в целом, только добей до результат REST и другие сущности:
Про мапстракт - https://stackoverflow.com/questions/60868345/map-abstract-class-to-dto-with-mapstruct
src/list_students.html
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
кажется этот файл тут не нужен?))
@@ -0,0 +1,41 @@ | |||
package com.kupreychik; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
com.kupreychik))))))))))))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
исправить название пакета
|
||
@UtilityClass | ||
public class FileConsts { | ||
public static final String FILE_STUDENTS_GROUP1 = "C:/Java/zulu_project3/группа 1.txt"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а почему тут полный путь? на моем пк такого пути не будет и программа упадет
log.debug("Проверка пройдена. Дата подходит"); | ||
LocalDate.parse(model.getBirthday(), DateTimeFormatter.ofPattern(DATE_FORMAT)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
будет прикольно, когда у тебя будет лог что проверка пройдена, а потом в методе parse выпадет исключение)))
группа 1.txt
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вводить данные из json было бы гораздо проще, чем парсить такой текст и превращать это в объекты
private final List<Teacher> teachers = new ArrayList<>(); | ||
|
||
|
||
public TeacherServiceFromMyComputer() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я понимаю, что эти методы для тестирования локального кода. но:
- читай данный из json, а не текста, ты же сама видишь, как проще вызвать objectMapper.read, чем писать такую сложную логику
- если этот класс тебе нужен для локально разработки, пометь его с помощью javaDoc
public class StudentServiceFromMyComputer { | ||
private final List<Student> list= new ArrayList<>(); | ||
|
||
public StudentServiceFromMyComputer(String fileName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тоже самое, описал в класс TeacherServiceFromMyPC
src/main/webapp/student.jsp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
мы вроде обсуждали что это будет REST приложение, которое возращает json и просто можно будет из Postman'a дергать это.
@SneakyThrows | ||
private void sendOk(HttpServletRequest req, HttpServletResponse resp, Object object) { | ||
req.setAttribute("object", object); | ||
getServletContext().getRequestDispatcher("/students.jsp").forward(req, resp); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут кажется хотели делать REST
Про юнит тесты - начинай с малого, берешь самый маленький метод и пытаешься его протестировать на каких-то вводных данных. Начни с этого класс - StudentRepository он самый простой у тебя для тестирования, то есть ты тестируешь как сохраняются, удаляются и получаются студенты |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все окей, нужно больше тестов
@@ -0,0 +1,41 @@ | |||
package com.kupreychik; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
исправить название пакета
public GroupController(GroupService groupService, JsonParseService jsonParseService) { | ||
this.groupService = groupService; | ||
this.jsonParseService = jsonParseService; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
есть у ломбока такая аннотация, как @RequiredArgConstrcutor - почитай про нее
if (url.contains("number")) { | ||
Long number = Long.parseLong(url.substring((url.indexOf("=") + 1))); | ||
responseAsString = groupService.getGroupByNumber(number); | ||
} else if (url.contains("surname")) { | ||
String paramSurname = url.substring((url.indexOf("=") + 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
number surname = - все выноси в константы
} | ||
} | ||
} | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Возвращай лучше Optional вместо null
return jsonParseService.writeToJson(new ErrorResponse("Cannot found timetable for groupNumber")); | ||
} | ||
} | ||
@SneakyThrows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а зачем тебе @SneakyThrows если у тебя уже есть обработка исключения
No description provided.