package com.iailab.module.data.ind.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.iailab.framework.common.constant.Constant; import com.iailab.framework.common.page.PageData; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.module.data.ind.dao.IndItemAtomDao; import com.iailab.module.data.ind.dto.IndItemAtomDTO; import com.iailab.module.data.ind.dao.IndItemAtomDao; import com.iailab.module.data.ind.dto.IndItemAtomDTO; import com.iailab.module.data.ind.dao.IndItemAtomDao; import com.iailab.module.data.ind.dto.IndItemAtomDTO; import com.iailab.module.data.ind.entity.IndItemAtomEntity; import com.iailab.module.data.ind.service.IndItemAtomService; import com.iailab.module.data.ind.dao.IndItemAtomDao; import com.iailab.module.data.ind.dto.IndItemAtomDTO; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.Map; /** * @author PanZhibao * @Description * @createTime 2024年05月25日 */ @Service public class IndItemAtomServiceImpl extends BaseServiceImpl implements IndItemAtomService { @Override public PageData page(Map params) { IPage page = baseDao.selectPage( getPage(params, Constant.CREATE_DATE, false), getWrapper(params) ); return getPageData(page, IndItemAtomDTO.class); } private QueryWrapper getWrapper(Map params){ String itemId = (String)params.get("itemId"); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); return wrapper; } @Override public IndItemAtomDTO get(String id) { IndItemAtomEntity entity = baseDao.selectById(id); return ConvertUtils.sourceToTarget(entity, IndItemAtomDTO.class); } @Override public IndItemAtomDTO getItemId(String itemId) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); IndItemAtomEntity entity = baseDao.selectOne(wrapper); return ConvertUtils.sourceToTarget(entity, IndItemAtomDTO.class); } @Override public void save(IndItemAtomDTO dto) { IndItemAtomEntity entity = ConvertUtils.sourceToTarget(dto, IndItemAtomEntity.class); insert(entity); } @Override public void update(IndItemAtomDTO dto) { IndItemAtomEntity entity = ConvertUtils.sourceToTarget(dto, IndItemAtomEntity.class); updateById(entity); } @Override @Transactional(rollbackFor = Exception.class) public void delete(String[] ids) { baseDao.deleteBatchIds(Arrays.asList(ids)); } @Override public void deleteByItemId(String[] ids) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.in("item_id", ids); baseDao.delete(wrapper); } }