
package com.jeelowcode.module.biz.service.impl;

import com.jeelowcode.core.framework.service.IFrameSqlService;
import com.jeelowcode.framework.plus.SqlHelper;
import com.jeelowcode.framework.plus.build.buildmodel.wrapper.SqlInfoQueryWrapper;
import com.jeelowcode.module.biz.mapper.DrillPlanMapper;
import com.jeelowcode.module.biz.service.IDrillPlanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;


/**
 * demo
 */
@Slf4j
@Service
public class DrillPlanServiceImpl implements IDrillPlanService {


    @Autowired
    private IFrameSqlService sqlService;

    @Override
    public Map<String, Object> getDrillPlanById(long id) {
        SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper();
        wrapper.setTableName("lc_drill_plan");
        wrapper.setWhere(where->{
            where.eq("id",id);
        });
        Map<String, Object> dataMap = sqlService.getDataOneByPlus(wrapper);
        return dataMap;
    }

    @Override
    public List<Map<String, Object>> getDrillPlanCycles(Long drillPlanId) {
        SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper();
        wrapper.setTableName("lc_drill_plan_cycle");
        wrapper.setWhere(where->{
            where.eq("drill_plan_id",drillPlanId);
            where.eq("is_deleted",0);
        });
        List<Map<String, Object>> dataMapList = sqlService.getDataListByPlus(wrapper);
        return dataMapList;
    }

    @Override
    public Map<String, Object> getDrillTaskById(long id) {
        SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper();
        wrapper.setTableName("lc_drill_task");
        wrapper.setWhere(where->{
            where.eq("id",id);
        });
        Map<String, Object> dataMap = sqlService.getDataOneByPlus(wrapper);
        return dataMap;
    }

    @Override
    public List<Map<String, Object>> getDrillTaskByPlanId(Long drillPlanId) {
        SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper();
        wrapper.setTableName("lc_drill_task");
        wrapper.setWhere(where->{
            where.eq("drill_plan_id",drillPlanId);
        });
        List<Map<String, Object>> dataMapList = sqlService.getDataListByPlus(wrapper);
        return dataMapList;
    }


}
