package cn.superdesk.uniorder.dubbo.consumer.organisation;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.security.JwtUtil;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.organisation.UnifiedSupplier;
import cn.superdesk.uniorder.dto.param.organisation.SysSupplierQueryParam;
import cn.superdesk.uniorder.dto.param.organisation.UnifiedSupplierParam;
import cn.superdesk.uniorder.dto.param.organisation.UnifiedSupplierQueryCriteria;
import cn.superdesk.uniorder.dto.vo.organisation.UnifiedSupplierVo;
import cn.superdesk.uniorder.dto.vo.sys.SysSelectVo;
import cn.superdesk.uniorder.dto.vo.sys.SysSupplierVo;
import cn.superdesk.uniorder.dubbo.facade.organisation.DubboSysSupplierService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author: linjinyu
 * @Email linjinyu@avic-s.com
 * @CreateDate: 2021-05-14 12:51:18
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021-05-14 12:51:18
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Component
public class SysSupplierDubboConsumerService {

    @Reference(version = "1.0.0", timeout = 30000, retries = -1)
    private DubboSysSupplierService dubboUnifiedSupplierService;


    /****************************************** extends BaseService 部分 start ******************************************/

    public void addObj(UnifiedSupplierParam param) {

        dubboUnifiedSupplierService.addObj(param);

    }

    public void updateObj(UnifiedSupplierParam param) {

        dubboUnifiedSupplierService.updateObj(param);
    }

    public void deleteObj(Long id) {

        dubboUnifiedSupplierService.deleteObj(id);
    }

    public UnifiedSupplier findById(Long id) {

        return dubboUnifiedSupplierService.findById(id);
    }

    public PageInfo<UnifiedSupplier> entityPageQuery(Map<String, Object> conditions, Integer pageNun, Integer pageSize) {

        return dubboUnifiedSupplierService.entityPageQuery(conditions, pageNun, pageSize);
    }

    @Deprecated
    public List<UnifiedSupplier> findAll(Map<String, Object> queryMap) {

        return dubboUnifiedSupplierService.findAll(queryMap);
    }


    /****************************************** extends BaseService 部分   end ******************************************/


    public int addUnifiedSupplier(UnifiedSupplierParam param, String token) {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboUnifiedSupplierService.addUnifiedSupplier(param, loginSysUser);
    }

    public int updateUnifiedSupplier(UnifiedSupplierParam param, String token) {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboUnifiedSupplierService.updateUnifiedSupplier(param, loginSysUser);
    }

    public int deleteUnifiedSupplier(Long id, String token) {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboUnifiedSupplierService.deleteUnifiedSupplier(id, loginSysUser);
    }

    public UnifiedSupplier findUnifiedSupplierById(Long id) {

        return dubboUnifiedSupplierService.findUnifiedSupplierById(id);
    }

    public R<List<UnifiedSupplier>> pageQuery(Map<String, Object> conditions, int pageNun, int pageSize) {

        return dubboUnifiedSupplierService.pageQuery(conditions, pageNun, pageSize);
    }


    /****************************************** extends BaseService 部分 start ******************************************/


    public void updateObj(UnifiedSupplier oe) {
        dubboUnifiedSupplierService.updateObj(oe);
    }

    public void addObj(UnifiedSupplier oe) {
        dubboUnifiedSupplierService.addObj(oe);
    }

    /****************************************** extends BaseService 部分   end ******************************************/


    /******************************************  start ******************************************/

    public R<List<UnifiedSupplierVo>> pageQuery(UnifiedSupplierQueryCriteria queryCriteria, String token) {

        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

        return dubboUnifiedSupplierService.pageQuery(queryCriteria, loginSysUser);
    }

    public void kafkaMergeReceiveMerchant4SuperdeskMall(String message) {
        dubboUnifiedSupplierService.kafkaMergeReceiveMerchant4SuperdeskMall(message);
    }

    @Deprecated
    public void kafkaDeleteReceiveMerchant4SuperdeskMall(String message) {
        dubboUnifiedSupplierService.kafkaDeleteReceiveMerchant4SuperdeskMall(message);
    }


    public void kafkaMergeReceiveMerchant4SuperdeskMallFLSC_QCH(String message) {
        dubboUnifiedSupplierService.kafkaMergeReceiveMerchant4SuperdeskMallFLSC_QCH(message);
    }

    /**
     * 20200707 林志鹏说是没删除
     *
     * @param message
     */
    @Deprecated
    public void kafkaDeleteReceiveMerchant4SuperdeskMallFLSC_QCH(String message) {
        dubboUnifiedSupplierService.kafkaDeleteReceiveMerchant4SuperdeskMallFLSC_QCH(message);
    }

    public R<List<SysSupplierVo>> findSupplierList(SysSupplierQueryParam param){
        return dubboUnifiedSupplierService.findSupplierList(param);
    }

    public List<SysSelectVo> selectList(Map<String,Object> params){
        return dubboUnifiedSupplierService.selectList(params);
    }
}
