package com.elephant.framework.galaxy.aroad.module.system.service.impl;

import com.elephant.framework.galaxy.aroad.module.system.entity.OauthClientDetails;
import com.elephant.framework.galaxy.aroad.module.system.mapper.OauthClientDetailsMapper;
import com.elephant.framework.galaxy.aroad.module.system.service.OauthClientDetailsService;
import com.elephant.framework.galaxy.aroad.constant.SecurityConstants;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 终端信息表 服务实现类
 * </p>
 *
 * @author wangjian
 * @since 2019-02-21
 */
@Service
public class OauthClientDetailsServiceImpl extends ServiceImpl<OauthClientDetailsMapper, OauthClientDetails> implements OauthClientDetailsService {
    /**
     * 通过ID删除客户端
     *
     * @param id
     * @return
     */
    @Override
    @CacheEvict(value = SecurityConstants.CLIENT_DETAILS_KEY, key = "#id")
    public Boolean removeClientDetailsById(String id) {
        return this.removeById(id);
    }

    /**
     * 根据客户端信息
     *
     * @param clientDetails
     * @return
     */
    @Override
    @CacheEvict(value = SecurityConstants.CLIENT_DETAILS_KEY, key = "#clientDetails.clientId")
    public Boolean updateClientDetailsById(OauthClientDetails clientDetails) {
        return this.updateById(clientDetails);
    }

}
