HzInfoRepository.java 2.4 KB
package com.agent.repository.system;

import com.agent.entity.agent.HZSHIPPERINFORMATIONEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Auther: shenhl
 * @Date: 2019/4/17 14:36
 */
public interface HzInfoRepository extends PagingAndSortingRepository<HZSHIPPERINFORMATIONEntity, Long>,
        JpaSpecificationExecutor<HZSHIPPERINFORMATIONEntity>{

    @Query(value = "select count(*) from HZ_SHIPPER_INFORMATION where FOR_SHORT=?1 and THE_SHIPPER_TYPE = ?2 and delete_flag = 1",nativeQuery = true)
    int forShortShipperType(String forshort, String theshippertype);

    @Modifying
    @Query(value = "update HZ_SHIPPER_INFORMATION set delete_flag=2 where id=?1", nativeQuery = true)
    void deletes(Long id);

    @Transactional
    @Modifying
    @Query(value = "update HZ_SHIPPER_INFORMATION set for_short=?2, full_name=?3, the_shipper_type=?4, contacts=?5, phone=?6, delete_flag=?7 where id=?1", nativeQuery = true)
    int update(Long id, String for_short, String full_name, String the_shipper_type,
               String contacts, String phone, String delete_flag);
    @Transactional
    @Modifying(clearAutomatically=true)
    @Query(value = "insert into HZ_SHIPPER_INFORMATION(FOR_SHORT, FULL_NAME, THE_SHIPPER_TYPE, CONTACTS, PHONE, DELETE_FLAG) values(?1, ?2, ?3, ?4, ?5, ?6)", nativeQuery = true)
    int saves(String forShort, String fullName, String theShipperType, String contacts, String phone, String deleteFlag);

    @Query(value = "select * from HZ_SHIPPER_INFORMATION where the_shipper_type=1 and delete_flag = 1", nativeQuery = true)
    List<HZSHIPPERINFORMATIONEntity> findShipeer();

    @Query(value = "select * from HZ_SHIPPER_INFORMATION where the_shipper_type=2 and delete_flag = 1", nativeQuery = true)
    List<HZSHIPPERINFORMATIONEntity> findBooking();

    @Query(value = "select * from HZ_SHIPPER_INFORMATION where the_shipper_type=3 and delete_flag = 1", nativeQuery = true)
    List<HZSHIPPERINFORMATIONEntity> findOperaion();

    @Query(value = "select * from HZ_SHIPPER_INFORMATION where id=?1 and delete_flag = 1", nativeQuery = true)
    HZSHIPPERINFORMATIONEntity findOnes(Long id);
}