|
|
@ -140,32 +140,17 @@ public class CMSAdvertisementService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(param.getName()))
|
|
|
|
|
|
|
|
ad.setName(param.getName());
|
|
|
|
ad.setName(param.getName());
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(param.getLocation()))
|
|
|
|
|
|
|
|
ad.setLocation(param.getLocation());
|
|
|
|
ad.setLocation(param.getLocation());
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(param.getStartTime()))
|
|
|
|
|
|
|
|
ad.setStartTime(LocalDateTime.parse(param.getStartTime(), Constants.formatter));
|
|
|
|
ad.setStartTime(LocalDateTime.parse(param.getStartTime(), Constants.formatter));
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(param.getEndTime()))
|
|
|
|
|
|
|
|
ad.setEndTime(LocalDateTime.parse(param.getEndTime(), Constants.formatter));
|
|
|
|
ad.setEndTime(LocalDateTime.parse(param.getEndTime(), Constants.formatter));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(param.getType()))
|
|
|
|
|
|
|
|
ad.setType(param.getType());
|
|
|
|
ad.setType(param.getType());
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(param.getUrl()))
|
|
|
|
|
|
|
|
ad.setUrl(param.getUrl());
|
|
|
|
ad.setUrl(param.getUrl());
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(param.getIsDisplay()))
|
|
|
|
|
|
|
|
ad.setDisplay(param.getIsDisplay());
|
|
|
|
ad.setDisplay(param.getIsDisplay());
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(param.getContent())) {
|
|
|
|
|
|
|
|
ad.setContent(param.getContent());
|
|
|
|
ad.setContent(param.getContent());
|
|
|
|
ad.setSummary(contentToSummary(param.getContent()));
|
|
|
|
ad.setSummary(contentToSummary(param.getContent()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
adDao.save(ad);
|
|
|
|
|
|
|
|
|
|
|
|
return Result.success();
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -186,9 +171,13 @@ public class CMSAdvertisementService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Result<PageResult<AdvertisementRespDTO>> search(int page, int size) {
|
|
|
|
public Result<PageResult<AdvertisementRespDTO>> search(int page, int size) {
|
|
|
|
|
|
|
|
return search(page,size,null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Result<PageResult<AdvertisementRespDTO>> search(int page, int size,String location) {
|
|
|
|
List<AdvertisementRespDTO> result = new ArrayList<>();
|
|
|
|
List<AdvertisementRespDTO> result = new ArrayList<>();
|
|
|
|
PageRequest pageRequest = PageRequest.of(page - 1, size);
|
|
|
|
PageRequest pageRequest = PageRequest.of(page - 1, size);
|
|
|
|
Specification<Advertisement> AdSpecification = buildSearchSpecification();
|
|
|
|
Specification<Advertisement> AdSpecification = buildSearchSpecification(location);
|
|
|
|
Page<Advertisement> AdPage = adDao.findAll(AdSpecification,pageRequest);
|
|
|
|
Page<Advertisement> AdPage = adDao.findAll(AdSpecification,pageRequest);
|
|
|
|
|
|
|
|
|
|
|
|
long totalElements = AdPage.getTotalElements();
|
|
|
|
long totalElements = AdPage.getTotalElements();
|
|
|
@ -201,12 +190,19 @@ public class CMSAdvertisementService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Result.success(new PageResult<>(totalElements, result));
|
|
|
|
return Result.success(new PageResult<>(totalElements, result));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private Specification<Advertisement> buildSearchSpecification() {
|
|
|
|
private Specification<Advertisement> buildSearchSpecification(String location) {
|
|
|
|
return (Root<Advertisement> root, CriteriaQuery<?> query, CriteriaBuilder builder) -> {
|
|
|
|
return (Root<Advertisement> root, CriteriaQuery<?> query, CriteriaBuilder builder) -> {
|
|
|
|
List<Predicate> predicateList = new ArrayList<Predicate>();
|
|
|
|
List<Predicate> predicateList = new ArrayList<Predicate>();
|
|
|
|
Predicate isDeleted = builder.equal(root.get("isDeleted"), "0");
|
|
|
|
Predicate isDeleted = builder.equal(root.get("isDeleted"), "0");
|
|
|
|
Predicate isDisplay = builder.equal(root.get("display"), "1");
|
|
|
|
Predicate isDisplay = builder.equal(root.get("display"), "1");
|
|
|
|
predicateList.add(builder.and(isDeleted, isDisplay));
|
|
|
|
Predicate predicate = builder.and(isDeleted, isDisplay);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(location !=null){
|
|
|
|
|
|
|
|
Predicate locationPredicate = builder.equal(root.get("location"), location);
|
|
|
|
|
|
|
|
predicate.getExpressions().add(locationPredicate);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
predicateList.add(predicate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// LocalDateTime now = LocalDateTime.now();
|
|
|
|
// LocalDateTime now = LocalDateTime.now();
|
|
|
@ -217,6 +213,7 @@ public class CMSAdvertisementService {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String contentToSummary(String content){
|
|
|
|
private String contentToSummary(String content){
|
|
|
|
String originalString = content;
|
|
|
|
String originalString = content;
|
|
|
|
String[] parts = originalString.split("<.*?>");
|
|
|
|
String[] parts = originalString.split("<.*?>");
|
|
|
|