package com.ruoyi.ibs.list.controller;

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

import com.ruoyi.ibs.list.domain.SignedProducts;
import com.ruoyi.ibs.list.service.ISignedProductsService;
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-07
 */
@RestController
@RequestMapping("/system/products")
public class SignedProductsController extends BaseController
{
    @Autowired
    private ISignedProductsService signedProductsService;

    /**
     * 查询个人签约产品列表
     */
    @PreAuthorize("@ss.hasPermi('system:products:list')")
    @GetMapping("/list")
    @Log(title = "客户视图-查询个人签约产品列表", businessType = BusinessType.EXPORT)
    public TableDataInfo list(SignedProducts signedProducts)
    {
        startPage();
        List<SignedProducts> list = signedProductsService.selectSignedProductsList(signedProducts);
        return getDataTable(list);
    }

    /**
     * 导出个人签约产品列表
     */
    @PreAuthorize("@ss.hasPermi('system:products:export')")
    @Log(title = "客户视图-个人签约产品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SignedProducts signedProducts)
    {
        List<SignedProducts> list = signedProductsService.selectSignedProductsList(signedProducts);
        ExcelUtil<SignedProducts> util = new ExcelUtil<SignedProducts>(SignedProducts.class);
        util.exportExcel(response, list, "个人签约产品数据");
    }

    /**
     * 获取个人签约产品详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:products:query')")
    @GetMapping(value = "/{currdeposFlag}")
    public AjaxResult getInfo(@PathVariable("currdeposFlag") String currdeposFlag)
    {
        return success(signedProductsService.selectSignedProductsByCurrdeposFlag(currdeposFlag));
    }

    /**
     * 新增个人签约产品
     */
    @PreAuthorize("@ss.hasPermi('system:products:add')")
    @Log(title = "客户视图-个人签约产品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SignedProducts signedProducts)
    {
        return toAjax(signedProductsService.insertSignedProducts(signedProducts));
    }

    /**
     * 修改个人签约产品
     */
    @PreAuthorize("@ss.hasPermi('system:products:edit')")
    @Log(title = "客户视图-个人签约产品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SignedProducts signedProducts)
    {
        return toAjax(signedProductsService.updateSignedProducts(signedProducts));
    }

    /**
     * 删除个人签约产品
     */
    @PreAuthorize("@ss.hasPermi('system:products:remove')")
    @Log(title = "客户视图-个人签约产品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{currdeposFlags}")
    public AjaxResult remove(@PathVariable String[] currdeposFlags)
    {
        return toAjax(signedProductsService.deleteSignedProductsByCurrdeposFlags(currdeposFlags));
    }
}
