package vip.xiaonuo.risk.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import vip.xiaonuo.risk.entity.RiskTarget;
import vip.xiaonuo.risk.mapper.RiskTargetMapper;
import vip.xiaonuo.risk.param.RiskParam;
import vip.xiaonuo.risk.service.IRiskTargetService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 风控指标 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-12-09
 */
@Service
public class RiskTargetServiceImpl extends ServiceImpl<RiskTargetMapper, RiskTarget> implements IRiskTargetService {

    @Autowired
    private RiskTargetMapper riskTargetMapper;

    @Override
    public RiskTarget getOneRisk(RiskParam riskParam) {
        String orgId = riskParam.getOrgId();
        QueryWrapper<RiskTarget> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotBlank(orgId), "org_id", orgId)
                .orderByDesc("create_time").last(" limit 1");
        return riskTargetMapper.selectOne(queryWrapper);
    }

}
