package com.hzs.member.detail.provider;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hzs.common.core.domain.R;
import com.hzs.common.domain.member.detail.CuMemberServiceLog;
import com.hzs.common.domain.member.detail.CuMemberServiceLogExt;
import com.hzs.member.detail.ICuMemberServiceLogServiceApi;
import com.hzs.member.detail.service.ICuMemberServiceLogService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

@DubboService
public class CuMemberServiceLogProvider implements ICuMemberServiceLogServiceApi {

    @Autowired
    private ICuMemberServiceLogService iCuMemberServiceLogService;

    @Override
    public List<CuMemberServiceLog> queryMaxCuMemberServiceLog(Long pkMember, List<Integer> editTypeList) {
        return iCuMemberServiceLogService.queryMaxCuMemberServiceLog(pkMember, editTypeList);
    }

    @Override
    public Integer selectByMaxApproveNumber(Long pkMember, Integer editType, Integer approveStatus) {
        return iCuMemberServiceLogService.selectByMaxApproveNumber(pkMember, editType, approveStatus);
    }

    @Override
    public R<Boolean> insert(CuMemberServiceLog memberLog) {
        return R.ok(iCuMemberServiceLogService.save(memberLog));
    }

    @Override
    public R<CuMemberServiceLog> selectByBusinessNo(String businessNo) {
        return iCuMemberServiceLogService.selectByBusinessNo(businessNo);
    }

    @Override
    public R<Boolean> updateByBusinessNo(CuMemberServiceLog memberLog) {
        return iCuMemberServiceLogService.updateByBusinessNo(memberLog);
    }

    @Override
    public R<List<CuMemberServiceLog>> selectCuMemberServiceLog(String businessNo) {
        return iCuMemberServiceLogService.selectCuMemberServiceLog(businessNo);
    }

    @Override
    public R<CuMemberServiceLogExt> queryPolicy(Long pkMember) {
        return R.ok(iCuMemberServiceLogService.queryPolicy(pkMember));
    }

    @Override
    public R<Integer> queryCount(Long pkMember, Integer approvalBusiness, Integer approveStatus) {
        LambdaQueryWrapper<CuMemberServiceLog> query = new LambdaQueryWrapper<>();
        query.eq(CuMemberServiceLog::getApproveStatus, approveStatus);
        query.eq(CuMemberServiceLog::getEditType, approvalBusiness);
        query.eq(CuMemberServiceLog::getPkMember, pkMember);
        return R.ok(iCuMemberServiceLogService.count(query));
    }

    @Override
    public R<CuMemberServiceLog> selectTopData(Long pkMember, int editType, int approveStatus) {
        return R.ok(iCuMemberServiceLogService.selectTopData(pkMember, editType, approveStatus));
    }

    @Override
    public R<List<CuMemberServiceLog>> listActivateLog(Date queryDate) {
        return R.ok(iCuMemberServiceLogService.listActivateLog(queryDate));
    }
}
