package com.qmth.sop.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qmth.sop.business.bean.result.SysDingGroupRoleResult;
import com.qmth.sop.business.entity.SysDingObj;
import com.qmth.sop.business.mapper.SysDingObjMapper;
import com.qmth.sop.business.service.SysDingObjService;
import com.qmth.sop.common.contant.SystemConstant;
import com.qmth.sop.common.enums.SopRoleTypeEnum;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 考勤组对象表 服务实现类
 * </p>
 *
 * @author wangliang
 * @since 2023-08-01
 */
@Service
public class SysDingObjServiceImpl extends ServiceImpl<SysDingObjMapper, SysDingObj> implements SysDingObjService {

    @Override
    public List<SysDingGroupRoleResult> getList(long id) {
        List<SysDingGroupRoleResult> result = this.baseMapper.getList(id);
        for (SysDingGroupRoleResult sysDingGroupRoleResult : result) {
            Long roleId = sysDingGroupRoleResult.getRoleId();
            if (!SystemConstant.longNotNull(roleId)) {
                // 打卡类型 名称根据sop_role_type来
                SopRoleTypeEnum sopRoleType = sysDingGroupRoleResult.getSopRoleType();
                if (Objects.nonNull(sopRoleType)) {
                    sysDingGroupRoleResult.setRoleName(sopRoleType.getTitle());
                }
            }
        }
        return result;
    }
}
