package me.zhengjie.modules.company.repository;

import java.util.Set;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import me.zhengjie.modules.company.domain.Company;

public interface CompanyRepository extends JpaRepository<Company, Long>, JpaSpecificationExecutor<Company> {

    Company findByName(String name);

    /**
     * 修改名称
     * 
     * @param username 企业名称
     */
    @Modifying
    @Query(value = "update sys_company set name = ?2 where name = ?1", nativeQuery = true)
    void updateName(String oldName, String newName);

    /**
     * 根据Id删除
     * 
     * @param ids /
     */
    void deleteAllByIdIn(Set<Long> ids);
}
