|
@@ -0,0 +1,86 @@
|
|
|
|
|
+package cn.iocoder.yudao.module.system.service.biz;
|
|
|
|
|
+
|
|
|
|
|
+import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.biz.vo.AppointmentConfigRespVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.biz.vo.AppointmentConfigSaveReqVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.biz.AppointmentConfigDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.biz.AppointmentGroupDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.mysql.biz.AppointmentConfigMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.mysql.biz.AppointmentGroupMapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
+
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 预约配置 Service 实现
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author system
|
|
|
|
|
+ */
|
|
|
|
|
+@Service
|
|
|
|
|
+public class AppointmentConfigServiceImpl implements AppointmentConfigService {
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private AppointmentConfigMapper appointmentConfigMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private AppointmentGroupMapper appointmentGroupMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public void add(AppointmentConfigSaveReqVO reqVO) {
|
|
|
|
|
+ AppointmentConfigDO config = reqVO.getConfig();
|
|
|
|
|
+ Long tenantId = config.getTenantId() != null ? config.getTenantId() : TenantContextHolder.getTenantId();
|
|
|
|
|
+ config.setTenantId(tenantId);
|
|
|
|
|
+ appointmentConfigMapper.insert(config);
|
|
|
|
|
+
|
|
|
|
|
+ List<AppointmentGroupDO> groupList = reqVO.getGroup();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(groupList)) {
|
|
|
|
|
+ groupList.forEach(group -> group.setTenantId(tenantId));
|
|
|
|
|
+ appointmentGroupMapper.insertBatch(groupList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public void update(AppointmentConfigSaveReqVO reqVO) {
|
|
|
|
|
+ AppointmentConfigDO config = reqVO.getConfig();
|
|
|
|
|
+ Long tenantId = config.getTenantId() != null ? config.getTenantId() : TenantContextHolder.getTenantId();
|
|
|
|
|
+
|
|
|
|
|
+ // 先删除:清除该机构下已有的配置与预约组
|
|
|
|
|
+ appointmentConfigMapper.delete(new LambdaQueryWrapper<AppointmentConfigDO>()
|
|
|
|
|
+ .eq(AppointmentConfigDO::getTenantId, tenantId));
|
|
|
|
|
+ appointmentGroupMapper.delete(new LambdaQueryWrapper<AppointmentGroupDO>()
|
|
|
|
|
+ .eq(AppointmentGroupDO::getTenantId, tenantId));
|
|
|
|
|
+
|
|
|
|
|
+ // 后新增
|
|
|
|
|
+ config.setId(null);
|
|
|
|
|
+ config.setTenantId(tenantId);
|
|
|
|
|
+ appointmentConfigMapper.insert(config);
|
|
|
|
|
+
|
|
|
|
|
+ List<AppointmentGroupDO> groupList = reqVO.getGroup();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(groupList)) {
|
|
|
|
|
+ groupList.forEach(group -> {
|
|
|
|
|
+ group.setId(null);
|
|
|
|
|
+ group.setTenantId(tenantId);
|
|
|
|
|
+ });
|
|
|
|
|
+ appointmentGroupMapper.insertBatch(groupList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public AppointmentConfigRespVO getByTenant(Long tenantId) {
|
|
|
|
|
+ AppointmentConfigDO config = appointmentConfigMapper.selectOne(
|
|
|
|
|
+ new LambdaQueryWrapper<AppointmentConfigDO>().eq(AppointmentConfigDO::getTenantId, tenantId));
|
|
|
|
|
+ List<AppointmentGroupDO> groups = appointmentGroupMapper.selectList(
|
|
|
|
|
+ new LambdaQueryWrapper<AppointmentGroupDO>().eq(AppointmentGroupDO::getTenantId, tenantId));
|
|
|
|
|
+ AppointmentConfigRespVO respVO = new AppointmentConfigRespVO();
|
|
|
|
|
+ respVO.setConfig(config);
|
|
|
|
|
+ respVO.setGroup(groups);
|
|
|
|
|
+ return respVO;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|