package com.huiju.estateagents.property.controller;


import com.alibaba.fastjson.JSONObject;
import com.huiju.estateagents.base.BaseController;
import com.huiju.estateagents.base.ResponseBean;
import com.huiju.estateagents.property.service.IUserService;
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.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 所有小区表 前端控制器
 * </p>
 *
 * @author weiximei
 * @since 2018-12-19
 */
@RestController

@RequestMapping("/")
@Api(value = "小区Api", description = "小区Api")
public class CommunitiesController extends BaseController {

    @Autowired
    private IUserService iUserService;

    @ApiOperation(value = "根据手机号 和 验证码 获取小区列表", notes = "根据手机号 和 验证码 获取小区列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter", value = "loginName手机号;code验证码")
    })
    @RequestMapping(value = "/community/user", method = RequestMethod.POST)
    public ResponseBean userCommunity(@RequestBody String parameter){
        ResponseBean responseBean = new ResponseBean();

        JSONObject jsonObject = JSONObject.parseObject(parameter);
        responseBean = iUserService.userCommunity(jsonObject.getString("loginName"), jsonObject.getString("code"));
        return responseBean;
    }

}
