package org.springblade.code.dao.impl; import com.vci.mdm.dao.SysIntBaseDaoI; import com.vci.mdm.model.SysIntBaseDO; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.PageHelper; import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.wrapper.VciQueryWrapperForDO; import com.vci.web.pageModel.BatchCBO; import com.vci.web.service.OsLifeCycleServiceI; import com.vci.web.service.WebBoServiceI; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import java.util.Collection; import java.util.List; import java.util.Map; import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; /** * 系统集成的系统信息数据操作层实现类 * * @author lihang * @date 2022-03-07 */ @Repository public class SysIntBaseDaoImpl implements SysIntBaseDaoI{ /** * 业务类型操作的服务 */ @Autowired private WebBoServiceI boService; /** * 生命周期的服务 */ @Autowired private OsLifeCycleServiceI lifeCycleService; /** * 使用主键删除 * @param oid 数据主键 * @return 执行结果 */ @Override public BatchCBO deleteByPrimaryKey(String oid){ VciBaseUtil.alertNotNull(oid,"主键"); SysIntBaseDO sysIntBaseDO = selectByPrimaryKey(oid); return boService.delete(sysIntBaseDO); } /** * 添加数据 * @param record 系统集成的系统信息数据对象 * @return 执行结果 */ @Override public BatchCBO insert(SysIntBaseDO record){ VciBaseUtil.alertNotNull(record,"要添加的数据"); return boService.addSave(record); } /** * 批量添加数据 * @param records 系统集成的系统信息数据对象集合 * @return 执行结果数 */ @Override public BatchCBO batchInsert(List records){ VciBaseUtil.alertNotNull(records,"要添加的数据"); BatchCBO batchCBO = boService.batchAddSave(records); return batchCBO; } /** * 根据主键查询 * @param oid 数据主键 * @return 数据对象 */ @Override public SysIntBaseDO selectByPrimaryKey(String oid){ VciBaseUtil.alertNotNull(oid,"主键"); SysIntBaseDO record = boService.selectByOid(oid, SysIntBaseDO.class); if(record == null || StringUtils.isBlank(record.getOid())){ throw new VciBaseException(DATA_OID_NOT_EXIST); } return record; } /** * 根据主键批量获取对象 * @param oids 主键,包含单引号,但是不能超过1000 * @return 数据对象列表 */ @Override public List selectByPrimaryKeys(String oids){ VciBaseUtil.alertNotNull(oids,"主键集合"); return boService.selectByOidCollection(VciBaseUtil.str2List(oids), SysIntBaseDO.class); } /** * 根据主键批量查询对象 * @param oids 对象主键,使用逗号分隔,但是不能超过1000 * @return 业务对象 */ @Override public List selectByPrimaryKeyCollection(Collection oids){ VciBaseUtil.alertNotNull(oids,"主键集合"); return boService.selectByOidCollection(oids, SysIntBaseDO.class); } /** * 查询所有分类 * @return 查询结果 */ @Override public List selectAll(){ return boService.queryObject(SysIntBaseDO.class,null); } /** * 更新对象 * @param record 系统集成的系统信息数据对象 * @return 执行结果 */ @Override public BatchCBO updateByPrimaryKey(SysIntBaseDO record){ VciBaseUtil.alertNotNull(record,"要修改的对象",record.getOid(),"主键"); return boService.editSave(record); } /** * 批量更新 * @param records 系统集成的系统信息数据对象集合 * @return 执行结果行数 */ @Override public BatchCBO batchUpdate(List records){ VciBaseUtil.alertNotNull(records,"要修改的对象"); BatchCBO batchCBO = boService.batchEditSave(records); return batchCBO; } /** * 根据查询条件查询数据 * @param conditionMap 查询条件, * @param pageHelper 包括分页,排序 * @return 数据对象列表 */ @Override public List selectByCondition(Map< String,String> conditionMap, PageHelper pageHelper){ return boService.queryObject(SysIntBaseDO.class,conditionMap,pageHelper); } /** * 根据查询条件来查询总数 * @param conditionMap 查询条件 * @return 总数 */ @Override public Long countByCondition(Map< String,String> conditionMap){ return VciBaseUtil.getLong(String.valueOf(boService.queryCount(SysIntBaseDO.class,conditionMap))); } /** * 根据查询封装器来查询数据 * @param queryWrapper 查询封装器 * @return 数据对象列表 */ @Override public List selectByWrapper(VciQueryWrapperForDO queryWrapper){ return boService.selectByQueryWrapper(queryWrapper,SysIntBaseDO.class); } /** * 根据查询封装器来查询总数 * @param queryWrapper 查询封装器 * @return 总数 */ @Override public Long countByWrapper(VciQueryWrapperForDO queryWrapper){ return VciBaseUtil.getLong(String.valueOf(boService.countByQueryWrapper(queryWrapper,SysIntBaseDO.class))); } /** * 根据主键获取名称 * @param oid 主键 * @return 中文名称 */ @Override public String selectNameByOid(String oid){ return selectByPrimaryKey(oid).getName(); } /** * 批量删除对象 * @param oids 对象的主键集合 * @return 受影响的行数 */ @Override public BatchCBO batchDeleteByOids(Collection oids){ List dos = boService.selectByOidCollection(oids, SysIntBaseDO.class); BatchCBO batchCBO = boService.batchDelete(dos); return batchCBO; } }