package com.goafanti.portal.controller;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.goafanti.achievement.service.AchievementService;
import com.goafanti.common.bo.Result;
import com.goafanti.common.controller.BaseController;
import com.goafanti.demand.service.DemandService;
import com.goafanti.user.service.OrganizationIdentityService;
import com.goafanti.user.service.UserIdentityService;

@RestController
@RequestMapping(value = "/portal/search")
public class PortalSearchController extends BaseController {
	@Resource
	private AchievementService			achievementService;
	@Resource
	private DemandService				demandService;
	@Resource
	private UserIdentityService			userIdentityService;
	@Resource
	private OrganizationIdentityService	organizationIdentityService;

	/**
	 * 用户搜索
	 */
	@RequestMapping(value = "/subscriberList", method = RequestMethod.GET)
	public Result subscriberSearchList(HttpServletRequest req,String name, Integer level, Integer type, String field, Integer province,
			Integer city, Integer area,Integer international, String pageNo, String pageSize, Integer auditStatus) {
		Result res = new Result();
		String url=req.getServerName();
		url=url.substring(url.indexOf(".")+1, url.length());
		Integer pNo = 1;
		Integer pSize = 12;
		if (StringUtils.isNumeric(pageSize)) {
			pSize = Integer.parseInt(pageSize);
		}
		if (StringUtils.isNumeric(pageNo)) {
			pNo = Integer.parseInt(pageNo);
		}
		if(field!=null && field.length()<=0) {
			field=null;
		}
		if(province ==null || province.intValue()<=0)province=null;
			res.setData(userIdentityService.listSubscriber(url,name, level, field, province, city, area, international, pNo, pSize,auditStatus));
		return res;
	}
	
	
}
