| 12345678910111213141516171819202122232425262728293031323334 |
- package com.izouma.jiashanxia.repo;
- import com.izouma.jiashanxia.domain.UserPackage;
- import com.izouma.jiashanxia.dto.UserPackageDTO;
- import com.izouma.jiashanxia.enums.PackageType;
- 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 javax.transaction.Transactional;
- import java.util.List;
- public interface UserPackageRepo extends JpaRepository<UserPackage, Long>, JpaSpecificationExecutor<UserPackage> {
- @Query("update UserPackage t set t.del = true where t.id = ?1")
- @Modifying
- @Transactional
- void softDelete(Long id);
- List<UserPackage> findAllByUserId(Long userId);
- List<UserPackage> findAllByUserIdAndType(Long userId, PackageType type);
- @Query("update UserPackage t set t.userId = ?2 where t.userId = ?1 and t.type = 'TEAM'")
- @Modifying
- @Transactional
- void updateUserId(Long oldUserId,Long newUserId);
- @Query(value = "select goods_info.*, ifnull(user_package.num, 0) as num " +
- "from goods_info " +
- "left join user_package on goods_info.id = user_package.goods_info_id and user_package.user_id = ?1 " +
- "where goods_info.del = 0", nativeQuery = true)
- List<UserPackageDTO> userPackage(Long userId);
- }
|