发表于: 2018-01-26 20:25:50
1 585
今天完成的事情:
学习了一波公司的dal
定义一个动态查询字段的map
public static Map<String, Object> getVideoList(String title, Integer classify, Integer grade, Integer subject,Integer favoriteMin, Integer favoriteMax, Integer collectionMin, Integer collectionMax, Integer teacherId, Integer statu)
{
Map<String, Object> params = new HashMap<String, Object>();
params.put("@video", "video");
params.put("@order", "update_at desc");
if (title != null) {
params.put("title & like", "'%" + title + "%'");
}
if (classify != null) {
params.put("classify", classify);
}
if (grade != null) {
params.put("grade", grade);
}
if (subject != null) {
params.put("subject", subject);
}
if (favoriteMin != null) {
params.put("favoriteMin >=", favoriteMin);
}
if (favoriteMax != null) {
params.put("favoriteMax <=", favoriteMax);
}
if (collectionMin != null) {
params.put("collectionMin >=", collectionMin);
}
if (collectionMax != null) {
params.put("collectionMax <=", collectionMax);
}
if (teacherId != null) {
params.put("teacherId", teacherId);
}
if (status != null) {
params.put("status", status);
}
return params;
}
然后调用公司封装好的方法,得到所有数据的id集合值。
idList = videoService.getIdsByDynamicCondition(Video.class, params, start, size);
最后再getObjectsByIds就能得到list对象了
明天计划的事情:
完成视频列表的接口
遇到的问题:
暂无
收获:
对公司的dal有了了解,是sql进行拼接的一个过程,费点时间,理解起来还是不难的。
评论