feat(converter): 实现通用枚举转换器和供应商类型转换器
添加EnumEntityStringConverter作为通用枚举转换基类 实现VendorTypeStringConverter用于供应商类型本地化转换 在VendorTypeService中添加findByLocaleAndValue方法支持转换器 优化ComboBoxUtils的绑定逻辑使其支持可选属性 新增VendorCatalogService提供供应商目录CRUD功能
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.VendorType;
|
||||
import com.ecep.contract.converter.VendorTypeStringConverter;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.VendorTypeLocalViewModel;
|
||||
import com.ecep.contract.vo.VendorTypeLocalVo;
|
||||
import javafx.util.StringConverter;
|
||||
import org.springframework.cache.annotation.*;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "vendor-type")
|
||||
@@ -36,15 +34,27 @@ public class VendorTypeService extends QueryService<VendorTypeLocalVo, VendorTyp
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@Caching(put = { @CachePut(key = "#p0.id"), @CachePut(key = "'type-'+#p0.type"), @CachePut(key = "'all'") })
|
||||
@Caching(put = {@CachePut(key = "#p0.id"), @CachePut(key = "'type-'+#p0.type"), @CachePut(key = "'all'")})
|
||||
@Override
|
||||
public VendorTypeLocalVo save(VendorTypeLocalVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = { @CacheEvict(key = "#p0.id"), @CacheEvict(key = "'type-'+#p0.type"), @CacheEvict(key = "'all'") })
|
||||
@Caching(evict = {@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'type-'+#p0.type"), @CacheEvict(key = "'all'")})
|
||||
@Override
|
||||
public void delete(VendorTypeLocalVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
private StringConverter<VendorTypeLocalVo> stringConverter = new VendorTypeStringConverter(this);
|
||||
|
||||
@Override
|
||||
public StringConverter<VendorTypeLocalVo> getStringConverter() {
|
||||
return stringConverter;
|
||||
}
|
||||
|
||||
public VendorTypeLocalVo findByLocaleAndValue(Locale locale, String string) {
|
||||
return findAll(ParamUtils.builder().equals("lang", locale.toLanguageTag()).equals("value", string).build(), Pageable.ofSize(1))
|
||||
.stream().findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user