Subversion Repositories SmartDukaan

Rev

View as "text/plain" | Blame | Last modification | View Log | RSS feed

package com.spice.profitmandi.service.user;

import java.time.LocalDate;
import java.time.LocalDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
import com.spice.profitmandi.dao.entity.dtr.PunchInOut;
import com.spice.profitmandi.dao.repository.dtr.PunchInOutRepository;

@Component
public class PunchInOutServiceImpl implements PunchInOutService {
        
        @Autowired
        private PunchInOutRepository punchInOutRepository;

        @Override
        public void punchInOut(int fofoId) throws ProfitMandiBusinessException {
                PunchInOut punchInOut = null;
                try {
                        punchInOut = punchInOutRepository.selectByFofoIdAndCreateDate(fofoId, LocalDate.now());
                }catch(ProfitMandiBusinessException profitMandiBusinessException) {
                        
                }
                if(punchInOut == null) {
                        punchInOut = new PunchInOut();
                        punchInOut.setFofoId(fofoId);
                        punchInOut.setPunchInTimestamp(LocalDateTime.now());
                }else {
                        punchInOut.setPunchOutTimestamp(LocalDateTime.now());
                }
                punchInOutRepository.persist(punchInOut);
        }

}