|
|
@ -19,6 +19,7 @@ import org.springframework.stereotype.Repository; |
|
|
|
|
|
|
|
|
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
|
@ -31,6 +32,9 @@ public class VisitorDao extends BaseDao<Visitor> { |
|
|
|
@Value("${visitor.dateformat}") |
|
|
|
@Value("${visitor.dateformat}") |
|
|
|
private String dateformat; |
|
|
|
private String dateformat; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${visitor.page-size}") |
|
|
|
|
|
|
|
private Integer androidPageSize; |
|
|
|
|
|
|
|
|
|
|
|
//保存访客信息
|
|
|
|
//保存访客信息
|
|
|
|
public Visitor save(VisitorForm visitorForm) { |
|
|
|
public Visitor save(VisitorForm visitorForm) { |
|
|
|
Visitor visitor = new Visitor(); |
|
|
|
Visitor visitor = new Visitor(); |
|
|
@ -67,29 +71,38 @@ public class VisitorDao extends BaseDao<Visitor> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//用户加载访客信息
|
|
|
|
//用户加载访客信息
|
|
|
|
private List<Visitor> load(com.community.pocket.entity.vo.android.VisitorQuery visitorQuery, Criteria criteria) { |
|
|
|
private Page<Visitor> load(com.community.pocket.entity.vo.android.VisitorQuery visitorQuery, Criteria criteria) { |
|
|
|
if (visitorQuery.getStartDate() != null && visitorQuery.getEndDate() != null) { |
|
|
|
List<Criteria> criteriaList = new ArrayList<>(); |
|
|
|
criteria = criteria.andOperator(Criteria.where("time").gte(visitorQuery.getStartDate().getTime()), Criteria.where("time").lte(visitorQuery.getEndDate().getTime())); |
|
|
|
criteriaList.add(criteria); |
|
|
|
|
|
|
|
if (visitorQuery.getStartDate() != null) { |
|
|
|
|
|
|
|
criteriaList.add(Criteria.where("time").gte(visitorQuery.getStartDate().getTime())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (visitorQuery.getEndDate() != null) { |
|
|
|
|
|
|
|
criteriaList.add(Criteria.where("time").lte(visitorQuery.getEndDate().getTime())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Criteria c; |
|
|
|
|
|
|
|
if (criteriaList.size() > 1) { |
|
|
|
|
|
|
|
c = new Criteria().andOperator(criteriaList.toArray(new Criteria[]{})); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (visitorQuery.getStartDate() != null) { |
|
|
|
c = criteria; |
|
|
|
criteria = criteria.and("time").gte(visitorQuery.getStartDate().getTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (visitorQuery.getEndDate() != null) { |
|
|
|
|
|
|
|
criteria = criteria.and("time").lte(visitorQuery.getEndDate().getTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return mongoTemplate.find(new Query(criteria).with(Sort.by("time").ascending()), entityClass()); |
|
|
|
Query query = new Query(c).with(Sort.by("time").ascending()); |
|
|
|
|
|
|
|
long count = mongoTemplate.count(query, entityClass()); |
|
|
|
|
|
|
|
List<Visitor> visitorList = mongoTemplate.find(query.with(PageRequest.of(visitorQuery.getCurrentPage().intValue() - 1, androidPageSize)), entityClass()); |
|
|
|
|
|
|
|
Page<Visitor> visitorPage = new Page<>(count, visitorQuery.getCurrentPage(), androidPageSize); |
|
|
|
|
|
|
|
visitorPage.setList(visitorList); |
|
|
|
|
|
|
|
return visitorPage; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//加载我的访客信息
|
|
|
|
//加载我的访客信息
|
|
|
|
public List<Visitor> loadMyVisitor(com.community.pocket.entity.vo.android.VisitorQuery visitorQuery) { |
|
|
|
public Page<Visitor> loadMyVisitor(com.community.pocket.entity.vo.android.VisitorQuery visitorQuery) { |
|
|
|
Criteria criteria = Criteria.where("appointment").is(visitorQuery.getUsername()); |
|
|
|
Criteria criteria = Criteria.where("appointment").is(visitorQuery.getUsername()); |
|
|
|
return load(visitorQuery, criteria); |
|
|
|
return load(visitorQuery, criteria); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//加载我的预约
|
|
|
|
//加载我的预约
|
|
|
|
public List<Visitor> loadMyReservation(com.community.pocket.entity.vo.android.VisitorQuery visitorQuery) { |
|
|
|
public Page<Visitor> loadMyReservation(com.community.pocket.entity.vo.android.VisitorQuery visitorQuery) { |
|
|
|
Criteria criteria = Criteria.where("username").is(visitorQuery.getUsername()); |
|
|
|
Criteria criteria = Criteria.where("username").is(visitorQuery.getUsername()); |
|
|
|
return load(visitorQuery, criteria); |
|
|
|
return load(visitorQuery, criteria); |
|
|
|
} |
|
|
|
} |
|
|
|