/*
 *    Copyright (c) 2018-2025, hnqz All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: hnqz
 */

package com.qunzhixinxi.hnqz.daemon.quartz.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qunzhixinxi.hnqz.common.core.util.R;
import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
import com.qunzhixinxi.hnqz.daemon.quartz.entity.WmWkArticle;
import com.qunzhixinxi.hnqz.daemon.quartz.service.WmWkArticleService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 文库-文章
 *
 * @author pigx code generator
 * @date 2020-08-03 19:27:31
 */
@RestController
@AllArgsConstructor
@RequestMapping("/wmwkarticle" )
@Api(value = "wmwkarticle", tags = "文库-文章管理")
public class WmWkArticleController {

    private final  WmWkArticleService wmWkArticleService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param wmWkArticle 文库-文章
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('quartz_wmwkarticle_view')" )
    public R getWmWkArticlePage(Page page, WmWkArticle wmWkArticle) {
        return R.ok(wmWkArticleService.page(page, Wrappers.query(wmWkArticle)));
    }


    /**
     * 通过id查询文库-文章
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('quartz_wmwkarticle_view')" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(wmWkArticleService.getById(id));
    }

    /**
     * 新增文库-文章
     * @param wmWkArticle 文库-文章
     * @return R
     */
    @ApiOperation(value = "新增文库-文章", notes = "新增文库-文章")
    @SysLog("新增文库-文章" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('quartz_wmwkarticle_add')" )
    public R save(@RequestBody WmWkArticle wmWkArticle) {
        return R.ok(wmWkArticleService.save(wmWkArticle));
    }

    /**
     * 修改文库-文章
     * @param wmWkArticle 文库-文章
     * @return R
     */
    @ApiOperation(value = "修改文库-文章", notes = "修改文库-文章")
    @SysLog("修改文库-文章" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('quartz_wmwkarticle_edit')" )
    public R updateById(@RequestBody WmWkArticle wmWkArticle) {
        return R.ok(wmWkArticleService.updateById(wmWkArticle));
    }

    /**
     * 通过id删除文库-文章
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除文库-文章", notes = "通过id删除文库-文章")
    @SysLog("通过id删除文库-文章" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('quartz_wmwkarticle_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(wmWkArticleService.removeById(id));
    }

}
