package com.hc.web.controller.browser.back;

import com.hc.business.model.FloatWindow;
import com.hc.business.service.FloatWindowService;
import com.hc.core.utils.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 飘窗表(FloatWindow)表控制层
 *
 * @author makejava
 * @since 2023-04-13 08:54:39
 */

@RestController
@RequestMapping("/new/api/back/floatWindow")

public class BackFloatWindowController {

    /**
     * 服务对象
     */
    private final FloatWindowService floatWindowService;

    public BackFloatWindowController(FloatWindowService floatWindowService) {
        this.floatWindowService = floatWindowService;
    }


    @GetMapping("/{id}")
    @ApiOperation(value = "依据主键获取 FloatWindow", response = Result.class)
    public Result selectDetail(@PathVariable("id") Integer id) {
        return Result.success(this.floatWindowService.queryById(id));
    }

    @PostMapping("/insert")
    @ApiOperation(value = "新增附件", response = Result.class)
    public Result addFloatWindow(@Valid @RequestBody FloatWindow floatWindow) {
        return Result.success(floatWindowService.insert(floatWindow));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 FloatWindow", response = Result.class)
    public Result updateFloatWindow(@RequestBody FloatWindow floatWindow) {
        return Result.success(floatWindowService.update(floatWindow));
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "依据主键删除 FloatWindow", response = Result.class)
    public Result deleteFloatWindow(@PathVariable("id") Integer id) {
        return Result.success(floatWindowService.deleteById(id));
    }


    @GetMapping("/list")
    @ApiOperation(value = "获取 FloatWindow列表(分页)", response = Result.class)
    public Result listFloatWindow(@RequestParam(defaultValue = "0") Integer page,
                                  @RequestParam(defaultValue = "0") Integer size) {
        return Result.success(floatWindowService.queryAllByLimit(page, size));
    }


}
