package com.ruoyi.ibs.list.controller;

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

import com.ruoyi.ibs.list.domain.FamilyMembers;
import com.ruoyi.ibs.list.service.IFamilyMembersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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-11-01
 */
@RestController
@RequestMapping("/system/family/members")
@Api("360视图-家庭成员")
public class FamilyMembersController extends BaseController
{
    @Autowired
    private IFamilyMembersService familyMembersService;

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

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

    /**
     * 获取家庭成员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:members:query')")
    @Log(title = "客户视图-获取家庭成员信息详细信息", businessType = BusinessType.EXPORT)
    @GetMapping(value = "/{custIsn}")
    public AjaxResult getInfo(@PathVariable("custIsn") String custIsn)
    {
        return success(familyMembersService.selectFamilyMembersByCustIsn(custIsn));
    }

    /**
     * 新增家庭成员信息
     */
    //@PreAuthorize("@ss.hasPermi('system:members:add')")
    @Log(title = "客户视图-家庭成员信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增家庭成员信息")
    public AjaxResult add(FamilyMembers familyMembers)
    {
        return familyMembersService.insertFamilyMembers(familyMembers);
    }

    /**
     * 修改家庭成员信息
     */
    //@PreAuthorize("@ss.hasPermi('system:members:edit')")
    @Log(title = "客户视图-家庭成员信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    @ApiOperation("编辑家庭成员信息")
    public AjaxResult edit(FamilyMembers familyMembers)
    {
        return toAjax(familyMembersService.updateFamilyMembers(familyMembers));
    }

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