fire_point/src/main/java/com/xkrs/dao/FirePointOrdinaryDao.java
2023-03-13 13:52:07 +08:00

25 lines
1.4 KiB
Java

package com.xkrs.dao;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
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 org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Component
public interface FirePointOrdinaryDao extends JpaRepository<FirePointOrdinaryEntity, Long>, JpaSpecificationExecutor<FirePointOrdinaryEntity> {
@Query(value = "UPDATE fire_point_ordinary SET pro_code = concat(left(county_code, 2), '0000'), city_code = concat(left(county_code, 4), '00') WHERE id BETWEEN ?1 AND ?2", nativeQuery = true)
@Modifying(clearAutomatically = true)
@Transactional(rollbackFor = Exception.class)
void updateProCityCode(Long startId, Long endId);
@Query(value = "UPDATE fire_point_ordinary AS f SET pro_name = (SELECT s.pro_name AS proname FROM street AS s WHERE s.pro_code = f.pro_code LIMIT 1), city_name = (SELECT s.city_name AS cityname FROM street AS s WHERE s.city_code = f.city_code LIMIT 1) WHERE id BETWEEN ?1 AND ?2", nativeQuery = true)
@Modifying(clearAutomatically = true)
@Transactional(rollbackFor = Exception.class)
void updateProCityName(Long startId, Long endId);
}