webperside / course-erp-backend

We are developing this project on Youtube Live
14 stars 1 forks source link

[FEATURE] Investigate all codeblocks that throw exception by failing some condition #84

Closed hamidsultanzadeh closed 1 year ago

hamidsultanzadeh commented 1 year ago

For example,

if (userService.checkByEmail(payload.getEmail())) {
    throw BaseException.of(EMAIL_ALREADY_REGISTERED);
}

and also, look for that, where we use findById method for checking existence of that without using the return value

@Override
public void addStudentToGroup(long studentId, long groupId) {

    studentService.findById(studentId); // here
    groupService.findById(groupId); // here

    if(studentService.checkStudentAlreadyAddedToGroup(studentId)){ // here
        throw BaseException.of(STUDENT_ALREADY_ADDED_TO_GROUP);
    }

    studentService.addStudentToGroup(studentId, groupId);
}

please list (leave comments here) all classes and methods using similar code blocks.

ArabkhanDev commented 1 year ago

AuthBusinessServiceImpl(signUp method) StudentBusinessServiceImpl(addStudent method), StudentBusinessServiceImpl(addStudentToGroup method), SubjectBusinessServiceImpl(insertSubject method). UserDetailsServiceImpl(loadUserByUsername method), OTPChannel(getTarget method), RoleServiceImpl(getDefaultRole method), AuthBusinessServiceImpl(authenticate method).