package com.liquidnet.service.sweet.controller;


import com.github.pagehelper.PageInfo;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.sweet.dto.SweetManualDto;
import com.liquidnet.service.sweet.service.ISweetManualService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 电子宣传手册表 前端控制器
 * </p>
 *
 * @author liquidnet
 * @since 2021-07-23
 */
@Api(tags = "电子手册")
@RestController
@RequestMapping("/sweet-manual")
public class SweetManualController {

    @Autowired
    private ISweetManualService sweetManualService;

    @GetMapping("list")
    @ApiOperation("宣传手册列表")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "query", dataType = "Integer", name = "page", value = "页数", required = true),
            @ApiImplicitParam(type = "query", dataType = "Integer", name = "size", value = "数量", required = true),
            @ApiImplicitParam(type = "query", dataType = "String", name = "name", value = "姓名", required = false),
    })
    public ResponseDto<PageInfo<SweetManualDto>> getList(@RequestParam() Integer page,
                                                         @RequestParam() Integer size,
                                                         @RequestParam(required = false) String name) {
        return sweetManualService.getManualList(page, size, name);
    }


    @GetMapping("details")
    @ApiOperation("宣传手册详情")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "query", dataType = "String", name = "manualId", value = "手册id"),
    })
    public ResponseDto<SweetManualDto> details(@RequestParam(required = false) String manualId) {
        return sweetManualService.details(manualId);
    }

    @PostMapping("changeRelease")
    @ApiOperation("修改是否发布")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "query", dataType = "Integer", name = "page", value = "页数", required = true),
            @ApiImplicitParam(type = "query", dataType = "Integer", name = "size", value = "数量", required = true),
    })
    public ResponseDto<Boolean> changeRelease(@RequestParam() String manualId,
                                              @RequestParam() Integer isRelease) {
        return sweetManualService.changeRelease(manualId, isRelease);
    }

    @PostMapping("changeStatus")
    @ApiOperation("修改是否开启")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "query", dataType = "String", name = "manualId", value = "电子手册id", required = true),
            @ApiImplicitParam(type = "query", dataType = "String", name = "performancesId", value = "演出id", required = true),
            @ApiImplicitParam(type = "query", dataType = "Integer", name = "status", value = "开启状态", required = true),
    })
    public ResponseDto<Boolean> changeStatus(@RequestParam() String manualId,
                                             @RequestParam() String performancesId,
                                             @RequestParam() Integer status) {
        return sweetManualService.changeStatus(manualId, performancesId, status);
    }


    @PostMapping("changeReleaseManual")
    @ApiOperation("修改是否发布手册")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "query", dataType = "String", name = "manualId", value = "电子手册id", required = true),
            @ApiImplicitParam(type = "query", dataType = "Integer", name = "isReleaseManual", value = "是否发布手册", required = true),
    })
    public ResponseDto<Boolean> changeReleaseManual(@RequestParam(value = "manualId") String manualId,
                                                    @RequestParam(value = "isReleaseManual") Integer isReleaseManual) {
        return sweetManualService.changeReleaseManual(manualId, isReleaseManual);
    }

}
