package com.diagbot.web;

import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.GetModuleInfoOneDTO;
import com.diagbot.dto.RespDTO;
import com.diagbot.facade.QcModuleInfoFacade;
import com.diagbot.vo.GetModuleInfoOneVO;
import com.diagbot.vo.GetModuleMapVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 模型表 前端控制器
 * </p>
 *
 * @author zhoutg
 * @since 2020-04-27
 */
@RestController
@RequestMapping("/qc/module")
@SuppressWarnings("unchecked")
@Api(value = "模板相关API", tags = { "模板相关API" })
public class QcModuleInfoController {

    @Autowired
    QcModuleInfoFacade qcModuleInfoFacade;

    @ApiOperation(value = "根据id获取模板信息[by:zhoutg]",
            notes = "moduleId: 模板id<br>")
    @PostMapping("/getById")
    @SysLogger("getById")
    public RespDTO<GetModuleInfoOneDTO> getById(@RequestBody GetModuleInfoOneVO getModuleInfoVO) {
        GetModuleInfoOneDTO data = qcModuleInfoFacade.getByIdFac(getModuleInfoVO);
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "根据模块获取模板信息[by:zhoutg]",
            notes = "modeName: 模板名称<br>")
    @PostMapping("/getModuleMap")
    @SysLogger("getModuleMap")
    public RespDTO<Map<Long, GetModuleInfoOneDTO>> getModuleMap(@RequestBody GetModuleMapVO getModuleMapVO) {
        Map<Long, GetModuleInfoOneDTO> data = qcModuleInfoFacade.getModuleMap(getModuleMapVO);
        return RespDTO.onSuc(data);
    }
}
