|
@@ -0,0 +1,68 @@
|
|
|
+package com.fjhx.tenant.service.dict.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.tenant.entity.dict.dto.DictTenantTypeDto;
|
|
|
+import com.fjhx.tenant.entity.dict.dto.DictTenantTypeSelectDto;
|
|
|
+import com.fjhx.tenant.entity.dict.po.DictCommonType;
|
|
|
+import com.fjhx.tenant.entity.dict.po.DictTenantType;
|
|
|
+import com.fjhx.tenant.entity.dict.vo.DictTenantTypeVo;
|
|
|
+import com.fjhx.tenant.mapper.dict.DictTenantTypeMapper;
|
|
|
+import com.fjhx.tenant.service.dict.DictCommonTypeService;
|
|
|
+import com.fjhx.tenant.service.dict.DictTenantTypeService;
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 租户字典 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2023-03-30
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class DictTenantTypeServiceImpl extends ServiceImpl<DictTenantTypeMapper, DictTenantType> implements DictTenantTypeService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DictCommonTypeService dictCommonTypeService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<DictTenantTypeVo> getPage(DictTenantTypeSelectDto dto) {
|
|
|
+ return this.baseMapper.getPage(dto.getPage(), dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public DictTenantTypeVo detail(Long id) {
|
|
|
+ DictTenantType DictTenantType = this.getById(id);
|
|
|
+ return BeanUtil.toBean(DictTenantType, DictTenantTypeVo.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void add(DictTenantTypeDto dictTenantTypeDto) {
|
|
|
+ dictCommonTypeService.nameDuplication(DictCommonType::getCode, dictTenantTypeDto.getCode(), "字典编码已存在");
|
|
|
+ long count = count(q -> q
|
|
|
+ .eq(DictTenantType::getCode, dictTenantTypeDto.getCode())
|
|
|
+ .eq(DictTenantType::getTenantId, dictTenantTypeDto.getTenantId()));
|
|
|
+ if (count != 0) {
|
|
|
+ throw new ServiceException("字典编码已存在");
|
|
|
+ }
|
|
|
+ this.save(dictTenantTypeDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void edit(DictTenantTypeDto dictTenantTypeDto) {
|
|
|
+ dictTenantTypeDto.setCode(null);
|
|
|
+ dictTenantTypeDto.setTenantId(null);
|
|
|
+ this.updateById(dictTenantTypeDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|