package cd.casic.module.system.job;

import cd.casic.framework.datapermission.core.dal.AdminUserMapper;
import cd.casic.framework.job.core.handler.JobHandler;
import cd.casic.framework.commons.context.TenantContextHolder;
import cd.casic.framework.tenant.core.job.TenantJob;
import cd.casic.framework.security.dal.user.AdminUserDO;
import org.springframework.stereotype.Component;

import jakarta.annotation.Resource;
import java.util.List;

@Component
public class DemoJob implements JobHandler {

    @Resource
    private AdminUserMapper adminUserMapper;

    @Override
    @TenantJob // 标记多租户
    public String execute(String param) {
        System.out.println("当前租户：" + TenantContextHolder.getTenantId());
        List<AdminUserDO> users = adminUserMapper.selectList();
        return "用户数量：" + users.size();
    }

}
