package com.qianwen.smartman.modules.system.service.impl; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.qianwen.core.log.exception.ServiceException; import com.qianwen.core.tool.utils.BeanUtil; import com.qianwen.core.tool.utils.Func; import com.qianwen.smartman.common.utils.Lambda; import com.qianwen.smartman.modules.system.entity.MetaObjectTypeField; import com.qianwen.smartman.modules.system.entity.MetaRefObjectType; import com.qianwen.smartman.modules.system.mapper.MetaObjectTypeFieldMapper; import com.qianwen.smartman.modules.system.service.IMetaObjectTypeFieldService; import com.qianwen.smartman.modules.system.vo.MetaObjectTypeFieldVO; @Service public class MetaObjectTypeFieldServiceImpl extends ServiceImpl implements IMetaObjectTypeFieldService { @Override // org.springblade.modules.system.service.IMetaObjectTypeFieldService @Transactional public boolean saveOrUpdate(MetaObjectTypeFieldVO vo) { if ("5".equals(vo.getElementType()) && Func.isBlank(vo.getRefObjectTypeId())) { throw new ServiceException("元素类型是资料必须填写引用对象"); } if ("4".equals(vo.getElementType()) && Func.isBlank(vo.getEnumType())) { throw new ServiceException("元素类型是下拉框必须填写枚举类型"); } if (vo.getObjectId().equals(vo.getRefObjectTypeId())) { throw new ServiceException("业务对象不能跟引用对象相同"); } saveOrUpdate(BeanUtil.copy(vo, MetaObjectTypeField.class)); if (Func.isNotBlank(vo.getRefObjectTypeId())) { MetaRefObjectType metaRefObjectType = (new MetaRefObjectType()).selectOne(Lambda.eq(MetaRefObjectType::getObjectTypeId, vo.getObjectId()).eq(MetaRefObjectType::getFieldName, vo.getFCode())); /* MetaRefObjectType metaRefObjectType = (MetaRefObjectType) new MetaRefObjectType().selectOne((Wrapper) Lambda.eq((v0) -> { return v0.getObjectTypeId(); }, vo.getObjectId()).eq((v0) -> { return v0.getFieldName(); }, vo.getFCode()));*/ if (metaRefObjectType == null) { metaRefObjectType = new MetaRefObjectType(); } metaRefObjectType.setRefObjectTypeId(vo.getRefObjectTypeId()); metaRefObjectType.setObjectTypeId(vo.getObjectId()); metaRefObjectType.setFieldName(vo.getFCode()); metaRefObjectType.insertOrUpdate(); return true; } return true; } }