package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LcdInfoUserRelation;
import com.ruoyi.system.service.ILcdInfoUserRelationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 消息-用户-中间表信息Controller
 *
 * @author ruoyi
 * @date 2023-01-16
 */
@Api(tags = "LcdInfoUserRelationController",description = "消息-用户-中间表")
@RestController
@RequestMapping("/system/relation")
public class LcdInfoUserRelationController extends BaseController
{
    @Autowired
    private ILcdInfoUserRelationService lcdInfoUserRelationService;

    /**
     * 查询消息-用户-中间表信息列表
     */
    @ApiOperation("查询")
    @PreAuthorize("@ss.hasPermi('system:relation:list')")
    @GetMapping("/list")
    public TableDataInfo list(LcdInfoUserRelation lcdInfoUserRelation)
    {
        startPage();
        List<LcdInfoUserRelation> list = lcdInfoUserRelationService.selectLcdInfoUserRelationList(lcdInfoUserRelation);
        return getDataTable(list);
    }

    /**
     * 导出消息-用户-中间表信息列表
     */
    @ApiOperation("导出")
    @PreAuthorize("@ss.hasPermi('system:relation:export')")
    @Log(title = "消息-用户-中间表信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LcdInfoUserRelation lcdInfoUserRelation)
    {
        List<LcdInfoUserRelation> list = lcdInfoUserRelationService.selectLcdInfoUserRelationList(lcdInfoUserRelation);
        ExcelUtil<LcdInfoUserRelation> util = new ExcelUtil<LcdInfoUserRelation>(LcdInfoUserRelation.class);
        util.exportExcel(response, list, "消息-用户-中间表信息数据");
    }

    /**
     * 获取消息-用户-中间表信息详细信息
     */
    @ApiOperation("获取")
    @PreAuthorize("@ss.hasPermi('system:relation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(lcdInfoUserRelationService.selectLcdInfoUserRelationById(id));
    }

    /**
     * 新增消息-用户-中间表信息
     */
    @ApiOperation("新增")
    @PreAuthorize("@ss.hasPermi('system:relation:add')")
    @Log(title = "消息-用户-中间表信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LcdInfoUserRelation lcdInfoUserRelation)
    {
        return toAjax(lcdInfoUserRelationService.insertLcdInfoUserRelation(lcdInfoUserRelation));
    }

    /**
     * 修改消息-用户-中间表信息
     */
    @ApiOperation("修改")
    @PreAuthorize("@ss.hasPermi('system:relation:edit')")
    @Log(title = "消息-用户-中间表信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LcdInfoUserRelation lcdInfoUserRelation)
    {
        return toAjax(lcdInfoUserRelationService.updateLcdInfoUserRelation(lcdInfoUserRelation));
    }

    /**
     * 删除消息-用户-中间表信息
     */
    @ApiOperation("删除")
    @PreAuthorize("@ss.hasPermi('system:relation:remove')")
    @Log(title = "消息-用户-中间表信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lcdInfoUserRelationService.deleteLcdInfoUserRelationByIds(ids));
    }
}
