mirror of https://gitee.com/topiam/eiam
				
				
				
			⚡ 优化
							parent
							
								
									f7576ceedb
								
							
						
					
					
						commit
						fd6c83bd98
					
				| 
						 | 
				
			
			@ -57,7 +57,7 @@ export const Administrator = () => {
 | 
			
		|||
      ellipsis: true,
 | 
			
		||||
      width: 130,
 | 
			
		||||
      fixed: 'left',
 | 
			
		||||
      renderText: (dom, record) => (
 | 
			
		||||
      renderText: (_dom, record) => (
 | 
			
		||||
        <Space>
 | 
			
		||||
          <Avatar avatar={record.avatar} username={record.username} />
 | 
			
		||||
          {record.username}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,10 +24,6 @@ import org.slf4j.Logger;
 | 
			
		|||
import org.slf4j.LoggerFactory;
 | 
			
		||||
import org.springframework.scheduling.annotation.Scheduled;
 | 
			
		||||
 | 
			
		||||
import com.querydsl.core.types.ExpressionUtils;
 | 
			
		||||
import com.querydsl.core.types.Predicate;
 | 
			
		||||
 | 
			
		||||
import cn.topiam.employee.common.entity.account.QUserEntity;
 | 
			
		||||
import cn.topiam.employee.common.entity.account.UserEntity;
 | 
			
		||||
import cn.topiam.employee.common.enums.UserStatus;
 | 
			
		||||
import cn.topiam.employee.common.repository.account.UserRepository;
 | 
			
		||||
| 
						 | 
				
			
			@ -56,28 +52,21 @@ public class UserUnlockTask {
 | 
			
		|||
    @Scheduled(cron = "0 */1 * * * ?")
 | 
			
		||||
    public void execute() {
 | 
			
		||||
        logger.info("用户自动解锁任务开始");
 | 
			
		||||
        QUserEntity qUserEntity = QUserEntity.userEntity;
 | 
			
		||||
        Predicate predicate = ExpressionUtils.and(qUserEntity.isNotNull(),
 | 
			
		||||
            qUserEntity.deleted.eq(Boolean.FALSE));
 | 
			
		||||
        //查询条件
 | 
			
		||||
        //@formatter:off
 | 
			
		||||
        predicate = ExpressionUtils.and(predicate, qUserEntity.status.eq(UserStatus.LOCKED));
 | 
			
		||||
        List<UserEntity> list = (List<UserEntity>) userRepository.findAll(predicate);
 | 
			
		||||
        logger.info("待解锁用户数量: [{}] ",list.size());
 | 
			
		||||
        for (UserEntity entity:list) {
 | 
			
		||||
            logger.info("开始解锁用户:{}",entity.getUsername());
 | 
			
		||||
        List<UserEntity> list = userRepository.findAllByStatus(UserStatus.LOCKED);
 | 
			
		||||
        logger.info("待解锁用户数量: [{}] ", list.size());
 | 
			
		||||
        for (UserEntity entity : list) {
 | 
			
		||||
            logger.info("开始解锁用户: {}", entity.getUsername());
 | 
			
		||||
            LocalDateTime updateTime = entity.getUpdateTime();
 | 
			
		||||
            Integer unlockTime = getAutoUnlockTime();
 | 
			
		||||
            if (updateTime.plusMinutes(unlockTime).isBefore(LocalDateTime.now())){
 | 
			
		||||
            if (updateTime.plusMinutes(unlockTime).isBefore(LocalDateTime.now())) {
 | 
			
		||||
                entity.setStatus(UserStatus.ENABLE);
 | 
			
		||||
                userRepository.save(entity);
 | 
			
		||||
                logger.info("成功解锁用户:{}",entity.getUsername());
 | 
			
		||||
                logger.info("成功解锁用户: {}", entity.getUsername());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        logger.info("用户自动解锁任务结束");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * UserRepository
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue