Skip to content
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

Attendance endpoint #5

Open
miguel-merlin opened this issue Mar 29, 2024 · 0 comments
Open

Attendance endpoint #5

miguel-merlin opened this issue Mar 29, 2024 · 0 comments
Assignees

Comments

@miguel-merlin
Copy link
Member

Description

Team leaders and PMs should be able to take attendance for each sprint. To add this new feature create the following endpoints:

POST /api/v1/user/userId/attendance
GET /api/v1/user/userId/attendance
PUT /api/v1/users/userId/attendance
DELETE  /api/v1/users/userId/attendance

Notes on implementation

In model/users you will have to add a new table to persist the attendance records. Create a new class called Attendance.java. It should look something like this:

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;

@Entity
@Table(name = "attendance")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Attendance {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    private User user;

    private LocalDate date;

    private String status; // Could be an enum representing Present, Absent, Late, etc.
}

Once you added this class, you have to add to the user schema

@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Set<Attendance> attendanceRecords = new HashSet<>();

Create a new repository for the Attendance records in repostiory/users/. It should look something like this

package com.sitblueprint.admin.repository.users;

import com.sitblueprint.admin.model.users.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface UserRepository extends JpaRepository<User, Long> {
}

Add your new handlers in service/users/UserService and then implement them in service/users/UserServiceImpl

Finally, map your handlers to an endpoint in controller/UserController

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants