package com.muyu.warning.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.muyu.warning.domain.WarnRule;
import com.muyu.warning.domain.WarnRuleDTO;
import com.muyu.warning.domain.WarnStrategy;
import com.muyu.warning.mapper.WarnRulesMapper;
import com.muyu.warning.service.IWarRulesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName WarnRulesServiceImpl
 * @Description 描述
 * @Author Chen
 * @Date 2024/9/23 22:02
 */
@Service
public class WarnRulesServiceImpl
        extends ServiceImpl <WarnRulesMapper, WarnRuleDTO>
        implements IWarRulesService {

    @Autowired
    private WarnRulesMapper warnRulesMapper;

    @Override
    public List<WarnRuleDTO> selectWarnRulesList() {
        MPJLambdaWrapper<WarnRuleDTO> wrapper = new MPJLambdaWrapper<WarnRuleDTO>()
                .selectAll(WarnRule.class)
                .selectAs(WarnStrategy::getStrategyName, WarnRuleDTO::getStrategyName)
                .leftJoin(WarnStrategy.class, WarnStrategy::getId, WarnRule::getStrategyId);
        return this.list(wrapper);
    }

    /**
     * 双表查询
     * @return
     */
    @Override
    public List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO) {
        List<WarnRuleDTO> list = warnRulesMapper.selectWarnRulesListAll(warnRuleDTO);
        return list;
    }
}
