新增写字楼接口
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
package com.fangjia.service.datastore;
|
||||
|
||||
import com.fangjia.dal.mongo.model.OfficeRentStat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author shenjian
|
||||
* @since 2025/1/21
|
||||
*/
|
||||
public interface OfficeService {
|
||||
|
||||
|
||||
/**
|
||||
* @param city
|
||||
* @param region
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
List<OfficeRentStat> findOfficeRentStat(final String city, final String region, final Integer startDate, final Integer endDate);
|
||||
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.fangjia.service.datastore;
|
||||
|
||||
import com.fangjia.core.util.CacheUtils;
|
||||
import com.fangjia.dal.QueryParam;
|
||||
import com.fangjia.dal.SortParam;
|
||||
import com.fangjia.dal.mongo.dao.office.OfficeRentStatDao;
|
||||
import com.fangjia.dal.mongo.model.OfficeRentStat;
|
||||
import org.sothis.core.util.Closure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author shenjian
|
||||
* @since 2025/1/21
|
||||
*/
|
||||
public class OfficeServiceImpl implements OfficeService {
|
||||
|
||||
private OfficeRentStatDao officeRentStatDao;
|
||||
|
||||
public List<OfficeRentStat> findOfficeRentStat(final String city, final String region, final Integer startDate, final Integer endDate) {
|
||||
return CacheUtils.getValue(this.getClass(), "findOfficeRentStat", city + region + startDate + endDate,
|
||||
CacheUtils.CachePolicyEnum.MIDDLE, new Closure<List<OfficeRentStat>, String>() {
|
||||
public List<OfficeRentStat> execute(String input) {
|
||||
return doFindRegionBlockStat(city, region, startDate, endDate);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<OfficeRentStat> doFindRegionBlockStat(final String city, final String region, Integer startDate, Integer endDate) {
|
||||
if (startDate == null) {
|
||||
throw new IllegalArgumentException("开始日期不能为空");
|
||||
}
|
||||
if (endDate == null) {
|
||||
throw new IllegalArgumentException("结束日期不能为空");
|
||||
}
|
||||
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("city", city));
|
||||
params.add(new QueryParam("district", region));
|
||||
|
||||
if (startDate != null) {
|
||||
params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate));
|
||||
}
|
||||
if (endDate != null) {
|
||||
params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate));
|
||||
}
|
||||
List<SortParam> sortParams = new ArrayList<SortParam>();
|
||||
sortParams.add(new SortParam("date", true));
|
||||
List<OfficeRentStat> regionStats = officeRentStatDao.findAllByParams(params, sortParams);
|
||||
return regionStats;
|
||||
}
|
||||
|
||||
public void setOfficeRentStatDao(OfficeRentStatDao officeRentStatDao) {
|
||||
this.officeRentStatDao = officeRentStatDao;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user