package com.jiayue.ipp.idp.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiayue.ipp.common.data.entity.InitJobClass;
import com.jiayue.ipp.idp.service.InitJobClassService;
import com.jiayue.ipp.idp.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


/**
 * idp_init_job_class
 *
 * @author whc
 * @date 2022-03-18 15:49:03
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/initjobclass")
@Api(value = "initjobclass", tags = "idp_init_job_class管理")
public class InitJobClassController {

    private final InitJobClassService initJobClassService;

    /**
     * 分页查询
     *
     * @param page         分页对象
     * @param initJobClass idp_init_job_class
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    //@PreAuthorize("@pms.hasPermission('idp_initjobclass_get')")
    public R getInitJobClassPage(Page page, InitJobClass initJobClass) {
        return R.ok(initJobClassService.page(page, Wrappers.query(initJobClass)));
    }

    /**
     * 通过id查询idp_init_job_class
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    //@PreAuthorize("@pms.hasPermission('idp_initjobclass_get')")
    public R getById(@PathVariable("id") String id) {
        return R.ok(initJobClassService.getById(id));
    }

    /**
     * 新增idp_init_job_class
     *
     * @param initJobClass idp_init_job_class
     * @return R
     */
    @ApiOperation(value = "新增idp_init_job_class", notes = "新增idp_init_job_class")
    //    // ("新增idp_init_job_class")
    @PostMapping
    //@PreAuthorize("@pms.hasPermission('idp_initjobclass_add')")
    public R save(@RequestBody InitJobClass initJobClass) {
        return R.ok(initJobClassService.save(initJobClass));
    }

    /**
     * 修改idp_init_job_class
     *
     * @param initJobClass idp_init_job_class
     * @return R
     */
    @ApiOperation(value = "修改idp_init_job_class", notes = "修改idp_init_job_class")
    //    // ("修改idp_init_job_class")
    @PutMapping
    //@PreAuthorize("@pms.hasPermission('idp_initjobclass_edit')")
    public R updateById(@RequestBody InitJobClass initJobClass) {
        return R.ok(initJobClassService.updateById(initJobClass));
    }

    /**
     * 通过id删除idp_init_job_class
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除idp_init_job_class", notes = "通过id删除idp_init_job_class")
    //    // ("通过id删除idp_init_job_class")
    @DeleteMapping("/{id}")
    //@PreAuthorize("@pms.hasPermission('idp_initjobclass_del')")
    public R removeById(@PathVariable String id) {
        return R.ok(initJobClassService.removeById(id));
    }

}
