package com.limap.controller.manager;

import java.util.List;
import java.util.Arrays;
import javax.servlet.http.HttpServletResponse;
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.limap.common.log.annotation.Log;
import io.swagger.annotations.Api;
import com.limap.common.core.controller.BaseController;
import com.limap.common.core.domain.AjaxResult;
import com.limap.common.enums.BusinessType;
import io.swagger.annotations.ApiOperation;
import com.limap.core.basic.domain.BasicProfitSharing;
import com.limap.core.basic.service.IBasicProfitSharingService;
import com.limap.common.utils.poi.ExcelUtil;
import com.limap.common.core.page.TableDataInfo;

/**
 * 基础分润信息Controller
 *
 * @author jjb
 * @date 2025-04-11
 */
@Api(tags = "基础分润信息")
@RestController
@RequestMapping("/basic/profitSharing")
public class BasicProfitSharingController extends BaseController {
    @Autowired
    private IBasicProfitSharingService basicProfitSharingService;

    /**
     * 查询基础分润信息列表
     */
    @ApiOperation("查询基础分润信息列表")
    @PreAuthorize("@ss.hasPermi('basic:profitSharing:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicProfitSharing basicProfitSharing) {
        startPage();
        List<BasicProfitSharing> list = basicProfitSharingService.selectBasicProfitSharingList(basicProfitSharing);
        return getDataTable(list);
    }

    /**
     * 导出基础分润信息列表
     */
    @ApiOperation("导出基础分润信息列表")
    @PreAuthorize("@ss.hasPermi('basic:profitSharing:export')")
    @Log(title = "基础分润信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicProfitSharing basicProfitSharing) {
        List<BasicProfitSharing> list = basicProfitSharingService.selectBasicProfitSharingList(basicProfitSharing);
        ExcelUtil<BasicProfitSharing> util = new ExcelUtil<BasicProfitSharing>(BasicProfitSharing.class);
        util.exportExcel(response, list, "基础分润信息数据");
    }

    /**
     * 获取基础分润信息详细信息
     */
    @ApiOperation("获取基础分润信息详细信息")
    @PreAuthorize("@ss.hasPermi('basic:profitSharing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(basicProfitSharingService.getById(id));
    }

    /**
     * 新增基础分润信息
     */
    @ApiOperation("新增基础分润信息")
    @PreAuthorize("@ss.hasPermi('basic:profitSharing:add')")
    @Log(title = "基础分润信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicProfitSharing basicProfitSharing) {
        return toAjax(basicProfitSharingService.save(basicProfitSharing));
    }

    /**
     * 修改基础分润信息
     */
    @ApiOperation("修改基础分润信息")
    @PreAuthorize("@ss.hasPermi('basic:profitSharing:edit')")
    @Log(title = "基础分润信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicProfitSharing basicProfitSharing) {
        return toAjax(basicProfitSharingService.updateById(basicProfitSharing));
    }

    /**
     * 删除基础分润信息
     */
    @ApiOperation("删除基础分润信息")
    @PreAuthorize("@ss.hasPermi('basic:profitSharing:remove')")
    @Log(title = "基础分润信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(basicProfitSharingService.removeByIds(Arrays.asList(ids)));
    }
}
