TokenServiceImpl.java 1.13 KB
package com.huaheng.api.xinyi.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.api.xinyi.domian.TokenEntity;
import com.huaheng.api.xinyi.mapper.TokenMapper;
import jdk.nashorn.internal.parser.Token;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by Enzo Cotter on 2019/12/20.
 */
@Service
public class TokenServiceImpl extends ServiceImpl<TokenMapper, TokenEntity> implements TokenService {

    @Resource
    private TokenMapper tokenMapper;
    @Resource
    private ApiTokenService apiTokenService;

    @Override
    public TokenEntity findOneByAll() {
        return tokenMapper.findOneByAll();
    }

    @Override
    public boolean insertSelective(TokenEntity tokenEntity) {
        return tokenMapper.insertSelective(tokenEntity)==1;
    }

    @Override
    public TokenEntity getTokenEntity() {
        TokenEntity tokenEntity = findOneByAll();
        if (tokenEntity == null){
            if ("success".equals(apiTokenService.apiToken())){
                tokenEntity = findOneByAll();
            }
        }
        return tokenEntity;
    }
}