package cn.com.ctop.performanceappraisal.service.impl;

import cn.com.ctop.performanceappraisal.entity.PerformanceConfig;
import cn.com.ctop.performanceappraisal.mapper.PerformanceConfigMapper;
import cn.com.ctop.performanceappraisal.service.IPerformanceConfigService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.util.DateUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 绩效配置文件表
 *
 * @author jeecg-boot
 * @version V1.0
 * @date 2020-01-08
 */
@Service
public class PerformanceConfigServiceImpl extends ServiceImpl<PerformanceConfigMapper, PerformanceConfig> implements IPerformanceConfigService {

    @Override
    public PerformanceConfig getNowConfig() {
        Integer year = DateUtils.getYear(new Date());
        Integer quarter = DateUtils.getQuarter(new Date());
        QueryWrapper<PerformanceConfig> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("year", year)
                .eq("quarter", quarter)
                .orderByDesc("id")
                .last("limit 1");
        return this.getOne(queryWrapper);
    }
}
