package com.pusong.business.controller;

import java.util.List;

import cn.dev33.satoken.annotation.SaIgnore;
import com.pusong.business.domain.vo.PsSalaryContractVo;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.pusong.common.idempotent.annotation.RepeatSubmit;
import com.pusong.common.log.annotation.Log;
import com.pusong.common.web.core.BaseController;
import com.pusong.common.mybatis.core.page.PageQuery;
import com.pusong.common.core.domain.R;
import com.pusong.common.core.validate.AddGroup;
import com.pusong.common.core.validate.EditGroup;
import com.pusong.common.log.enums.BusinessType;
import com.pusong.common.excel.utils.ExcelUtil;
import com.pusong.business.domain.vo.PsSalaryVo;
import com.pusong.business.domain.bo.PsSalaryBo;
import com.pusong.business.service.IPsSalaryService;
import com.pusong.common.mybatis.core.page.TableDataInfo;

/**
 * 员工提成提成
 *
 * @author wls
 * @date 2024-08-23
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/business/salary")
@SaIgnore
public class PsSalaryController extends BaseController {

    private final IPsSalaryService psSalaryService;

    /**
     * 提成列表查询
     */
    @SaCheckPermission("business:salary:list")
    @GetMapping("/list")
    public TableDataInfo<PsSalaryVo> list(PsSalaryBo bo, PageQuery pageQuery) {
        return psSalaryService.queryPageList(bo, pageQuery);
    }

    /**
     * 提成关联合同查询
     * @param id  列表主键id
     * @param status 1已完成合同 2未完成合同 （空查全部）
     * @return
     */
    @GetMapping("/queryContractPageList")
    public TableDataInfo<PsSalaryContractVo> queryContractPageList(Long id,String status, PageQuery pageQuery) {
        return psSalaryService.queryContractPageList(id,status, pageQuery);
    }

//    /**
//     * 导出员工提成提成列表
//     */
//    @SaCheckPermission("business:salary:export")
//    @Log(title = "员工提成提成", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(PsSalaryBo bo, HttpServletResponse response) {
//        List<PsSalaryVo> list = psSalaryService.queryList(bo);
//        ExcelUtil.exportExcel(list, "员工提成提成", PsSalaryVo.class, response);
//    }
//
//    /**
//     * 获取员工提成提成详细信息
//     *
//     * @param id 主键
//     */
//    @SaCheckPermission("business:salary:query")
//    @GetMapping("/{id}")
//    public R<PsSalaryVo> getInfo(@NotNull(message = "主键不能为空")
//                                     @PathVariable Long id) {
//        return R.ok(psSalaryService.queryById(id));
//    }
//
//    /**
//     * 新增员工提成提成
//     */
//    @SaCheckPermission("business:salary:add")
//    @Log(title = "员工提成提成", businessType = BusinessType.INSERT)
//    @RepeatSubmit()
//    @PostMapping()
//    public R<Void> add(@Validated(AddGroup.class) @RequestBody PsSalaryBo bo) {
//        return toAjax(psSalaryService.insertByBo(bo));
//    }
//
//    /**
//     * 修改员工提成提成
//     */
//    @SaCheckPermission("business:salary:edit")
//    @Log(title = "员工提成提成", businessType = BusinessType.UPDATE)
//    @RepeatSubmit()
//    @PutMapping()
//    public R<Void> edit(@Validated(EditGroup.class) @RequestBody PsSalaryBo bo) {
//        return toAjax(psSalaryService.updateByBo(bo));
//    }
//
//    /**
//     * 删除员工提成提成
//     *
//     * @param ids 主键串
//     */
//    @SaCheckPermission("business:salary:remove")
//    @Log(title = "员工提成提成", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public R<Void> remove(@NotEmpty(message = "主键不能为空")
//                          @PathVariable Long[] ids) {
//        return toAjax(psSalaryService.deleteWithValidByIds(List.of(ids), true));
//    }
}
