package com.ruoyi.ibs.list.controller;

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

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

/**
 * 建档家庭成员信息Controller
 * 
 * @author ruoyi
 * @date 2024-12-20
 */
@RestController
@RequestMapping("/system/family/record")
@Api("建档家庭成员相关")
public class FamilyMembersRecordController extends BaseController
{
    @Autowired
    private IFamilyMembersRecordService familyMembersRecordService;

    /**
     * 查询建档家庭成员信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:record:list')")
    @Log(title = "客户视图-查询建档家庭成员信息列表", businessType = BusinessType.EXPORT)
    @GetMapping("/list")
    public TableDataInfo list(FamilyMembersRecord familyMembersRecord)
    {
        startPage();
        List<FamilyMembersRecord> list = familyMembersRecordService.selectFamilyMembersRecordList(familyMembersRecord);
        return getDataTable(list);
    }

    /**
     * 导出建档家庭成员信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:record:export')")
    @Log(title = "客户视图-导出建档家庭成员信息列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FamilyMembersRecord familyMembersRecord)
    {
        List<FamilyMembersRecord> list = familyMembersRecordService.selectFamilyMembersRecordList(familyMembersRecord);
        ExcelUtil<FamilyMembersRecord> util = new ExcelUtil<FamilyMembersRecord>(FamilyMembersRecord.class);
        util.exportExcel(response, list, "建档家庭成员信息数据");
    }

    /**
     * 获取建档家庭成员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:record:query')")
    @GetMapping(value = "/{custIdc}")
    public AjaxResult getInfo(@PathVariable("custIdc") String custIdc)
    {
        return success(familyMembersRecordService.selectFamilyMembersRecordByCustIdc(custIdc));
    }

    /**
     * 新增建档家庭成员信息
     */
    //@PreAuthorize("@ss.hasPermi('system:record:add')")
    @Log(title = "客户视图-新增建档家庭成员信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增建档家庭成员")
    public AjaxResult add(FamilyMembersRecord familyMembersRecord)
    {
        return toAjax(familyMembersRecordService.insertFamilyMembersRecord(familyMembersRecord));
    }

    /**
     * 修改建档家庭成员信息
     */
    //@PreAuthorize("@ss.hasPermi('system:record:edit')")
    @Log(title = "客户视图-修改建档家庭成员信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    @ApiOperation("建档家庭成员编辑")
    public AjaxResult edit(FamilyMembersRecord familyMembersRecord)
    {
        return toAjax(familyMembersRecordService.updateFamilyMembersRecord(familyMembersRecord));
    }

    /**
     * 删除建档家庭成员信息
     */
    @PreAuthorize("@ss.hasPermi('system:record:remove')")
    @Log(title = "客户视图-建档家庭成员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{custIdcs}")
    public AjaxResult remove(@PathVariable String[] custIdcs)
    {
        return toAjax(familyMembersRecordService.deleteFamilyMembersRecordByCustIdcs(custIdcs));
    }
}
