30 lines
1.7 KiB
Java
30 lines
1.7 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;
|
|
|
|
@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')", nativeQuery = true)
|
|
@Modifying(clearAutomatically = true)
|
|
void updateProCityCode();
|
|
|
|
@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)", nativeQuery = true)
|
|
@Modifying(clearAutomatically = true)
|
|
void updateProCityName();
|
|
|
|
@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 = ?1", nativeQuery = true)
|
|
@Modifying(clearAutomatically = true)
|
|
void updateProCityCodeById(Long id);
|
|
|
|
@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 = ?1", nativeQuery = true)
|
|
@Modifying(clearAutomatically = true)
|
|
void updateProCityNameById(Long id);
|
|
|
|
}
|