| | |
| | | package com.yeshi.buwan.dao; |
| | | |
| | | import com.yeshi.buwan.dao.base.BaseDao; |
| | | import org.hibernate.HibernateException; |
| | | import org.hibernate.Session; |
| | | import org.springframework.orm.hibernate4.HibernateCallback; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @Repository |
| | |
| | | return list("from VideoInfo vi where vi.name=?", start, count, new Serializable[]{name}); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据主键批量查询 |
| | | * |
| | | * @param videoIds |
| | | * @return |
| | | */ |
| | | public List<VideoInfo> listByVideoIds(List<String> videoIds) { |
| | | String hql = "from VideoInfo vi where "; |
| | | List<String> ors = new ArrayList<>(); |
| | | for (String vi : videoIds) { |
| | | ors.add(" vi.id=? "); |
| | | } |
| | | hql += StringUtil.concat(ors, "or"); |
| | | String[] videos = new String[videoIds.size()]; |
| | | videoIds.toArray(videos); |
| | | return list(hql, videos); |
| | | } |
| | | |
| | | /** |
| | | * 统计视频附加信息(包含地区,分类,来源) |
| | | * |
| | | * @param videoId -视频ID |
| | | */ |
| | | public void statisticVideoExtraInfo(final String videoId) { |
| | | excute(new HibernateCallback() { |
| | | @Override |
| | | public Object doInHibernate(Session session) throws HibernateException { |
| | | session.getTransaction().begin(); |
| | | session.createSQLQuery(String.format("call copyvideotemp(%s)", videoId)).executeUpdate(); |
| | | session.getTransaction().commit(); |
| | | return null; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |