package com.bocloud.ims.booter.controller.resource.topology;

import com.bocloud.common.model.BocloudResult;
import com.bocloud.common.utils.ResultTools;
import com.bocloud.ims.interfaces.topology.PropertyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 模型属性controller
 *
 * @author lyy
 * @Version 1.0
 * @since 2017年10月16日
 */
@Api(value = "属性", tags = "属性")
@RestController
@RequestMapping("/v1/properties")
public class PropertyController {

    @Autowired
    private PropertyService propertyService;

    /**
     * 根据code查询明细
     *
     * @param code
     * @return
     */
    @ApiOperation(tags = {"CMC"}, value = "查看CI属性详情", httpMethod = "GET")
    @GetMapping
    public BocloudResult queryByCode(@RequestParam(value = "code", required = true) String code) {
        if (null != code) {
            return propertyService.detail(null, code);
        } else {
            return ResultTools.formatErrResult();
        }
    }
}
