| | |
| | | import com.bstek.dorado.annotation.DataProvider; |
| | | import com.bstek.dorado.annotation.DataResolver; |
| | | import com.bstek.dorado.annotation.Expose; |
| | | import com.bstek.dorado.data.provider.Page; |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.data.ApiParam; |
| | | import com.fzzy.api.dto.ResponseDto; |
| | |
| | | import com.fzzy.api.service.ApiCommonService; |
| | | import com.fzzy.api.service.ApiPushManager; |
| | | import com.fzzy.api.service.ApiRemoteService; |
| | | import com.fzzy.api.utils.ContextUtil; |
| | | import com.fzzy.api.view.repository.ApiInfoDataRep; |
| | | import com.fzzy.otherview.whhpjl.WhjlConstant; |
| | | import com.fzzy.otherview.whhpjl.dto.WhjlApi1112; |
| | | import com.fzzy.otherview.whhpjl.dto.WhjlApi1112; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.PageRequest; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.jpa.domain.Specification; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.persistence.criteria.CriteriaBuilder; |
| | | import javax.persistence.criteria.CriteriaQuery; |
| | | import javax.persistence.criteria.Predicate; |
| | | import javax.persistence.criteria.Root; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public List<WhjlApi1112> listData() { |
| | | List<ApiInfoData> result = apiInfoDataRep.getDataByInteId(WhjlConstant.API_CODE_1111); |
| | | if (null == result || result.isEmpty()) { |
| | | return null; |
| | | public void listData(Page<WhjlApi1112> page, ApiParam param) { |
| | | |
| | | Pageable pageable = PageRequest.of(page.getPageNo() - 1, page.getPageSize(), Sort.Direction.DESC, "updateTime"); |
| | | |
| | | Specification specification = new Specification<ApiInfoData>() { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Override |
| | | public Predicate toPredicate(Root<ApiInfoData> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) { |
| | | List<Predicate> predicates = new ArrayList<>(); //所有的断言 |
| | | Predicate predicate = criteriaBuilder.equal(root.get("inteId"), WhjlConstant.API_CODE_1112); |
| | | predicates.add(predicate); |
| | | if (null != param) { |
| | | if (StringUtils.isNotBlank(param.getKqdm())) { |
| | | Predicate predicate1 = criteriaBuilder.equal(root.get("kqdm"), param.getKqdm()); |
| | | predicates.add(predicate1); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(param.getCzbz())) { |
| | | Predicate predicate2 = criteriaBuilder.equal(root.get("czbz"), param.getCzbz()); |
| | | predicates.add(predicate2); |
| | | } |
| | | if (null != param.getStart()) { |
| | | Predicate predicate3 = criteriaBuilder.greaterThan(root.get("updateTime"), ContextUtil.getCurZero(param.getStart())); |
| | | predicates.add(predicate3); |
| | | } |
| | | |
| | | if (null != param.getEnd()) { |
| | | Predicate predicate4 = criteriaBuilder.lessThan(root.get("updateTime"), ContextUtil.getNextZero(param.getEnd())); |
| | | predicates.add(predicate4); |
| | | } |
| | | } |
| | | return criteriaBuilder.and(predicates.toArray(new Predicate[0])); |
| | | } |
| | | }; |
| | | org.springframework.data.domain.Page<ApiInfoData> japPage = apiInfoDataRep.findAll(specification, pageable); |
| | | page.setEntityCount((int) japPage.getTotalElements()); |
| | | List<WhjlApi1112> list = new ArrayList<>(); |
| | | WhjlApi1112 whjlApi1111; |
| | | for (ApiInfoData infoData : result) { |
| | | whjlApi1111 = JSONObject.parseObject(infoData.getData(), WhjlApi1112.class); |
| | | whjlApi1111.setKqdm(infoData.getKqdm()); |
| | | whjlApi1111.setCzbz(infoData.getCzbz()); |
| | | whjlApi1111.setUpdateTime(infoData.getUpdateTime()); |
| | | whjlApi1111.setBizId(infoData.getDataId()); |
| | | list.add(whjlApi1111); |
| | | WhjlApi1112 whjlApi1112; |
| | | for (ApiInfoData infoData : japPage.getContent()) { |
| | | whjlApi1112 = JSONObject.parseObject(infoData.getData(), WhjlApi1112.class); |
| | | whjlApi1112.setKqdm(infoData.getKqdm()); |
| | | whjlApi1112.setCzbz(infoData.getCzbz()); |
| | | whjlApi1112.setUpdateTime(infoData.getUpdateTime()); |
| | | whjlApi1112.setBizId(infoData.getDataId()); |
| | | list.add(whjlApi1112); |
| | | } |
| | | return list; |
| | | page.setEntities(list); |
| | | |
| | | } |
| | | |
| | | /** |