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.utils.lang.StudyFormUtil;
import com.hxhq.common.core.exception.ServiceException;
import com.hxhq.system.api.domain.SysUser;
import org.springframework.stereotype.Service;
import com.hxhq.business.mapper.StudyFormFillQmxxMapper;
import com.hxhq.business.domain.StudyFormFillQmxx;
import com.hxhq.business.service.IStudyFormFillQmxxService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 试验-填报单-签名信息Service业务层处理
 *
 * @author hxhq
 * @date 2025-12-31
 */
@Service
public class StudyFormFillQmxxServiceImpl extends ServiceImpl<StudyFormFillQmxxMapper, StudyFormFillQmxx> implements IStudyFormFillQmxxService
{

    /**
     * 查询试验-填报单-签名信息列表
     *
     * @param studyFormFillQmxx 试验-填报单-签名信息
     * @return 试验-填报单-签名信息
     */
    @Override
    public List<StudyFormFillQmxx> queryList(StudyFormFillQmxx studyFormFillQmxx)
    {
        QueryWrapper<StudyFormFillQmxx> queryWrapper = Wrappers.query();
        if(studyFormFillQmxx.getFormId()==null||studyFormFillQmxx.getFormId().longValue()<0){
            throw new ServiceException("表单id不能为空");
        }
        queryWrapper.eq("form_id",studyFormFillQmxx.getFormId());
        queryWrapper.orderByDesc("id");
        return this.list(queryWrapper);
    }

    /**
     * 新增签名信息
     * @param formId
     * @param qmyy
     * @param qmr
     * @param remark
     */
    @Override
    public  void saveQmxx(Long  formId, String qmyy, SysUser qmr, String remark){
        StudyFormFillQmxx studyFormFillQmxx=new StudyFormFillQmxx();
        studyFormFillQmxx.setFormId(formId);
        studyFormFillQmxx.setQmyy(qmyy);
        studyFormFillQmxx.setQmyyEn(StudyFormUtil.getEn(qmyy));
        studyFormFillQmxx.setQmrId(qmr.getUserId());
        studyFormFillQmxx.setQmrMc(qmr.getNickName());
        studyFormFillQmxx.setQmrMcEn(qmr.getUserName());
        studyFormFillQmxx.setRemark(remark);
        this.save(studyFormFillQmxx);
    }

}
