|
@ -1,7 +1,6 @@
|
|
|
package com.yihu.jw.base.service.servicePackage;
|
|
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.yihu.jw.base.dao.servicePackage.ServiceItemConfigDao;
|
|
|
import com.yihu.jw.entity.base.servicePackage.ServiceItemConfig;
|
|
|
import com.yihu.jw.mysql.query.BaseJpaService;
|
|
@ -9,12 +8,12 @@ import com.yihu.jw.restmodel.qvo.ParamQvo;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@ -36,31 +35,38 @@ public class ServiceItemConfigService extends BaseJpaService<ServiceItemConfig,
|
|
|
* 保存服务项的配置
|
|
|
*/
|
|
|
public void changeItemConfig(ParamQvo qvo) throws Exception {
|
|
|
|
|
|
// ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
String jsonContent = qvo.getJsonContent();
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
//转换成数组
|
|
|
List<ServiceItemConfig> itemConfigList = objectMapper.readValue(jsonContent, new TypeReference<List<ServiceItemConfig>>() {
|
|
|
});
|
|
|
List<ServiceItemConfig> itemConfigList = JSON.parseArray(jsonContent, ServiceItemConfig.class);
|
|
|
// //转换成数组
|
|
|
// List<ServiceItemConfig> itemConfigList = objectMapper.readValue(jsonContent, new TypeReference<List<ServiceItemConfig>>() {
|
|
|
// });
|
|
|
String collect = itemConfigList.stream().map(vo -> String.valueOf("'" + vo.getServerItemId() + "'"))
|
|
|
.collect(Collectors.joining(",", "(", ") "));
|
|
|
//删除服务项的配置
|
|
|
String sql = " DELETE FROM base_service_item_config q WHERE q.package_id='" + qvo.getId() + "' AND q.server_item_id IN " + collect;
|
|
|
jdbcTemplate.execute(sql);
|
|
|
//保存
|
|
|
// for (ServiceItemConfig config : itemConfigList) {
|
|
|
// itemConfigDao.save(config);
|
|
|
// }
|
|
|
itemConfigDao.saveAll(itemConfigList);
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> findItemConfig(ParamQvo qvo) {
|
|
|
public List<ServiceItemConfig> findItemConfig(ParamQvo qvo) {
|
|
|
String sql = "SELECT\n" +
|
|
|
" b.name,a.* \n" +
|
|
|
"FROM\n" +
|
|
|
" base_service_item_config a\n" +
|
|
|
" INNER JOIN base_service_package_item b ON a.package_id = b.service_package_id \n" +
|
|
|
" AND a.server_item_id = b.service_package_item_id\n" +
|
|
|
" AND a.server_item_id = b.id \n" +
|
|
|
" WHERE 1=1 AND a.package_id='" + qvo.getId() + "'";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
|
|
|
List<ServiceItemConfig> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ServiceItemConfig.class));
|
|
|
// List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
}
|