package com.hotent.portal.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hotent.base.exception.BaseException;
import com.hotent.base.manager.impl.BaseManagerImpl;
import com.hotent.base.model.CommonResult;
import com.hotent.base.query.*;
import com.hotent.base.util.BeanUtils;
import com.hotent.base.util.StringUtil;
import com.hotent.portal.model.PortalBizSystem;
import com.hotent.portal.model.PortalDingTodoTask;
import com.hotent.portal.model.SysIndexLayoutManage;
import com.hotent.portal.model.SysIndexMyLayout;
import com.hotent.portal.params.IndexLayoutVo;
import com.hotent.portal.persistence.dao.PortalBizSystemDao;
import com.hotent.portal.persistence.dao.PortalDingTodoTasklDao;
import com.hotent.portal.persistence.manager.SysIndexLayoutManageManager;
import com.hotent.portal.persistence.manager.SysIndexMyLayoutManager;
import com.hotent.portal.service.MainPortalService;
import com.hotent.portal.service.PortalDingTodoTaskService;
import com.hotent.sys.persistence.manager.SysAuthUserManager;
import com.hotent.sys.persistence.model.SysAuthUser;
import com.hotent.uc.api.impl.util.ContextUtil;
import com.hotent.uc.api.model.IUser;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;


@Service
public class PortalDingTodoTaskServiceImpl  extends BaseManagerImpl<PortalDingTodoTasklDao, PortalDingTodoTask> implements PortalDingTodoTaskService {

    @Resource
    SysIndexLayoutManageManager sysIndexlayoutManageService;
    @Resource
    private SysAuthUserManager sysAuthUserManager;
    @Resource
    SysIndexMyLayoutManager sysIndexMylayoutService;


    @Override
    public List<PortalDingTodoTask> queryEntityById(String todoTaskId, String dingUserId) {
        LambdaQueryWrapper<PortalDingTodoTask> qw=new LambdaQueryWrapper<>();
        qw.eq(PortalDingTodoTask::getTodoTaskId,todoTaskId);
        if(StringUtil.isNotEmpty(dingUserId)){
            qw.eq(PortalDingTodoTask::getDingUserId,todoTaskId);
        }
        List<PortalDingTodoTask> list= this.baseMapper.selectList(qw);
        if(list.size()>0){
            return list;
        }
        return null;
    }

    @Override
    public void saveEntity(String dingTodoTaskId, String dingtalkIds, String userDingUnionId, String taskId, String orgId) {
        PortalDingTodoTask taskEntity=new PortalDingTodoTask();
        taskEntity.setCreateTime(LocalDateTime.now());
        taskEntity.setDingTodoTaskId(dingTodoTaskId);
        taskEntity.setDingUserId(dingtalkIds);
        taskEntity.setDingUserUnionId(userDingUnionId);
        taskEntity.setTodoTaskId(taskId);
        taskEntity.setOrgId(orgId);
        this.save(taskEntity);
    }
}
