package com.liquidnet.service.sweet.controller;


import com.github.pagehelper.PageInfo;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.sweet.entity.SweetArtists;
import com.liquidnet.service.sweet.entity.SweetManualNotify;
import com.liquidnet.service.sweet.service.ISweetArtistsService;
import com.liquidnet.service.sweet.service.ISweetManualNotifyService;
import com.sun.org.apache.xpath.internal.operations.Bool;
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-notify")
public class SweetManualNotifyController {

    @Autowired
    ISweetManualNotifyService sweetManualNotifyService;

    @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 = "通知标题 不查询从传递null", required = false),
            @ApiImplicitParam(type = "query", dataType = "String", name = "manualId", value = "手册id", required = true),
    })
    public ResponseDto<PageInfo<SweetManualNotify>> getList(@RequestParam(defaultValue = "1") Integer page,
                                                            @RequestParam(defaultValue = "10") Integer size,
                                                            @RequestParam(defaultValue = "标题", required = false) String name,
                                                            @RequestParam(defaultValue = "手册id") String manualId) {
        return sweetManualNotifyService.getList(page, size, name, manualId);
    }

    @PostMapping("add")
    @ApiOperation("添加通知")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "query", dataType = "String", name = "manualId", value = "手册id", required = true),
            @ApiImplicitParam(type = "query", dataType = "String", name = "title", value = "标题", required = true),
            @ApiImplicitParam(type = "query", dataType = "String", name = "content", value = "内容", required = true),
    })
    public ResponseDto<Boolean> add(@RequestParam(defaultValue = "") String manualId,
                                    @RequestParam(defaultValue = "标题") String title,
                                    @RequestParam(defaultValue = "内容") String content) {
        return sweetManualNotifyService.add(manualId, title, content);
    }

    @GetMapping("detail")
    @ApiOperation("通知详情")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "query", dataType = "String", name = "manualId", value = "手册id", required = true),
    })
    public ResponseDto<SweetManualNotify> detail(@RequestParam(defaultValue = "1") String manualId) {
        return sweetManualNotifyService.details(manualId);
    }

    @PostMapping("change")
    @ApiOperation("修改通知")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "query", dataType = "String", name = "manualId", value = "手册id", required = true),
            @ApiImplicitParam(type = "query", dataType = "String", name = "manualNotifyId", value = "通知id", required = true),
            @ApiImplicitParam(type = "query", dataType = "String", name = "title", value = "标题", required = true),
            @ApiImplicitParam(type = "query", dataType = "String", name = "content", value = "内容", required = true),
    })
    public ResponseDto<Boolean> change(@RequestParam(defaultValue = "") String manualId,
                                       @RequestParam(defaultValue = "") String manualNotifyId,
                                       @RequestParam(defaultValue = "标题") String title,
                                       @RequestParam(defaultValue = "内容") String content) {
        return sweetManualNotifyService.change(manualId, manualNotifyId, title, content);
    }

    @DeleteMapping("delete")
    @ApiOperation("删除通知")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "query", dataType = "String", name = "manualNotifyId", value = "手册通知id", required = true),
    })
    public ResponseDto<Boolean> delete(@RequestParam(defaultValue = "1") String manualNotifyId) {
        return sweetManualNotifyService.delete(manualNotifyId);
    }
}
