
package com.tmerclub.cloud.auth.feign;

import com.tmerclub.cloud.api.auth.feign.PasswordFeignClient;
import com.tmerclub.cloud.auth.manager.PasswordManager;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author 菠萝凤梨
 * @date 2022/1/20 15:07
 */
@DubboService
public class PasswordFeignController implements PasswordFeignClient {

    @Autowired
    private PasswordManager passwordManager;

    @Override
    public ServerResponseEntity<String> getDecryptPassword(String password) {
        ServerResponseEntity<String> decryptPasswordEntity = passwordManager.decryptPassword(password);
        if (!decryptPasswordEntity.isSuccess()) {
            return ServerResponseEntity.transform(decryptPasswordEntity);
        }
        return ServerResponseEntity.success(decryptPasswordEntity.getData());
    }
}
