package com.vci.web.dao.impl; import com.vci.constant.VciFileBtmTypeConstant; import com.vci.model.VciFileVolumeDO; import com.vci.starter.web.constant.QueryOptionConstant; import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.wrapper.VciQueryWrapperForDO; import com.vci.web.dao.VciFileVolumeDaoI; import com.vci.web.service.WebBoServiceI; import com.vci.web.util.WebUtil; 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.HashMap; import java.util.List; import java.util.Map; /** * 文件柜的数据操作层 * @author weidy * @date 2021/3/11 */ @Repository public class VciFileVolumeDaoImpl implements VciFileVolumeDaoI { /** * 业务数据对象的服务 */ @Autowired private WebBoServiceI boService; /** * 使用主键删除 * * @param oid 数据主键 * @return 执行结果 */ @Override public int deleteByPrimaryKey(String oid) { VciBaseUtil.alertNotNull(oid,"文件的主键"); boService.deleteByCondition(VciFileBtmTypeConstant.FILE_VOLUME, WebUtil.getOidQuery(oid)); return StringUtils.countMatches(oid,",") + 1; } /** * 添加数据 * * @param record 文仓管理数据对象 * @return 执行结果 */ @Override public int insert(VciFileVolumeDO record) { VciBaseUtil.alertNotNull(record,"要添加的内容"); if(StringUtils.isBlank(record.getOid())){ record.setOid(VciBaseUtil.getPk()); } boService.addSave(record); return 1; } /** * 根据主键查询 * * @param oid 数据主键 * @return 数据对象 */ @Override public VciFileVolumeDO selectByPrimaryKey(String oid) { return boService.selectByOid(oid, VciFileVolumeDO.class); } /** * 根据主键批量获取对象 * * @param oids 主键,包含单引号,但是不能超过1000 * @return 数据对象列表 */ @Override public List selectByPrimaryKeys(String oids) { return boService.selectByOidCollection(VciBaseUtil.str2List(oids),VciFileVolumeDO.class); } /** * 根据主键批量查询对象 * * @param oids 对象主键,使用逗号分隔,但是不能超过1000 * @return 业务对象 */ @Override public List selectByPrimaryKeyCollection(Collection oids) { return boService.selectByOidCollection(oids,VciFileVolumeDO.class); } /** * 查询所有分类 * * @return 查询结果 */ @Override public List selectAll() { return boService.queryObject(VciFileVolumeDO.class,null); } /** * 更新物料、工具基本分类 * * @param record 物料、工具基本分类数据对象 * @return 执行结果 */ @Override public int updateByPrimaryKey(VciFileVolumeDO record) { VciBaseUtil.alertNotNull(record,"要修改的内容",record.getOid(),"主键"); boService.editSave(record); return 1; } /** * 根据查询条件查询数据 * * @param wrapper 查询条件,包括分页,排序 * @return 数据对象列表 */ @Override public List selectByWrapper(VciQueryWrapperForDO wrapper) { return boService.selectByQueryWrapper(wrapper,VciFileVolumeDO.class); } /** * 根据查询条件来查询总数 * * @param wrapper 查询条件 * @return 总数 */ @Override public Long countByWrapper(VciQueryWrapperForDO wrapper) { return Long.valueOf(boService.countByQueryWrapper(wrapper,VciFileVolumeDO.class)); } /** * 根据主键获取名称 * * @param oid 主键 * @return 中文名称 */ @Override public String selectNameByOid(String oid) { VciFileVolumeDO fileObjectDO = selectByPrimaryKey(oid); return fileObjectDO!=null?fileObjectDO.getName():""; } /** * 批量删除对象 * * @param oids 对象的主键集合 * @return 受印象的行数 */ @Override public long batchDeleteByOids(Collection oids) { VciBaseUtil.switchCollectionForOracleIn(oids).forEach(oidList->{ Map conditionMap = new HashMap<>(); conditionMap.put("oid", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(oidList.toArray(new String[0])) + ")"); boService.deleteByCondition(VciFileBtmTypeConstant.FILE_VOLUME,conditionMap); }); return oids.size(); } /** * 更新使用的容量 * * @param oid 主键 * @param usedVolume 使用的容量 * @return 受影响的行数 */ @Override public int updateUsedVolume(String oid, String usedVolume) { //这个暂时没有 return 0; } }