package com.kcim.dao.repository;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kcim.common.enums.DateStyleEnum;
import com.kcim.common.util.DateUtils;
import com.kcim.common.util.UserContext;
import com.kcim.dao.mapper.ShareParamValueMapper;
import com.kcim.dao.model.CostCostingGroup;
import com.kcim.dao.model.ShareParamValue;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @program: CostAccount
 * @description:
 * @author: Wang.YS
 * @create: 2024-04-08 15:35
 **/
@Repository
public class ShareParamValueRepository extends ServiceImpl<ShareParamValueMapper, ShareParamValue> {
    public List<ShareParamValue> getList(String computeDate) {
        int year = 0;
        int month = 0;
        if (StrUtil.isNotBlank(computeDate)) {
            Date dateTime = DateUtils.StringToDate(computeDate, DateStyleEnum.YYYY_MM);
            year = DateUtil.year(dateTime);
            month = DateUtil.month(dateTime) + 1;
        }

        LambdaQueryWrapper<ShareParamValue> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ShareParamValue::getHospId, UserContext.getHospId());
        queryWrapper.eq(ShareParamValue::getDateYear,year);
        queryWrapper.eq(ShareParamValue::getDateMonth,month);
        return this.list(queryWrapper);
    }
}
