package cn.superdesk.uniorder.dubbo.consumer.invoice.common;

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.invoice.common.InvoiceType;
import cn.superdesk.uniorder.dto.param.invoice.common.InvoiceTypeCacheCriteria;
import cn.superdesk.uniorder.dto.param.invoice.common.InvoiceTypeOpCriteria;
import cn.superdesk.uniorder.dto.param.invoice.common.InvoiceTypeParam;
import cn.superdesk.uniorder.dto.param.invoice.common.InvoiceTypeQueryCriteria;
import cn.superdesk.uniorder.dto.vo.invoice.common.InvoiceTypeOpInvoiceSettingLoadingVo;
import cn.superdesk.uniorder.dto.vo.invoice.common.InvoiceTypePageQueryVo;
import cn.superdesk.uniorder.dto.vo.invoice.common.InvoiceTypeSelectVo;
import cn.superdesk.uniorder.dubbo.consumer._permission.PermissionDubboCustomerService;
import cn.superdesk.uniorder.dubbo.facade.invoice.common.DubboInvoiceTypeService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author: linjinyu
 * @Email linjinyu@avic-s.com
 * @CreateDate: 2021-07-23 15:30:45
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021-07-23 15:30:45
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Component
public class InvoiceTypeDubboConsumerService {

	@Reference(version = "1.0.0", timeout = 10000, retries = -1)
	private DubboInvoiceTypeService dubboInvoiceTypeService;

	@Resource
	private PermissionDubboCustomerService permissionDubboCustomerService;


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

	public void addObj(InvoiceTypeParam param) {

		dubboInvoiceTypeService.addObj(param);

	}

	public void updateObj(InvoiceTypeParam param) {

		dubboInvoiceTypeService.updateObj(param);
	}

	public void deleteObj(Long id) {

		dubboInvoiceTypeService.deleteObj(id);
	}

	public InvoiceType findById(Long id) {

		return dubboInvoiceTypeService.findById(id);
	}

	public PageInfo<InvoiceType> findByPaging(Map<String, Object> conditions, Integer pageNun, Integer pageSize) {

		return dubboInvoiceTypeService.findByPaging(conditions, pageNun, pageSize);
	}

	public List<InvoiceType> findAll(Map<String, Object> queryMap) {

		return dubboInvoiceTypeService.findAll(queryMap);
	}

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


	public void addInvoiceType(InvoiceTypeParam param) {

		dubboInvoiceTypeService.addInvoiceType(param);
	}


	public void updateInvoiceType(InvoiceTypeParam param) {

		dubboInvoiceTypeService.updateInvoiceType(param);
	}


	public void deleteInvoiceType(Long id) {
		dubboInvoiceTypeService.deleteInvoiceType(id);
	}


	public InvoiceType findInvoiceTypeById(Long id) {

		return dubboInvoiceTypeService.findInvoiceTypeById(id);
	}


	public R<List<InvoiceType>> pageQuery(InvoiceTypeQueryCriteria queryCriteria, String token) {

		Boolean isPass = permissionDubboCustomerService.addOnPerm(token, queryCriteria);
		if (isPass.equals(false)) {
			return null;
		}

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceTypeService.pageQuery(queryCriteria, loginSysUser);
	}

	public R<List<InvoiceTypePageQueryVo>> pageQuerySugarUp(InvoiceTypeQueryCriteria queryCriteria, String token) {

		Boolean isPass = permissionDubboCustomerService.addOnPerm(token, queryCriteria);
		if (isPass.equals(false)) {
			return null;
		}

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceTypeService.pageQuerySugarUp(queryCriteria, loginSysUser);

	}

	public List<InvoiceTypeSelectVo> selectQuery(InvoiceTypeQueryCriteria queryCriteria, String token) {

		Boolean isPass = permissionDubboCustomerService.addOnPerm(token, queryCriteria);
		if (isPass.equals(false)) {
			return null;
		}

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceTypeService.selectQuery(queryCriteria, loginSysUser);

	}


	/****************************************** 操作部分 start ******************************************/

	public int opSetDefault(InvoiceTypeOpCriteria opCriteria, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceTypeService.opSetDefault(opCriteria, loginSysUser);
	}

	public int opSetNormal(InvoiceTypeOpCriteria opCriteria, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceTypeService.opSetNormal(opCriteria, loginSysUser);
	}

	public int opSetEnable(InvoiceTypeOpCriteria opCriteria, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceTypeService.opSetEnable(opCriteria, loginSysUser);
	}

	public int opSetDisable(InvoiceTypeOpCriteria opCriteria, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceTypeService.opSetDisable(opCriteria, loginSysUser);
	}

	/****************************************** 操作部分   end ******************************************/


	/****************************************** 操作类 进阶 模块X发票种类-开票方式 start ******************************************/

	public int opInvoiceSettingSetDefault(InvoiceTypeOpCriteria opCriteria, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceTypeService.opInvoiceSettingSetDefault(opCriteria, loginSysUser);
	}
	public int opInvoiceSettingSetNormal(InvoiceTypeOpCriteria opCriteria, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceTypeService.opInvoiceSettingSetNormal(opCriteria, loginSysUser);
	}


	public int opInvoiceSettingSetEnable(InvoiceTypeOpCriteria opCriteria, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceTypeService.opInvoiceSettingSetDisable(opCriteria, loginSysUser);
	}
	public int opInvoiceSettingSetDisable(InvoiceTypeOpCriteria opCriteria, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceTypeService.opInvoiceSettingSetDisable(opCriteria, loginSysUser);
	}

	/****************************************** 操作类 进阶 模块X发票种类-开票方式   end ******************************************/

	public InvoiceTypeOpInvoiceSettingLoadingVo opInvoiceSettingLoading(InvoiceTypeOpCriteria opCriteria, String token) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboInvoiceTypeService.opInvoiceSettingLoading(opCriteria, loginSysUser);
	}

	/****************************************** 操作类 进阶   end ******************************************/


	/****************************************** 缓存 start ******************************************/

	/**
	 * 初始化
	 *
	 * @param criteria
	 */
	public void cacheInit(InvoiceTypeCacheCriteria criteria) {
		dubboInvoiceTypeService.cacheInit(criteria);
	}

	/**
	 * 刷新
	 *
	 * @param criteria
	 */
	public void cacheRefresh(InvoiceTypeCacheCriteria criteria) {
		dubboInvoiceTypeService.cacheRefresh(criteria);
	}

	/**
	 * 清除
	 *
	 * @param criteria
	 */
	public void cacheRemove(InvoiceTypeCacheCriteria criteria) {
		dubboInvoiceTypeService.cacheRemove(criteria);
	}

	public String cacheGet(InvoiceTypeCacheCriteria criteria) {
		return dubboInvoiceTypeService.cacheGet(criteria);
	}
}
