You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.1 KiB

3 years ago
package com.fr.plugin.web.hander.ytconfig;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.plugin.beans.MyYituanBean;
import com.fr.plugin.beans.MyYituanBean;
import com.fr.plugin.entitys.YTYiTuanEntity;
import com.fr.plugin.entitys.YTYiTuanEntity;
import com.fr.plugin.utils.MyUtils;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Iterator;
import java.util.List;
public class GetCompanyHandler extends BaseHttpHandler {
@Override
public RequestMethod getMethod() {
return RequestMethod.GET;
}
@Override
public String getPath() {
return "/yt/configList";
}
@Override
public boolean isPublic() {
return false;
}
@Override
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
int startIdx = WebUtils.getHTTPRequestIntParameter(httpServletRequest, "startIdx", -1);
int count = WebUtils.getHTTPRequestIntParameter(httpServletRequest, "count", -1);
List<YTYiTuanEntity> companys = MyUtils.getCompanysSortedByTimeStamp();
JSONArray lists = new JSONArray();
JSONObject var7 = MyUtils.createSuccessResponseJSONObject();
if (startIdx == -1 && count == -1) {
for (YTYiTuanEntity company : companys) {
lists.put(company.createBean(new MyYituanBean()).toJSONObject());
}
} else if (startIdx > -1 && count > -1) {
int var8 = Math.min(count + startIdx, companys.size());
for(int var9 = startIdx; var9 < var8; ++var9) {
YTYiTuanEntity var10 = (YTYiTuanEntity)companys.get(var9);
lists.put(var10.createBean(new MyYituanBean()).toJSONObject());
}
}
var7.put("total", companys.size());
var7.put("companys", lists);
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, var7);
}
}