package com.app.controller.platform;

import com.app.dto.Result;
import com.app.entity.platform.system.Address;
import com.app.service.platform.AddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;

/**
 * 功能描述：
 *
 * @Auther: 梁展鹏
 * @Date: 2018/7/24 11:38
 */
@Api(tags = "地址管理")
@Slf4j
@RestController("PlatformAddressController")
@RequestMapping("/platform/address")
public class AddressController {

    @Autowired
    private AddressService addressService;

    @ApiOperation(value = "查询[地址名称]底下的地址信息")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "name", value = "地址名称", dataType = "String", paramType = "path", required = true, defaultValue = "广州市")
    )
    @GetMapping("/{name}/child")
    public ResponseEntity<Result<Address>> addressFindNextLevel(@NotBlank @PathVariable("name") String name) {
        return new ResponseEntity(new Result().ok(addressService.findNextLevel(name)), HttpStatus.OK);
    }

}
