package com.hzs.third.share.provider;

import com.hzs.common.core.domain.R;
import com.hzs.third.share.IShareServiceApi;
import com.hzs.third.share.dto.ShareServiceDTO;
import com.hzs.third.share.service.ITShareCodeService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description: 分享码服务
 * @Author: jiang chao
 * @Time: 2023/3/15 11:33
 * @Classname: ShareServiceProvider
 * @PackageName: com.hzs.third.share.provider
 */
@Slf4j
@DubboService
public class ShareServiceProvider implements IShareServiceApi {

    @Autowired
    private ITShareCodeService itShareCodeService;

    @Override
    public R<String> queryShareCode(ShareServiceDTO dto) {
        try {
            String str = itShareCodeService.queryShareCode(dto);
            if (null != str) {
                return R.ok(str);
            }
            log.error("分享码生成失败");
            return R.fail();
        } catch (Exception e) {
            log.error("分享码生成异常 param: {}", dto, e);
            return R.fail(e.getMessage());
        }
    }

}
