|
@@ -0,0 +1,76 @@
|
|
|
+package cn.cslg.permission.service.qiaobi;
|
|
|
+
|
|
|
+import cn.cslg.permission.common.model.Records;
|
|
|
+import cn.cslg.permission.common.model.qiaobi.QiaoBiVIPTypeVO;
|
|
|
+import cn.cslg.permission.common.model.qiaobi.QiaoBiVipTypeDTO;
|
|
|
+import cn.cslg.permission.common.model.qiaobi.paidCode.VipTypeNumDTO;
|
|
|
+import cn.cslg.permission.common.model.qiaobi.tenant.QiaoBiTenantVO;
|
|
|
+import cn.cslg.permission.common.model.qiaobi.tenant.QueryQiaoBiTenantDTO;
|
|
|
+import cn.cslg.permission.common.model.qiaobi.tenant.UpdateQiaoBiTenantDTO;
|
|
|
+import cn.cslg.permission.domain.Tenant;
|
|
|
+import cn.cslg.permission.mapper.TenantMapper;
|
|
|
+import cn.cslg.permission.mapper.qiaobi.AppVipTypeMapper;
|
|
|
+import cn.cslg.permission.service.TenantService;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class QiaoBiTenantService {
|
|
|
+ private final TenantMapper tenantMapper;
|
|
|
+ private final AppVipTypeMapper appVipTypeMapper;
|
|
|
+ private final TenantService tenantService;
|
|
|
+ private final AssoTenantVipTypeService assoTenantVipTypeService;
|
|
|
+ public Records queryQiaoBiTenants(QueryQiaoBiTenantDTO queryQiaoBiTenantDTO) {
|
|
|
+ Long current = queryQiaoBiTenantDTO.getCurrent();
|
|
|
+ Long size = queryQiaoBiTenantDTO.getSize();
|
|
|
+ if (current != null && size != null) {
|
|
|
+ queryQiaoBiTenantDTO.setCurrent(((current - 1) * size));
|
|
|
+ }
|
|
|
+ List<QiaoBiTenantVO> qiaoBiTenantVOS = tenantMapper.queryQiaoBiTenants(queryQiaoBiTenantDTO);
|
|
|
+ this.loadQiaoBiTenantVO(qiaoBiTenantVOS);
|
|
|
+ Long total = tenantMapper.queryQiaoBiTenantsTotal(queryQiaoBiTenantDTO);
|
|
|
+ Records records = new Records();
|
|
|
+ records.setSize(size);
|
|
|
+ records.setCurrent(current);
|
|
|
+ records.setTotal(total);
|
|
|
+ records.setRecords(qiaoBiTenantVOS);
|
|
|
+ return records;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void loadQiaoBiTenantVO(List<QiaoBiTenantVO> qiaoBiTenantVOS) {
|
|
|
+ if (qiaoBiTenantVOS == null || qiaoBiTenantVOS.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Integer> tenantIds = qiaoBiTenantVOS.stream().map(QiaoBiTenantVO::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ QiaoBiVipTypeDTO qiaoBiVipTypeDTO = new QiaoBiVipTypeDTO();
|
|
|
+ qiaoBiVipTypeDTO.setTenantIds(tenantIds);
|
|
|
+ List<QiaoBiVIPTypeVO> qiaoBiVIPTypeVOList = appVipTypeMapper.qiaoBiTenantsVIPTypeVOList(qiaoBiVipTypeDTO);
|
|
|
+ for (QiaoBiTenantVO qiaoBiTenantVO : qiaoBiTenantVOS) {
|
|
|
+ List<QiaoBiVIPTypeVO> temVOs = qiaoBiVIPTypeVOList.stream().filter(item -> item.getTenantId().equals(qiaoBiTenantVO.getId())).collect(Collectors.toList());
|
|
|
+ qiaoBiTenantVO.setVipTypes(temVOs);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public void updateQiaoBiTenant(UpdateQiaoBiTenantDTO updateQiaoBiTenantDTO) {
|
|
|
+ Integer tenantId = updateQiaoBiTenantDTO.getTenantId();
|
|
|
+ Tenant tenant = tenantService.getById(tenantId);
|
|
|
+ tenant.setTenantName(updateQiaoBiTenantDTO.getName());
|
|
|
+ tenant.setTenantStatus(updateQiaoBiTenantDTO.getState());
|
|
|
+ tenant.setTenantAddress(updateQiaoBiTenantDTO.getAddress());
|
|
|
+ tenant.setTenantType(updateQiaoBiTenantDTO.getType());
|
|
|
+ tenant.setTenantDescription(updateQiaoBiTenantDTO.getDescribe());
|
|
|
+ tenant.updateById();
|
|
|
+ List<VipTypeNumDTO> vipTypeNumDTOS = updateQiaoBiTenantDTO.getVipTypes();
|
|
|
+ assoTenantVipTypeService.saveFunctionModuleBatch(vipTypeNumDTOS,tenantId);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|