package com.ecep.contract.ds.project.repository;

import java.util.Optional;

import org.springframework.stereotype.Repository;

import com.ecep.contract.ds.MyRepository;
import com.ecep.contract.model.Project;
import com.ecep.contract.model.ProjectSaleType;

@Repository
public interface ProjectRepository extends
        MyRepository<Project, Integer> {


    Optional<Project> findFirstBySaleTypeAndCodeYearOrderByCodeSequenceNumberDesc(ProjectSaleType type, int year);

    /**
     * 根据销售类型、年、序号查询项目
     *
     * @param type           销售类型
     * @param year           年份
     * @param sequenceNumber 序号
     * @return 项目
     */
    Optional<Project> findBySaleTypeAndCodeYearAndCodeSequenceNumber(ProjectSaleType type, int year, int sequenceNumber);

    Optional<Project> findByName(String name);

    Optional<Project> findByCode(String code);
}
