package cn.iocoder.yudao.module.system.api.group;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.group.AttendanceGroupDO;
import cn.iocoder.yudao.module.system.service.attendance.group.AttendanceGroupService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class AttendanceGroupApiImpl implements AttendanceGroupApi{

    @Resource
    private AttendanceGroupService attendanceGroupService;

    @Override
    public CommonResult<Integer> getReplacementCardNum(Long userId) {
        int num = 0;
        AttendanceGroupDO group = attendanceGroupService.getByUserId(userId);
        if (group != null) {
            num = group.getReplacementCardNum();
        }
        return success(num);
    }
}
