| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.vincent.rsf.framework.common.SpringUtils; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.system.entity.Fields; |
| | | import com.vincent.rsf.server.system.entity.FieldsItem; |
| | | import com.vincent.rsf.server.system.service.FieldsItemService; |
| | | import com.vincent.rsf.server.system.service.FieldsService; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author Ryan |
| | |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @description 通过字段唯一标识获取动态字段Map |
| | | * @description 通过字段唯一标识获取动态字段对象key-value |
| | | * @param |
| | | * @return |
| | | * @time 2025/3/12 12:50 |
| | |
| | | |
| | | return fieldsMap; |
| | | } |
| | | |
| | | /** |
| | | * @param template |
| | | * @return |
| | | * @author Ryan |
| | | * @description 动态字段value保存 |
| | | * @time 2025/3/18 15:00 |
| | | */ |
| | | public static void saveFields(Map<String, String> template, String uuid) { |
| | | List<Fields> fields = getFieldsSta(); |
| | | FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class); |
| | | if (fields.isEmpty()) { |
| | | throw new CoolException("扩展字段不存在!!"); |
| | | } |
| | | List<FieldsItem> fieldsItems = new ArrayList<>(); |
| | | fields.forEach(fields1 -> { |
| | | if (!Objects.isNull(template.get(fields1.getFields()))) { |
| | | FieldsItem item = new FieldsItem(); |
| | | item.setFieldsId(fields1.getId()) |
| | | .setUuid(uuid) |
| | | .setValue(template.get(fields1.getFields())); |
| | | fieldsItems.add(item); |
| | | } |
| | | }); |
| | | if (!fieldsItemService.saveBatch(fieldsItems)) { |
| | | throw new CoolException("动态字段值保存失败!!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取所有开启动态扩展字段 |
| | | * @return |
| | | */ |
| | | public static List<Fields> getFieldsSta() { |
| | | FieldsService fieldsService = SpringUtils.getBean(FieldsService.class); |
| | | return fieldsService.list(new LambdaQueryWrapper<Fields>().eq(Fields::getStatus, 1).eq(Fields::getFlagEnable, 1)); |
| | | } |
| | | } |