com.haoxuer.discover.area.rest.resource.AreaResource Maven / Gradle / Ivy
package com.haoxuer.discover.area.rest.resource;
import com.haoxuer.discover.area.data.entity.Area;
import com.haoxuer.discover.area.rest.conver.AreaDataSimpleConver;
import com.haoxuer.discover.area.rest.api.AreaHandler;
import com.haoxuer.discover.area.data.dao.AreaDao;
import com.haoxuer.discover.area.rest.domain.request.AreaCodeRequest;
import com.haoxuer.discover.area.rest.domain.request.AreaLevelRequest;
import com.haoxuer.discover.area.rest.domain.request.AreaListRequest;
import com.haoxuer.discover.area.rest.domain.request.AreaTypeRequest;
import com.haoxuer.discover.area.rest.domain.response.list.AreaDataList;
import com.haoxuer.discover.area.rest.domain.response.list.AreaList;
import com.haoxuer.discover.area.rest.domain.response.simple.AreaDataSimple;
import com.haoxuer.discover.area.rest.domain.response.simple.AreaSimple;
import com.haoxuer.discover.area.rest.conver.AreaSimpleConver;
import com.haoxuer.discover.data.page.Filter;
import com.haoxuer.discover.data.page.Order;
import java.util.ArrayList;
import java.util.List;
import com.haoxuer.discover.user.utils.ConverResourceUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Scope("prototype")
@Transactional
@Component
public class AreaResource implements AreaHandler {
@Autowired
AreaDao areaDao;
@Override
public AreaList list(AreaListRequest request) {
AreaList result = new AreaList();
List orders = new ArrayList();
orders.add(Order.asc("lft"));
List filters = new ArrayList();
filters.add(Filter.eq("parent.id", request.getId()));
List areas = areaDao.list(0, request.getSize(), filters, orders);
List simples = ConverResourceUtils.coverList(areas, new AreaSimpleConver());
result.setList(simples);
return result;
}
@Override
public AreaList list(AreaCodeRequest request) {
AreaList result = new AreaList();
List orders = new ArrayList();
orders.add(Order.asc("lft"));
List filters = new ArrayList();
filters.add(Filter.eq("parent.code", request.getCode()));
List areas = areaDao.list(0, request.getSize(), filters, orders);
List simples = ConverResourceUtils.coverList(areas, new AreaSimpleConver());
result.setList(simples);
return result;
}
@Override
public AreaList level(AreaLevelRequest request) {
AreaList result = new AreaList();
List orders = new ArrayList();
orders.add(Order.asc("lft"));
List filters = new ArrayList();
filters.add(Filter.eq("levelInfo", request.getLevel()));
List areas = areaDao.list(0, request.getSize(), filters, orders);
List simples = ConverResourceUtils.coverList(areas, new AreaSimpleConver());
result.setList(simples);
return result;
}
@Override
public AreaDataList id(AreaListRequest request) {
AreaDataList result = new AreaDataList();
List orders = new ArrayList();
orders.add(Order.asc("id"));
List filters = new ArrayList();
filters.add(Filter.eq("parent.id", request.getId()));
List areas = areaDao.list(0, request.getSize(), filters, orders);
List simples = ConverResourceUtils.coverList(areas, new AreaDataSimpleConver());
result.setList(simples);
return result;
}
@Override
public AreaDataList code(AreaCodeRequest request) {
AreaDataList result = new AreaDataList();
List orders = new ArrayList();
orders.add(Order.asc("lft"));
List filters = new ArrayList();
filters.add(Filter.eq("parent.code", request.getCode()));
List areas = areaDao.list(0, request.getSize(), filters, orders);
List simples = ConverResourceUtils.coverList(areas, new AreaDataSimpleConver());
result.setList(simples);
return result;
}
@Override
public AreaList type(AreaTypeRequest request) {
AreaList areaList = new AreaList();
List orders = new ArrayList();
orders.add(Order.asc("id"));
List filters = new ArrayList();
filters.add(Filter.eq("type", request.getType()));
List areas = areaDao.list(0, 10000, filters, orders);
List simples = ConverResourceUtils.coverList(areas, new AreaSimpleConver());
areaList.setList(simples);
return areaList;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy