package com.dl.workflow.service.impl; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.dl.common.core.domain.PageQuery; import com.dl.common.core.page.TableDataInfo; import com.dl.common.utils.StringUtils; import com.dl.workflow.domain.WfForm; import com.dl.workflow.domain.bo.WfFormBo; import com.dl.workflow.domain.vo.WfFormVo; import com.dl.workflow.mapper.WfFormMapper; import com.dl.workflow.service.IWfFormService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.util.Collection; import java.util.List; import java.util.Map; /** * 流程表单Service业务层处理 * * @author KonBAI * @createTime 2022/3/7 22:07 */ @RequiredArgsConstructor @Service public class WfFormServiceImpl implements IWfFormService { private final WfFormMapper baseMapper; /** * 查询流程表单 * * @param formId 流程表单ID * @return 流程表单 */ @Override public WfFormVo queryById(Long formId) { return baseMapper.selectVoById(formId); } /** * 查询流程表单列表 * * @param bo 流程表单 * @return 流程表单 */ @Override public TableDataInfo queryPageList(WfFormBo bo, PageQuery pageQuery) { LambdaQueryWrapper lqw = buildQueryWrapper(bo); Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); return TableDataInfo.build(result); } /** * 查询流程表单列表 * * @param bo 流程表单 * @return 流程表单 */ @Override public List queryList(WfFormBo bo) { LambdaQueryWrapper lqw = buildQueryWrapper(bo); return baseMapper.selectVoList(lqw); } /** * 新增流程表单 * * @param bo 流程表单 * @return 结果 */ @Override public int insertForm(WfFormBo bo) { WfForm wfForm = new WfForm(); wfForm.setFormName(bo.getFormName()); wfForm.setContent(bo.getContent()); wfForm.setRemark(bo.getRemark()); return baseMapper.insert(wfForm); } /** * 修改流程表单 * * @param bo 流程表单 * @return 结果 */ @Override public int updateForm(WfFormBo bo) { return baseMapper.update(new WfForm(), new LambdaUpdateWrapper() .set(StrUtil.isNotBlank(bo.getFormName()), WfForm::getFormName, bo.getFormName()) .set(StrUtil.isNotBlank(bo.getContent()), WfForm::getContent, bo.getContent()) .set(StrUtil.isNotBlank(bo.getRemark()), WfForm::getRemark, bo.getRemark()) .eq(WfForm::getFormId, bo.getFormId())); } /** * 批量删除流程表单 * * @param ids 需要删除的流程表单ID * @return 结果 */ @Override public Boolean deleteWithValidByIds(Collection ids) { return baseMapper.deleteBatchIds(ids) > 0; } private LambdaQueryWrapper buildQueryWrapper(WfFormBo bo) { Map params = bo.getParams(); LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); lqw.like(StringUtils.isNotBlank(bo.getFormName()), WfForm::getFormName, bo.getFormName()); return lqw; } }