package com.yihu.hos.standard.controller;

import com.yihu.hos.standard.service.standard.StdPublisherService;
import com.yihu.hos.web.framework.model.DictionaryResult;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.util.controller.BaseController;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by LLH on 2016/1/6.
 */
@RestController("PublisherController")
@RequestMapping("/standardCenter")
//@Api(protocols = "https", value = "PublisherController", description = "发布者管理", tags = {"发布者"})
public class PublisherController extends BaseController {

    @Resource(name = StdPublisherService.BEAN_ID)
    private StdPublisherService stdPublisherService;
    /**
     * 根据标准ID获取发布机构（get）
     * @param publisherId
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getForPublisherId")
    @ApiOperation(value = "获取发布机构", response = Result.class, produces = "application/json", notes = "获取发布机构")
    public Result get(
            @ApiParam(name = "publisherId", value = "机构ID")
            @RequestParam(value = "publisherId") String publisherId) {
        return stdPublisherService.get(publisherId);
    }

    @RequestMapping(value = "/getStandardPublisher")
    @ApiOperation(value = "获取发布机构", response = Result.class, produces = "application/json", notes = "获取发布机构")
    public Result getStandardPublisher(){
        return stdPublisherService.getStandardPublisher();
    }

    /**
     * 获取发布机构名称列表
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getPublishers")
    @ApiOperation(value = "获取发布机构列表", response = DictionaryResult.class, produces = "application/json", notes = "获取发布机构列表")
    public DictionaryResult getPublishers(
            @ApiParam(name = "condition", value = "Must be Json")
            @RequestParam(value = "condition", required = false) String condition,
            @ApiParam(name = "order", value = "Must be Json")
            @RequestParam(value = "order", required = false) String order,
            @ApiParam(name = "rows", value = "Limit the size of result set. Must be an integer")
            @RequestParam(value = "rows", required = false) Integer rows,
            @ApiParam(name = "page", value = "Start position of result set. Must be an integer")
            @RequestParam(value = "page", required = false) Integer page) {
        return stdPublisherService.getDictionaryResult(condition, order, rows, page);
    }
}
