package com.community.huiju.controller;

import com.community.commom.mode.ResponseBean;
import com.community.huiju.model.ToCommunities;
import com.community.huiju.service.CommunityServiceI;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author FXF
 * @date 2018-10-22
 */
@RestController
@RefreshScope
@RequestMapping("/")
@Api(value = "小区相关的API",description = "小区相关的API")
public class CommunityController {
	
	@Autowired
	private CommunityServiceI communityService;
	
	@ApiOperation(value = "根据小区名获取小区列表", notes = "根据小区名获取小区列表")
	@ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType = "String", name = "communityName", value = "小区名字") })
	@RequestMapping(value = "/communitys",method = RequestMethod.GET)
	public ResponseBean getCommunitys(@RequestParam(required = false) String communityName){
		ResponseBean responseBean = new ResponseBean();
		List<ToCommunities> communitiesList = communityService.getCommunitys(communityName);
		responseBean.addSuccess(communitiesList);
		return responseBean;
	}
}
