|
@@ -1,12 +1,18 @@
|
|
|
package com.songhua.system.service.impl;
|
|
|
|
|
|
import com.songhua.system.domain.ShhTicketRules;
|
|
|
+import com.songhua.system.domain.ShhTicketRulesData;
|
|
|
+import com.songhua.system.mapper.ShhTicketRulesDataMapper;
|
|
|
import com.songhua.system.mapper.ShhTicketRulesMapper;
|
|
|
import com.songhua.system.service.IShhTicketRulesService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 票种规则Service业务层处理
|
|
@@ -18,6 +24,8 @@ import java.util.List;
|
|
|
public class ShhTicketRulesServiceImpl implements IShhTicketRulesService {
|
|
|
@Autowired
|
|
|
private ShhTicketRulesMapper shhTicketRulesMapper;
|
|
|
+ @Autowired
|
|
|
+ private ShhTicketRulesDataMapper shhTicketRulesDataMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询票种规则
|
|
@@ -27,7 +35,11 @@ public class ShhTicketRulesServiceImpl implements IShhTicketRulesService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ShhTicketRules selectShhTicketRulesById(Long id) {
|
|
|
- return shhTicketRulesMapper.selectShhTicketRulesById(id);
|
|
|
+ ShhTicketRules returnEntity = shhTicketRulesMapper.selectShhTicketRulesById(id);
|
|
|
+ String[] split = returnEntity.getTicketId().split(",");
|
|
|
+ List<Long> list = Arrays.stream(split).map(Long::parseLong).collect(Collectors.toList());
|
|
|
+ returnEntity.setTicketList(list);
|
|
|
+ return returnEntity;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -49,7 +61,24 @@ public class ShhTicketRulesServiceImpl implements IShhTicketRulesService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int insertShhTicketRules(ShhTicketRules shhTicketRules) {
|
|
|
- return shhTicketRulesMapper.insertShhTicketRules(shhTicketRules);
|
|
|
+ shhTicketRulesMapper.insertShhTicketRules(shhTicketRules);
|
|
|
+ extracted(shhTicketRules);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void extracted(ShhTicketRules shhTicketRules) {
|
|
|
+ List<ShhTicketRulesData> saveList = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(shhTicketRules.getTicketList())) {
|
|
|
+ for (Long var : shhTicketRules.getTicketList()) {
|
|
|
+ ShhTicketRulesData saveData = new ShhTicketRulesData();
|
|
|
+ saveData.setRulesId(shhTicketRules.getId());
|
|
|
+ saveData.setTicketId(var);
|
|
|
+ saveList.add(saveData);
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(saveList)) {
|
|
|
+ shhTicketRulesDataMapper.insertTicketRulesDataBatch(saveList);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -60,6 +89,10 @@ public class ShhTicketRulesServiceImpl implements IShhTicketRulesService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int updateShhTicketRules(ShhTicketRules shhTicketRules) {
|
|
|
+ if (!CollectionUtils.isEmpty(shhTicketRules.getTicketList())) {
|
|
|
+ shhTicketRulesDataMapper.deleteShhTicketRulesDataByRulesId(shhTicketRules.getId());
|
|
|
+ extracted(shhTicketRules);
|
|
|
+ }
|
|
|
return shhTicketRulesMapper.updateShhTicketRules(shhTicketRules);
|
|
|
}
|
|
|
|
|
@@ -71,6 +104,9 @@ public class ShhTicketRulesServiceImpl implements IShhTicketRulesService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int deleteShhTicketRulesByIds(Long[] ids) {
|
|
|
+ for (Long id : ids) {
|
|
|
+ shhTicketRulesDataMapper.deleteShhTicketRulesDataByRulesId(id);
|
|
|
+ }
|
|
|
return shhTicketRulesMapper.deleteShhTicketRulesByIds(ids);
|
|
|
}
|
|
|
|
|
@@ -84,4 +120,6 @@ public class ShhTicketRulesServiceImpl implements IShhTicketRulesService {
|
|
|
public int deleteShhTicketRulesById(Long id) {
|
|
|
return shhTicketRulesMapper.deleteShhTicketRulesById(id);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|