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

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

import javax.validation.Valid;


/**
 * (ZccmClassConfigSponsor)表控制层
 *
 * @author java
 * @since 2021-05-28 14:11:29
 */

@RestController
@RequestMapping("/api/back/classConfigSponsor")
public class BackClassConfigSponsorController {

    /**
     * 服务对象
     */
    private final ZccmClassConfigSponsorService classConfigSponsorService;

    public BackClassConfigSponsorController(ZccmClassConfigSponsorService classConfigSponsorService) {
        this.classConfigSponsorService = classConfigSponsorService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 ZccmClassConfigSponsor", response = Result.class)
    public Result addZccmClassConfigSponsor(@Valid @RequestBody ZccmClassConfigSponsor classConfigSponsor) {
        return Result.success(classConfigSponsorService.insert(classConfigSponsor));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 ZccmClassConfigSponsor", response = Result.class)
    public Result updateZccmClassConfigSponsor(@RequestBody ZccmClassConfigSponsor classConfigSponsor) {
        return Result.success(classConfigSponsorService.update(classConfigSponsor));
    }

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

    @GetMapping("/list")
    @ApiOperation(value = "获取 ZccmClassConfigSponsor列表(分页)", response = Result.class)
    public Result listZccmClassConfigSponsor(@RequestParam(defaultValue = "0") Integer page,
                                         @RequestParam(defaultValue = "0") Integer size,
                                         @RequestParam(required = false) Integer classId) {
        return Result.success(classConfigSponsorService.queryAllByLimit(page, size, classId));
    }


}
