package com.ruoyi.web.controller.activity;


import javax.servlet.http.HttpServletResponse;

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

import java.util.List;

/**
 * 政协活动Controller
 *
 * @author boman
 * @date 2024-03-14
 */
@RestController
@RequestMapping("/zxActivity/activity")
public class ZxActivityController extends BaseController {
    @Autowired
    private IZxActivityService zxActivityService;

    /**
     * 查询政协活动列表
     */
    @PreAuthorize("@ss.hasPermi('zxActivity:activity:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZxActivity zxActivity) {
        startPage();
        List<ZxActivity> list = zxActivityService.selectZxActivityList(zxActivity);
        return getDataTable(list);
    }

    /**
     * 查询政协活动列表不分页
     */
    @PreAuthorize("@ss.hasPermi('zxActivity:activity:listNoPage')")
    @GetMapping("/listNoPage")
    public TableDataInfo listNoPage(ZxActivity zxActivity) {
        List<ZxActivity> list = zxActivityService.selectZxActivityList(zxActivity);
        return getDataTable(list);
    }

    /**
     * 导出政协活动列表
     */
    @PreAuthorize("@ss.hasPermi('zxActivity:activity:export')")
    @Log(title = "政协活动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZxActivity zxActivity) {
        List<ZxActivity> list = zxActivityService.selectZxActivityList(zxActivity);
        ExcelUtil<ZxActivity> util = new ExcelUtil<ZxActivity>(ZxActivity.class);
        util.exportExcel(response, list, "政协活动数据");
    }

    /**
     * 获取政协活动详细信息
     */
    @PreAuthorize("@ss.hasPermi('zxActivity:activity:query')")
    @GetMapping(value = "/{activityId}")
    public AjaxResult getInfo(@PathVariable("activityId") Long activityId) {
        return success(zxActivityService.selectZxActivityByActivityId(activityId));
    }

    /**
     * 获取政协活动人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('zxActivity:activity:getUserInfo')")
    @PostMapping(value = "/getUserInfo")
    public TableDataInfo getUserInfo(@RequestBody ZxActivityUser zxActivityUser) {
        return getDataTable(zxActivityService.selectZxActivityUser(zxActivityUser));
    }

    /**
     * 新增政协活动
     */
    @PreAuthorize("@ss.hasPermi('zxActivity:activity:add')")
    @Log(title = "政协活动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZxActivity zxActivity) {
        return toAjax(zxActivityService.insertZxActivity(zxActivity));
    }

    /**
     * 修改活动答复信息
     */
    @PreAuthorize("@ss.hasPermi('zxActivity:activity:updateReply')")
    @PostMapping(value = "/updateReply")
    public AjaxResult updateReply(@RequestBody ZxActivityUser zxActivityUser) {
        return success(zxActivityService.updateReply(zxActivityUser));
    }
    /**
     * 修改政协活动
     */
    @PreAuthorize("@ss.hasPermi('zxActivity:activity:edit')")
    @Log(title = "政协活动", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody ZxActivity zxActivity) {
        return toAjax(zxActivityService.updateZxActivity(zxActivity));
    }

    /**
     * 删除政协活动
     */
    @PreAuthorize("@ss.hasPermi('zxActivity:activity:remove')")
    @Log(title = "政协活动", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{activityIds}")
    public AjaxResult remove(@PathVariable Long[] activityIds) {
        return toAjax(zxActivityService.deleteZxActivityByActivityIds(activityIds));
    }
}
