package com.diagbot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.diagbot.entity.ServiceToken;
import com.diagbot.enums.IsDeleteEnum;
import com.diagbot.mapper.ServiceTokenMapper;
import com.diagbot.service.ServiceTokenService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务令牌表 服务实现类
 * </p>
 *
 * @author zhaops
 * @since 2018-09-17
 */
@Service
public class ServiceTokenServiceImpl extends ServiceImpl<ServiceTokenMapper, ServiceToken> implements ServiceTokenService {
    /**
     * 更新令牌
     *
     * @param entity
     * @param updateWrapper
     * @return
     */
    public Integer updateRecord(ServiceToken entity, UpdateWrapper<ServiceToken> updateWrapper) {
        updateWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
        return this.baseMapper.update(entity, updateWrapper);
    }

    /**
     * 查找令牌（单记录）
     *
     * @param queryWrapper
     * @return
     */
    public ServiceToken selectOneRecord(QueryWrapper<ServiceToken> queryWrapper) {
        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
        return this.baseMapper.selectOne(queryWrapper);
    }
}
