|
@@ -0,0 +1,118 @@
|
|
|
|
+package com.zhongzheng.modules.order.service.impl;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
|
+import com.zhongzheng.modules.course.domain.CourseChapter;
|
|
|
|
+import com.zhongzheng.modules.order.bo.OrderBusinessConfigAddBo;
|
|
|
|
+import com.zhongzheng.modules.order.bo.OrderBusinessConfigEditBo;
|
|
|
|
+import com.zhongzheng.modules.order.bo.OrderBusinessConfigQueryBo;
|
|
|
|
+import com.zhongzheng.modules.order.domain.OrderBusinessConfig;
|
|
|
|
+import com.zhongzheng.modules.order.mapper.OrderBusinessConfigMapper;
|
|
|
|
+import com.zhongzheng.modules.order.service.IOrderBusinessConfigService;
|
|
|
|
+import com.zhongzheng.modules.order.vo.OrderBusinessConfigVo;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
+import com.github.pagehelper.Page;
|
|
|
|
+
|
|
|
|
+import java.util.Collection;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 录单配置Service业务层处理
|
|
|
|
+ *
|
|
|
|
+ * @author hjl
|
|
|
|
+ * @date 2022-04-01
|
|
|
|
+ */
|
|
|
|
+@Service
|
|
|
|
+public class OrderBusinessConfigServiceImpl extends ServiceImpl<OrderBusinessConfigMapper, OrderBusinessConfig> implements IOrderBusinessConfigService {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public OrderBusinessConfigVo queryById(Long id){
|
|
|
|
+ OrderBusinessConfig db = this.baseMapper.selectById(id);
|
|
|
|
+ return BeanUtil.toBean(db, OrderBusinessConfigVo.class);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<OrderBusinessConfigVo> queryList(OrderBusinessConfigQueryBo bo) {
|
|
|
|
+ LambdaQueryWrapper<OrderBusinessConfig> lqw = Wrappers.lambdaQuery();
|
|
|
|
+ lqw.eq(bo.getBusinessId() != null, OrderBusinessConfig::getBusinessId, bo.getBusinessId());
|
|
|
|
+ lqw.like(StrUtil.isNotBlank(bo.getConfigName()), OrderBusinessConfig::getConfigName, bo.getConfigName());
|
|
|
|
+ lqw.eq(bo.getStatus() != null, OrderBusinessConfig::getStatus, bo.getStatus());
|
|
|
|
+ return entity2Vo(this.list(lqw));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 实体类转化成视图对象
|
|
|
|
+ *
|
|
|
|
+ * @param collection 实体类集合
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<OrderBusinessConfigVo> entity2Vo(Collection<OrderBusinessConfig> collection) {
|
|
|
|
+ List<OrderBusinessConfigVo> voList = collection.stream()
|
|
|
|
+ .map(any -> BeanUtil.toBean(any, OrderBusinessConfigVo.class))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if (collection instanceof Page) {
|
|
|
|
+ Page<OrderBusinessConfig> page = (Page<OrderBusinessConfig>)collection;
|
|
|
|
+ Page<OrderBusinessConfigVo> pageVo = new Page<>();
|
|
|
|
+ BeanUtil.copyProperties(page,pageVo);
|
|
|
|
+ pageVo.addAll(voList);
|
|
|
|
+ voList = pageVo;
|
|
|
|
+ }
|
|
|
|
+ return voList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean insertByAddBo(OrderBusinessConfigAddBo bo) {
|
|
|
|
+ OrderBusinessConfig add = BeanUtil.toBean(bo, OrderBusinessConfig.class);
|
|
|
|
+ validEntityBeforeSave(add);
|
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ return this.save(add);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean updateByEditBo(OrderBusinessConfigEditBo bo) {
|
|
|
|
+ OrderBusinessConfig update = BeanUtil.toBean(bo, OrderBusinessConfig.class);
|
|
|
|
+ validEntityBeforeSave(update);
|
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ return this.updateById(update);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存前的数据校验
|
|
|
|
+ *
|
|
|
|
+ * @param entity 实体类数据
|
|
|
|
+ */
|
|
|
|
+ private void validEntityBeforeSave(OrderBusinessConfig entity){
|
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
|
+ if(isValid){
|
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
+ }
|
|
|
|
+ return this.removeByIds(ids);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean checkNameUnique(OrderBusinessConfig entity) {
|
|
|
|
+ OrderBusinessConfig info = getOne(new LambdaQueryWrapper<OrderBusinessConfig>()
|
|
|
|
+ .eq(OrderBusinessConfig::getConfigName,entity.getConfigName()).ne(OrderBusinessConfig::getStatus,-1).last("limit 1"));
|
|
|
|
+ if (Validator.isNotNull(info)) {
|
|
|
|
+ if(Validator.isNotEmpty(entity.getId())){
|
|
|
|
+ if(entity.getId().longValue() != info.getId().longValue()){
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+}
|