package com.ruoyi.web.controller.conference;


import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.conference.ZxConference;
import com.ruoyi.system.domain.conference.ZxConferenceUser;
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.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.service.IZxConferenceService;
import com.ruoyi.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 政协会议活动Controller
 *
 * @author boman
 * @date 2024-03-06
 */
@RestController
@RequestMapping("/zxConference/conference")
public class ZxConferenceController extends BaseController {
    @Autowired
    private IZxConferenceService zxConferenceService;

    /**
     * 查询政协会议活动列表
     */
    @PreAuthorize("@ss.hasPermi('zxConference:conference:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZxConference zxConference) {
        startPage();
        List<ZxConference> list = zxConferenceService.selectZxConferenceList(zxConference);
        return getDataTable(list);
    }

    /**
     * 查询政协会议活动列表
     */
    @PreAuthorize("@ss.hasPermi('zxConference:conference:listNoPage')")
    @GetMapping("/listNoPage")
    public TableDataInfo listNoPage(ZxConference zxConference) {
        List<ZxConference> list = zxConferenceService.selectZxConferenceList(zxConference);
        return getDataTable(list);
    }

    /**
     * 导出政协会议活动列表
     */
    @PreAuthorize("@ss.hasPermi('zxConference:conference:export')")
    @Log(title = "政协会议活动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZxConference zxConference) {
        List<ZxConference> list = zxConferenceService.selectZxConferenceList(zxConference);
        ExcelUtil<ZxConference> util = new ExcelUtil<ZxConference>(ZxConference.class);
        util.exportExcel(response, list, "政协会议活动数据");
    }

    /**
     * 获取政协会议活动详细信息
     */
    @PreAuthorize("@ss.hasPermi('zxConference:conference:query')")
    @GetMapping(value = "/{conferenceId}")
    public AjaxResult getInfo(@PathVariable("conferenceId") Long conferenceId) {
        return success(zxConferenceService.selectZxConferenceByConferenceId(conferenceId));
    }

    /**
     * 获取政协会议活动人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('zxConference:conference:getUserInfo')")
    @PostMapping(value = "/getUserInfo")
    public TableDataInfo getUserInfo(@RequestBody ZxConferenceUser zxConferenceUser) {
        return getDataTable(zxConferenceService.selectZxConferenceUser(zxConferenceUser));
    }

    /**
     * 修改会议答复信息
     */
    @PreAuthorize("@ss.hasPermi('zxConference:conference:updateReply')")
    @PostMapping(value = "/updateReply")
    public AjaxResult updateReply(@RequestBody ZxConferenceUser zxConferenceUser) {
        return success(zxConferenceService.updateReply(zxConferenceUser));
    }

    /**
     * 新增政协会议活动
     */
    @PreAuthorize("@ss.hasPermi('zxConference:conference:add')")
    @Log(title = "政协会议活动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZxConference zxConference) {
        return toAjax(zxConferenceService.insertZxConference(zxConference));
    }

    /**
     * 修改政协会议活动
     */
    @PreAuthorize("@ss.hasPermi('zxConference:conference:edit')")
    @Log(title = "政协会议活动", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody ZxConference zxConference) {
        return toAjax(zxConferenceService.updateZxConference(zxConference));
    }

    /**
     * 删除政协会议活动
     */
    @PreAuthorize("@ss.hasPermi('zxConference:conference:remove')")
    @Log(title = "政协会议活动", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{conferenceIds}")
    public AjaxResult remove(@PathVariable Long[] conferenceIds) {
        return toAjax(zxConferenceService.deleteZxConferenceByConferenceIds(conferenceIds));
    }
}
