Buisness logic docs updated
This commit is contained in:
@ -10,7 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Service of CourseService which can get(Course By Name, All Courses, Courses Ammount ), save, delete course.
|
||||
* Service of CourseService which can get(Course By Name, All Courses, Courses
|
||||
* Ammount ), save, delete course.
|
||||
*/
|
||||
|
||||
@Service
|
||||
@ -18,42 +19,46 @@ public class CourseService {
|
||||
@Autowired
|
||||
private CourseRepository repo;
|
||||
|
||||
/*
|
||||
/**
|
||||
* getCourseByName
|
||||
* Return Course By Name
|
||||
*
|
||||
* @param name
|
||||
* @return Course By Name
|
||||
*/
|
||||
public Optional<Course> getCourseByName(String name) {
|
||||
return this.repo.findByName(name);
|
||||
}
|
||||
|
||||
/*
|
||||
* getAllCourses
|
||||
* Return List of get courses
|
||||
/**
|
||||
*
|
||||
* @return all courses from db
|
||||
*/
|
||||
public List<Course> getAllCourses() {
|
||||
return this.repo.findAll();
|
||||
}
|
||||
|
||||
/*
|
||||
* save
|
||||
/**
|
||||
* save to db
|
||||
*
|
||||
* @param course which course you would like to save
|
||||
* @return Course instance with id from db
|
||||
*/
|
||||
public Course save(Course course) {
|
||||
this.repo.save(course);
|
||||
return course;
|
||||
}
|
||||
|
||||
/*
|
||||
* delete
|
||||
/**
|
||||
* delete course from db
|
||||
*
|
||||
* @param course which course you would like to delete
|
||||
*/
|
||||
public void delete(Course course) {
|
||||
this.repo.delete(course);
|
||||
}
|
||||
|
||||
/*
|
||||
* getCoursesAmmount
|
||||
* Return a ammount of courses
|
||||
/**
|
||||
* @return ammount of courses in db
|
||||
*/
|
||||
public int getCoursesAmmount() {
|
||||
return (int) this.repo.count();
|
||||
|
Reference in New Issue
Block a user