package com.diagbot.web;


import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
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 com.baomidou.mybatisplus.core.metadata.IPage;
import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.DisclaimerInformationDTO;
import com.diagbot.dto.RespDTO;
import com.diagbot.facade.DisclaimerInformationFacade;
import com.diagbot.vo.DisclaimerInformationAllVO;
import com.diagbot.vo.DisclaimerInformationIdVO;
import com.diagbot.vo.DisclaimerInformationTitleVO;
import com.diagbot.vo.DisclaimerInformationVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;


/**
 * @author wangfeng
 * @Description: 免责申明详情 前端控制器
 * @date 2018年12月5日 下午3:44:22
 */
@RestController
@RequestMapping("/disclaimerInformation")
@Api(value = "免责申明详情API[by:wangfeng]", tags = { "WF——免责申明详情API" })
@SuppressWarnings("unchecked")
public class DisclaimerInformationController {

    @Autowired
    DisclaimerInformationFacade disclaimerInformationFacade;

    @ApiOperation(value = "分页查询获取免责申明[by:wangfeng]", notes = "分页查询获取免责申明")
    @PostMapping("/getDisclaimerInformations")
    @SysLogger("getDisclaimerInformations")
    @Transactional
    public RespDTO<IPage<DisclaimerInformationDTO>> getDisclaimerInformations(@RequestBody DisclaimerInformationTitleVO disclaimerInformationTitleVO) {

    	IPage<DisclaimerInformationDTO> data = disclaimerInformationFacade.getDisclaimerInformation(disclaimerInformationTitleVO, disclaimerInformationTitleVO.getTitle());

        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "增加免责申明详情[by:wangfeng]", notes = "增加免责申明详情")
    @PostMapping("/addDisclaimerInformations")
    @SysLogger("addDisclaimerInformations")
    @Transactional
    public RespDTO<Boolean> addDisclaimerInformations(@Valid @RequestBody DisclaimerInformationVO disclaimerInformationVO) {

        boolean res = disclaimerInformationFacade.addDisclaimerInformation(disclaimerInformationVO);

        return RespDTO.onSuc(res);
    }

    @ApiOperation(value = "修改免责申明详情[by:wangfeng]", notes = "修改免责申明详情")
    @PostMapping("/updateDisclaimerInformations")
    @SysLogger("updateDisclaimerInformations")
    @Transactional
    public RespDTO<Boolean> updateDisclaimerInformations(@Valid @RequestBody DisclaimerInformationAllVO disclaimerInformationAllVO) {

        boolean res = disclaimerInformationFacade.updateDisclaimerInformation(disclaimerInformationAllVO);

        return RespDTO.onSuc(res);
    }

    @ApiOperation(value = "删除免责申明详情[by:wangfeng]", notes = "删除免责申明详情")
    @PostMapping("/cancelDisclaimerInformations")
    @SysLogger("cancelDisclaimerInformations")
    @Transactional
    public RespDTO<Boolean> cancelDisclaimerInformations(@Valid @RequestBody DisclaimerInformationIdVO disclaimerInformationIdVO) {

        boolean res = disclaimerInformationFacade.cancelDisclaimerInformation(disclaimerInformationIdVO);

        return RespDTO.onSuc(res);
    }

    @ApiOperation(value = "启用免责申明详情[by:wangfeng]", notes = "启用免责申明详情")
    @PostMapping("/startDisclaimerInformations")
    @SysLogger("startDisclaimerInformations")
    @Transactional
    public RespDTO<Boolean> startDisclaimerInformations(@Valid @RequestBody DisclaimerInformationIdVO disclaimerInformationIdVO) {

        boolean res = disclaimerInformationFacade.startDisclaimerInformations(disclaimerInformationIdVO);

        return RespDTO.onSuc(res);
    }

    @ApiOperation(value = "停用免责申明详情[by:wangfeng]", notes = "停用免责申明详情")
    @PostMapping("/endDisclaimerInformations")
    @SysLogger("endDisclaimerInformations")
    @Transactional
    public RespDTO<Boolean> endDisclaimerInformations(@Valid @RequestBody DisclaimerInformationIdVO disclaimerInformationEndVO) {

        boolean res = disclaimerInformationFacade.endDisclaimerInformations(disclaimerInformationEndVO);

        return RespDTO.onSuc(res);
    }
}
