/*
 *    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.admin.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qunzhixinxi.hnqz.admin.entity.WmRelation;
import com.qunzhixinxi.hnqz.admin.service.WmRelationService;
import com.qunzhixinxi.hnqz.common.core.util.R;
import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * CSO关系表
 *
 * @author pigx code generator
 * @date 2021-01-05 14:49:04
 */
@RestController
@AllArgsConstructor
@RequestMapping("/wmrelation" )
@Api(value = "wmrelation", tags = "CSO关系表管理")
public class WmRelationController {

    private final WmRelationService wmRelationService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param wmRelation CSO关系表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public R getWmRelationPage(Page page, WmRelation wmRelation) {
        return R.ok(wmRelationService.page(page, Wrappers.query(wmRelation)));
    }


    /**
     * 通过id查询CSO关系表
     * @param upId id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{upId}" )
    public R getById(@PathVariable("upId" ) Integer upId) {
        return R.ok(wmRelationService.getById(upId));
    }

    /**
     * 新增CSO关系表
     * @param wmRelation CSO关系表
     * @return R
     */
    @ApiOperation(value = "新增CSO关系表", notes = "新增CSO关系表")
    @SysLog("新增CSO关系表" )
    @PostMapping
    public R save(@RequestBody WmRelation wmRelation) {
        return R.ok(wmRelationService.save(wmRelation));
    }

    /**
     * 修改CSO关系表
     * @param wmRelation CSO关系表
     * @return R
     */
    @ApiOperation(value = "修改CSO关系表", notes = "修改CSO关系表")
    @SysLog("修改CSO关系表" )
    @PutMapping
    public R updateById(@RequestBody WmRelation wmRelation) {
        return R.ok(wmRelationService.updateById(wmRelation));
    }

    /**
     * 通过id删除CSO关系表
     * @param upId id
     * @return R
     */
    @ApiOperation(value = "通过id删除CSO关系表", notes = "通过id删除CSO关系表")
    @SysLog("通过id删除CSO关系表" )
    @DeleteMapping("/{upId}" )
    public R removeById(@PathVariable Integer upId) {
        return R.ok(wmRelationService.removeById(upId));
    }

}
