package com.bonus.material.basic.service.impl;

import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.basic.domain.ToDoBean;
import com.bonus.material.basic.mapper.ToDoMapper;
import com.bonus.material.basic.service.ToDoService;
import com.bonus.system.api.RemoteUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

@Service
@Slf4j
public class ToDoServiceImpl implements ToDoService {

    @Resource
    private ToDoMapper toDoMapper;

//    @Resource
//    private RemoteUserService remoteUserService;

    @Override
    public List<ToDoBean> getToDoList(ToDoBean bean) {
        bean.setNoticeCompanyId(Optional.ofNullable(SecurityUtils.getLoginUser().getSysUser().getCompanyId())
                .orElse(SecurityUtils.getLoginUser().getSysUser().getDeptId()));
        return toDoMapper.getToDoList(bean);
    }

    @Override
    public AjaxResult getTaskType(ToDoBean bean) {
        List<ToDoBean> list =new ArrayList<>();
        try {
            list = toDoMapper.getTaskType(bean);
        } catch (Exception e) {
            log.error("代办事件-查询失败", e);
        }
        return AjaxResult.success(list);
    }

}
