|
@@ -1,6 +1,8 @@
|
|
|
package org.jeecg.modules.rooms.service;
|
|
package org.jeecg.modules.rooms.service;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
@@ -20,6 +22,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -61,8 +64,8 @@ public class CesGoodsUnitServiceImpl extends ServiceImpl<CesGoodsUnitMapper, Ces
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
public Result create(CesGoodsUnitDto dto){
|
|
public Result create(CesGoodsUnitDto dto){
|
|
|
- CesGoodsUnit unit = cesGoodsUnitMapper.selectOne(Wrappers.<CesGoodsUnit>lambdaQuery().eq(CesGoodsUnit::getInvalid,false).eq(CesGoodsUnit::getName,dto.getName()));
|
|
|
|
|
- if(!ObjectUtils.isEmpty(unit)) return Result.error("已存在相同名称的单位!");
|
|
|
|
|
|
|
+ CesGoodsUnit unit = cesGoodsUnitMapper.selectOne(Wrappers.<CesGoodsUnit>lambdaQuery().eq(CesGoodsUnit::getInvalid,false).eq(CesGoodsUnit::getName,dto.getName()));
|
|
|
|
|
+ if(!ObjectUtils.isEmpty(unit)) return Result.error("已存在相同名称的单位!");
|
|
|
CesGoodsUnit cesGoodsUnit = new CesGoodsUnit();
|
|
CesGoodsUnit cesGoodsUnit = new CesGoodsUnit();
|
|
|
BeanUtil.copyProperties(dto,cesGoodsUnit);
|
|
BeanUtil.copyProperties(dto,cesGoodsUnit);
|
|
|
cesGoodsUnit.setCreateAt(LocalDateTime.now());
|
|
cesGoodsUnit.setCreateAt(LocalDateTime.now());
|
|
@@ -73,5 +76,54 @@ public class CesGoodsUnitServiceImpl extends ServiceImpl<CesGoodsUnitMapper, Ces
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改
|
|
|
|
|
+ * @param dto
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public Result modify(CesGoodsUnitDto dto){
|
|
|
|
|
+ CesGoodsUnit unit = cesGoodsUnitMapper.selectById(dto.getId());
|
|
|
|
|
+ if(ObjectUtils.isEmpty(unit)) return Result.error("数据未找到!");
|
|
|
|
|
+
|
|
|
|
|
+ BeanUtil.copyProperties(dto,unit, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
|
|
|
|
|
+ unit.setUpdateAt(LocalDateTime.now());
|
|
|
|
|
+ cesGoodsUnitMapper.updateById(unit);
|
|
|
|
|
+ return Result.OK("修改成功!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除单个
|
|
|
|
|
+ * @param id
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public Result delete(String id){
|
|
|
|
|
+ CesGoodsUnit unit = cesGoodsUnitMapper.selectById(id);
|
|
|
|
|
+ if(ObjectUtils.isEmpty(unit)) return Result.error("数据未找到!");
|
|
|
|
|
+
|
|
|
|
|
+ unit.setUpdateAt(LocalDateTime.now());
|
|
|
|
|
+ unit.setInvalid(true);
|
|
|
|
|
+ cesGoodsUnitMapper.updateById(unit);
|
|
|
|
|
+ return Result.OK("删除成功!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 批量删除
|
|
|
|
|
+ * @param ids
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public Result deleteBatch(List<String> ids){
|
|
|
|
|
+ List<CesGoodsUnit> units = cesGoodsUnitMapper.selectList(Wrappers.<CesGoodsUnit>lambdaQuery().in(CesGoodsUnit::getId,ids).eq(CesGoodsUnit::getInvalid,false));
|
|
|
|
|
+ if(CollectionUtil.isEmpty(units)) return Result.error("数据未找到!");
|
|
|
|
|
+
|
|
|
|
|
+ units.forEach(unit -> {
|
|
|
|
|
+ unit.setUpdateAt(LocalDateTime.now());
|
|
|
|
|
+ unit.setInvalid(true);
|
|
|
|
|
+ });
|
|
|
|
|
+ saveOrUpdateBatch(units);
|
|
|
|
|
+ return Result.OK("删除成功!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|