package com.ruoyi.ibs.list.controller;

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

import com.ruoyi.ibs.list.domain.SocialSecurity;
import com.ruoyi.ibs.list.service.ISocialSecurityService;
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.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 个人视图社保信息Controller
 * 
 * @author ruoyi
 * @date 2024-12-17
 */
@RestController
@RequestMapping("/system/security")
public class SocialSecurityController extends BaseController
{
    @Autowired
    private ISocialSecurityService socialSecurityService;

    /**
     * 查询个人视图社保信息列表
     */
    //@PreAuthorize("@ss.hasPermi('system:security:list')")
    @GetMapping("/list")
    @ApiOperation("查询个人社保信息")
    @Log(title = "客户视图-查询个人社保信息", businessType = BusinessType.EXPORT)
    public TableDataInfo list(SocialSecurity socialSecurity)
    {
        startPage();
        List<SocialSecurity> list = socialSecurityService.selectSocialSecurityList(socialSecurity);
        return getDataTable(list);
    }

    /**
     * 导出个人视图社保信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:security:export')")
    @Log(title = "客户视图-个人视图社保信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SocialSecurity socialSecurity)
    {
        List<SocialSecurity> list = socialSecurityService.selectSocialSecurityList(socialSecurity);
        ExcelUtil<SocialSecurity> util = new ExcelUtil<SocialSecurity>(SocialSecurity.class);
        util.exportExcel(response, list, "个人视图社保信息数据");
    }

    /**
     * 获取个人视图社保信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:security:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(socialSecurityService.selectSocialSecurityById(id));
    }

    /**
     * 新增个人视图社保信息
     */
    @PreAuthorize("@ss.hasPermi('system:security:add')")
    @Log(title = "客户视图-个人视图社保信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SocialSecurity socialSecurity)
    {
        return toAjax(socialSecurityService.insertSocialSecurity(socialSecurity));
    }

    /**
     * 修改个人视图社保信息
     */
    @PreAuthorize("@ss.hasPermi('system:security:edit')")
    @Log(title = "客户视图-个人视图社保信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SocialSecurity socialSecurity)
    {
        return toAjax(socialSecurityService.updateSocialSecurity(socialSecurity));
    }

    /**
     * 删除个人视图社保信息
     */
    @PreAuthorize("@ss.hasPermi('system:security:remove')")
    @Log(title = "客户视图-个人视图社保信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(socialSecurityService.deleteSocialSecurityByIds(ids));
    }
}
