package com.ssj.dao.sys.appinfo.dao;

import com.ssj.bean.sys.appinfo.bean.AppInfo;
import com.ssj.service.sys.appinfo.service.dto.LastVersionAppInfoDto;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Mount Liu
 * @date 2019/3/17
 */
@Repository
public interface AppInfoDao extends JpaRepository<AppInfo, String> {

    Page<AppInfo> findAll(Specification<AppInfo> specification, Pageable page);

    List<AppInfo> findByVersionTypeAndTypeOrderByCreateTimeDescIssueNumDesc(String versionType, int type);
    
    public AppInfo findTopByVersionAndType(String version, int type);

    @Query(nativeQuery = true,value = "select * from scon_app_info where version_type=?1 and type=?2 order by create_time desc limit 1 ")
    AppInfo findLastPackageByVersionTypeAndType(String versionType,int type);
}
