package com.hxhq.business.controller;

import com.hxhq.business.domain.GspRkjl;
import com.hxhq.business.domain.GspRkjlJcgj;
import com.hxhq.business.enums.zykgl.DaztEnum;
import com.hxhq.business.form.gsp.*;
import com.hxhq.business.service.IGspRkjlJcgjService;
import com.hxhq.business.service.IGspRkjlService;
import com.hxhq.common.core.web.controller.BaseController;
import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.common.core.web.page.TableDataInfo;
import com.hxhq.common.security.annotation.RequiresPermissions;
import com.hxhq.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 供试品入库记录Controller
 *
 * @author hxhq
 * @date 2025-12-30
 */
@RestController
@RequestMapping("/business/gspRkjlArchive")
public class GspRkjlArchiveController extends BaseController
{
    @Autowired
    private IGspRkjlService gspRkjlService;

    /**
     * 查询供试品入库记录列表
     */
    @GetMapping("/list")
    @RequiresPermissions("business:resource:gsp:rklist")
    public TableDataInfo list(GspSearchListForm form)
    {
        startPage();
        form.setArchive(DaztEnum.ygd.getValue());
        List<GspRkjl> list = gspRkjlService.queryList(form);
        return getDataTable(list);
    }

    /**
     * 同意解档
     */
    @PostMapping("/jd/agree")
    @RequiresPermissions("business:resource:gsp:gd")
    public AjaxResult agreeJd(@RequestBody @Validated GspGdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.agreeJd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 拒绝解档
     */
    @PostMapping("/jd/refuse")
    @RequiresPermissions("business:resource:gsp:gd")
    public AjaxResult refuseJd(@RequestBody @Validated GspGdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.refuseJd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 同意借阅
     */
    @PostMapping("/jy/agree")
    @RequiresPermissions("business:resource:gsp:gd")
    public AjaxResult agreeJy(@RequestBody @Validated GspJyForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.agreeJy(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 拒绝借阅
     */
    @PostMapping("/jy/refuse")
    @RequiresPermissions("business:resource:gsp:gd")
    public AjaxResult refuseJy(@RequestBody @Validated GspJyForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.refuseJy(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 档案确认归还
     */
    @PostMapping("/gh/archive")
    @RequiresPermissions("business:resource:gsp:gd")
    public AjaxResult archiveGh(@RequestBody @Validated GspGdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.archiveGh(form);
        return AjaxResult.success("操作成功");
    }
}
