初始化货品单位

This commit is contained in:
2024-02-26 19:56:53 +08:00
parent 45b4ce94a3
commit 44e6152534

View File

@@ -20,6 +20,9 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Set;
@Service
@Slf4j
@Transactional
@@ -68,4 +71,26 @@ public class WarehouseGoodsUnitService
return page.map(this.mapper::toDto);
}
public void init(String orgId) {
List<WarehouseGoodsUnitEntity> all = this.repository.findByOrganizationId(orgId);
if (!all.isEmpty()) {
return;
}
Set<String> units = Set.of(
"", "千克", "", "", "毫升", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "");
for (String unit : units) {
WarehouseGoodsUnitEntity entity = new WarehouseGoodsUnitEntity();
entity.setName(unit);
entity.setOrganizationId(orgId);
this.repository.save(entity);
}
}
}