package com.diagbot.facade;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.diagbot.entity.SysHospitalSet;
import com.diagbot.enums.IsDeleteEnum;
import com.diagbot.service.impl.SysHospitalSetServiceImpl;
import com.diagbot.util.StringUtil;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @author: gaodm
 * @time: 2024/7/6 9:29
 */
@Component
public class SysHospitalSetFacade extends SysHospitalSetServiceImpl {

    public String getScoreType(Long hospitalId) {
        String res = "0";
        SysHospitalSet sysHospitalSet
                = this.getOne(new QueryWrapper<SysHospitalSet>()
                        .eq("is_deleted", IsDeleteEnum.N.getKey())
                        .eq("hospital_id", hospitalId)
                        .eq("code", "score_type")
                , false);
        if (null != sysHospitalSet
                && sysHospitalSet.getValue().equals("1")) {
            res = "1";
        }
        return res;
    }

    public String getValue(Long hospitalId, String code) {
        String res = "";
        SysHospitalSet sysHospitalSet
                = this.getOne(new QueryWrapper<SysHospitalSet>()
                        .eq("is_deleted", IsDeleteEnum.N.getKey())
                        .eq("hospital_id", hospitalId)
                        .eq("code", code)
                , false);
        if (null != sysHospitalSet
                && StringUtil.isNotBlank(sysHospitalSet.getValue())) {
            res = sysHospitalSet.getValue();
        }
        return res;
    }
}
