sunpengfei
2025-08-15 a57346a5d1f132ab39e3172cf7614163da79bc2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Furion.DatabaseAccessor;
using Furion.Schedule;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
 
namespace FlexJobApi.Core
{
    /// <summary>
    /// 定时根据身份证计算用户年龄
    /// </summary>
    public class CalcUserAgeByIdCardJob(
            IRepository<User> rep
        ) : IJob
    {
        private readonly IRepository<User> rep = rep;
 
        public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
        {
            var enities = await rep.AsQueryable()
                .Where(it => it.Type == EnumUserType.Personal && it.Identity != null && it.Identity != "")
                .ToListAsync(stoppingToken);
            foreach (var entity in enities)
            {
                var age = entity.Identity.GetAge();
                entity.Age = age;
            }
        }
    }
}