package com.hxhq.business.controller;

import com.hxhq.business.domain.GyzjFfjlJcgj;
import com.hxhq.business.dto.gyzj.FfjlListDto;
import com.hxhq.business.form.gyzj.*;
import com.hxhq.business.service.IGyzjFfjlJcgjService;
import com.hxhq.business.service.IGyzjFfjlService;
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.Logical;
import com.hxhq.common.security.annotation.RequiresPermissions;
import com.hxhq.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 给药制剂发放记录Controller
 *
 * @author hxhq
 * @date 2025-12-15
 */
@RestController
@RequestMapping("/business/gyzjFfjl")
public class GyzjFfjlController extends BaseController
{
    @Autowired
    private IGyzjFfjlJcgjService gyzjFfjlJcgjService;
    @Autowired
    private IGyzjFfjlService gyzjFfjlService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @RequiresPermissions("business:resource:gyzj:ffjllist")
    public TableDataInfo list(FfjlSearchForm form)
    {
        startPage();
        List<FfjlListDto> list = gyzjFfjlService.queryList(form);
        return getDataTable(list);
    }

    /**
     * 详细信息
     */
    @RequiresPermissions(value={"business:resource:gyzj:ffjlxq","business:archive:gyzj:ffjlxq"}, logical= Logical.OR)
    @GetMapping(value = "/info")
    public AjaxResult getInfo(Long id)
    {
        return AjaxResult.success(gyzjFfjlService.queryInfo(id));
    }

    /**
     * 稽查轨迹列表
     */
    @RequiresPermissions(value={"business:resource:gyzj:ffjlxq","business:archive:gyzj:ffjlxq"}, logical= Logical.OR)
    @GetMapping("/jcgjList")
    public TableDataInfo jcgjList(GyzjFfjlJcgj form)
    {
        startPage();
        List<GyzjFfjlJcgj> list = gyzjFfjlJcgjService.queryList(form);
        return getDataTable(list);
    }

    /**
     * 解档
     */
    @PostMapping("/jd")
    @RequiresPermissions("business:resource:gyzj:ffjljd")
    public AjaxResult jd(@RequestBody FfjlJdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gyzjFfjlService.jd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 批量归档
     */
    @PostMapping("/plgd")
    @RequiresPermissions("business:resource:gyzj:ffjlgd")
    public AjaxResult plgd(@RequestBody FfjlGdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gyzjFfjlService.plgd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 归档
     */
    @PostMapping("/gd")
    @RequiresPermissions("business:resource:gyzj:ffjlgd")
    public AjaxResult gd(@RequestBody FfjlGdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gyzjFfjlService.gd(form);
        return AjaxResult.success("操作成功");
    }


    /**
     * 批量锁定
     */
    @PostMapping("/plsd")
    @RequiresPermissions("business:resource:gyzj:ffjlsd")
    public AjaxResult plsd(@RequestBody FfjlSdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gyzjFfjlService.plsd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 锁定
     */
    @PostMapping("/sd")
    @RequiresPermissions("business:resource:gyzj:ffjlsd")
    public AjaxResult sd(@RequestBody FfjlSdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gyzjFfjlService.sd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 解锁
     */
    @PostMapping("/js")
    @RequiresPermissions("business:resource:gyzj:ffjljs")
    public AjaxResult js(@RequestBody FfjlJsForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gyzjFfjlService.js(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 借阅
     */
    @PostMapping("/jy")
    @RequiresPermissions("business:resource:gyzj:ffjljy")
    public AjaxResult jy(@RequestBody FfjlJyForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gyzjFfjlService.jy(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 加签
     */
    @PostMapping("/jq")
    @RequiresPermissions("business:resource:gyzj:ffjljq")
    public AjaxResult jq(@RequestBody FfjlJqForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gyzjFfjlService.jq(form);
        return AjaxResult.success("操作成功");
    }

}
