package com.engine.salary.service.impl;


import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.entity.salaryBill.dto.MySalaryShowSetDTO;
import com.engine.salary.service.MySalaryShowSetService;
import com.engine.salary.sys.constant.SalarySysConstant;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.math.NumberUtils;
import weaver.hrm.User;

/**
 * @Description: 我的薪资福利显示设置
 * @Author: wangxiangzhong
 * @Date: 2023/8/7 11:16
 */
@Slf4j
public class MySalaryShowSetServiceImpl extends Service implements MySalaryShowSetService {

    private SalarySysConfService getSalarySysConfService(User user) {
        return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
    }

    /**
     * 获取显示设置
     *
     * @return
     */
    @Override
    public MySalaryShowSetDTO get() {
        SalarySysConfPO salaryShowStatus = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_SHOW_STATUS);
        SalarySysConfPO adjustShowStatus = getSalarySysConfService(user).getOneByCode(SalarySysConstant.ADJUST_SHOW_STATUS);

        return  MySalaryShowSetDTO.builder()
                .salaryShowStatus(salaryShowStatus == null ? true : NumberUtils.INTEGER_ONE.equals(salaryShowStatus.getConfValue()))
                .adjustShowStatus(adjustShowStatus == null ? true : NumberUtils.INTEGER_ONE.equals(adjustShowStatus.getConfValue()))
                .build();
    }

}
