package com.iailab.module.model.mcs.pre.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.iailab.framework.common.pojo.PageResult;
|
import com.iailab.framework.common.service.impl.BaseServiceImpl;
|
import com.iailab.framework.common.util.collection.CollectionUtils;
|
import com.iailab.module.model.mcs.pre.dao.MmItemTypeDao;
|
import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity;
|
import com.iailab.module.model.mcs.pre.service.MmItemTypeService;
|
import com.iailab.module.model.mcs.pre.vo.MmItemTypePageReqVO;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.Arrays;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.UUID;
|
|
/**
|
* @author PanZhibao
|
* @date 2021年04月23日 15:29
|
*/
|
@Service("mmItemTypeService")
|
public class MmItemTypeImpl extends BaseServiceImpl<MmItemTypeDao, MmItemTypeEntity> implements MmItemTypeService {
|
|
@Override
|
public PageResult<MmItemTypeEntity> page(MmItemTypePageReqVO reqVO) {
|
return baseDao.selectPage(reqVO);
|
}
|
|
private QueryWrapper<MmItemTypeEntity> getWrapper(Map<String, Object> params) {
|
String itemtypename = (String)params.get("itemtypename");
|
|
QueryWrapper<MmItemTypeEntity> wrapper = new QueryWrapper<>();
|
wrapper.like(StringUtils.isNotBlank(itemtypename),"itemtypename", itemtypename);
|
|
return wrapper;
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void saveItemType(MmItemTypeEntity itemType) {
|
itemType.setId(UUID.randomUUID().toString());
|
baseDao.insert(itemType);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void update(MmItemTypeEntity itemType) {
|
baseDao.updateById(itemType);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void deleteBatch(String[] moduleIds) {
|
baseDao.deleteBatchIds(Arrays.asList(moduleIds));
|
}
|
|
@Override
|
public int check(MmItemTypeEntity itemType) {
|
String id = itemType.getId();
|
String itemtypename = itemType.getItemtypename();
|
QueryWrapper<MmItemTypeEntity> moduleWrapper = new QueryWrapper<>();
|
moduleWrapper.ne(StringUtils.isNotBlank(id), "id", id);
|
moduleWrapper.and(wrapper -> wrapper.eq("itemtypename",itemtypename));
|
List<MmItemTypeEntity> list = baseDao.selectList(moduleWrapper);
|
return list.size();
|
}
|
|
public MmItemTypeEntity getById(String itemtypeid) {
|
MmItemTypeEntity entity = baseDao.selectById(itemtypeid);
|
return entity;
|
}
|
|
@Override
|
public MmItemTypeEntity getItemTypeByItemId(String itemId) {
|
List<MmItemTypeEntity> list = baseDao.getItemTypeByItemId(itemId);
|
if (CollectionUtils.isAnyEmpty(list)) {
|
return null;
|
}
|
return list.get(0);
|
}
|
}
|