package com.jpsoft.shinestar.modules.business.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jpsoft.shinestar.modules.business.dao.AdjustShiftPersonDAO;
import com.jpsoft.shinestar.modules.business.entity.AdjustShiftPerson;
import com.jpsoft.shinestar.modules.business.service.AdjustShiftPersonService;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author 墨鱼_mo
 * @date 2021-4-27 15:44
 */
@Transactional
@Component(value="adjustShiftPersonService")
public class AdjustShiftPersonServiceImpl implements AdjustShiftPersonService {

    @Resource(name="adjustShiftPersonDAO")
    private AdjustShiftPersonDAO adjustShiftPersonDAO;


    @Autowired
    private ValueOperations<String,Object> valueOperations;

    @Override
    public AdjustShiftPerson get(String id) {
        // TODO Auto-generated method stub
        return adjustShiftPersonDAO.get(id);
    }

    @Override
    public int insert(AdjustShiftPerson model) {
        // TODO Auto-generated method stub
        //model.setId(UUID.randomUUID().toString());

        return adjustShiftPersonDAO.insert(model);
    }

    @Override
    public int update(AdjustShiftPerson model) {
        // TODO Auto-generated method stub
        return adjustShiftPersonDAO.update(model);
    }

    @Override
    public int delete(String id) {
        // TODO Auto-generated method stub
        return adjustShiftPersonDAO.delete(id);
    }

    @Override
    public boolean exist(String id) {
        // TODO Auto-generated method stub
        int count = adjustShiftPersonDAO.exist(id);

        return count > 0 ? true : false;
    }

    @Override
    public List<AdjustShiftPerson> list() {
        // TODO Auto-generated method stub
        return adjustShiftPersonDAO.list();
    }

    @Override
    public Page<AdjustShiftPerson> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList) {
        Page<AdjustShiftPerson> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
            adjustShiftPersonDAO.search(searchParams,sortList);
        });

        return page;
    }

    @Override
    public List<AdjustShiftPerson> findByAdjustShiftId(String id) {
        return adjustShiftPersonDAO.findByAdjustShiftId(id);
    }
}
