package com.unis.module.coding.dal.mysql.cwxxyear;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.unis.framework.common.pojo.PageResult;
import com.unis.framework.mybatis.core.mapper.BaseMapperX;
import com.unis.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.unis.module.coding.controller.admin.cwxxyear.vo.CwxxYearPageReqVO;
import com.unis.module.coding.dal.dataobject.bank.BankDO;
import com.unis.module.coding.dal.dataobject.cwxxyear.CwxxYearDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 财年务情况 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface CwxxYearMapper extends BaseMapperX<CwxxYearDO> {

    default PageResult<CwxxYearDO> selectPage(CwxxYearPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CwxxYearDO>()
                .eqIfPresent(CwxxYearDO::getCn, reqVO.getCn())
                .eqIfPresent(CwxxYearDO::getZfz, reqVO.getZfz())
                .eqIfPresent(CwxxYearDO::getYysr, reqVO.getYysr())
                .eqIfPresent(CwxxYearDO::getJlr, reqVO.getJlr())
                .eqIfPresent(CwxxYearDO::getCwxxId, reqVO.getCwxxId())
                .orderByDesc(CwxxYearDO::getId));
    }

    default List<CwxxYearDO> selectByCwxxId(Long cwxxId){
        return selectList(new LambdaQueryWrapperX<CwxxYearDO>()
                .eq(CwxxYearDO::getCwxxId, cwxxId)
                .orderByDesc(CwxxYearDO::getCn));
    }
    default int deleteListByCwxxId(Long  cwxxId) {
        return delete(
                new LambdaUpdateWrapper<CwxxYearDO>()
                        .eq(cwxxId!=null,CwxxYearDO::getCwxxId, cwxxId)
        );
    }
}