package com.hxhq.business.controller;

import com.hxhq.business.domain.GspFfjlJcgj;
import com.hxhq.business.dto.gsp.GspFfjlListDto;
import com.hxhq.business.enums.zykgl.DaztEnum;
import com.hxhq.business.form.gsp.GspGdForm;
import com.hxhq.business.form.gsp.GspJyForm;
import com.hxhq.business.form.gsp.GspSearchListForm;
import com.hxhq.business.form.mjy.*;
import com.hxhq.business.service.IGspFfjlJcgjService;
import com.hxhq.business.service.IGspFfjlService;
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/gspFfjlArchive")
public class GspFfjlArchiveController extends BaseController
{
    @Autowired
    private IGspFfjlService gspFfjlService;

    @Autowired
    private IGspFfjlJcgjService gspFfjlJcgjService;

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


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

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

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

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

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

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

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