package com.njcn.user.service.impl;

import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.system.api.AreaFeignClient;
import com.njcn.system.pojo.po.Area;
import com.njcn.user.mapper.AuthClientMapper;
import com.njcn.user.pojo.param.AuthClientParam;
import com.njcn.user.pojo.po.AuthClient;
import com.njcn.user.service.IAuthClientService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hongawen
 * @since 2021-12-15
 */
@Service
@RequiredArgsConstructor
public class AuthClientServiceImpl extends ServiceImpl<AuthClientMapper, AuthClient> implements IAuthClientService {

    @Override
    public AuthClient getAuthClientByName(String clientName) {
      return lambdaQuery()
              .eq(AuthClient::getName,clientName)
              .eq(AuthClient::getState,DataStateEnum.ENABLE.getCode())
              .one();
    }

    @Override
    public Boolean sessionConfigUpdate(AuthClientParam authClientParam) {
        return  lambdaUpdate().set(AuthClient::getRefreshTokenValidity,authClientParam.getRefreshTokenValidity())
                .set(AuthClient::getAccessTokenValidity,authClientParam.getAccessTokenValidity())
                .update();
    }
}
