package com.hxhq.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hxhq.business.domain.MjyFfjlJcgj;
import com.hxhq.system.api.domain.SysUser;
import org.springframework.stereotype.Service;
import com.hxhq.business.mapper.GspFfjlJcgjMapper;
import com.hxhq.business.domain.GspFfjlJcgj;
import com.hxhq.business.service.IGspFfjlJcgjService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 供试品发放记录-稽查轨迹Service业务层处理
 *
 * @author hxhq
 * @date 2025-12-30
 */
@Service
public class GspFfjlJcgjServiceImpl extends ServiceImpl<GspFfjlJcgjMapper, GspFfjlJcgj> implements IGspFfjlJcgjService
{
    /**
     * 查询供试品发放记录-稽查轨迹列表
     *
     * @param gspFfjlJcgj 供试品发放记录-稽查轨迹
     * @return 供试品发放记录-稽查轨迹
     */
    @Override
    public List<GspFfjlJcgj> queryList(GspFfjlJcgj gspFfjlJcgj)
    {
        QueryWrapper<GspFfjlJcgj> queryWrapper = Wrappers.query();
        if(gspFfjlJcgj.getFfjlId() != null) {
            queryWrapper.eq("ffjl_id", gspFfjlJcgj.getFfjlId());
        }
        queryWrapper.orderByDesc("id");
        return this.list(queryWrapper);
    }

    @Override
    public void saveJcgj(Long  ffjlId, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr) {
        GspFfjlJcgj gspFfjlJcgj = new GspFfjlJcgj();
        gspFfjlJcgj.setFfjlId(ffjlId);
        gspFfjlJcgj.setJcgjlx(jcgjlx);
        gspFfjlJcgj.setJcmc(jcmc);
        gspFfjlJcgj.setJcmcEn(jcmcEn);
        gspFfjlJcgj.setJcmcys(jcmcys);
        gspFfjlJcgj.setJcnr(jcnr);
        gspFfjlJcgj.setJcnrEn(jcnrEn);
        gspFfjlJcgj.setQmrId(qmr.getUserId());
        gspFfjlJcgj.setQmrMc(qmr.getNickName());
        gspFfjlJcgj.setQmrMcEn(qmr.getUserName());
        this.save(gspFfjlJcgj);
    }

}
