fix: 恢复实体类型并处理Boolean转Integer问题
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Agent
2026-03-30 13:28:08 +00:00
parent c4de5572f5
commit 6ee37775b1
2 changed files with 8 additions and 19 deletions

View File

@@ -2,7 +2,6 @@ package com.example.building.service;
import com.example.building.entity.CategoryAttribute;
import java.util.List;
import java.util.Map;
/**
* 种类属性服务接口
@@ -17,7 +16,7 @@ public interface CategoryAttributeService {
/**
* 保存属性
*/
void saveAttributes(String categoryId, List<Map<String, Object>> attrs);
void saveAttributes(String categoryId, List<CategoryAttribute> attrs);
/**
* 删除种类的所有属性

View File

@@ -31,7 +31,7 @@ public class CategoryAttributeServiceImpl implements CategoryAttributeService {
@Override
@Transactional
public void saveAttributes(String categoryId, List<Map<String, Object>> attrs) {
public void saveAttributes(String categoryId, List<CategoryAttribute> attrs) {
System.out.println("=== saveAttributes called ===");
System.out.println("categoryId: " + categoryId);
System.out.println("attrs size: " + (attrs != null ? attrs.size() : 0));
@@ -43,26 +43,16 @@ public class CategoryAttributeServiceImpl implements CategoryAttributeService {
// 保存新属性
if (attrs != null && !attrs.isEmpty()) {
for (int i = 0; i < attrs.size(); i++) {
Map<String, Object> attrMap = attrs.get(i);
CategoryAttribute attr = new CategoryAttribute();
CategoryAttribute attr = attrs.get(i);
attr.setAttrId(UUID.randomUUID().toString());
attr.setCategoryId(categoryId);
attr.setSortOrder(i);
if (attrMap.get("name") != null) {
attr.setName(attrMap.get("name").toString());
}
if (attrMap.get("attrType") != null) {
attr.setAttrType(attrMap.get("attrType").toString());
}
if (attrMap.get("unit") != null) {
attr.setUnit(attrMap.get("unit").toString());
}
if (attrMap.get("required") != null) {
attr.setRequired((Boolean) attrMap.get("required"));
}
if (attrMap.get("formula") != null) {
attr.setFormula(attrMap.get("formula").toString());
// 处理 required 字段类型(前端可能是 Boolean后端存 Integer
if (attr.getRequired() != null) {
if (attr.getRequired() instanceof Boolean) {
attr.setRequired(((Boolean) attr.getRequired()) ? 1 : 0);
}
}
System.out.println(" attr: " + attr.getName() + ", type=" + attr.getAttrType() + ", unit=" + attr.getUnit());