
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.service.IExamPlanService;
import com.jeelowcode.module.biz.service.IWorkItemService;
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 WorkItemServiceImpl implements IWorkItemService {


    @Autowired
    private IFrameSqlService sqlService;


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

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

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